typst-lsp icon indicating copy to clipboard operation
typst-lsp copied to clipboard

Configuration read from top-level `exportPdf` instead of from `typst-lsp.exportPdf`

Open kotatsuyaki opened this issue 1 year ago • 0 comments

  • Component:

    • LSP (used with Emacs with Eglot)
  • LSP version: 0.13.0 from Nixpkgs

  • OS version and name: NixOS unstable

  • I am on the latest stable version of the extension/LSP.

  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

On Emacs with the Eglot LSP client (after applying a workaround for #434), I configured typst-lsp to export onType with the following .dir-locals.el, but typst-lsp keeps exporting on save instead of on type:

;; The non-working configuration.
((nil
  . ((eglot-workspace-configuration
      . (:typst-lsp (:exportPdf "onType"))))))

The above configuration for Eglot translates to the following call to didChangeConfiguration:

// The non-working call.
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"typst-lsp":{"exportPdf":"onType"}}}}

I read the code, and it seems like this line in lsp.rs calls config.update_by_map(&values) where values corresponds to {"typst-lsp":{"exportPdf":"onType"}} in the above JSON. However, in this line in config.rs it accesses the map with the key "exportPdf", instead of with "typst-lsp" first and then "exportPdf".

I modified my configuration to have the "exportPdf" key at the root, instead of under "typst-lsp", and it worked:

;; The working (but wrong) configuration.
((nil
  . ((eglot-workspace-configuration
      . (:exportPdf "onType")))))

The above working config translates to:

// The working (but wrong) call.
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"exportPdf":"onType"}}}

I believe that this is a bug, as the configurations should be under the key "typst-lsp".

kotatsuyaki avatar Jun 17 '24 10:06 kotatsuyaki