diff options
Diffstat (limited to 'lua/lvim/lsp/config.lua')
-rw-r--r-- | lua/lvim/lsp/config.lua | 188 |
1 files changed, 98 insertions, 90 deletions
diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index f6abeeca..4cb9cf54 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -45,107 +45,115 @@ local skipped_servers = { local skipped_filetypes = { "markdown", "rst", "plaintext", "toml", "proto" } -local join_paths = require("lvim.utils").join_paths +local M = {} -return { - templates_dir = join_paths(get_runtime_dir(), "site", "after", "ftplugin"), - diagnostics = { - signs = { - active = true, - values = { - { name = "DiagnosticSignError", text = lvim.icons.diagnostics.Error }, - { name = "DiagnosticSignWarn", text = lvim.icons.diagnostics.Warning }, - { name = "DiagnosticSignHint", text = lvim.icons.diagnostics.Hint }, - { name = "DiagnosticSignInfo", text = lvim.icons.diagnostics.Information }, +M.config = function() + local join_paths = require("lvim.utils").join_paths + + lvim.lsp = { + -- Function that gets called to configure lvim.lsp + config = nil, + templates_dir = join_paths(get_runtime_dir(), "site", "after", "ftplugin"), + diagnostics = { + signs = { + active = true, + values = { + { name = "DiagnosticSignError", text = lvim.icons.diagnostics.Error }, + { name = "DiagnosticSignWarn", text = lvim.icons.diagnostics.Warning }, + { name = "DiagnosticSignHint", text = lvim.icons.diagnostics.Hint }, + { name = "DiagnosticSignInfo", text = lvim.icons.diagnostics.Information }, + }, + }, + virtual_text = true, + update_in_insert = false, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + format = function(d) + local code = d.code or (d.user_data and d.user_data.lsp.code) + if code then + return string.format("%s [%s]", d.message, code):gsub("1. ", "") + end + return d.message + end, }, }, - virtual_text = true, - update_in_insert = false, - underline = true, - severity_sort = true, + document_highlight = false, + code_lens_refresh = true, float = { focusable = true, style = "minimal", border = "rounded", - source = "always", - header = "", - prefix = "", - format = function(d) - local code = d.code or (d.user_data and d.user_data.lsp.code) - if code then - return string.format("%s [%s]", d.message, code):gsub("1. ", "") - end - return d.message - end, }, - }, - document_highlight = false, - code_lens_refresh = true, - float = { - focusable = true, - style = "minimal", - border = "rounded", - }, - on_attach_callback = nil, - on_init_callback = nil, - automatic_configuration = { - ---@usage list of servers that the automatic installer will skip - skipped_servers = skipped_servers, - ---@usage list of filetypes that the automatic installer will skip - skipped_filetypes = skipped_filetypes, - }, - buffer_mappings = { - normal_mode = { - ["K"] = { "<cmd>lua vim.lsp.buf.hover()<cr>", "Show hover" }, - ["gd"] = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Goto Definition" }, - ["gD"] = { "<cmd>lua vim.lsp.buf.declaration()<cr>", "Goto declaration" }, - ["gr"] = { "<cmd>lua vim.lsp.buf.references()<cr>", "Goto references" }, - ["gI"] = { "<cmd>lua vim.lsp.buf.implementation()<cr>", "Goto Implementation" }, - ["gs"] = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "show signature help" }, - ["gl"] = { - function() - local config = lvim.lsp.diagnostics.float - config.scope = "line" - vim.diagnostic.open_float(0, config) - end, - "Show line diagnostics", + on_attach_callback = nil, + on_init_callback = nil, + automatic_configuration = { + ---@usage list of servers that the automatic installer will skip + skipped_servers = skipped_servers, + ---@usage list of filetypes that the automatic installer will skip + skipped_filetypes = skipped_filetypes, + }, + buffer_mappings = { + normal_mode = { + ["K"] = { "<cmd>lua vim.lsp.buf.hover()<cr>", "Show hover" }, + ["gd"] = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Goto Definition" }, + ["gD"] = { "<cmd>lua vim.lsp.buf.declaration()<cr>", "Goto declaration" }, + ["gr"] = { "<cmd>lua vim.lsp.buf.references()<cr>", "Goto references" }, + ["gI"] = { "<cmd>lua vim.lsp.buf.implementation()<cr>", "Goto Implementation" }, + ["gs"] = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "show signature help" }, + ["gl"] = { + function() + local config = lvim.lsp.diagnostics.float + config.scope = "line" + vim.diagnostic.open_float(0, config) + end, + "Show line diagnostics", + }, }, + insert_mode = {}, + visual_mode = {}, }, - insert_mode = {}, - visual_mode = {}, - }, - buffer_options = { - --- enable completion triggered by <c-x><c-o> - omnifunc = "v:lua.vim.lsp.omnifunc", - --- use gq for formatting - formatexpr = "v:lua.vim.lsp.formatexpr(#{timeout_ms:500})", - }, - ---@usage list of settings of nvim-lsp-installer - installer = { - setup = { - ensure_installed = {}, - automatic_installation = { - exclude = {}, + buffer_options = { + --- enable completion triggered by <c-x><c-o> + omnifunc = "v:lua.vim.lsp.omnifunc", + --- use gq for formatting + formatexpr = "v:lua.vim.lsp.formatexpr(#{timeout_ms:500})", + }, + ---@usage list of settings of nvim-lsp-installer + installer = { + setup = { + ensure_installed = {}, + automatic_installation = { + exclude = {}, + }, }, }, - }, - nlsp_settings = { - setup = { - config_home = join_paths(get_config_dir(), "lsp-settings"), - -- set to false to overwrite schemastore.nvim - append_default_schemas = true, - ignored_servers = {}, - loader = "json", + nlsp_settings = { + setup = { + config_home = join_paths(get_config_dir(), "lsp-settings"), + -- set to false to overwrite schemastore.nvim + append_default_schemas = true, + ignored_servers = {}, + loader = "json", + }, }, - }, - null_ls = { - setup = { - debug = false, + null_ls = { + setup = { + debug = false, + }, + config = {}, }, - config = {}, - }, - ---@deprecated use lvim.lsp.automatic_configuration.skipped_servers instead - override = {}, - ---@deprecated use lvim.lsp.installer.setup.automatic_installation instead - automatic_servers_installation = nil, -} + ---@deprecated use lvim.lsp.automatic_configuration.skipped_servers instead + override = {}, + ---@deprecated use lvim.lsp.installer.setup.automatic_installation instead + automatic_servers_installation = nil, + } +end + +return M |