refactor lsp

This commit is contained in:
dlond 2025-05-29 21:24:30 +12:00
parent b48c2e9acf
commit 68450346a1
4 changed files with 13 additions and 8 deletions

View file

@ -1,8 +1,6 @@
local M = {}
local lspconfig = require 'lspconfig'
local capabilities = require('blink.cmp').get_lsp_capabilities()
local Path = require 'plenary.path'
-- local Path = require 'plenary.path'
local pickers = require 'telescope.pickers'
local finders = require 'telescope.finders'
local conf = require('telescope.config').values
@ -50,6 +48,9 @@ function M.pick_target()
end
function M.setup()
local lspconfig = require 'lspconfig'
local capabilities = require('blink.cmp').get_lsp_capabilities()
lspconfig.clangd.setup {
cmd = make_clangd_cmd(),
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
@ -59,4 +60,6 @@ function M.setup()
}
end
return M
M.setup()
return {}

View file

@ -0,0 +1,4 @@
return {
require 'custom.plugins.lsp.lsp',
require 'custom.plugins.lsp.clangd',
}

View file

@ -0,0 +1,36 @@
-- ~/dlond/nvim/lua/custom/plugins/lsp.lua
-- LSP configuration, assuming LSP servers are installed via Nix/Home Manager
local lspconfig = require 'lspconfig'
local capabilities = require('blink.cmp').get_lsp_capabilities()
local servers = {
pyright = {
settings = {
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = 'openFilesOnly',
useLibraryCodeForTypes = true,
typeCheckingMode = 'basic',
},
},
positionEncoding = 'utf-8',
},
},
nixd = {},
ruff = {},
texlab = {},
cmake = {
cmd = { 'cmake-language-server' },
filetypes = { 'cmake' },
root_dir = require('lspconfig.util').root_pattern('CMakeLists.txt', '.git'),
},
}
for server_name, server in pairs(servers) do
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
lspconfig[server_name].setup(server)
end
return {}