neovim: nvim-cmp: delete unused sources, add other

This commit is contained in:
Hoang Nguyen 2021-10-23 21:30:14 +07:00
parent 30ba9f6f1d
commit 2a2c753ffd
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
6 changed files with 76 additions and 59 deletions

View File

@ -1,3 +1,3 @@
setlocal spell " setlocal spell
setlocal wrap setlocal wrap
" setlocal nonumber norelativenumber setlocal nonumber norelativenumber

View File

@ -1,3 +1,3 @@
setlocal spell " setlocal spell
setlocal wrap setlocal wrap
" setlocal nonumber norelativenumber setlocal nonumber norelativenumber

View File

@ -25,6 +25,10 @@ api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true}
api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true}) api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true}) api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
-- Also move up/down virual lines (:set wrap)
api.nvim_set_keymap('n', 'j', 'gj', {noremap = true, silent = true})
api.nvim_set_keymap('n', 'k', 'gk', {noremap = true, silent = true})
-- winshift.nvim -- winshift.nvim
api.nvim_set_keymap('n', '<C-w><C-m>', ':WinShift<CR>', {noremap = true, silent = true}) api.nvim_set_keymap('n', '<C-w><C-m>', ':WinShift<CR>', {noremap = true, silent = true})
api.nvim_set_keymap('n', '<C-w>m', ':WinShift<CR>', {noremap = true, silent = true}) api.nvim_set_keymap('n', '<C-w>m', ':WinShift<CR>', {noremap = true, silent = true})
@ -69,12 +73,12 @@ wk.register({
vim.opt.expandtab = false vim.opt.expandtab = false
vim.opt.smarttab = false vim.opt.smarttab = false
vim.opt.softtabstop = 0 -- reset to default vim.opt.softtabstop = 0 -- reset to default
vim.notify('Switched to indent with tabs.', vim.log.levels.INFO) vim.notify('Indent with Tabs.', vim.log.levels.INFO)
else else
vim.opt.expandtab = true vim.opt.expandtab = true
vim.opt.smarttab = true vim.opt.smarttab = true
vim.opt.softtabstop = -1 -- fallback to shiftwidth vim.opt.softtabstop = -1 -- fallback to shiftwidth
vim.notify('Switched to indent with spaces.', vim.log.levels.INFO) vim.notify('Indent with Spaces.', vim.log.levels.INFO)
end end
end, end,
'Switch indent style' 'Switch indent style'
@ -215,7 +219,7 @@ wk.register({
name = 'Editor', name = 'Editor',
a = {':EasyAlign<CR>', 'Align elements'}, a = {':EasyAlign<CR>', 'Align elements'},
g = 'Generate annotations', g = 'Generate annotations',
h = {':TSHighlightCapturesUnderCursor<CR>', 'Syntax groups under cursor'}, h = {':TSHighlightCapturesUnderCursor<CR>', 'Syntax under cursor'},
s = {':ISwapWith<CR>', 'Swap elements'}, s = {':ISwapWith<CR>', 'Swap elements'},
t = {':Twilight<CR>', 'Twilight mode'}, t = {':Twilight<CR>', 'Twilight mode'},
v = { v = {
@ -225,24 +229,27 @@ wk.register({
vim.b.venn_enabled = true vim.b.venn_enabled = true
vim.api.nvim_command('setlocal virtualedit=all') vim.api.nvim_command('setlocal virtualedit=all')
-- Draw lines with HJKL keystroke -- Draw lines with HJKL keystroke
vim.api.nvim_buf_set_keymap(0, 'n', '<Left>', '<C-v>h:VBox<CR>', {noremap = true, silent = true}) vim.api.nvim_buf_set_keymap(0, 'n', 'H', '<C-v>h:VBox<CR>', {noremap = true, silent = true})
vim.api.nvim_buf_set_keymap(0, 'n', '<Down>', '<C-v>j:VBox<CR>', {noremap = true, silent = true}) vim.api.nvim_buf_set_keymap(0, 'n', 'J', '<C-v>j:VBox<CR>', {noremap = true, silent = true})
vim.api.nvim_buf_set_keymap(0, 'n', '<Up>', '<C-v>k:VBox<CR>', {noremap = true, silent = true}) vim.api.nvim_buf_set_keymap(0, 'n', 'K', '<C-v>k:VBox<CR>', {noremap = true, silent = true})
vim.api.nvim_buf_set_keymap(0, 'n', '<Right>', '<C-v>l:VBox<CR>', {noremap = true, silent = true}) vim.api.nvim_buf_set_keymap(0, 'n', 'L', '<C-v>l:VBox<CR>', {noremap = true, silent = true})
-- Draw boxes by pressing 'f' with visual selection -- Draw boxes by pressing 'f' with visual selection
vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox<CR>', {noremap = true, silent = true}) vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox<CR>', {noremap = true, silent = true})
vim.notify('Virtual box edit enabled.', vim.log.levels.INFO) vim.notify('Virtual box edit enabled.', vim.log.levels.INFO)
else else
vim.b.venn_enabled = nil vim.b.venn_enabled = nil
vim.api.nvim_command('setlocal virtualedit=block') vim.api.nvim_command('setlocal virtualedit=block')
-- vim.api.nvim_command('mapclear <buffer>') -- this also deletes buf keymap for lsp -- vim.api.nvim_command('mapclear <buffer>') -- quicker, but also deletes buf keymap for lsp
vim.api.nvim_buf_del_keymap(0, 'v', 'f') vim.api.nvim_buf_del_keymap(0, 'v', 'f')
vim.api.nvim_buf_del_keymap(0, 'n', '<Left>') vim.api.nvim_buf_del_keymap(0, 'n', 'H')
vim.api.nvim_buf_del_keymap(0, 'n', '<Down>') vim.api.nvim_buf_del_keymap(0, 'n', 'J')
vim.api.nvim_buf_del_keymap(0, 'n', '<Up>') vim.api.nvim_buf_del_keymap(0, 'n', 'L')
vim.api.nvim_buf_del_keymap(0, 'n', '<Right>') local present, _ = pcall(require, 'lspconfig') -- Check to re-enable buf keymap for hover
if present then
vim.api.nvim_buf_set_keymap(0, 'n', 'K', ':lua vim.lsp.buf.hover()<CR>', {noremap = true, silent = true})
else
vim.api.nvim_buf_del_keymap(0, 'n', 'K')
end
vim.notify('Virtual box edit disabled.', vim.log.levels.INFO) vim.notify('Virtual box edit disabled.', vim.log.levels.INFO)
end end
end, end,

View File

@ -10,6 +10,18 @@ function M.cmp_conf()
end end
cmp.setup { cmp.setup {
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
require('cmp-under-comparator').under,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order
}
},
formatting = { formatting = {
format = function(entry, vim_item) format = function(entry, vim_item)
local lspkind_icons = { local lspkind_icons = {
@ -47,14 +59,11 @@ function M.cmp_conf()
path = '[PATH]', path = '[PATH]',
buffer = '[BUF]', buffer = '[BUF]',
-- calc = '[CALC]', -- calc = '[CALC]',
-- nuspell = '[SPELL]', dictionary = '[DICT]',
spell = '[SPELL]', treesitter = '[TS]',
emoji = '[EMOJI]',
-- treesitter = '[TS]',
nvim_lsp = '[LSP]', nvim_lsp = '[LSP]',
-- cmp_tabnine = '[TN]', -- cmp_tabnine = '[TN]',
latex_symbols = '[TEX]', latex_symbols = '[TEX]',
-- tmux = '[TMUX]',
-- conjure = '[CJ]', -- conjure = '[CJ]',
orgmode = '[ORG]' orgmode = '[ORG]'
})[entry.source.name] })[entry.source.name]
@ -119,18 +128,19 @@ function M.cmp_conf()
{name = 'path'}, {name = 'path'},
{name = 'buffer'}, {name = 'buffer'},
-- {name = 'calc'}, -- {name = 'calc'},
-- {name = 'nuspell'}, {name = 'dictionary', keyword_length = 2},
{name = 'spell'}, {name = 'treesitter'},
{name = 'emoji'},
-- {name = 'treesitter'},
{name = 'nvim_lsp'}, {name = 'nvim_lsp'},
-- {name = 'cmp_tabnine'}, -- {name = 'cmp_tabnine'},
{name = 'latex_symbols'}, {name = 'latex_symbols'},
-- {name = 'tmux'},
-- {name = 'conjure'}, -- {name = 'conjure'},
{name = 'orgmode'} {name = 'orgmode'}
} }
} }
-- Setup for cmp-dictionary
-- TODO: do this on FileType * (cmp.setup.buffer) with custom dicts
-- vim.opt.dictionary = {'/usr/share/dict/words'}
end end
-- function M.tabnine_conf() -- function M.tabnine_conf()

View File

@ -236,16 +236,16 @@ function M.eft_conf()
vim.g.eft_index_function = {all = function() return true end} vim.g.eft_index_function = {all = function() return true end}
-- Mappings -- Mappings
vim.api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {}) vim.api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {silent = true})
vim.api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {}) vim.api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {silent = true})
vim.api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {}) vim.api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {silent = true})
vim.api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {}) vim.api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {silent = true})
vim.api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {}) vim.api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {silent = true})
vim.api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {}) vim.api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {silent = true})
vim.api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {}) vim.api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {silent = true})
vim.api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {}) vim.api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {silent = true})
vim.api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {}) vim.api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {silent = true})
vim.api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {}) vim.api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {silent = true})
end end
function M.dial_conf() function M.dial_conf()
@ -294,12 +294,12 @@ function M.dial_conf()
} }
-- Mappings -- Mappings
vim.api.nvim_set_keymap('n', '<C-a>', '<Plug>(dial-increment)', {}) vim.api.nvim_set_keymap('n', '<C-a>', '<Plug>(dial-increment)', {silent = true})
vim.api.nvim_set_keymap('v', '<C-a>', '<Plug>(dial-increment)', {}) vim.api.nvim_set_keymap('v', '<C-a>', '<Plug>(dial-increment)', {silent = true})
vim.api.nvim_set_keymap('n', '<C-x>', '<Plug>(dial-decrement)', {}) vim.api.nvim_set_keymap('n', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
vim.api.nvim_set_keymap('v', '<C-x>', '<Plug>(dial-decrement)', {}) vim.api.nvim_set_keymap('v', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
vim.api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', {}) vim.api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', {silent = true})
vim.api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', {}) vim.api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', {silent = true})
end end
function M.comment_conf() function M.comment_conf()

View File

@ -173,7 +173,7 @@ return packer.startup(function(use)
-- LSP -- -- LSP --
--------- ---------
local lsp = require('modules.lsp') local lsp = require('modules.lsp')
use { use { -- TODO: reconsider lspsaga for actions
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
event = 'BufReadPre', event = 'BufReadPre',
wants = {'lsp_signature.nvim', 'null-ls.nvim'}, wants = {'lsp_signature.nvim', 'null-ls.nvim'},
@ -232,24 +232,25 @@ return packer.startup(function(use)
use { use {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
event = 'InsertEnter', event = 'InsertEnter',
wants = 'LuaSnip', wants = {'LuaSnip', 'cmp-under-comparator'},
requires = {{ requires = {
'L3MON4D3/LuaSnip', {
wants = 'friendly-snippets', 'L3MON4D3/LuaSnip',
requires = {{'rafamadriz/friendly-snippets', opt = true}}, wants = 'friendly-snippets',
config = completion.snippets_conf, requires = {{'rafamadriz/friendly-snippets', opt = true}},
opt = true config = completion.snippets_conf,
}}, opt = true
},
{'lukas-reineke/cmp-under-comparator', opt = true}
},
config = completion.cmp_conf config = completion.cmp_conf
} }
use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp'} use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp'}
use {'hrsh7th/cmp-path', after = 'nvim-cmp'} use {'hrsh7th/cmp-path', after = 'nvim-cmp'}
use {'hrsh7th/cmp-buffer', after = 'nvim-cmp'} use {'hrsh7th/cmp-buffer', after = 'nvim-cmp'}
-- use {'hrsh7th/cmp-calc', after = 'nvim-cmp'} -- use {'hrsh7th/cmp-calc', after = 'nvim-cmp'}
-- use {'f3fora/cmp-nuspell', after = 'nvim-cmp', rocks={'lua-nuspell'}} use {'uga-rosa/cmp-dictionary', after = 'nvim-cmp'} -- TODO: scripts to curl dicts from aspell.net
use {'f3fora/cmp-spell', after = 'nvim-cmp'} use {'ray-x/cmp-treesitter', after = {'nvim-cmp', 'nvim-treesitter'}}
use {'hrsh7th/cmp-emoji', after = 'nvim-cmp'}
-- use {'ray-x/cmp-treesitter', after = {'nvim-cmp', 'nvim-treesitter'}}
use {'hrsh7th/cmp-nvim-lsp', after = {'nvim-cmp', 'nvim-lspconfig'}} use {'hrsh7th/cmp-nvim-lsp', after = {'nvim-cmp', 'nvim-lspconfig'}}
-- use { -- use {
-- 'tzachar/cmp-tabnine', -- 'tzachar/cmp-tabnine',
@ -258,7 +259,6 @@ return packer.startup(function(use)
-- config = completion.tabnine_conf -- config = completion.tabnine_conf
-- } -- }
use {'kdheepak/cmp-latex-symbols', after = 'nvim-cmp'} use {'kdheepak/cmp-latex-symbols', after = 'nvim-cmp'}
-- use {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp'}
-- use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}} -- use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}}
use { use {
'windwp/nvim-autopairs', 'windwp/nvim-autopairs',
@ -332,7 +332,7 @@ return packer.startup(function(use)
opt = true opt = true
}} }}
} }
use { use { -- TODO: check out kat0h/bufpreview.vim
'iamcco/markdown-preview.nvim', 'iamcco/markdown-preview.nvim',
run = 'cd app && yarn install', run = 'cd app && yarn install',
ft = {'markdown', 'rmd'}, ft = {'markdown', 'rmd'},