Skip to content

Comments

Add auto-imports#79

Open
cgtudor wants to merge 10 commits intoPhilippeChab:migrate-nwnsc-to-nwn-script-compilerfrom
cgtudor:auto-imports
Open

Add auto-imports#79
cgtudor wants to merge 10 commits intoPhilippeChab:migrate-nwnsc-to-nwn-script-compilerfrom
cgtudor:auto-imports

Conversation

@cgtudor
Copy link

@cgtudor cgtudor commented Feb 11, 2026

This PR is built on top of #78 but I can't set that as the base branch on this repo.

This adds two new functionalities to the LSP:

  1. When you have a symbol in the file that isn't imported but the LSP is aware that it's available in a file, you now get the code fix action to automatically import said file.
  2. When you start typing the name of a function and get code completion, you now also get code completion from files that are not imported. If selected, this will also automatically import the file as well as complete the function name.

From a UX perspective, these are meant to mimick functionality from modern IDEs which allow you to do very much the same (vscode included) for normal languages.

Note: imports are added after the last import statement in the file if it exists. If it doesn't, they are added at line 0.

From my testing it seems to work great, and I don't see a performance dip either.

@cgtudor cgtudor changed the base branch from main to migrate-nwnsc-to-nwn-script-compiler February 11, 2026 21:04
@cgtudor cgtudor force-pushed the auto-imports branch 2 times, most recently from e34403c to 2eeb1f1 Compare February 13, 2026 13:02
Now, we prioritize functions with bodies and only jump to forward declaration if no full function was found. This also means there's no reason for forward declarations anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant