mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-10-24 05:23:19 +00:00
81662b99b5
Swap the completion engine to blink.cmp v1.x, dropping nvim-cmp, its eight cmp-* sources, lspkind, and LuaSnip. Swap the picker to snacks.picker, removing telescope.nvim and six telescope extensions. LSP capabilities now sourced from blink.cmp; LSP navigation keymaps and the colorscheme/keymaps/todo pickers move to Snacks.picker. friendly-snippets is preserved as blink's snippet source.
316 lines
6.6 KiB
Lua
316 lines
6.6 KiB
Lua
-- Setup language servers.
|
|
local conform = require("conform")
|
|
|
|
local opts = { noremap = true, silent = true }
|
|
|
|
local global_node_modules = vim.fn.system("npm root -g")
|
|
|
|
-- client, buffer
|
|
local on_attach = function(client, bufnr)
|
|
opts.buffer = bufnr
|
|
|
|
-- Enable completion triggered by <c-x><c-o>
|
|
vim.bo[opts.buffer].omnifunc = "v:lua.vim.lsp.omnifunc"
|
|
|
|
opts.desc = "Go to declaration"
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
|
|
opts.desc = "Go to definitions"
|
|
vim.keymap.set("n", "gd", function() Snacks.picker.lsp_definitions() end, opts)
|
|
|
|
opts.desc = "Show documentation for what is under cursor"
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
|
|
|
opts.desc = "Show LSP Implementation"
|
|
vim.keymap.set("n", "gi", function() Snacks.picker.lsp_implementations() end, opts)
|
|
|
|
opts.desc = "Get Help"
|
|
vim.keymap.set("n", "<leader>gh", vim.lsp.buf.signature_help, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
|
-- vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
|
-- vim.keymap.set('n', '<leader>wl', function()
|
|
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
-- end, opts)
|
|
|
|
opts.desc = "Show LSP type definitions"
|
|
vim.keymap.set("n", "gt", function() Snacks.picker.lsp_type_definitions() end, opts)
|
|
|
|
opts.desc = "Smart rename"
|
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
|
|
|
opts.desc = "See available code actions"
|
|
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
|
|
|
opts.desc = "Show LSP references"
|
|
vim.keymap.set("n", "<leader>cr", function() Snacks.picker.lsp_references() end, opts)
|
|
|
|
opts.desc = "Format File"
|
|
vim.keymap.set({ "n", "v" }, "<leader>f", function()
|
|
-- vim.lsp.buf.format({ async = true })
|
|
conform.format({
|
|
bufnr = opts.buffer,
|
|
async = true,
|
|
lsp_fallback = true,
|
|
})
|
|
end, opts)
|
|
|
|
opts.desc = "Restart LSP"
|
|
vim.keymap.set("n", "<leader>rs", "<cmd>LspRestart<CR>", opts)
|
|
|
|
-- LSP Only Settings
|
|
-- Ruff & Pyright behaviour
|
|
if client.name == "ruff" then
|
|
-- Disable hover in favor of Pyright
|
|
client.server_capabilities.hoverProvider = false
|
|
end
|
|
end
|
|
|
|
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
|
|
|
-- Configure diagnostic signs (Neovim 0.10+ API; required in 0.12)
|
|
vim.diagnostic.config({
|
|
signs = {
|
|
text = {
|
|
[vim.diagnostic.severity.ERROR] = " ",
|
|
[vim.diagnostic.severity.WARN] = " ",
|
|
[vim.diagnostic.severity.HINT] = " ",
|
|
[vim.diagnostic.severity.INFO] = " ",
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Configure LSP servers using vim.lsp.config
|
|
vim.lsp.config("html", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("ts_ls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
init_options = {
|
|
plugins = {
|
|
{
|
|
name = "@vue/typescript-plugin",
|
|
location = global_node_modules .. "@vue/typescript-plugin",
|
|
languages = { "vue" },
|
|
},
|
|
},
|
|
},
|
|
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
|
|
})
|
|
|
|
vim.lsp.config("cssls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("tailwindcss", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = { "html", "svelte", "vue", "astro" },
|
|
})
|
|
|
|
vim.lsp.config("svelte", {
|
|
capabilities = capabilities,
|
|
on_attach = function(client, bufnr)
|
|
on_attach(client, bufnr)
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
|
pattern = { "*.js", "*.ts" },
|
|
callback = function(ctx)
|
|
if client.name == "svelte" then
|
|
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
|
|
end
|
|
end,
|
|
})
|
|
end,
|
|
})
|
|
|
|
vim.lsp.config("emmet_ls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = {
|
|
"html",
|
|
"typescriptreact",
|
|
"javascriptreact",
|
|
"astro",
|
|
"css",
|
|
"sass",
|
|
"scss",
|
|
"less",
|
|
"svelte",
|
|
"vue",
|
|
},
|
|
})
|
|
|
|
vim.lsp.config("ruff", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("pyright", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = { "python" },
|
|
settings = {
|
|
python = {
|
|
analysis = {
|
|
autoSearchPaths = true,
|
|
useLibraryCodeForTypes = true,
|
|
diagnosticMode = "workspace",
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
vim.lsp.config("dockerls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("jsonls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("vue_ls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = { "vue" },
|
|
init_options = {
|
|
vue = {
|
|
hybridMode = false,
|
|
},
|
|
},
|
|
settings = {
|
|
typescript = {
|
|
inlayHints = {
|
|
enumMemberValues = {
|
|
enabled = true,
|
|
},
|
|
functionLikeReturnTypes = {
|
|
enabled = true,
|
|
},
|
|
propertyDeclarationTypes = {
|
|
enabled = true,
|
|
},
|
|
parameterTypes = {
|
|
enabled = true,
|
|
suppressWhenArgumentMatchesName = true,
|
|
},
|
|
variableTypes = {
|
|
enabled = true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
vim.lsp.config("rust_analyzer", {
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
["rust-analyzer"] = {},
|
|
},
|
|
})
|
|
|
|
vim.lsp.config("lua_ls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
workspace = {
|
|
library = {
|
|
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
|
[vim.fn.stdpath("config") .. "/lua"] = true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
vim.lsp.config("docker_compose_language_service", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("eslint", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("astro", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("kotlin_language_server", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("clangd", {
|
|
cmd = { "clangd", "--compile-commands-dir=./", "--background-index=false" },
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = { "c", "cpp", "objc", "objcpp" },
|
|
})
|
|
|
|
vim.lsp.config("buf_ls", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = { "proto" },
|
|
})
|
|
|
|
vim.lsp.config("arduino_language_server", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
})
|
|
|
|
vim.lsp.config("biome", {
|
|
capabilities = capabilities,
|
|
on_attach = on_attach,
|
|
filetypes = {
|
|
"javascript",
|
|
"javascriptreact",
|
|
"json",
|
|
"jsonc",
|
|
"typescript",
|
|
"typescript.tsx",
|
|
"typescriptreact",
|
|
"astro",
|
|
"svelte",
|
|
"vue",
|
|
},
|
|
})
|
|
|
|
-- Enable all configured LSP servers
|
|
vim.lsp.enable({
|
|
"html",
|
|
"ts_ls",
|
|
"cssls",
|
|
"tailwindcss",
|
|
"svelte",
|
|
"emmet_ls",
|
|
"ruff",
|
|
"pyright",
|
|
"dockerls",
|
|
"jsonls",
|
|
"vue_ls",
|
|
"rust_analyzer",
|
|
"lua_ls",
|
|
"docker_compose_language_service",
|
|
"eslint",
|
|
"astro",
|
|
"kotlin_language_server",
|
|
"clangd",
|
|
"buf_ls",
|
|
"arduino_language_server",
|
|
"biome",
|
|
})
|