huge updates
This commit is contained in:
1 parent
d93e388067
commit
c9d290595f
37 files changed
+1309
-601
No files matched your search
+72
-87
@@ -1,100 +1,85 @@
|
||||
-- configure autocomplete
|
||||
return {
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = { 'InsertEnter', 'CmdlineEnter' },
|
||||
dependencies = {
|
||||
-- autocomplete plugins
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-nvim-lua',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
-- "hrsh7th/cmp-nvim-lsp-signature-help",
|
||||
-- "hrsh7th/cmp-calc",
|
||||
|
||||
-- vscode like icons to autocomplete list
|
||||
'onsails/lspkind.nvim',
|
||||
-- snippet plugin
|
||||
{ 'L3MON4D3/LuaSnip', event = { 'BufReadPost', 'BufNewFile' } },
|
||||
{ 'rafamadriz/friendly-snippets', event = { 'BufReadPost', 'BufNewFile' } },
|
||||
},
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
require('luasnip/loaders/from_vscode').lazy_load()
|
||||
|
||||
dependencies = {
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'rafamadriz/friendly-snippets',
|
||||
'onsails/lspkind.nvim',
|
||||
},
|
||||
event = 'InsertEnter',
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
cmp.setup({
|
||||
completion = {
|
||||
keyword_length = 1,
|
||||
completeopt = 'menu,menuone',
|
||||
},
|
||||
formatting = {
|
||||
fields = { 'kind', 'abbr', 'menu' },
|
||||
format = function(entry, vim_item)
|
||||
local kind = require('lspkind').cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, '%s', { trimempty = true })
|
||||
kind.kind = ' ' .. (strings[1] or '') .. ' '
|
||||
kind.menu = ' (' .. (strings[2] or '') .. ')'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
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({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
}),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require('luasnip').expandable() then
|
||||
luasnip.expand()
|
||||
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 require('luasnip').jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
return kind
|
||||
end,
|
||||
},
|
||||
snippet = { -- configure how nvim-cmp interacts with snippet engine
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<Tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
['<S-Tab>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(), -- show completion suggestions
|
||||
['<C-e>'] = cmp.mapping.abort(), -- close completion window
|
||||
['<Esc>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
{ name = 'codeium' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = 'symbol',
|
||||
maxwidth = 50,
|
||||
ellipsis_char = '...',
|
||||
show_labelDetails = true,
|
||||
|
||||
before = function(entry, vim_item)
|
||||
return vim_item
|
||||
end,
|
||||
}),
|
||||
},
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'cmdline' },
|
||||
},
|
||||
})
|
||||
}),
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false },
|
||||
})
|
||||
end,
|
||||
},
|
||||
}),
|
||||
-- sources for autocompletion
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- snippets
|
||||
{ name = 'buffer' }, -- text within current buffer
|
||||
{ name = 'path' }, -- file system paths
|
||||
{ name = 'codeium' }, -- AI for autocompletion
|
||||
-- { name = "nvim_lsp_signature_help" },
|
||||
-- { name = "calc" }, --for maths calculations
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
Reference in new issue
Block a user