Files
nvim/lua/plugins/completion/lspconfig.lua
2026-05-03 19:59:47 +01:00

112 lines
2.5 KiB
Lua

vim.pack.add({
{ src = "https://github.com/neovim/nvim-lspconfig", name = "lspconfig" },
{ src = "https://github.com/saghen/blink.cmp", name = "blink" },
})
vim.lsp.config("lua_ls", {
settings = {
Lua = {
-- Tell the server to let Neovim handle snippet expansion
completion = {
callSnippet = "Replace",
},
-- Use LuaJIT (which Neovim uses)
runtime = {
version = "LuaJIT",
},
},
},
})
-- vim.lsp.config("emmet_language_server", {
-- -- capabilities = require("cmp_nvim_lsp").default_capabilities(),
-- filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
-- init_options = {
-- preferences = {},
-- show_expanded_abbreviation = "always",
-- show_abbreviation_suggestions = true,
-- show_suggestions_as_snippets = true,
-- html = {
-- options = {
-- ["bem.enabled"] = true,
-- ["output.selfClosingStyle"] = "xhtml",
-- },
-- },
-- },
-- })
vim.lsp.enable({
"lua_ls",
"ts_ls",
"pylsp",
"cssls",
"svelte_language_server",
"nixd",
"rust_analyzer",
"emmet_language_server",
})
vim.o.pumborder = "rounded"
require("blink.cmp").setup({
fuzzy = { implementation = "lua" },
signature = {
enabled = true,
},
completion = {
list = {
selection = {
preselect = false,
auto_insert = true,
},
},
},
-- Keymaps
keymap = {
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
},
sources = {
default = {
-- "lazydev",
"lsp", -- (Equivalent to cmp-nvim-lsp)
"snippets", -- (Handled by the snippets config, replaces cmp_luasnip source)
"buffer", -- (Equivalent to cmp-buffer)
"path", -- (Equivalent to cmp-path)
},
providers = {
-- lazydev = {
-- name = "LazyDev",
-- module = "lazydev.integrations.blink",
-- -- make lazydev completions top priority (see `:h blink.cmp`)
-- score_offset = 100,
-- },
},
},
})
vim.api.nvim_create_autocmd("FileType", { -- Lazy load lazydev when in lua file (no pun intended)
pattern = "lua",
callback = function()
vim.pack.add({
{ src = "https://github.com/folke/lazydev.nvim", name = "lazydev" },
})
require("lazydev").setup()
require("blink.cmp").setup({ -- Reload blink with lazydev as a source
sources = {
-- add lazydev to your completion providers
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
},
},
},
})
end,
})