Open Ziqi-Yang opened 2 months ago
Can emacs put entries under tinymist
or configure tinymist
separately without changing lsp server? Since, for example, neovim retrieve settings per lsp server.
Btw, you can try tinymist.exportPdf
, as lsp server requests both xxx
and tinymist.xxx
at same time.
Can emacs put entries under tinymist or configure tinymist separately without changing lsp server?
Emacs have many lsp client implementations, such as eglot
, lsp-mode
, lsp-bridge
and lspce
, among which eglot
becomes as the official one since Emacs 29.
For eglot, it is not possible to pass configuration separately and specifically to a certain langauge server. It will always pass the value of eglot-workspace-configuration
as a whole into the the language server it launched. I think it does this style is because many other language server does make their name as the top-level entry just like namespace.
Btw, you can try tinymist.exportPdf, as lsp server requests both xxx and tinymist.xxx at same time.
This can work (corresponding to exportPdf
), but tinymist
's configuration pollutes eglot-workspace-configuration
(setq-default eglot-workspace-configuration
'(:pylsp (:plugins (:ruff (:enabled t)))
:exportPdf "onSave"))
And this is its log:
[stderr] [2024-08-15T12:29:09Z INFO tinymist::init] preferred theme: None {"exportPdf": String("onSave"), "pylsp": Object {"plugins": Object {"ruff": Object {"enabled": Bool(true)}}}}
[stderr] [2024-08-15T12:29:09Z INFO tinymist::server] new settings applied
But this cannot: (corresponding to tinymist.exportPdf
)
(setq-default eglot-workspace-configuration
'(
:pylsp (:plugins (:ruff (:enabled t)))
:tinymist (:exportPdf "onSave")))
And this is its log:
[stderr] [2024-08-15T12:31:26Z INFO tinymist::init] preferred theme: None {"pylsp": Object {"plugins": Object {"ruff": Object {"enabled": Bool(true)}}}, "tinymist": Object {"exportPdf": String("onSave")}}
[stderr] [2024-08-15T12:31:26Z INFO tinymist::server] new settings applied
I'm confused because I don't know whether when we add a tinymist
section, the neovim users must configure like this:
-- add tinymist to lspconfig
{
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
tinymist = {
settings = {
tinymist = { exportPdf = "onTyped" }
}
},
},
},
},
On the path, tinymist
occurs twice.
gopls also have gopls
occurs twice (see https://github.com/golang/tools/blob/master/gopls/doc/vim.md#configuration):
local lspconfig = require("lspconfig")
lspconfig.gopls.setup({
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
gofumpt = true,
},
},
})
Though I don't think it's mandatory. And there may also be some or many language servers don't use its name as the top-level entry beyond my preliminary investigation.
If you don't like to add an top-level entry/namespace, it's absolutely OK. The reason I propose it is because that setting it in Emacs eglot-workspace-configuration
seems awkward. However, I can also change the initial launch argument to make it work too. BTW, I'd like to add a instruction file for using tinymist
in Emacs.
I think of it reasonable to detect whether there is a tinymist
section returned from client and merged with rest sections, which should have higher priority. It means the following configuration is totally valid:
settings = {
tinymist = { exportPdf = "onTyped" } -- priority: high
'tinymist.exportPdf' = "onTyped" -- priority: middle
exportPdf = "onTyped" -- priority: low
}
It requires server changes. Three styles look a bit unclear but we can collect all voices for break change. The only thing must be ensured is not to disturb users from other editors.
The reason I propose it is because that setting it in Emacs eglot-workspace-configuration seems awkward.
Btw, I think it is probably a design defect of eglot-workspace-configuration
. Someone (editor or you) may do wrong, but I see the configuration for pylsp
is shown in the log which is not needed by tinymist.
To add README for emacs, you can update this file.
And run:
yarn build:typlite
node .\scripts\link-docs.mjs
If you don't have node runtime, you can just update the script and add a typ file. I'll run the script them.
Note: I'm not talking about initialization options, but settings.
I have read the tinymist language server configuration doc. It has configuration entries like
outputPath
directly on the top-most level, i.e.However, many other language servers like rust-analyzer, python language server, gopls uses
rust-analyzer
,pylsp
,gopls
as the top-most entry of their setting respectively. That's to say:Currently, I have to configure Emacs like this to successfully customize Tinymis (though I know I can also specify the initialization option to configure it):
Instead of this:
You can see the difference. If I want to customize
tinymist
, then I need to discard all configurations for other language servers, sinceeglot-workspace-configuration
is directly passed intotinymist
as a whole (the following log corresponds to the first one configuration style):I believe having
tinymist
as the top-most level configuration entry is meaningful - maybe it enables multiple language servers working?