Neovim nvim-cmp configuration
This commit is contained in:
96
lazyvim/.config/nvim/lua/plugins/cmp.lua
Normal file
96
lazyvim/.config/nvim/lua/plugins/cmp.lua
Normal file
@@ -0,0 +1,96 @@
|
||||
return {
|
||||
{
|
||||
"mason-org/mason.nvim",
|
||||
opts = {
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
ensure_installed = {
|
||||
-- LSP servers
|
||||
"clangd", -- C / C++
|
||||
"gopls", -- Go
|
||||
"python-lsp-server", -- Python
|
||||
"bash-language-server", -- Bash
|
||||
"zls", -- Zig
|
||||
"lua-language-server", -- Lua
|
||||
-- Formatters / Linters
|
||||
"stylua", -- Lua formatter
|
||||
"shfmt", -- Shell formatter
|
||||
"black", -- Python formatter
|
||||
"clang-format", -- C/C++ formatter
|
||||
"goimports", -- Go formatter
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-nvim-lua",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"onsails/lspkind.nvim", -- icone carine nel completamento
|
||||
},
|
||||
opts = function(_, opts)
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
-- Carica snippet
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
opts.snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
}
|
||||
|
||||
opts.mapping = vim.tbl_extend("force", opts.mapping, {
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<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" }),
|
||||
})
|
||||
|
||||
opts.sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
})
|
||||
|
||||
opts.formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = "symbol_text",
|
||||
maxwidth = 50,
|
||||
ellipsis_char = "...",
|
||||
}),
|
||||
}
|
||||
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -21,15 +21,12 @@ return {
|
||||
lspconfig.gopls.setup({})
|
||||
lspconfig.bashls.setup({})
|
||||
lspconfig.zls.setup({})
|
||||
-- src: https://docs.astral.sh/ruff/editors/setup/#neovim
|
||||
lspconfig.ruff.setup({})
|
||||
lspconfig.pylsp.setup({
|
||||
settings = {
|
||||
-- configure plugins in pylsp
|
||||
pylsp = {
|
||||
plugins = {
|
||||
pyflakes = { enabled = false },
|
||||
pylint = { enabled = false },
|
||||
pycodestyle = { enabled = false },
|
||||
},
|
||||
},
|
||||
@@ -1,17 +0,0 @@
|
||||
return {
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
dependencies = {
|
||||
"mason-org/mason.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash-language-server",
|
||||
"clangd",
|
||||
"gopls",
|
||||
"lua_ls",
|
||||
"pylsp",
|
||||
"zls",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
return {
|
||||
"mason-org/mason.nvim",
|
||||
opts = {
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user