more stuff too lazy to seperate

This commit is contained in:
2023-11-24 21:38:31 -05:00
parent ebf9d2d1c4
commit f35b13d669
33 changed files with 488 additions and 246 deletions

View File

@ -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
}