From 3e1894cd0825e028c9e37c90f8dbaa8499fdd4e3 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 2 Jan 2023 19:11:55 +0100 Subject: move client config and capabilities into separate file This helps to move code out of the to big init.lua as well as allows to use the vis-lspc version in different lua files. --- init.lua | 73 +++------------------------------------------------------------- 1 file changed, 3 insertions(+), 70 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 23c4223..2c97d4b 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2021 Florian Fischer. All rights reserved. +-- Copyright (c) 2021-2023 Florian Fischer. All rights reserved. -- Use of this source code is governed by a MIT license found in the LICENSE file. -- We require vis compiled with the communicate patch local source_str = debug.getinfo(1, 'S').source:sub(2) @@ -52,34 +52,7 @@ jsonrpc.error_codes = { } -- state of our language server client -local lspc = { - -- mapping language server names to their state tables - running = {}, - name = 'vis-lspc', - version = '0.1.5', - -- write log messages to lspc.log_file - logging = false, - log_file = nil, - -- automatically start a language server when a new window is opened - autostart = true, - -- program used to let the user make choices - -- The available choices are pass to on stdin separated by '\n' - menu_cmd = 'vis-menu', - -- program used to ask the user for confirmation - confirm_cmd = 'vis-menu', - - -- should diagnostics be highlighted if available - highlight_diagnostics = false, - -- style id used by lspc to register the style used to highlight diagnostics - diagnostic_style_id = 43, - -- style used by lspc to highlight the diagnostic range - -- 60% solarized red - diagnostic_style = 'back:#e3514f', - - -- message level to show in the UI when receiving messages from the server - -- Error = 1, Warning = 2, Info = 3, Log = 4 - message_level = 3, -} +local lspc = dofile(source_path .. 'lspc.lua') -- Forward declaration of lspc_err to use it in capture_cmd local lspc_err @@ -174,46 +147,6 @@ do end assert(vis_pid) --- ---- ClientCapabilities we tell the language server when calling "initialize" --- -local supported_markup_kind = {'plaintext'} - -local goto_methods_capabilities = { - linkSupport = true, - dynamicRegistration = false, -} - -local client_capabilites = { - workspace = {configuration = false}, - textDocument = { - synchronization = {dynamicRegistration = false, didSave = true}, - -- ask the server to send us only plaintext completionItems - completion = { - dynamicRegistration = false, - completionItem = {documentationFormat = supported_markup_kind}, - }, - -- ask the server to send us only plaintext hover results - hover = {dynamicRegistration = false, contentFormat = supported_markup_kind}, - -- ask the server to send us only plaintext signatureHelp results - signatureHelp = { - dynamicRegistration = false, - signatureInformation = {documentationFormat = supported_markup_kind}, - }, - declaration = {dynamicRegistration = false, linkSupport = true}, - definition = goto_methods_capabilities, - typeDefinition = goto_methods_capabilities, - implementation = goto_methods_capabilities, - references = {dynamicRegistration = false}, - rename = { - dynamicRegistration = false, - prepareSupport = false, - honorsChangeAnnotations = false, - }, - }, - window = {workDoneProgress = false, showDocument = {support = false}}, -} - -- check if fzf is available and use fzf instead of vis-menu per default if os.execute('type fzf >/dev/null 2>/dev/null') then lspc.menu_cmd = 'fzf' @@ -1145,7 +1078,7 @@ local function ls_start_server(syntax) processId = vis_pid, clientInfo = {name = lspc.name, version = lspc.version}, rootUri = json.null, - capabilities = client_capabilites, + capabilities = lspc.client_capabilites, } ls_call_method(ls, 'initialize', params) -- cgit v1.2.3