diff options
| author | dacctal <dacctal@symlinx.net> | 2026-04-27 05:30:46 +0000 |
|---|---|---|
| committer | dacctal <dacctal@symlinx.net> | 2026-04-27 05:30:46 +0000 |
| commit | d33d907f53c50d323eca75c4bfc02ab5b989b30a (patch) | |
| tree | 6888a2074338a723f0fde99b03b09fbab91a265f /.config/vis/plugins/vis-lspc/lspc.lua | |
| parent | 89505535c652cd6f31a15df73293c6e90eaa852f (diff) | |
Diffstat (limited to '.config/vis/plugins/vis-lspc/lspc.lua')
| -rw-r--r-- | .config/vis/plugins/vis-lspc/lspc.lua | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/.config/vis/plugins/vis-lspc/lspc.lua b/.config/vis/plugins/vis-lspc/lspc.lua new file mode 100644 index 0000000..389961d --- /dev/null +++ b/.config/vis/plugins/vis-lspc/lspc.lua @@ -0,0 +1,160 @@ +--- State and methods of the language server client. +-- This module table is returned when requiring the vis-lspc plugin. +-- @module lspc +-- @author Florian Fischer +-- @license GPL-3 +-- @copyright Florian Fischer 2021-2024 +--- Initial state of the client. +-- This includes the default configuration that can be modified in +-- your visrc.lua file. +local lspc = { + -- mapping language server names to their state tables + running = {}, + open_files = {}, + name = 'vis-lspc', + version = '0.1.8', + -- 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 passed to <menu_cmd> on stdin separated by '\n' + menu_cmd = 'vis-menu -l 10', + -- program used to ask the user for confirmation + confirm_cmd = 'vis-menu', + -- apply workspaceEdits without confirmation + autoconfirm_edits = false, + + -- should diagnostics be highlighted if available + highlight_diagnostics = 'line', + -- style id used by lspc to register the style used to highlight diagnostics + -- by default win.STYLE_LEXER_MAX is used (the last style id available for the lexer styles). See vis/ui.h. + diagnostic_style_id = nil, + -- styles used by lspc to highlight the diagnostic range + -- must be set by the user + diagnostic_styles = { + error = 'fore:red,italics,reverse', + warning = 'fore:yellow,italics,reverse', + information = 'fore:yellow,italics,reverse', + hint = 'fore:yellow,italics,reverse', + }, + + -- restore the position of the primary curser after applying a workspace edit + workspace_edit_remember_cursor = true, + + -- message level to show in the UI when receiving messages from the server + -- Error = 1, Warning = 2, Info = 3, Log = 4 + message_level = 3, + + -- How to present messages to the user. + -- 'message': use vis:message; 'open': use a new split window allowing for syntax highlighting + show_message = 'message', + + -- Globs that are considered to be workspace roots (e.g. ".git" or ".hg") + universal_root_globs = {}, + + -- Should a file's directory be used as workspace root if no explicit root was found. + fallback_dirname_as_root = false, + + -- Format string how the symbols are presented in the navigation window. + -- The following arguments are passed to the string.format function: + -- indentation, symbol kind, name, line, column + navwin_symbol_format = '%s[%.1s] %s\n', -- short version + -- navwin_symbol_format = '%s[%s] %s %d:%d\n', -- verbose version + + -- The layout where the navigation window will be placed. + -- The following layout identifiers are supported: + -- 'vr' -- DEFAULT: vertical right + -- 'vl' -- vertical left + -- 'ht' -- horizontal top + -- 'hb' -- horizontak bottom + navwin_layout = 'vr', + + -- active navigation windows + navwins = {}, + + -- events + events = { + LS_INITIALIZED = 'LspcEvent::LS_INITIALIZED', + LS_DID_OPEN = 'LspcEvent::LS_DID_OPEN', + }, +} + +-- 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' +end + +local supported_markup_kind = {'markdown'} + +local goto_methods_capabilities = { + linkSupport = true, + dynamicRegistration = false, +} + +--- ClientCapabilities we tell the language server when calling "initialize". +local client_capabilites = { + workspace = { + configuration = true, + didChangeConfiguration = {dynamicRegistration = false}, + }, + textDocument = { + synchronization = {dynamicRegistration = false, didSave = true}, + -- ask the server to send us only markdown completionItems + completion = { + dynamicRegistration = false, + completionItem = {documentationFormat = supported_markup_kind}, + }, + -- ask the server to send us only markdown hover results + hover = {dynamicRegistration = false, contentFormat = supported_markup_kind}, + -- ask the server to send us only markdown signatureHelp results + signatureHelp = { + dynamicRegistration = false, + signatureInformation = {documentationFormat = supported_markup_kind}, + }, + declaration = {dynamicRegistration = false, linkSupport = true}, + definition = goto_methods_capabilities, + publishDiagnostics = {relatedInformation = false}, + diagnostic = {dynamicRegistration = false}, + typeDefinition = goto_methods_capabilities, + implementation = goto_methods_capabilities, + references = {dynamicRegistration = false}, + rename = { + dynamicRegistration = false, + prepareSupport = false, + honorsChangeAnnotations = false, + }, + }, + window = {workDoneProgress = false, showDocument = {support = false}}, +} + +lspc.client_capabilites = client_capabilites + +local Lspc = {} + +--- Log a message. +-- @string: the message to log +function Lspc:log(msg) + self.logger:log(msg) +end + +--- Present a warning to the user. +-- @string: the warning message +function Lspc:warn(msg) + local warning = 'LSPC Warning: ' .. msg + self.logger:log(warning) + vis:info(warning) +end + +--- Present an error to the user. +-- @string: the error message +function Lspc:err(msg) + local warning = 'LSPC Error: ' .. msg + self.logger:log(warning) + vis:info(warning) +end + +setmetatable(lspc, {__index = Lspc}) + +return lspc |
