nushell / vscode-nushell-lang

A Nushell grammar for Visual Studio Code with IDE support
https://www.nushell.sh/
MIT License
122 stars 27 forks source link

Remove `/` and `\` from wordPattern #186

Closed ajhall closed 5 months ago

ajhall commented 5 months ago

This removes / and \ from the wordPattern value in the language-configuration.json, which fixes #185, allowing path completion to work properly.

https://code.visualstudio.com/api/language-extensions/language-configuration-guide#word-pattern

wordPattern defines what's considered as a word in the programming language. Code suggestion features will use this setting to determine word boundaries if wordPattern is set.

I'm not entirely sure this is the best possible fix, but everything I tested seems to work the way I expected and I can auto-complete paths now. For example, I tried creating a variable with a slash in the name, but it still doesn't treat that as a valid variable name.

Two thoughts according to my limited understanding of how this works:

  1. I see that the current value of wordPattern comes straight from the official example. My best guess is that a typical language server doesn't implement path completion, so usually you wouldn't want directory separators included in your word pattern. Nushell's language server does appear to do path completion, though, so it seems to make sense to allow those characters when trying to auto-complete.
  2. Most of the built-in VSCode plugins (including shellscript) don't have a wordPattern defined, so maybe this field isn't even needed most of the time?
fdncred commented 5 months ago

Seems reasonable to try this. I couldn't remember where I stole that bit from. Thanks!