131 lines
3.8 KiB
Lua
131 lines
3.8 KiB
Lua
return {
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
config = function ()
|
|
require'lspconfig'.lua_ls.setup(require('lsp.lua'))
|
|
end
|
|
},
|
|
{
|
|
"williamboman/mason.nvim",
|
|
config = function()
|
|
require("mason").setup({})
|
|
end
|
|
},
|
|
{
|
|
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
|
|
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
|
|
'hrsh7th/cmp-path', -- { name = 'path' }
|
|
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
|
|
'hrsh7th/cmp-vsnip',
|
|
{
|
|
'onsails/lspkind-nvim',
|
|
config = function()
|
|
require('lspkind').init({
|
|
mode = 'symbol_text',
|
|
preset = 'codicons',
|
|
symbol_map = {
|
|
Text = "",
|
|
Method = "",
|
|
Function = "",
|
|
Constructor = "",
|
|
Field = "",
|
|
Variable = "",
|
|
Class = "",
|
|
Interface = "",
|
|
Module = "",
|
|
Property = "",
|
|
Unit = "",
|
|
Value = "",
|
|
Enum = "",
|
|
Keyword = "",
|
|
Snippet = "",
|
|
Color = "",
|
|
File = "",
|
|
Reference = "",
|
|
Folder = "",
|
|
EnumMember = "",
|
|
Constant = "",
|
|
Struct = "",
|
|
Event = "",
|
|
Operator = "",
|
|
TypeParameter = "",
|
|
},
|
|
})
|
|
end
|
|
},
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
config = function()
|
|
local has_words_before = function()
|
|
unpack = unpack or table.unpack
|
|
local line, col = unpack(G.api.nvim_win_get_cursor(0))
|
|
return col ~= 0 and G.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
|
|
end
|
|
local cmp = require('cmp')
|
|
local lspkind = require('lspkind')
|
|
cmp.setup {
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'buffer' },
|
|
{ name = 'path' },
|
|
{ name = 'cmdline' },
|
|
{name = 'vnsip'},
|
|
}),
|
|
mapping = cmp.mapping.preset.insert({
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
['<Tab>'] = function(fallback)
|
|
if not cmp.select_next_item() then
|
|
if vim.bo.buftype ~= 'prompt' and has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback()
|
|
end
|
|
end
|
|
end,
|
|
|
|
['<S-Tab>'] = function(fallback)
|
|
if not cmp.select_prev_item() then
|
|
if vim.bo.buftype ~= 'prompt' and has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback()
|
|
end
|
|
end
|
|
end,
|
|
|
|
}),
|
|
window = {
|
|
completion = {
|
|
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
|
col_offset = -3,
|
|
side_padding = 0,
|
|
},
|
|
},
|
|
fomatting = {
|
|
format = lspkind.cmp_format({
|
|
mode = 'symbol', -- show only symbol annotations
|
|
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
|
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
|
before = function (_, vim_item)
|
|
return vim_item
|
|
end
|
|
})
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
end,
|
|
},
|
|
}
|
|
end,
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|