diff options
Diffstat (limited to 'lua/core/lsp')
-rw-r--r-- | lua/core/lsp/functions.lua | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/lua/core/lsp/functions.lua b/lua/core/lsp/functions.lua index e37cc02..1c9f18a 100644 --- a/lua/core/lsp/functions.lua +++ b/lua/core/lsp/functions.lua @@ -1,5 +1,5 @@ local misc = require("core.misc") -local map, include = misc.map, misc.include +local map, auto = misc.map, misc.auto local M = {} @@ -34,6 +34,11 @@ local list_opts = { ---@diagnostic disable-next-line: assign-type-mismatch local location_opts = vim.tbl_deep_extend("force", list_opts, {}) +-- disable the default keybinds (they're bad) +for _, bind in ipairs({ "grn", "gra", "gri", "grr" }) do + pcall(vim.keymap.del, "n", bind) +end + --- setup basic options on lsp attach ---@param bufnr number buffer number local function attach(bufnr) @@ -55,27 +60,18 @@ local function attach(bufnr) -- Diagnostics map("n", "[d", function() - if not vim.fn.has("nvim-0.11") then - vim.diagnostic.goto_prev() - else - vim.diagnostic.jump({ count = -1 }) - end + vim.diagnostic.jump({ count = -1 }) end, opts) map("n", "]d", function() - if not vim.fn.has("nvim-0.11") then - vim.diagnostic.goto_next() - else - vim.diagnostic.jump({ count = 1 }) - end + vim.diagnostic.jump({ count = 1 }) end, opts) - -- map("n", "qD", vim.diagnostic.setqflist, opts) end function M.setup() vim.diagnostic.config { virtual_text = false, virtual_lines = { - only_current_line = true, + only_current_line = true }, update_in_insert = false, underline = true, @@ -90,38 +86,17 @@ function M.setup() } } - if not vim.fn.has("nvim-0.11") then - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( - vim.lsp.handlers.hover, { border = vim.g.border_style }) - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( - vim.lsp.handlers.signature_help, { border = vim.g.border_style }) - end - - -- set default capabilities - include("lspconfig.util").default_config.capabilities = M.capabilities + -- set default capabilities and attach function + vim.lsp.config['*'] = { + capabilities = vim.lsp.protocol.make_client_capabilities() + } - -- run whenever a client attaches - vim.api.nvim_create_autocmd("LspAttach", { + -- make my attach function always run + auto("LspAttach", { callback = function(event) - -- map keybinds attach(event.buf) end }) end --- FIXME: I don"t like this way of doing things, there has to be a better way - ---- capabilities that are to be used in lsp servers, for those setup through ---- lspconfig, this is already set as the default. Incase there is a server ---- not setup through lspconfig this function may be called to receive the ---- proper capabilities data. -M.capabilities = vim.lsp.protocol.make_client_capabilities() - ---- add capabilities to the default capabilities string ----@param new_capabilities lsp.ClientCapabilities -function M.add_capabilities(new_capabilities) - vim.tbl_deep_extend("force", M.capabilities, new_capabilities) -end - return M |