Repository navigation
Make formatting work, and say which formatter is behind it - #115
Merged
Merged
Conversation
…t that formatting works
…ored into tinymist
…test directory names
Simplified the description of the Typst formatter option.
Removed extra details from gopls formatter description.
Removed extra information from the description of the Haskell formatter option.
Shortened the description for the Python formatter option in the lsp configuration.
Removed description for Solargraph formatting option.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Went through every language server to see whether formatting works and what backs it.
Fixed where it didn't:
rustfmtfromPATH, which wasn't there, so every format request failed withFailed to spawn "rustfmt". Added it (19 MB; rustc/cargo were already in the closure).kernels.ruby.lsp.solargraph.formatting; it formats with rubocop, already a gem dependency with a config in this repo.Added a setting where there's more than one formatter to choose from, all of them already built into the server except Python's:
kernels.go.lsp.gopls.formatterkernels.haskell.lsp.haskell-language-server.formattingProviderkernels.python3.lsp.python-lsp-server.formatterexporters.typst.lsp.tinymist.formatterclangd, clojure-lsp, LanguageServer.jl, R's languageserver and typescript-language-server needed nothing.
The feature matrix's Formatting column is derived, not hand-written: each language server declares
passthru.formatters, and the column counts as supported only when the server advertises formatting and a formatter is named — which is exactly the bash/shfmt failure mode. The formatter's name shows in the SVG cell's tooltip and in the table in FEATURE-MATRIX.md.Every formatter has a test that formats a misformatted document over LSP and checks the result.
Four languages reach their server through a notebook proxy, so those also get the same test against a
main.ipynbcell — the only case where the server sees a bare.ipynbURI. Rust passes. Go passes for a cell of plain statements and ispendingfor a cell with an import. C++ and Haskell arepending: cpp-notebook-language-server forwards the notebook's URI so clangd answers "trying to format non-added document", and HLS rejects the extension outright ("ormolu does not support .ipynb filetypes").plans/notebook-formatting-in-proxies.mdhas the details. The other nine languages set a non-emptynotebook_suffix, so codedown hands their servermain.ipynb.rband friends — the same case the raw-file test already covers.Rust also bumps rust-notebook-language-server to 0.2.5.0, which fixes formatting inside notebook cells (it was forwarding
textDocument/formattingwith the notebook's URI instead of the shadow file's).Getting the R language server to run at all
R had no LSP test before this, and four separate things stopped one from working:
/bin/shat startup (processx's.onLoadcallssystem(), which goes throughpopen).parallel::detectCores()shells out togrep "^processor" /proc/cpuinfo | wc -l, and the hermetic PATH had nogrep. Without it detectCores returns NA and the server dies sizing its session pool.show code, so they contained backslashes; R.cache rewrites those to forward slashes and then can't write styler's cache. Formatting test names no longer embed the code.shutdownwithresult: []where the spec saysnull. lsp-test couldn't decode it, the thread reading the server's output died, and the session hung in teardown forever. Fixed in lsp-test (lsp-test: don't let an undecodable message or a silent server hang the session lsp#1): undecodable messages are skipped and the shutdown wait is bounded.The
result: []is a server bug either way, so languageserver now builds from codedownio/languageserver — upstream master plus the one-line fix. That also moves us off the 0.3.16 pin this repo has carried since 2024. The same branch is what goes upstream as a PR; thesrchere goes back to REditorSupport once it lands.Unmerged pin
tests/stack.yamlpoints atcodedownio/lsp-test-helpersbranchkernel-piggyback-and-binsh(the/bin/sh), which needs merging and the pin moved.Unrelated change in the regenerated matrix
Go's Semantic highlighting flips to "not available". gopls 0.22 leaves its
semanticTokenssetting off by default; the stored probe data was stale.