adding lsp server options pt 1
This commit is contained in:
parent
3d1eeaa62c
commit
4fed66be0f
|
@ -18,31 +18,73 @@ return {
|
||||||
-- This config function runs AFTER the plugin and its dependencies are loaded.
|
-- This config function runs AFTER the plugin and its dependencies are loaded.
|
||||||
-- It sets up the LSP servers.
|
-- It sets up the LSP servers.
|
||||||
|
|
||||||
|
-- Load Nix-provided paths from the generated Lua file
|
||||||
|
local nix_paths_status, nix_paths = pcall(require, 'custom.nix_paths')
|
||||||
|
if not nix_paths_status then
|
||||||
|
vim.notify('Error loading custom.nix_paths: ' .. (nix_paths or 'Unknown error'), vim.log.levels.ERROR)
|
||||||
|
nix_paths = {} -- Provide an empty table to avoid further errors
|
||||||
|
end
|
||||||
|
|
||||||
-- Get LSP capabilities, augmented by nvim-cmp
|
-- Get LSP capabilities, augmented by nvim-cmp
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
-- Define the list of LSP servers you want to configure.
|
-- Define the list of LSP servers you want to configure.
|
||||||
-- These servers must be installed via Nix/Home Manager and be in your PATH.
|
-- These servers must be installed via Nix/Home Manager and be in your PATH.
|
||||||
local servers_to_setup = {
|
local servers = {
|
||||||
'lua_ls',
|
lua_ls = {
|
||||||
|
-- cmd = { ... }
|
||||||
|
-- filetypes = { ... }
|
||||||
|
-- capabilities = {}
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
completion = {
|
||||||
|
callSnippet = 'Replace',
|
||||||
|
},
|
||||||
|
diagnostics = { disable = { 'missing-fields' } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
clangd = {
|
||||||
|
cmd = (function()
|
||||||
|
if nix_paths.clang_driver_path then
|
||||||
|
return {
|
||||||
'clangd',
|
'clangd',
|
||||||
'pyright',
|
'--query-driver=' .. nix_paths.clang_driver_path,
|
||||||
'nixd',
|
}
|
||||||
'ruff',
|
else
|
||||||
|
vim.notify('Warning: Nix path for clang_driver_path not defined. clangd might not work correctly.', vim.log.levels.WARN)
|
||||||
|
return { 'clangd' } -- Fallback
|
||||||
|
end
|
||||||
|
end)(),
|
||||||
|
},
|
||||||
|
pyright = {
|
||||||
|
settings = {
|
||||||
|
python = {
|
||||||
|
analysis = {
|
||||||
|
autoSearchPaths = true,
|
||||||
|
diagnosticMode = 'openFilesOnly',
|
||||||
|
useLibraryCodeForTypes = true,
|
||||||
|
typeCheckingMode = 'basic',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
positionEncoding = 'utf-8',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nixd = {},
|
||||||
|
ruff = {},
|
||||||
-- Add other servers like "bashls", "yamlls", "gopls", "rust_analyzer" etc.
|
-- Add other servers like "bashls", "yamlls", "gopls", "rust_analyzer" etc.
|
||||||
-- Ensure the corresponding packages (e.g., pkgs.bash-language-server)
|
-- Ensure the corresponding packages (e.g., pkgs.bash-language-server)
|
||||||
-- are in your Home Manager home.packages list.
|
-- are in your Home Manager home.packages list.
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iterate through the defined servers list and set them up with lspconfig
|
-- Iterate through the defined servers list and set them up with lspconfig
|
||||||
for _, server_name in ipairs(servers_to_setup) do
|
for server_name, server_config_override in ipairs(servers) do
|
||||||
-- print('Attempting to set up LSP server: ' .. server_name) -- Debug print
|
local server_ops = {
|
||||||
require('lspconfig')[server_name].setup {
|
capabilities = capabilities,
|
||||||
capabilities = capabilities, -- Pass augmented capabilities
|
|
||||||
-- Add any server-specific overrides here if needed, e.g.:
|
|
||||||
-- For lua_ls:
|
|
||||||
-- settings = { Lua = { diagnostics = { globals = {'vim'} } } },
|
|
||||||
}
|
}
|
||||||
|
server_ops = vim.tbl_deep_extend('force', server_ops, server_config_override or {})
|
||||||
|
-- print('Attempting to set up LSP server: ' .. server_name) -- Debug print
|
||||||
|
require('lspconfig')[server_name].setup(server_ops)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup keymaps and diagnostics based on kickstart's original init.lua LSP section
|
-- Setup keymaps and diagnostics based on kickstart's original init.lua LSP section
|
||||||
|
|
Loading…
Reference in New Issue