dots/stow/.config/nvim/lua/nico/lazy/lsp.lua
2025-05-03 16:34:34 +10:00

102 lines
3.4 KiB
Lua

return {
"neovim/nvim-lspconfig",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/nvim-cmp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"j-hui/fidget.nvim",
"dundalek/lazy-lsp.nvim",
},
config = function()
local cmp = require('cmp')
local cmp_lsp = require("cmp_nvim_lsp")
local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
cmp_lsp.default_capabilities())
require("fidget").setup({})
require("lazy-lsp").setup {
-- By default all available servers are set up. Exclude unwanted or misbehaving servers.
excluded_servers = {
"ccls", "zk", "bufls", "ruff_lsp"
},
-- Alternatively specify preferred servers for a filetype (others will be ignored).
preferred_servers = {
markdown = {},
python = { "pyright" },
nix = { "nil_ls" },
rust = { "rust_analyzer" },
go = { "gopls" },
c = { "clangd" },
},
prefer_local = true, -- Prefer locally installed servers over nix-shell
-- Default config passed to all servers to specify on_attach callback and other options.
default_config = {
flags = {
debounce_text_changes = 150,
},
-- on_attach = on_attach,
-- capabilities = capabilities,
},
-- Override config for specific servers that will passed down to lspconfig setup.
-- Note that the default_config will be merged with this specific configuration so you don't need to specify everything twice.
configs = {
lua_ls = {
settings = {
Lua = {
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
},
},
},
},
}
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
['<A-Enter>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
['<C-x>'] = cmp.mapping.scroll_docs(-4),
['<C-z>'] = cmp.mapping.scroll_docs(4),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})
vim.diagnostic.config({
-- update_in_insert = true,
float = {
focusable = false,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
})
end
}