Formatting Doesn't work in emacs
Is there an existing issue for this?
- [x] I have searched the existing issues
Platform
x64 Linux (linux-x64, Most Common)
Editor
Emacs
Editor Version
30.1
Describe the bug
When running the command eglot-format or eglot-format-buffer using the configuration from the tinymist docs, I get the following error:
eglot--error: [eglot] Unsupported or ignored LSP capability `:documentFormattingProvider'
Server Logs
This is the output of the eglot-events-buffer which is hopefully what is wanted here.
[jsonrpc] D[15:40:11.994] Running language server: /home/david/.nix-profile/bin/tinymist
[jsonrpc] e[15:40:11.995] --> initialize[1] {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":31108,"clientInfo":{"name":"Eglot","version":"1.17.30"},"rootPath":"/home/david/","rootUri":"file:///home/david","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":true,"executeCommand":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":false},"configuration":true,"workspaceFolders":true},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":false,"deprecatedSupport":true,"resolveSupport":{"properties":["documentation","details","additionalTextEdits"]},"tagSupport":{"valueSet":[1]}},"contextSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true},"documentationFormat":["markdown","plaintext"],"activeParameterSupport":true}},"references":{"dynamicRegistration":false},"definition":{"dynamicRegistration":false,"linkSupport":true},"declaration":{"dynamicRegistration":false,"linkSupport":true},"implementation":{"dynamicRegistration":false,"linkSupport":true},"typeDefinition":{"dynamicRegistration":false,"linkSupport":true},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"documentHighlight":{"dynamicRegistration":false},"codeAction":{"dynamicRegistration":false,"resolveSupport":{"properties":["edit","command"]},"dataSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"isPreferredSupport":true},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false,"codeDescriptionSupport":false,"tagSupport":{"valueSet":[1,2]}}},"window":{"showDocument":{"support":true},"workDoneProgress":true},"general":{"positionEncodings":["utf-32","utf-8","utf-16"]},"experimental":{}},"workspaceFolders":[{"uri":"file:///home/david","name":"~/"}]}}
[stderr] [2025-04-18T19:40:11Z INFO tinymist] tinymist LSP version information: [["Build Timestamp", "1980-01-01T00:00:00.000000000Z"], ["Build Git Describe", "VERGEN_IDEMPOTENT_OUTPUT"], ["Commit SHA", "VERGEN_IDEMPOTENT_OUTPUT"], ["Commit Date", "None"], ["Commit Branch", "None"], ["Cargo Target Triple", "x86_64-unknown-linux-gnu"], ["Typst Version", "0.12.0"], ["Typst Source", "git+https://github.com/Myriad-Dreamin/typst.git?tag=tinymist-v0.12.0#58426a90a7ef721738a01be09793d33e55eb75a9"]]
[stderr] [2025-04-18T19:40:11Z INFO tinymist] starting LSP server: LspArgs {
[stderr] mirror: MirrorArgs {
[stderr] mirror: "",
[stderr] replay: "",
[stderr] },
[stderr] font: CompileFontArgs {
[stderr] font_paths: [],
[stderr] ignore_system_fonts: false,
[stderr] },
[stderr] }
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] handling initialize - (1) at Instant { tv_sec: 6550, tv_nsec: 540732341 }
[jsonrpc] e[15:40:11.998] <-- initialize[1] {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"codeActionProvider":true,"codeLensProvider":{"resolveProvider":false},"colorProvider":true,"completionProvider":{"triggerCharacters":["#","(","<",",",".",":","/","\"","@"]},"definitionProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{},"documentSymbolProvider":true,"executeCommandProvider":{"commands":["tinymist.getResources","tinymist.doKillPreview","tinymist.pinMain","tinymist.getDocumentMetrics","tinymist.doClearCache","tinymist.doInitTemplate","tinymist.interactCodeContext","tinymist.exportAnsiHighlight","tinymist.getWorkspaceLabels","tinymist.scrollPreview","tinymist.exportQuery","tinymist.exportHtml","tinymist.exportPdf","tinymist.exportSvg","tinymist.doGetTemplateEntry","tinymist.getServerInfo","tinymist.exportText","tinymist.doStartPreview","tinymist.exportMarkdown","tinymist.focusMain","tinymist.getDocumentTrace","tinymist.exportPng"]},"experimental":{"onEnter":true},"foldingRangeProvider":true,"hoverProvider":true,"inlayHintProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["strong","emph","math"],"tokenTypes":["comment","string","keyword","operator","number","function","decorator","bool","punct","escape","link","raw","label","ref","heading","marker","term","delim","pol","error","text"]}},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":{"change":2,"openClose":true,"save":true},"workspace":{"workspaceFolders":{"changeNotifications":true,"supported":true}},"workspaceSymbolProvider":true}}}
[jsonrpc] e[15:40:11.998] --> initialized {"jsonrpc":"2.0","method":"initialized","params":{}}
[jsonrpc] e[15:40:11.999] --> textDocument/didOpen {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/david/testagain.typ","version":0,"languageId":"typst","text":"\n\naasdf asdfasd asdf\n"}}}
[jsonrpc] e[15:40:11.999] --> workspace/didChangeConfiguration {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"tinymist":{"formatterMode":"typstyle"}}}}
[jsonrpc] e[15:40:12.001] --> textDocument/inlayHint[2] {"jsonrpc":"2.0","id":2,"method":"textDocument/inlayHint","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"range":{"start":{"line":0,"character":0},"end":{"line":3,"character":0}}}}
[stderr] [2025-04-18T19:40:11Z INFO tinymist::init] preferred theme: None {}
[stderr] [2025-04-18T19:40:11Z INFO tinymist::server] LanguageState: initialized with config Config { const_config: ConstConfig { position_encoding: Utf8, cfg_change_registration: true, notify_will_rename_files: false, tokens_dynamic_registration: false, tokens_overlapping_token_support: false, tokens_multiline_token_support: false, doc_line_folding_only: true, doc_fmt_dynamic_registration: false }, compile: CompileConfig { roots: ["/home/david"], output_path: PathPattern(""), export_pdf: Never, root_path: None, font_opts: CompileFontArgs { font_paths: [], ignore_system_fonts: false }, system_fonts: None, font_paths: [], fonts: OnceCell(Uninit), notify_status: false, periscope_args: None, typst_extra_args: Some(CompileExtraOpts { root_dir: None, entry: None, inputs: {}, font: CompileFontArgs { font_paths: [], ignore_system_fonts: false }, creation_timestamp: None, cert: None }), preferred_theme: None, has_default_entry_path: false, lsp_inputs: {"x-preview": "{\"version\":1,\"theme\":\"\"}"} }, semantic_tokens: Enable, formatter_mode: Disable, formatter_print_width: None }
[stderr] [2025-04-18T19:40:11Z INFO tinymist::actor] TypstActor: creating server for primary, entry: EntryState { rooted: true, root: Some("/home/david"), main: None }, inputs: {"x-preview": "{\"version\":1,\"theme\":\"\"}"}
[stderr] [2025-04-18T19:40:11Z INFO tinymist::init] creating SharedFontResolver with CompileFontArgs { font_paths: [], ignore_system_fonts: false }
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] handled initialize - (1) in 829.63µs
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] notifying initialized - at Instant { tv_sec: 6550, tv_nsec: 541961446 }
[stderr] [2025-04-18T19:40:11Z INFO tinymist::server] server initialized
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] notifing initialized succeeded in 28.78µs
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] notifying textDocument/didOpen - at Instant { tv_sec: 6550, tv_nsec: 542807744 }
[stderr] [2025-04-18T19:40:11Z INFO tinymist::server] did open Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/david/testagain.typ", query: None, fragment: None }
[stderr] [2025-04-18T19:40:11Z INFO tinymist::server] create source: "/home/david/testagain.typ"
[stderr] [2025-04-18T19:40:11Z INFO tinymist::actor::typ_client] the entry file of TypstActor(primary) is changing to EntryState { rooted: true, root: Some("/home/david"), main: Some(/testagain.typ) }
[stderr] [2025-04-18T19:40:11Z INFO tinymist::server] file focused[implicit,o]: Some("/home/david/testagain.typ")
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] notifing textDocument/didOpen succeeded in 94.24µs
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] notifying workspace/didChangeConfiguration - at Instant { tv_sec: 6550, tv_nsec: 543193991 }
[stderr] [2025-04-18T19:40:11Z INFO tinymist::init] preferred theme: None {"tinymist": Object {"formatterMode": String("typstyle")}}
[stderr] [2025-04-18T19:40:11Z INFO tinymist::server] new settings applied
[stderr] [2025-04-18T19:40:11Z INFO sync_lsp] notifing workspace/didChangeConfiguration succeeded in 51.12µs
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handling textDocument/inlayHint - (2) at Instant { tv_sec: 6550, tv_nsec: 545431995 }
[jsonrpc] e[15:40:12.005] <-- client/registerCapability[0] {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"config","method":"workspace/didChangeConfiguration"}]}}
[jsonrpc] e[15:40:12.009] --> client/registerCapability[0] {"jsonrpc":"2.0","id":0,"result":null}
[stderr] [2025-04-18T19:40:12Z INFO tinymist::actor::editor] received status request(primary) Compiling
[jsonrpc] e[15:40:12.083] <-- textDocument/inlayHint[2] {"jsonrpc":"2.0","id":2,"result":[]}
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handled textDocument/inlayHint - (2) in 81.03ms
[stderr] [2025-04-18T19:40:12Z INFO tinymist::actor::editor] received diagnostics from primary:4: diag(Some(0))
[stderr] [2025-04-18T19:40:12Z INFO tinymist::actor::editor] received status request(primary) CompileSuccess
[stderr] [2025-04-18T19:40:12Z INFO tinymist::task::cache] CacheEvictTask: evict cache in 2.474µs
[stderr] [2025-04-18T19:40:12Z INFO tinymist::actor::editor] received status request(primary) Compiling
[stderr] [2025-04-18T19:40:12Z INFO tinymist::actor::editor] received diagnostics from primary:5: diag(Some(0))
[stderr] [2025-04-18T19:40:12Z INFO tinymist::actor::editor] received status request(primary) CompileSuccess
[stderr] [2025-04-18T19:40:12Z INFO tinymist::task::cache] CacheEvictTask: evict cache in 581ns
[jsonrpc] e[15:40:12.505] --> textDocument/hover[3] {"jsonrpc":"2.0","id":3,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"position":{"line":2,"character":17}}}
[jsonrpc] e[15:40:12.505] --> textDocument/documentHighlight[4] {"jsonrpc":"2.0","id":4,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"position":{"line":2,"character":17}}}
[jsonrpc] e[15:40:12.506] --> textDocument/signatureHelp[5] {"jsonrpc":"2.0","id":5,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"position":{"line":2,"character":17}}}
[jsonrpc] e[15:40:12.508] <-- textDocument/hover[3] {"jsonrpc":"2.0","id":3,"result":null}
[jsonrpc] e[15:40:12.508] <-- textDocument/documentHighlight[4] {"jsonrpc":"2.0","id":4,"result":null}
[jsonrpc] e[15:40:12.508] <-- textDocument/signatureHelp[5] {"jsonrpc":"2.0","id":5,"result":null}
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handling textDocument/hover - (3) at Instant { tv_sec: 6551, tv_nsec: 49643601 }
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handling textDocument/documentHighlight - (4) at Instant { tv_sec: 6551, tv_nsec: 49858458 }
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handling textDocument/signatureHelp - (5) at Instant { tv_sec: 6551, tv_nsec: 50150178 }
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handled textDocument/hover - (3) in 632.11µs
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handled textDocument/documentHighlight - (4) in 467.99µs
[stderr] [2025-04-18T19:40:12Z INFO sync_lsp] handled textDocument/signatureHelp - (5) in 481.04µs
[jsonrpc] e[15:40:30.491] --> textDocument/hover[6] {"jsonrpc":"2.0","id":6,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"position":{"line":1,"character":0}}}
[jsonrpc] e[15:40:30.491] --> textDocument/documentHighlight[7] {"jsonrpc":"2.0","id":7,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"position":{"line":1,"character":0}}}
[jsonrpc] e[15:40:30.491] --> textDocument/signatureHelp[8] {"jsonrpc":"2.0","id":8,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///home/david/testagain.typ"},"position":{"line":1,"character":0}}}
[jsonrpc] e[15:40:30.498] <-- textDocument/hover[6] {"jsonrpc":"2.0","id":6,"result":null}
[jsonrpc] e[15:40:30.498] <-- textDocument/documentHighlight[7] {"jsonrpc":"2.0","id":7,"result":null}
[jsonrpc] e[15:40:30.498] <-- textDocument/signatureHelp[8] {"jsonrpc":"2.0","id":8,"result":null}
[stderr] [2025-04-18T19:40:30Z INFO sync_lsp] handling textDocument/hover - (6) at Instant { tv_sec: 6569, tv_nsec: 35167252 }
[stderr] [2025-04-18T19:40:30Z INFO sync_lsp] handling textDocument/documentHighlight - (7) at Instant { tv_sec: 6569, tv_nsec: 35318301 }
[stderr] [2025-04-18T19:40:30Z INFO sync_lsp] handling textDocument/signatureHelp - (8) at Instant { tv_sec: 6569, tv_nsec: 35418595 }
[stderr] [2025-04-18T19:40:30Z INFO sync_lsp] handled textDocument/hover - (6) in 342.15µs
[stderr] [2025-04-18T19:40:30Z INFO sync_lsp] handled textDocument/documentHighlight - (7) in 277.44µs
[stderr] [2025-04-18T19:40:30Z INFO sync_lsp] handled textDocument/signatureHelp - (8) in 429.00µs
Browser Logs
Forgive, me, but not really sure what is wanted here. This is the eglot error though
eglot--error: [eglot] Unsupported or ignored LSP capability `:documentFormattingProvider'
Additional context
The only other issue that references documentFormattingProvider is this one https://github.com/Myriad-Dreamin/tinymist/issues/1018, though I'm not sure it is related.
Could you help check it? @Ziqi-Yang
Staled user questions. Should have found solutions by themselves.
For anyone struggling with this, I was able to get it to work in lsp-mode by calling
(lsp--set-configuration `(:formatterMode "typstyle"))
after tinymist had started with a custom hook.
I'm not familiar with eglot, but this might help for changing settings 👍🏼