Closed in0ni closed 2 months ago
Hey, cool that you're setting up a Helix client and aur package @in0ni π₯³
I see from the Helix docs that config
is used for initialization options.
LSP initialization options
The way I'm reading that, config
will be passed on the initialize
lifecycle message (likely becoming initializationOptions
in the message).
some-sass-language-server
doesn't read settings from that message. Instead it does a request to the client for its settings in the editor
and somesass
"namespaces".
What you want is probably to add this to your config.toml
.
[somesass]
suggestFromUseOnly = true
loadPaths = ["test/"]
And then this would be (ish) what language.toml
looks like.
[language-server.some-sass-language-server]
command = "some-sass-language-server"
args = ["--stdio"]
[[language]]
name = "scss"
scope = "source.scss"
injection-regex = "scss"
file-types = ["scss"]
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [ "some-sass-language-server" ]
In your documentation, why do you mention this is meant to work with vscode-css-lsp?
It's a bit of legacy, and for sure can be a bit confusing.
This whole project began as a language server that filled the gaps in VS Code. For that reason, I don't include things like completions and hover info for CSS attributes, among other things, since those shipped with the built-in CSS/SCSS/Less language features in Code.
What I mean by that line is, you probably want to run both some-sass-language-server
and vscode-css-language-server
at the same time. That way vscode-css
handles all the CSS stuff, and some-sass
handles all the extra workspace magic for SCSS.
Hmm, seems Helix is strict about what goes in config.toml
β that won't work π
I see this PR is what introduced support for the workspace/configuration
message that we use. You might have some luck digging there.
Hey @wkillerud, took a brief look at this -- and did some quick checking of the verbose logs. I do think the workspace/config is passed. I hope to get some time today/tomorrow to dig deeper, will keep you posted. Thanks for the links/info, they are very helpful.
I'm attaching a log file, that might help, I think we're getting a little closer:
workspace/didChangeConfiguration
, and from what I can tell it's passing the settings properly (see below)workspace/configuration
you mentionedFrom logs:
helix_lsp::transport [INFO] some-sass-lsp -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"somesass.loadPaths":["web/themes/uw/theme/"],"somesass.suggestFromUseOnly":true}}}
I see you are working with didChangeConfiguration
, but unfamiliar with LSP
https://github.com/wkillerud/some-sass/blob/e0b0af656ed5fa7fda7529dfbae61af20fb53732/packages/language-server/src/server.ts#L225
Would you mind taking a quick look at the log? helix-some-sass.log
Maybe I need to tweak how the settings are sent, let me know if I can assist with anything on my end.
Sorry for the late reply @in0ni, I missed your last post.
That's great that the Helix language client "speaks" workspace/didChangeConfiguration
π₯³ We should be close I think.
Looking at the logs, I think I see a potential issue in the message that's sent to the server.
{
"settings": {
"somesass.loadPaths": ["web/themes/uw/theme/"],
"somesass.suggestFromUseOnly": true
}
}
The server expects that somesass
is an object with keys like loadPaths
, suggestFromUseOnly
etc.
This is the shape of the params sent by VS Code/VSCodium
{
"settings": {
"somesass": {
"loadPaths": [],
"scannerDepth": 30,
"scannerExclude": [
"**/.git/**",
"**/node_modules/**",
"**/bower_components/**"
],
"scanImportedFiles": true,
"suggestionStyle": "all",
"suggestAllFromOpenDocument": false,
"suggestFromUseOnly": true,
"suggestFunctionsInStringContextAfterSymbols": " (+-*%",
"triggerPropertyValueCompletion": false
}
}
}
I added a note to the docs on how you can log the messages sent by VS Code/VSCodium to the server in case you want to compare other messages.
I tried running hx -v
and the :log-open
command to see. This config in languages.toml
seems to work for me @in0ni
[language-server.some-sass-language-server]
command = "some-sass-language-server"
args = ["--stdio"]
config = { somesass = { suggestFromUseOnly = true, loadPaths = ["test/"], completion = { afterModule = "", beforeVariable = "" } } }
[[language]]
name = "scss"
scope = "source.scss"
injection-regex = "scss"
file-types = ["scss"]
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [ "some-sass-language-server" ]
auto-format = true
indent = { tab-width = 2, unit = " " }
I see the completions are a bit quirky in some cases, adding an extra .
or $
.
I think this is due to the grammar Helix uses for SCSS. We might be able to add some settings to the language server to work around that.
Edit: added here, available in some-sass-language-server@1.7.0
:
I updated the config example above with these new settings.
Hey @wkillerud, saw this but have not had a change to implement and test. I will try these settings soon -- and confirm. Thank you. In terms of the bugs of extra .
or $
I doubt it's the grammar being used as I have not had any issues thus far using vscode-css-language server or default completions for some time now. I should be able to test all this in the upcoming days.
Really appreciate it and look forward to finally using this lang server!
Hey, so have updated to 1.7.0 -- no longer see the issue with double .
or $
but it seems like loadPaths is not working properly. I don't want to get ahead of myself -- will do some more testing (kinda rushed it now). Tomorrow I'll invest a little time and get back to you.
Gah, of course I missed the most important setting you were after in the handler for workspace/didChangeConfiguration
π Sorry about that @in0ni, fixed in 1.7.1.
Whooohooo! I finally see loadPath
working!
I had updated to 1.7.1 -- but have not had a chance to tests (have not been working with scss and been a bit swamped). I see one bug which is I still get double $
after tabbing to auto-complete, but perhaps that is fixed in your recent release. I have to head out soon, but will update the aur, install, test and get back to you.
Thanks much, this is something I've been needing for quite some time~! I will be ensuring colleagues install as well now that I have tested (for those that have vscode).
Glad to hear that!
I'll be shipping #232 soon which makes the settings completion = { afterModule = "", beforeVariable = "" }
obsolete. It replaces the current method for inserting text with a much more predictable edit. I tested it in Helix and it should at least not make things worse π
Version 1.8.1 is out now, which rewrites the code that has caused us some grief with auto-complete.
It makes the somesass.completion.afterModule
and somesass.completion.beforeVariable
settings obsolete, so they can be removed from the config.
I tested the release in Helix and completions seem to work as they should. Of course I might have missed something, so let me know if you still get weird double $
or other problems with the auto-complete.
Ok, aur updated -- and from initial tests, all is looking great! No more issues with double $
or .
.
Once I have time, I will see about having this included in helix list of default language servers, as vscode doesn't support these useful features yet -- and updating the config section as well in their wiki. FYI this is my config:
[language-server.some-sass-lsp]
command="some-sass-language-server"
args = ["--stdio"]
[language-server.some-sass-lsp.config]
somesass = { suggestFromUseOnly = true, loadPaths = ["some/path/"] }
Nothing else is needed (well add it to the list of lang servers for scss), so you may update your docs :)
In case you're interested I have this for scss config
[[language]]
name="scss"
auto-format=true
formatter = { command = "npx", args = ["--no-install", "prettier", "--stdin-filepath ${INPUT}", "--parser", "scss"] }
language-servers = [
"cspell",
{ name = "some-sass-lsp", except-features = ["format"] },
{ name = "vscode-css-language-server", except-features = ["format"] },
# stylelint
{ name = "efm-langserver", except-features = ["format"] },
{ name = "emmet-ls", only-features = ["completion"] },
]
Thanks much!
Glad to hear that! I'll close this issue now that we have it working.
Thank you for testing and doing the config work and all π
Hey, thanks for this language server, very much needed!
I will be maintaining the aur package for arch, and thinking about contributing to helix editor in terms of documenting on the wiki, and seeing about having it as one of the default lsp's for scss.
I have been unable to get the settings to work with Helix, I am using the aur package (npm 1.5.2). I know the lsp is working, as I have disabled
vscode-css-language-server
, and I'm able to get completion for modules (finally!!).In particular I cannot get the following settings to work:
somesass.suggestFromUseOnly
somesass.loadPaths
I have tried various methods to configure, last syntax (not too familiar with toml) is this:
I also tried variations such as:
and
For reference here are all the language server configs that come with Helix out-of-the-box: https://github.com/helix-editor/helix/blob/master/languages.toml
I have several language servers configured, and only efm-language-server with config settings -- and all works well. From my understanding the
suggestFromUseOnly
would avoid me gettingmap-get
as a suggestion, if I start typingmap
(unless I have added it with a@use
.Lastly, and a little unrelated:
Thanks much in advance!