summaryrefslogtreecommitdiffstats
path: root/after/plugin/cmp.lua
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2023-11-24 21:38:31 -0500
committerSquibid <me@zacharyscheiman.com>2023-11-24 21:38:31 -0500
commitf35b13d669867209427449840ff0930a732591dc (patch)
tree3acb658ec5d01f456c49a097d56f736cbfbbfc7d /after/plugin/cmp.lua
parentebf9d2d1c4682068f5116f7efc1568ce5adf4f1b (diff)
downloadnvim-f35b13d669867209427449840ff0930a732591dc.tar.gz
nvim-f35b13d669867209427449840ff0930a732591dc.tar.bz2
nvim-f35b13d669867209427449840ff0930a732591dc.zip
more stuff too lazy to seperate
Diffstat (limited to '')
-rw-r--r--after/plugin/cmp.lua61
1 files changed, 20 insertions, 41 deletions
diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua
index d9a83d2..0e8de6b 100644
--- a/after/plugin/cmp.lua
+++ b/after/plugin/cmp.lua
@@ -3,34 +3,6 @@ if not status_ok then
return
end
-local lspicons = {
- Text = 'Tx',
- Snippet = '<>',
- Method = '{}',
- Function = '{}',
- Constructor = '{}',
- Field = '""',
- Variable = 'i=',
- Class = '{}',
- Interface = '.h',
- Module = '{}',
- Property = '@p',
- Unit = ' ',
- Value = 'x=',
- Enum = 'E#',
- Keyword = '$1',
- Color = ' ',
- File = '#`',
- Reference = ' ',
- Folder = '[/',
- EnumMember = ' ',
- Constant = 'c=',
- Struct = ' ',
- Event = ' ',
- Operator = '%*',
- TypeParameter = ' ',
-}
-
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(a.nvim_win_get_cursor(0))
@@ -38,11 +10,9 @@ local has_words_before = function()
[1]:sub(col, col):match("%s") == nil
end
--- insert '(' after completing a function
-cmp.event:on(
- 'confirm_done',
- require('nvim-autopairs.completion.cmp').on_confirm_done()
-)
+-- insert '()' after completing a function
+cmp.event:on('confirm_done',
+ require('nvim-autopairs.completion.cmp').on_confirm_done())
local luasnip = require('luasnip')
local neogen = require('neogen')
@@ -57,7 +27,7 @@ cmp.setup {
sources = cmp.config.sources({
{ name = 'nvim_lsp', keyword_length = 3 },
- { name = 'luasnip', keyword_length = 3 },
+ { name = 'luasnip_choice' },
{ name = 'async_path' },
{ name = 'buffer', keyword_length = 3, max_item_count = 7 },
{ name = 'calc' },
@@ -80,12 +50,17 @@ cmp.setup {
-- mappings -----------------------------------------------------------------
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
+ if #cmp.get_entries() == 1 then
+ cmp.confirm({ select = true })
+ elseif cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
+ if #cmp.get_entries() == 1 then
+ cmp.confirm({ select = true })
+ end
elseif neogen.jumpable() then
neogen.jump_next()
else
@@ -103,7 +78,7 @@ cmp.setup {
fallback()
end
end, { "i", "s" }),
- ['<CR>'] = cmp.mapping({
+ ['<CR>'] = cmp.mapping {
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
@@ -112,9 +87,13 @@ cmp.setup {
end
end,
s = cmp.mapping.confirm({ select = true }),
- c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
- }),
+ c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace,
+ select = true }),
+ },
+ ["<C-u>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-d>"] = cmp.mapping.scroll_docs(4),
['<ESC>'] = cmp.mapping.close(),
+ ["<C-e>"] = cmp.mapping.abort(),
}),
sorting = {
@@ -122,12 +101,12 @@ cmp.setup {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
- require "cmp-under-comparator".under,
+ require("cmp-under-comparator").under,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
- },
+ }
},
enabled = function()
local context = require 'cmp.config.context'
@@ -135,7 +114,7 @@ cmp.setup {
return true
else
return not context.in_treesitter_capture("comment")
- and not context.in_syntax_group("Comment")
+ and not context.in_syntax_group("Comment")
end
end
}