moved ftplugins, and fixed some plugins
This commit is contained in:
parent
3a09e91ad6
commit
8c56556c86
23 changed files with 578 additions and 244 deletions
|
|
@ -3,29 +3,64 @@ return {
|
|||
'hrsh7th/nvim-cmp',
|
||||
dependencies = {
|
||||
-- Snippet Engine & its associated nvim-cmp source
|
||||
'L3MON4D3/LuaSnip',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
{ 'L3MON4D3/LuaSnip', lazy = true },
|
||||
{ 'saadparwaiz1/cmp_luasnip', lazy = true },
|
||||
|
||||
-- Adds LSP completion capabilities
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
|
||||
-- Adds a number of user-friendly snippets
|
||||
'rafamadriz/friendly-snippets',
|
||||
{ 'rafamadriz/friendly-snippets', lazy = true },
|
||||
|
||||
-- Optional sources
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-buffer',
|
||||
-- Optional sources for path and buffer completion
|
||||
{ 'hrsh7th/cmp-path', lazy = true },
|
||||
{ 'hrsh7th/cmp-buffer', lazy = true },
|
||||
|
||||
-- Optional: additional completions for cmdline and git
|
||||
{ 'hrsh7th/cmp-cmdline', lazy = true },
|
||||
{ 'petertriho/cmp-git', lazy = true }, -- Git completions for commit messages
|
||||
|
||||
-- Optional: icons for completion menu
|
||||
{ 'onsails/lspkind-nvim', lazy = true }, -- Adds nice icons to completion
|
||||
},
|
||||
event = { 'InsertEnter', 'CmdlineEnter' },
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
-- Set completion options
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
|
||||
-- Import required modules
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
local cmp_mappings = {
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(), -- Trigger completion
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Confirm selection
|
||||
['<C-l>'] = 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' }),
|
||||
['<C-h>'] = 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' }),
|
||||
['<C-e>'] = cmp.mapping.abort(), -- Abort completion
|
||||
}
|
||||
|
||||
-- Setup luasnip
|
||||
-- Setup LuaSnip configuration
|
||||
luasnip.config.setup({
|
||||
history = true,
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
|
|
@ -39,59 +74,34 @@ return {
|
|||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
luasnip.lsp_expand(args.body) -- Expand snippets
|
||||
end,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
{ name = 'nvim_lsp' }, -- LSP completions
|
||||
{ name = 'luasnip' }, -- Snippet completions
|
||||
{ name = 'path' }, -- Path completions
|
||||
{ name = 'buffer' }, -- Buffer completions
|
||||
}),
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
completion = cmp.config.window.bordered(), -- Border for completion window
|
||||
documentation = cmp.config.window.bordered(), -- Border for documentation window
|
||||
},
|
||||
formatting = {
|
||||
fields = { 'abbr', 'kind', 'menu' },
|
||||
format = function(entry, item)
|
||||
local menu_icon = {
|
||||
nvim_lsp = 'λ',
|
||||
luasnip = '⋗',
|
||||
buffer = 'Ω',
|
||||
path = '🖫',
|
||||
}
|
||||
item.menu = menu_icon[entry.source.name] or entry.source.name
|
||||
return item
|
||||
end,
|
||||
format = lspkind.cmp_format({ -- Use lspkind for icons
|
||||
with_text = true,
|
||||
menu = {
|
||||
nvim_lsp = '[LSP]',
|
||||
luasnip = '[Snip]',
|
||||
buffer = '[Buffer]',
|
||||
path = '[Path]',
|
||||
cmdline = '[Cmd]',
|
||||
git = '[Git]',
|
||||
},
|
||||
}),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-l>'] = 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' }),
|
||||
['<C-h>'] = 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' }),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
}),
|
||||
mapping = cmp.mapping.preset.insert(cmp_mappings),
|
||||
})
|
||||
|
||||
-- Setup for SQL filetype with vim-dadbod-completion
|
||||
|
|
@ -101,6 +111,36 @@ return {
|
|||
{ name = 'buffer' },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Setup for markdown with buffer-only completions
|
||||
cmp.setup.filetype('markdown', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Setup for cmdline '/' (search) and ':' (command) mode
|
||||
cmp.setup.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(cmp_mappings),
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(cmp_mappings),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Setup git commit message completion
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' },
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue