-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vscode-langservers (HTML, CSS, JSON) deleting end of file newlines, lacking diagnostics #7155
Comments
Haven't tested the formatting part, but I can confirm the issue with diagnostics, at least with JSON files. I checked the logs when running |
You need to set the json.validate.enable in the config like so: config = { "json" = { "validate" = { "enable" = true } } } This fixed it for me, thanks! |
@jonas-w Thanks a lot, that worked for me for json files. Haven't tested yet in HTML and CSS. One question: Where did you found that option? Is it documented somewhere? |
This is the way the helix lsp config works. json is an object which contains the key validate which is also an object that co tains a key enable which is a boolean. If you have a look at the json language server config you can see that validate is an object which contains the key enable, thats why you need to do this also in the toml file. |
Good to know. With that hint I was able to make work the CSS language server as well. Here are the configs that worked for me: [language-server.vscode-json-language-server.config]
json = { validate = { enable = true }, format = { enable = true } }
provideFormatter = true
[language-server.vscode-css-language-server.config]
css = { validate = { enable = true } }
scss = { validate = { enable = true } }
less = { validate = { enable = true } }
provideFormatter = true The HTML language server seems that doesn't support validation. I can however use hover and formatting with the default configuration. |
Thanks @jonas-w and @yusuphgammut for weighing in! Your comments led me to revisit my initial problem and I got things set up as desired. In case it helps others here's a quick illustration of what did and didn't work for me. (I may have had some conflicting lines in my Formattingwith default
|
Summary
I have installed
vscode-langservers-extracted
globally via Homebrew. (I also tried installing globally via NPM and see the same behavior.)hx --health json
(html and css options also find the binary in the path):With nothing specified in my
languages.toml
file, the symbol picker and:format
command each work across the three specified filetypes, so the LSPs are working to some extent. Formatting will fix indentation, but also remove the newline at the end of files. Uninstalling "vscode-langservers-extracted" and running:format
does not alter the files, as expected.Additionally, I do not receive any diagnostics information from any of these language servers.
My issue seems very similarly to these ones, but I decided to open a new one since the solutions in each did not work for me:
Formatting
I tried adding the
config = { "provideFormatter" = true, "json" = { "keepLines" = { "enable" = true } } }
line to my json config as suggested in this comment, but it did not appear to make a difference.I also attempted to set prettier as a formatter (I want to use the bundled Prettier, and this syntax worked with another non-vscode language server):
To confirm,
npx prettier -w package.json
works in the project directory and adds back the removed ending newline.Diagnostics
I also tried adding
config = { json.validate.enable = true }
to my json config per this comment, but the issue persisted.Reproduction Steps
I tried this:
hx package.json
:format
I expected this to happen:
No changes are applied to the file
Instead, this happened:
The end of file newline is deleted.
I tried this:
hx package.json
:w
I expected this to happen:
Diagnostics appear in the list.
Instead, this happened:
The diagnostics list is empty.
Helix log
~/.cache/helix/helix.log
Platform
macOS 13.3
Terminal Emulator
iTerm 2 Build 3.4.19
Helix Version
helix 23.05 (7f5940b)
The text was updated successfully, but these errors were encountered: