From 36c7ed2b678f352c9938da3188ad3f689cd1a7bb Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 26 Jan 2025 22:26:53 +0100 Subject: add language server configuration to its object table --- init.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index a47ad22..865d35a 100644 --- a/init.lua +++ b/init.lua @@ -1280,7 +1280,10 @@ local function find_root_uri(ls, file_path) end local function ls_start(ls, init_options) - ls.fd = vis:communicate(ls.name, 'exec ' .. ls.cmd) + ls.fd = vis:communicate(ls.name, 'exec ' .. ls.conf.cmd) + + -- detect the workspace root + ls.rootUri = vis.win.file and find_root_uri(ls, vis.win.file.path) -- register the response handler vis.events.subscribe(vis.events.PROCESS_RESPONSE, function(name, event, code, msg) @@ -1310,7 +1313,7 @@ local function ls_start(ls, init_options) local params = { processId = vis_pid, clientInfo = {name = lspc.name, version = lspc.version}, - rootUri = (vis.win.file and find_root_uri(ls, vis.win.file.path)) or lspc.json.null, + rootUri = ls.rootUri or lspc.json.null, capabilities = lspc.client_capabilites, } @@ -1324,10 +1327,8 @@ end function LanguageServer.new(ls_conf) local ls = { name = ls_conf.name, - cmd = ls_conf.cmd, - settings = ls_conf.settings, - roots = ls_conf.roots, - formatting_options = ls_conf.formatting_options, + conf = ls_conf, + initialized = false, id = 0, inflight = {}, @@ -1635,7 +1636,7 @@ vis:command_register('lspc-format', function(argv, _, win) local params = { textDocument = {uri = path_to_uri(win.file.path)}, - options = ls.formatting_options, + options = ls.conf.formatting_options, } if params.options == nil then params.options = { -- cgit v1.2.3