From 52e297395b6a08c287f38a79e3d22a6a2feaf147 Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 4 Jun 2025 18:40:35 +0200 Subject: [PATCH] update lsp --- lua/configs/lspconfig.lua | 73 +++++++-------------------------------- 1 file changed, 12 insertions(+), 61 deletions(-) diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 17d8fa7..2d762b4 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -8,7 +8,13 @@ local servers = { pyright = {}, basedpyright = {}, lua_ls = {}, - clangd = {}, + clangd = { + capabilities = { + documentFormattingProvider = false, + documentRangeFormattingProvider = false, + textDocument = { formatting = { dynamicRegistration = false } } + }, + }, ccls = { init_options = { highlight = { @@ -43,18 +49,16 @@ local enabled = {} for server, config in pairs(servers) do local lsp = require("lspconfig")[server] - -- print(server) - local config = vim.tbl_deep_extend("keep", config, default, lsp.document_config.default_config) - if config.cmd ~= nil then - if vim.fn.executable(config.cmd[1]) == 1 then - enabled[server] = config + local config_merged = vim.tbl_deep_extend("keep", config, default, lsp.document_config.default_config) + if config_merged.cmd ~= nil then + if vim.fn.executable(config_merged.cmd[1]) == 1 then + enabled[server] = config_merged end end end for server, config in pairs(enabled) do - local lsp = require("lspconfig")[server] - lsp.setup(config) + vim.lsp.enable(server, config) end @@ -65,56 +69,3 @@ vim.diagnostic.config({ -- update_in_insert = false, -- severity_sort = false, }) - -vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - vim.schedule(function() - local client = vim.lsp.get_client_by_id(args.data.client_id) - - if client then - local signatureProvider = client.server_capabilities.signatureHelpProvider - if signatureProvider and signatureProvider.triggerCharacters then - local M = {} - local api = vim.api - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - focusable = false, - silent = true, - max_height = 7, - }) - - local function check_triggeredChars(triggerChars) - local cur_line = api.nvim_get_current_line() - local pos = api.nvim_win_get_cursor(0)[2] - local prev_char = cur_line:sub(pos - 1, pos - 1) - local cur_char = cur_line:sub(pos, pos) - - for _, char in ipairs(triggerChars) do - if cur_char == char or prev_char == char then - return true - end - end - end - - M.setup = function(client, bufnr) - local group = api.nvim_create_augroup("LspSignature", { clear = false }) - api.nvim_clear_autocmds { group = group, buffer = bufnr } - - local triggerChars = client.server_capabilities.signatureHelpProvider.triggerCharacters - - api.nvim_create_autocmd("TextChangedI", { - group = group, - buffer = bufnr, - callback = function() - if check_triggeredChars(triggerChars) then - vim.lsp.buf.signature_help() - end - end, - }) - end - M.setup(client, args.buf) - end - end - end) - end, -})