98 lines
3.8 KiB
Lua
98 lines
3.8 KiB
Lua
return {
|
|
{
|
|
'williamboman/mason-lspconfig.nvim',
|
|
opts = {
|
|
ensure_installed = { 'lua_ls', 'gopls', 'rust_analyzer', 'pylsp' }
|
|
}
|
|
},
|
|
{
|
|
'L3MON4D3/LuaSnip',
|
|
version = 'v2.*',
|
|
build = 'make install_jsregexp',
|
|
dependencies = {
|
|
'rafamadriz/friendly-snippets'
|
|
},
|
|
config = function()
|
|
local vscode_loader = require('luasnip.loaders.from_vscode')
|
|
vscode_loader.lazy_load()
|
|
vscode_loader.lazy_load({ paths = { './snippets' } })
|
|
local ls = require('luasnip')
|
|
vim.keymap.set({ "i" }, "<C-K>", function() ls.expand() end, { silent = true })
|
|
vim.keymap.set({ "i", "s" }, "<C-L>", function() ls.jump(1) end, { silent = true })
|
|
vim.keymap.set({ "i", "s" }, "<C-J>", function() ls.jump(-1) end, { silent = true })
|
|
end
|
|
},
|
|
{
|
|
'hrsh7th/nvim-cmp',
|
|
event = 'InsertEnter',
|
|
dependencies = {
|
|
'hrsh7th/cmp-buffer',
|
|
'hrsh7th/cmp-path',
|
|
'hrsh7th/cmp-cmdline',
|
|
'hrsh7th/cmp-nvim-lsp',
|
|
'saadparwaiz1/cmp_luasnip'
|
|
},
|
|
config = function()
|
|
local has_words_before = function()
|
|
unpack = unpack or table.unpack
|
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
return col ~= 0 and
|
|
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
end
|
|
|
|
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({
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
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" }),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' },
|
|
{ name = 'buffer' },
|
|
{ name = 'path' },
|
|
})
|
|
})
|
|
end
|
|
},
|
|
{
|
|
'neovim/nvim-lspconfig',
|
|
config = function()
|
|
local lspconfig = require('lspconfig')
|
|
local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
lspconfig.lua_ls.setup({ capabilities = lsp_capabilities })
|
|
lspconfig.rust_analyzer.setup({ capabilities = lsp_capabilities })
|
|
lspconfig.gopls.setup({ capabilities = lsp_capabilities })
|
|
lspconfig.typst_lsp.setup({ capabilities = lsp_capabilities })
|
|
lspconfig.clangd.setup({ capabilities = lsp_capabilities })
|
|
lspconfig.cmake.setup({ capabilities = lsp_capabilities })
|
|
end
|
|
},
|
|
}
|