major improvements, better stuff overall
This commit is contained in:
47
lua/plugins/completion/blink.lua
Normal file
47
lua/plugins/completion/blink.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
return {
|
||||
"saghen/blink.cmp",
|
||||
dependencies = {
|
||||
"L3MON4D3/LuaSnip",
|
||||
},
|
||||
opts = {
|
||||
providers = {
|
||||
lazydev = {
|
||||
name = "LazyDev",
|
||||
module = "lazydev.integrations.blink",
|
||||
priority = 100,
|
||||
},
|
||||
},
|
||||
|
||||
-- Snippet configuration
|
||||
snippets = {
|
||||
preset = "luasnip", -- Tells blink.cmp to use LuaSnip
|
||||
},
|
||||
|
||||
fuzzy = { implementation = "lua" },
|
||||
|
||||
signature = { enabled = true },
|
||||
|
||||
completion = {
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Keymaps
|
||||
keymap = {
|
||||
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||
},
|
||||
sources = {
|
||||
default = {
|
||||
"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)
|
||||
-- "cmdline", -- Generally configured separately, but often included by default
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip", -- Completion for snippets
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Confirm selection with Enter
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" }, -- This should provide LSP completions like for ESLint
|
||||
-- { name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
25
lua/plugins/completion/lazydev.lua
Normal file
25
lua/plugins/completion/lazydev.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
return {
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua", -- only load on lua files
|
||||
opts = {
|
||||
library = {
|
||||
-- See the configuration section for more details
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,55 +1,37 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
-- This custom config function will run *instead* of the default.
|
||||
-- It receives the 'opts' table (second argument) and loops through it.
|
||||
config = function(_, opts)
|
||||
-- 1. Get the default capabilities from cmp_nvim_lsp
|
||||
-- (Your emmet_ls config was already using this, so we'll make it
|
||||
-- the default for all servers. This includes snippetSupport.)
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- 2. Loop over the servers defined in 'opts.servers'
|
||||
for server_name, server_config in pairs(opts.servers or {}) do
|
||||
-- 3. Merge default capabilities with server-specific config
|
||||
-- 'vim.tbl_deep_extend' ensures server-specific settings
|
||||
-- (like for emmet_ls) are preserved.
|
||||
local config = vim.tbl_deep_extend("force", {
|
||||
capabilities = capabilities,
|
||||
}, server_config or {})
|
||||
|
||||
-- 4. Setup the server
|
||||
lspconfig[server_name].setup(config)
|
||||
end
|
||||
end,
|
||||
|
||||
-- 'opts' table now holds all server-specific configurations
|
||||
opts = {
|
||||
servers = {
|
||||
-- Servers with no special config are just empty tables
|
||||
nil_ls = {},
|
||||
nixd = {},
|
||||
lua_ls = {},
|
||||
pyright = {},
|
||||
cssls = {}, -- No longer needs 'capabilities = capabilities'
|
||||
ts_ls = {}, -- No longer needs 'capabilities = capabilities'
|
||||
rust_analyzer = {},
|
||||
|
||||
-- emmet_ls settings are preserved here
|
||||
emmet_ls = {
|
||||
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
|
||||
init_options = {
|
||||
html = {
|
||||
options = {
|
||||
["bem.enabled"] = true,
|
||||
},
|
||||
config = function()
|
||||
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",
|
||||
},
|
||||
},
|
||||
-- Note: We no longer need to define 'capabilities' here,
|
||||
-- as it gets the merged default from the config function.
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.config("emmet_ls", {
|
||||
-- capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
|
||||
init_options = {
|
||||
html = {
|
||||
options = {
|
||||
["bem.enabled"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.enable({
|
||||
"lua_ls",
|
||||
"ts_ls",
|
||||
"cssls",
|
||||
"rust_analyzer",
|
||||
"emmet_ls",
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user