106 lines
3.1 KiB
Lua
106 lines
3.1 KiB
Lua
-- LSP configuration using Nix-managed servers
|
|
return {
|
|
-- Disable Mason plugins (we use Nix-managed servers instead)
|
|
{ "mason-org/mason.nvim", enabled = false },
|
|
{ "mason-org/mason-lspconfig.nvim", enabled = false },
|
|
{ "jay-babu/mason-null-ls.nvim", enabled = false },
|
|
{ "jay-babu/mason-nvim-dap.nvim", enabled = false },
|
|
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
dependencies = {
|
|
"saghen/blink.cmp", -- For LSP capabilities
|
|
},
|
|
config = function()
|
|
-- Get blink.cmp capabilities
|
|
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
|
|
|
-- Common LSP attach keybindings
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
|
callback = function(ev)
|
|
local opts = { buffer = ev.buf }
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
|
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
|
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
|
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
|
end,
|
|
})
|
|
|
|
-- Configure each LSP server
|
|
local lspconfig = require("lspconfig")
|
|
|
|
-- Lua
|
|
lspconfig.lua_ls.setup({
|
|
capabilities = capabilities,
|
|
settings = {
|
|
Lua = {
|
|
runtime = { version = "LuaJIT" },
|
|
diagnostics = { globals = { "vim" } },
|
|
workspace = {
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
checkThirdParty = false,
|
|
},
|
|
telemetry = { enable = false },
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Nix
|
|
lspconfig.nil_ls.setup({
|
|
capabilities = capabilities,
|
|
settings = {
|
|
["nil"] = {
|
|
formatting = { command = { "nixfmt" } },
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Python
|
|
lspconfig.pyright.setup({
|
|
capabilities = capabilities,
|
|
settings = {
|
|
python = {
|
|
analysis = {
|
|
typeCheckingMode = "basic",
|
|
autoSearchPaths = true,
|
|
useLibraryCodeForTypes = true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- TypeScript/JavaScript
|
|
lspconfig.ts_ls.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
-- Rust
|
|
lspconfig.rust_analyzer.setup({
|
|
capabilities = capabilities,
|
|
settings = {
|
|
["rust-analyzer"] = {
|
|
checkOnSave = { command = "clippy" },
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Go
|
|
lspconfig.gopls.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
-- C/C++
|
|
lspconfig.clangd.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
end,
|
|
},
|
|
}
|