philippechab / nwscript-ee-language-server Goto Github PK
View Code? Open in Web Editor NEWA NWScript Language Server.
Home Page: https://marketplace.visualstudio.com/items?itemName=PhilippeChab.nwscript-ee-language-server
License: MIT License
A NWScript Language Server.
Home Page: https://marketplace.visualstudio.com/items?itemName=PhilippeChab.nwscript-ee-language-server
License: MIT License
Pretty minor, but if you declare multiple variables on one line like so int nFoo, nBar, nBaz;
it'll only recognize the first one with regards to hover/completion data
Use multiple threads or parallelization.
I've notice an anomaly that I haven't exactly nailed down the cause of yet, but I believe it's related to problems that are identified through the diagnostics provider which remain on the problems panel after the associated file is closed. There appears to be some cross-talk in the reported problems that assigns a problem from one file (a closed file) to another file (an open file). In the following screenshot, you can see that this error is obviously misplaced from a previously open file.
Additionally, my problems panel has problems from previously open file which are no longer open. Is this desired behavior or is there an option to clear the problems panel when the offending file is closed?
I understand fully the ease of indexing all of the available scripts that aren't in the ignore path, and I'm not even sure this would be desirable behavior, but I'd like to get your take on it.
For example, if I have added a function from my "core_inc.nss", and this file is indexed because it exists in my project, but not #included in the script I'm currently working on, is it possible to add a warning (yellow squiggly) to let the user know he's adding a function from a non-included file, but still provide all the normal lsp functionality for said function?
Alternately, would it be desirable to remove all indexing/access to any script that's not in the #include chain for the script that's currently being edited? That is, if I'm trying to pull in a function from an indexed script, but that script isn't #included in the file I'm currently editing, should lsp functionality for that file be blocked as kind of a hint that this script doesn't have access to those functions?
Or, just let nwnsc do its thing and let the user be smart enough to figure it out.
While nwscript.nss
is indexed through a lib-def build, the organic scripts (such as nw_i0_spells
and such) that are available via #include "<scriptname>"
are not indexed, likely because they typically only exist in the game's .bif
files unless there's a custom override in the module. Is there a way to index the organic scripts if they're included? These are the same .bif
files that nwnsc uses for compilation of organic scripts.
Type: Bug
The noted extension (nwscript-ee-language-server) is a language server implementation for a custom language that relies on a textMate grammar. Under 1.85 and all previous versions of vsCode, this textmate grammar parses correctly and the language server reliably provided the product it is desgined to supply.
When vscode updated to 1.86, the textmate grammar no longer reliable parses and always errors on a line including </dict>
, though the actual grammar component it errors out on varies considerably. This, and the fact that it worked reliably until 1.86, leads me to believe there was a base code change that caused the issue, not the grammar itself, since the grammar hasn't changed in years. Multiple members of our development team have noted the same behavior on 1.86. Reverting to 1.85 fixed the issue.
Extension version: 2.1.0
VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:10.514Z)
OS version: Windows_NT x64 10.0.19045
Modes:
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:30899288
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30951796
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
dsvsc019bcf:30953938
7j2b6412:30949929
e3gdj431:30956216
It appears that the auto-formatter is eating code when encountering color codes that are commonly used by NWN. This break happens regardless of whether the color code is in comments or not.
// "<c ¤|>"
// "<c ¥ÿ>"
// "<c¡¡¡>"
// "<cÔ ¶>"
// "<c| >"
// "<cÿ? >"
void testFunction(object oPC)
{
int nFoo = foo(oPC);
int nFooBarFooBar = nFoo(oPC);
}
You should notice the following: https://gyazo.com/fc3ee592f76cc5c26fa85ba4243568e6
"nwscript-ee-lsp.formatter": {
"enabled": true,
"BasedOnStyle": "Google",
"AlignTrailingComments": true,
"AlignConsecutiveAssignments": true,
"ColumnLimit": 250,
"BreakBeforeBraces": "Allman",
"AlignEscapedNewlinesLeft": true,
"AlwaysBreakBeforeMultilineStrings": true,
"MaxEmptyLinesToKeep": 1,
"TabWidth": 4,
"IndentWidth": 4,
"UseTab": "Always",
"ignoredGlobs": [
"src/core/nui/**/*"
]
}
2.0.0 intermittently stops working for me.
Sometimes the LSP seemingly does not start after opening vscode and opening a nwscript file. Other times, it will start but after a while of use (anywhere from a few minutes to a few hours), hover information will say "Loading...", and compiling, diagnostics, auto completion, signature help/intellisense, goto definition all stop working. This happens regardless whether I'm only working in a single nwscript file with no includes, or working in a large module project with thousands (~3,300) custom scripts.
The only temporary fix I've found is to restart vscode, where it'll sometimes begin working only to again stop working after a few minutes to a few hours.
I'm not terribly experienced with LSPs or vscode extensions, so I'm not sure where to find the logs for this.
My settings if relevant,
"nwscript-ee-lsp.autoCompleteFunctionsWithParams": true,
"nwscript-ee-lsp.includeCommentsInFunctionsHover": true,
"nwscript-ee-lsp.formatter": {
"enabled": false
},
"nwscript-ee-lsp.compiler": {
"enabled": true,
"verbose": true,
"nwnHome": "N:\\Games\\Neverwinter Nights",
"nwnInstallation": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Neverwinter Nights",
"reportWarnings": true
}
For now I've reverted back to 1.5.5.
the nwn_script_comp added a new feature:
https://nwn.beamdog.net/docs/#88819336-8---2023-12-10
Added nwscript support for raw string literals: r".." and R"..", which can also span multiple lines.
The formatter appears to be adding a space between the R and quote. Ie, should be:
R"
, but formatter formats it to R "
which causes problems with the compiler.
Feature request:
Would it be possible to show the default parameter values in the hover info?
To reproduce:
myinclude.nss
// Do a thing
void DoThing(string sThing);
void DoThing(string sThing)
{
PrintString("Doing: " + sThing);
}
myscript.nss
#include "myinclude"
void main()
{
DoThing("Thing");
}
myscript.nss
and save itRestarting VSCode fixes it but I guess that's because it re-indexes everything.
Hi, I've been using your plugin for awhile now and really love it! It makes scripting in NWN so much fun.
One feature that would be nice is outlines and breadcrumbs. Currently, it says "No Symbols found in document XYZ.nss". I'm not too familiar with vscode or plugins, but I think that information comes from a "Symbols provider" from the language server ?
Again, sorry for lack of technical knowledge, but outlines and breadcrumbs would be a nice feature if possible.
Thanks for consideration.
Use factory design pattern.
I was able to successfully (and easily!) install this lsp, however I can't seem to get clang-format pathed correctly. I'm tried leaving "executable"
as clang-format
because it's on the PATH, but that didn't work. Also tried absolute pathing as mentioned in setup using both /
and \\
as directory separators to the clang-format
file (like this -> "executable": "C:/Users/Ed/AppData/Roaming/npm/clang-format"
), also with no luck. Any guidance on the correct pathing formatting to get clang-format to work on a Windows install? Do I need to change this option somewhere other than vscode's settings.json
, such as in package.json or config.ts?
First of all, thank you for this amazing extension!
I'm using Linux, Manjaro 6.2.10-1 and VSCodium with Marketplace and Features (from AUR)
I've been using your plugin for a while now and I've always noticed that as time goes on my computer fans starts ramping up and the entire system starts to slow down to a point where I was forced to reboot to fix this issue.
Then one day I decided to look into what was causing it, I ran "htop" command in the terminal to check for running processes and noticed that there was alot of nwnsc instances (called from your extension) running.
Since I'm too lazy I just created a script that runs "sudo killall nwnsc" periodically instead of posting the issue here.
So basically everytime the extension calls for nwnsc it never terminates it after its done.
Here's a screen snip of my hotp
Missing:
Small issue with struct member completion, it only works when accessing the variable standalone, for example:
struct SomeRandomStruct
{
int a;
string b;
};
void SomeFunction(struct SomeRandomStruct str)
{
str. // Completion shows the struct member vars here
if (str. // Completion doesn't show the struct member vars
}
I'm sure this regex is standard, so I may not be following the normal rules for constant definition, but here's what I'm seeing based on the following constant.language.nss
scope in nwscript-ee.tmLanguage.json
-> "\\b[A-Z]+(_[A-Z]+)*(_[a-zA-Z0-9]+){0,1}(?!\\()\\b"
:
H2_BLEED_TIMER_SCRIPT
-> Not a constant token (because of the 2
in the first group)
H_2BLEED_TIMER_SCRIPT
-> Not a constant token (because of the 2
in the second group)
H_BLEED_2TIMER_SCRIPT
-> Not a constant token (because of the 2
in the third group)
H_BLEED_TIMER_2SCRIPT
-> Valid constant token (numbers allowed in this capture group)
Also, any constant that would otherwise meet the definition, but starts with an underscore (i.e. _H2_BLEED_TIMER
) is also unrecognized. Are these generally accepted rules (numbers nearly never allowed and underscores can't start), even though they're acceptable in nwscript? If so, no bid deal, I'll work within the normal rules. If not, can the regex be changed to reflect these limitations?
I don't know much about regex, but this seems to work (but again, as long as it's valid in the greater language context, which I'm no expert at): \\b_*([A-Z])+([_a-zA-Z0-9])*(?!\\()\\b
Hi, the 1.5.4 update seems to have broken the indexer, it doesn't find include files anymore.
Here's the log:
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'c:\Users\Daz\.vscode\extensions\philippechab.nwscript-ee-language-server-1.5.4\server\out\indexer.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
[Info - 1:38:26 PM] Compiling file:///d%3A/Github/EquinoxFramework/Systems/ef_s_console.nss:
[Info - 1:38:26 PM] Loading base game resources...
[Info - 1:38:26 PM] ef_s_console.nss(8): Error: NSC1085: Unable to open the include file "ef_i_core"
[Info - 1:38:26 PM] Compilation aborted with errors.
[Info - 1:38:26 PM] Total Execution time = 0.0620 seconds
[Info - 1:38:26 PM] Done.```
It works fine as well but it could be cleaner.
Hey, my VSCode recently updated to the following version and now I'm getting the following plugin error.
Version: 1.86.0 (user setup)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:28:19.990Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Windows_NT x64 10.0.22631
[Info - 13:53:05] Compiling inc_armor_ed.nss:
[Info - 13:53:05] Usage: version -128-NOTFOUND.-128-NOTFOUND.-128-NOTFOUND - built Jul 28 2022 02:55:26
[Error - 13:53:05] Unable to resolve nwscript.nss. Are your Neverwinter Nights home and/or installation directories valid?
The home and install directories are set correctly. I added some debug text to the package: this.server.logger.error(args.toString());
which outputs: [Error - 13:53:05] -y,-c,-l,-r,SKIP_OUTPUT,-h,"C:/Users/Lia/Documents/Neverwinter Nights",-n,"C:/Program Files (x86)/Steam/steamapps/common/Neverwinter Nights",-i,,"d:\neverwinter-zombies\src\gui\inc_armor_ed.nss"
It's missing the -i, for whatever reason args.push([...new Set(paths.map((path) => `"${dirname(path)}"`))].join(";"));
is returning empty, at least for me on Windows. I hardcoded the path for now which fixed it for me. Maybe it's something local for me, I'm not blocked by this because I was able to hack around it. Just wanted to report the bug in case others experience it too.
c:\Users\Lia\.vscode\extensions\philippechab.nwscript-ee-language-server-1.4.0\server\out\Tokenizer\Tokenizer.js:50
return line.slice(token.startIndex, token.endIndex);
^
TypeError: Cannot read properties of undefined (reading 'startIndex')
at Tokenizer.getRawTokenContent (c:\Users\Lia\.vscode\extensions\philippechab.nwscript-ee-language-server-1.4.0\server\out\Tokenizer\Tokenizer.js:50:33)
at Tokenizer.getTokenLanguageType (c:\Users\Lia\.vscode\extensions\philippechab.nwscript-ee-language-server-1.4.0\server\out\Tokenizer\Tokenizer.js:56:33)
at Tokenizer.tokenizeLinesForGlobalScope (c:\Users\Lia\.vscode\extensions\philippechab.nwscript-ee-language-server-1.4.0\server\out\Tokenizer\Tokenizer.js:169:46)
at Tokenizer.tokenizeContent (c:\Users\Lia\.vscode\extensions\philippechab.nwscript-ee-language-server-1.4.0\server\out\Tokenizer\Tokenizer.js:293:25)
at generateTokens (c:\Users\Lia\.vscode\extensions\philippechab.nwscript-ee-language-server-1.4.0\server\out\Documents\DocumentsIndexer.js:19:39)
The ovr
folder contents are from the latest preview. I binary chopped the contents of the ovr
folder until I figured out that simply including nw_inc_nui
in your workspace causes this error.
A straightforward request that I understand might have very non-straightforward solutions.
Would be wonderful to use this excellent extension via vscode.dev, if that's practical given the limitations of the web version.
Much appreciated.
Recently, the official compiler has been open-sourced as part of the neverwinter.nim project. This compiler matches the toolset capabilities, and updates to the project will be reflected back into the toolset compiler over time where relevant.
Importantly, some new language features are not supported by nwnsc and report errors which are no longer true: For example, Switch-Case statements can now take strings, but nwnsc cannot handle that and reports errors. Swapping to nwn_script_comp would ensure it maintains correct diagnostics/compatibility with any additional features added.
Discord: Urothis#4019
Sorry for making an issue that isn't actually an issue, just couldn't find a means of contact.
The bug reported in #31 is now fixed, excellent and great work! Unfortunately I've run into a second issue now:
[Info - 11:27:44] Compiling inc_char_ed.nss:
[Info - 11:27:44] Loading base game resources...
[Info - 11:27:44] nw_inc_nui.nss(50): Error: NSC1040: Syntax error at "json"
[Info - 11:27:44] nw_inc_nui.nss(73): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(80): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(88): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(98): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(105): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(113): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(124): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(130): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(136): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(143): Error: NSC1040: Syntax error at "�"
[Info - 11:27:44] nw_inc_nui.nss(150): Error: NSC1040: Syntax error at "�"
On and on until the compiler hits 100 errors. When I compile this file with nwnsc manually it succeeds. I also don't encounter these errors when I'm editing a file which does use json but does not include nw_inc_nui
- I tested it because I had a suspicion that it was compiling in 1.69 mode, but it turns out not to be (at least for my script, maybe internally it's compiling the include in 1.69 mode?).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.