2023-08-29 20:07:23 +02:00
|
|
|
return {
|
2023-08-29 23:17:39 +02:00
|
|
|
{
|
|
|
|
"hrsh7th/nvim-cmp",
|
|
|
|
event = "InsertEnter",
|
|
|
|
dependencies = {
|
|
|
|
{ "L3MON4D3/LuaSnip" },
|
|
|
|
},
|
|
|
|
config = function()
|
|
|
|
require("lsp-zero.cmp").extend()
|
|
|
|
local cmp = require("cmp")
|
|
|
|
local cmp_action = require("lsp-zero.cmp").action()
|
2023-08-29 20:07:23 +02:00
|
|
|
|
2023-08-29 23:17:39 +02:00
|
|
|
cmp.setup({
|
2023-11-04 11:50:47 +01:00
|
|
|
completion = {
|
|
|
|
completeopt = "menu,menuone",
|
|
|
|
},
|
2023-08-29 23:17:39 +02:00
|
|
|
mapping = {
|
2023-11-04 11:50:47 +01:00
|
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
2023-08-29 23:17:39 +02:00
|
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
2023-11-04 11:50:47 +01:00
|
|
|
["<C-c>"] = cmp.mapping.close(),
|
|
|
|
["<CR>"] = cmp.mapping.confirm {
|
|
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
|
|
select = true,
|
|
|
|
},
|
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
elseif require("luasnip").expand_or_jumpable() then
|
|
|
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, {
|
|
|
|
"i",
|
|
|
|
"s",
|
|
|
|
}),
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item()
|
|
|
|
elseif require("luasnip").jumpable(-1) then
|
|
|
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, {
|
|
|
|
"i",
|
|
|
|
"s",
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
sources = {
|
|
|
|
{ name = "nvim_lsp" },
|
|
|
|
{ name = "luasnip" },
|
|
|
|
{ name = "buffer" },
|
|
|
|
{ name = "nvim_lua" },
|
|
|
|
{ name = "path" },
|
2023-08-29 23:17:39 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
-- LSP
|
|
|
|
{
|
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
cmd = "LspInfo",
|
|
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
|
|
dependencies = {
|
|
|
|
{ "hrsh7th/cmp-nvim-lsp" },
|
|
|
|
{ "williamboman/mason-lspconfig.nvim" },
|
|
|
|
{ "williamboman/mason.nvim" },
|
2024-09-17 16:11:37 +02:00
|
|
|
{ "VonHeikemen/lsp-zero.nvim", }
|
2023-08-29 23:17:39 +02:00
|
|
|
},
|
|
|
|
config = function()
|
2024-09-17 16:11:37 +02:00
|
|
|
local lsp_zero = require('lsp-zero')
|
|
|
|
|
|
|
|
local lsp_attach = function(client, bufnr)
|
|
|
|
-- this is where you enable features that only work
|
|
|
|
-- if there is a language server active in the file
|
|
|
|
end
|
|
|
|
|
|
|
|
lsp_zero.extend_lspconfig({
|
|
|
|
sign_text = true,
|
|
|
|
lsp_attach = lsp_attach,
|
|
|
|
})
|
|
|
|
|
2024-10-17 22:58:51 +02:00
|
|
|
configs = {
|
|
|
|
pylsp = {
|
|
|
|
settings = {
|
|
|
|
pylsp = {
|
|
|
|
plugins = {
|
|
|
|
mypy = { enabled = true },
|
|
|
|
black = { enabled = true },
|
|
|
|
isort = { enabled = true, profile = "black" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ruff_lsp = {
|
|
|
|
settings = {
|
|
|
|
args = {},
|
|
|
|
format = {
|
|
|
|
args = { "--line-length=120", "--config", "format.quote-style = 'single'" },
|
|
|
|
},
|
|
|
|
lint = {
|
|
|
|
-- args = { "--config", "lint.select = ['F', 'E']", "--config", "lint.ignore = ['E501']" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pyright = {
|
|
|
|
settings = {
|
|
|
|
pyright = {
|
|
|
|
disableOptimizeImports = true,
|
|
|
|
},
|
|
|
|
python = {
|
|
|
|
analysis = {
|
|
|
|
typeCheckingMode = "basic",
|
|
|
|
autoImportCompletions = false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-21 12:14:42 +02:00
|
|
|
require('mason').setup({})
|
|
|
|
require('mason-lspconfig').setup({
|
|
|
|
-- Replace the language servers listed here
|
|
|
|
-- with the ones you want to install
|
|
|
|
ensure_installed = {
|
2023-09-04 00:10:21 +02:00
|
|
|
"lua_ls",
|
2023-08-29 23:17:39 +02:00
|
|
|
"gopls",
|
2024-10-17 22:58:51 +02:00
|
|
|
"pyright",
|
2024-08-22 17:27:16 +02:00
|
|
|
"ruff_lsp",
|
2024-09-17 12:27:59 +02:00
|
|
|
"ts_ls",
|
2024-10-17 22:58:51 +02:00
|
|
|
"mypy"
|
2024-07-21 12:14:42 +02:00
|
|
|
},
|
|
|
|
handlers = {
|
|
|
|
function(server_name)
|
2024-10-17 22:58:51 +02:00
|
|
|
require('lspconfig')[server_name].setup(configs[server_name] or {})
|
2024-09-17 16:11:37 +02:00
|
|
|
end,
|
|
|
|
}
|
2024-08-22 17:08:06 +02:00
|
|
|
})
|
2024-09-17 16:11:37 +02:00
|
|
|
end
|
2023-08-29 23:17:39 +02:00
|
|
|
},
|
2023-08-29 20:07:23 +02:00
|
|
|
}
|