Skip to content
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

Closed
djpowers opened this issue May 27, 2023 · 6 comments · Fixed by djpowers/dotfiles#41
Labels
C-bug Category: This is a bug

Comments

@djpowers
Copy link
Contributor

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):

Configured language server: vscode-json-language-server
Binary for language server: /opt/homebrew/bin/vscode-json-language-server
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✓

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):

formatter = { command = 'npx', args = ["prettier", "--parser", "json"] }

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:

  1. hx package.json
  2. :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:

  1. hx package.json
  2. Delete closing brackets in JSON file
  3. :w
  4. Space + s (Open symbol picker)

I expected this to happen:
Diagnostics appear in the list.

Instead, this happened:
The diagnostics list is empty.

Helix log

~/.cache/helix/helix.log

2023-05-27T17:28:45.123 helix_vcs [INFO] Error {
    context: "failed to open git repo",
    source: Discover(
        NoGitRepository {
            path: "~/.cache/helix",
        },
    ),
}
2023-05-27T17:28:45.124 helix_vcs [INFO] failed to open diff base for ~/.cache/helix/helix.log
2023-05-27T17:28:45.124 helix_vcs [INFO] Error {
    context: "failed to open git repo",
    source: Discover(
        NoGitRepository {
            path: "~/.cache/helix",
        },
    ),
}
2023-05-27T17:28:45.124 helix_vcs [INFO] failed to obtain current head name for ~/.cache/helix/helix.log
2023-05-27T17:28:45.124 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2023-05-27T17:28:45.125 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:28:45.125 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:28:47.247 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:28:47.248 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:28:47.345 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:28:47.346 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:28:47.745 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:28:52.096 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:28:52.097 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:28:52.497 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:28:58.615 helix_view::editor [DEBUG] editor status: register '/' set to '2023\-05\-27T17:28:44\.697 '
2023-05-27T17:28:58.617 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:28:58.617 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:28:59.018 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:00.392 helix_view::editor [DEBUG] editor status: Wrapped around document
2023-05-27T17:29:00.395 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:00.396 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:00.792 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:00.873 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:00.874 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:01.165 helix_view::editor [DEBUG] editor status: Wrapped around document
2023-05-27T17:29:01.167 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:01.167 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:01.383 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:01.384 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:01.564 helix_view::editor [DEBUG] editor status: Wrapped around document
2023-05-27T17:29:01.566 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:01.567 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:01.720 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:01.721 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:01.885 helix_view::editor [DEBUG] editor status: Wrapped around document
2023-05-27T17:29:01.886 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:01.887 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:02.033 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:02.033 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:02.179 helix_view::editor [DEBUG] editor status: Wrapped around document
2023-05-27T17:29:02.180 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:02.180 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:02.580 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:03.029 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:03.030 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:03.120 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:03.121 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:03.521 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:04.495 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:04.496 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:04.787 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:04.788 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:04.877 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:04.877 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:04.895 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:05.030 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:05.031 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:05.351 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:29:05.352 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:05.352 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":true,"tabSize":2},"textDocument":{"uri":"file://~/path/package.json"}},"id":1}
2023-05-27T17:29:05.355 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":[{"range":{"start":{"line":23,"character":1},"end":{"line":24,"character":0}},"newText":""}]}
2023-05-27T17:29:05.355 helix_lsp::transport [INFO] <- [{"newText":"","range":{"end":{"character":0,"line":24},"start":{"character":1,"line":23}}}]
2023-05-27T17:29:05.355 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":24},"start":{"character":1,"line":23}},"text":""}],"textDocument":{"uri":"file://~/path/package.json","version":1}}}
2023-05-27T17:29:05.368 helix_vcs::diff::worker [INFO] Diff computation timed out, update of diffs might appear delayed
2023-05-27T17:29:05.369 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:05.369 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:05.860 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file://~/path/package.json","diagnostics":[]}}
2023-05-27T17:29:05.860 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [], "uri": String("file://~/path/package.json")}) })))
2023-05-27T17:29:05.861 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:05.863 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:06.438 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:06.439 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:06.838 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:06.996 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:06.996 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:07.396 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:07.399 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:07.400 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:08.607 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:08.608 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:09.007 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:10.048 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:10.049 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:10.449 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:11.003 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:11.004 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:11.080 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:11.081 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:11.232 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:11.232 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:11.632 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:11.890 helix_view::editor [DEBUG] editor status: Wrapped around document
2023-05-27T17:29:11.891 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:11.892 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:12.285 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:12.286 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:12.686 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:13.220 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:13.221 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:13.537 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:13.538 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:13.578 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:13.578 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:13.621 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:29:13.703 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:13.704 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:13.922 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:13.923 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:13.971 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:13.971 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:14.123 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:14.124 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0
2023-05-27T17:29:14.446 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:29:14.447 helix_view::document [DEBUG] id 3 modified - last saved: 0, current: 0


023-05-27T17:37:17.581 helix_view::clipboard [DEBUG] Using pbcopy+pbpaste to interact with the system clipboard
2023-05-27T17:37:17.585 helix_lsp::client [INFO] Using custom LSP config: {"provideFormatter":true}
2023-05-27T17:37:17.585 helix_view::editor [DEBUG] editor status: Loaded 1 file.
2023-05-27T17:37:17.586 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.05 (7f5940be)"},"initializationOptions":{"provideFormatter":true},"processId":34474,"rootPath":"/~/path","rootUri":"file:///~/path","workspaceFolders":[{"name":"personal-site","uri":"file:///~/path"}]},"id":0}
2023-05-27T17:37:17.586 helix_tui::backend::crossterm [DEBUG] The keyboard enhancement protocol is supported in this terminal (checked in 553.25µs)
2023-05-27T17:37:17.587 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:17.708 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"resolveProvider":false,"triggerCharacters":["\"",":"]},"hoverProvider":true,"documentSymbolProvider":true,"documentRangeFormattingProvider":true,"documentFormattingProvider":true,"colorProvider":{},"foldingRangeProvider":true,"selectionRangeProvider":true,"documentLinkProvider":{},"diagnosticProvider":{"documentSelector":null,"interFileDependencies":false,"workspaceDiagnostics":false}}}}
2023-05-27T17:37:17.708 helix_lsp::transport [INFO] <- {"capabilities":{"colorProvider":{},"completionProvider":{"resolveProvider":false,"triggerCharacters":["\"",":"]},"diagnosticProvider":{"documentSelector":null,"interFileDependencies":false,"workspaceDiagnostics":false},"documentFormattingProvider":true,"documentLinkProvider":{},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"foldingRangeProvider":true,"hoverProvider":true,"selectionRangeProvider":true,"textDocumentSync":2}}
2023-05-27T17:37:17.708 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2023-05-27T17:37:17.708 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: None, method: "initialized", params: None })))
2023-05-27T17:37:17.708 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"provideFormatter":true}}}
2023-05-27T17:37:17.708 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"json","text":"{\n  \"name\": \"personal-site\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Description\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"lh\": \"eleventy && npx lhci autorun ; npx lhci open --url\",\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"keywords\": [],\n  \"author\": \"Author\",\n  \"repository\": \"github:repo\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"@11ty/eleventy\": \"^2.0.0-beta.1\",\n    \"@lhci/cli\": \"^0.10.0\",\n    \"clean-css\": \"^5.0.1\",\n    \"eleventy-plugin-local-images\": \"^0.4.0\",\n    \"prettier\": \"^2.2.1\"\n  },\n  \"dependencies\": {\n    \"eleventy-plugin-reading-time\": \"0.0.1\"\n  }\n}\n","uri":"file:///~/path/package.json","version":0}}}
2023-05-27T17:37:17.709 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:17.983 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:37:18.225 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///~/path/package.json","diagnostics":[]}}
2023-05-27T17:37:18.225 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [], "uri": String("file:///~/path/package.json")}) })))
2023-05-27T17:37:18.226 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:18.948 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:19.347 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:37:19.366 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:19.509 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:19.718 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:20.170 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-05-27T17:37:20.172 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":true,"tabSize":2},"textDocument":{"uri":"file:///~/path/package.json"}},"id":1}
2023-05-27T17:37:20.174 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":[{"range":{"start":{"line":23,"character":1},"end":{"line":24,"character":0}},"newText":""}]}
2023-05-27T17:37:20.174 helix_lsp::transport [INFO] <- [{"newText":"","range":{"end":{"character":0,"line":24},"start":{"character":1,"line":23}}}]
2023-05-27T17:37:20.174 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":24},"start":{"character":1,"line":23}},"text":""}],"textDocument":{"uri":"file:///~/path/package.json","version":1}}}
2023-05-27T17:37:20.188 helix_vcs::diff::worker [INFO] Diff computation timed out, update of diffs might appear delayed
2023-05-27T17:37:20.189 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:37:20.678 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///~/path/package.json","diagnostics":[]}}
2023-05-27T17:37:20.679 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [], "uri": String("file:///~/path/package.json")}) })))
2023-05-27T17:37:20.680 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:37:21.409 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:37:21.610 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:37:21.795 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:37:21.810 helix_term::application [DEBUG] received editor event: IdleTimer
2023-05-27T17:37:21.860 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1
2023-05-27T17:37:22.187 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1

Platform

macOS 13.3

Terminal Emulator

iTerm 2 Build 3.4.19

Helix Version

helix 23.05 (7f5940b)

@djpowers djpowers added the C-bug Category: This is a bug label May 27, 2023
@yusuphgammut
Copy link
Contributor

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 hx -v, but seems that the server is not returning any diagnostics, so the problem might reside at the communication level, or at the servers themselves for some reason.

@jonas-w
Copy link

jonas-w commented Jun 5, 2023

You need to set the json.validate.enable in the config like so:

config = { "json" = { "validate" = { "enable" = true } } }

This fixed it for me, thanks!

@yusuphgammut
Copy link
Contributor

@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?

@jonas-w
Copy link

jonas-w commented Jun 5, 2023

@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.
https://github.com/microsoft/vscode/blob/aa88e727da3dcb58b112085afa466b5e43ab1c1b/extensions/json-language-features/server/src/jsonServer.ts#L205

@yusuphgammut
Copy link
Contributor

yusuphgammut commented Jun 5, 2023

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.

@djpowers
Copy link
Contributor Author

djpowers commented Jun 8, 2023

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 languages.toml config when initially testing, not sure.)

Formatting

with default languages.toml file

  • ⚠️ formatting works (via LSP)
  • ❌ deletes ending newline

with provideFormatter and keepLines both enabled

[[language]]
name = "json"
config = { "provideFormatter" = true, "json" = { "keepLines" = { "enable" = true } } }
  • ⚠️ formatting works (via LSP)
  • ✅ preserves ending newline

with only formatter set (no config necessary)

[[language]]
name = "json"
formatter = { command = 'prettier', args = ["--parser", "json"] }
  • ✅ formatting works (via Prettier)
  • ✅ preserves ending newline

I wasn't able to prevent the newline removal using the default LSP formatter for HTML or CSS, but I was planning to use Prettier for these anyway so that solution works for me.


Diagnostics

I must've had the validate syntax wrong before, but giving it another try I was able to get diagnostics working. Here's the full config change in context (using local Prettier):

[[language]]
name = "html"
formatter = { command = 'npx', args = ["prettier", "--parser", "html"] }

[[language]]
name = "json"
config = { "json" = { "validate" = { "enable" = true } } }
formatter = { command = 'npx', args = ["prettier", "--parser", "json"] }

[[language]]
name = "css"
config = { "css" = { validate = { enable = true } } }
formatter = { command = 'npx', args = ["prettier", "--parser", "css"] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants