lite-xl / lite-xl-lsp

LSP Plugin for Lite XL editor
MIT License
158 stars 21 forks source link

[Request] Easier configuring LSP server after initialization #89

Open ghost opened 7 months ago

ghost commented 7 months ago

Currently, if you want to configure something at runtime (eg; change the command for a specific project) you need to do something like this in your .lite_project.lua

local lsp = require "plugins.lsp"
lsp.servers.server_name.option = value

Real world example of adding another path to Jedi's init_options:

local lsp = require "plugins.lsp"
lsp.servers.jedi.init_options.workspace.extraPaths[2] = "foo"

I think it would be easier if you could configure things using lspconfig, something like this:

local lspconfig = require "plugins.lsp.config"
lspconfig.jedi.init_options.workspace.extraPaths[2] = "foo"

instead of digging through the code to find how to configure settings

Guldoman commented 7 months ago

What do you think about adding a function to retrieve a server table by name? Mostly because lspconfig only contains the "preconfigured" servers, and it wouldn't contain anything added directly via lsp.add_server.

So something like

local sumneko = lsp.get_server_by_name("lua-language-server")
sumneko.settings.Lua.signatureHelp.enable = false

Or even something like

lsp.update_server_config("lua-language-server", {
  settings = {
    Lua = {
      signatureHelp = { enable = false }
    }
  }
})
ghost commented 7 months ago

yeah that seems much better, I proposed lspconfig because it looked like the most obvious place to configure LSP servers

Guldoman commented 7 months ago

Until the end of the month I won't be able to implement this as I don't have much time. Until then, anyone that wants to give this a try, I'd be glad to review and merge their proposal!