Skip to content

Commit

Permalink
vim: Drop nvim-cmp for cmdline completion
Browse files Browse the repository at this point in the history
It's a dumpster fire. Not salvageable. See
hrsh7th/cmp-cmdline#83 (comment)
and hrsh7th/cmp-cmdline#110 (comment)
  • Loading branch information
liskin committed Sep 1, 2024
1 parent e7ac6ac commit f9b0a19
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
43 changes: 0 additions & 43 deletions .config/nvim/lua/init/plug_cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ local function cmp_complete_snippet()
}
end

local function map(modes, func)
local res = {}
for _, mode in ipairs(modes) do
res[mode] = func
end
return res
end

cmp.setup {
completion = {
autocomplete = false,
Expand Down Expand Up @@ -174,41 +166,6 @@ cmp.setup {
},
}

cmp.setup.cmdline(':', {
mapping = vim.tbl_map(function(f) return map({'c'}, f) end, {
['<Tab>'] = function(_fallback)
if cmp.visible() then
if #cmp.get_entries() == 1 then
cmp.confirm()
else
cmp_select_next()
end
else
cmp.complete()
end
end,
['<S-Tab>'] = cmp_or(cmp_select_prev),
['<Down>'] = cmp_or(cmp_select_next),
['<Up>'] = cmp_or(cmp_select_prev),
['<PageDown>'] = cmp_or(cmp_select_next_page),
['<PageUp>'] = cmp_or(cmp_select_prev_page),
['<Right>'] = cmp_or(cmp.confirm),
['<Left>'] = cmp_or(cmp.abort),
['<CR>'] = cmp_or(cmp.confirm),
['<C-N>'] = cmp_or(cmp_select_next),
['<C-P>'] = cmp_or(cmp_select_prev),
}),
sources = cmp.config.sources({{ name = 'cmdline' }}),
---@diagnostic disable-next-line: missing-fields
matching = {
disallow_symbol_nonprefix_matching = false,
},
---@diagnostic disable-next-line: missing-fields
formatting = {
fields = { 'abbr', 'menu' },
},
})

cmp.event:on('menu_opened', function(data)
-- start with an active entry
-- work around https://github.com/hrsh7th/nvim-cmp/issues/835
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
path = .local/share/nvim/site/bundle/nvim-cmp
# url = https://github.com/hrsh7th/nvim-cmp
url = https://github.com/liskin/nvim-cmp
[submodule ".local/share/nvim/site/bundle/cmp-cmdline"]
path = .local/share/nvim/site/bundle/cmp-cmdline
url = https://github.com/hrsh7th/cmp-cmdline
[submodule ".local/share/nvim/site/bundle/cmp-nvim-lsp"]
path = .local/share/nvim/site/bundle/cmp-nvim-lsp
url = https://github.com/hrsh7th/cmp-nvim-lsp
Expand Down
1 change: 0 additions & 1 deletion .local/share/nvim/site/bundle/cmp-cmdline
Submodule cmp-cmdline deleted from d250c6
13 changes: 13 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,19 @@ if !has('nvim')
inoremap <silent> <S-Tab> <C-R>=LiskinShiftTabComplete()<CR>
endif

" emulate vim's wildoptions=pum bindings in neovim {{{2
if has('nvim')
cnoremap <expr> <Up> wildmenumode() ? "\<Left>" : "\<Up>"
cnoremap <expr> <Down> wildmenumode() ? "\<Right>" : "\<Down>"
cnoremap <expr> <Left> wildmenumode() ? "\<Up>" : "\<Left>"
cnoremap <expr> <Right> wildmenumode() ? "\<Down>" : "\<Right>"
" also make it behave slightly more like ins-completion
set wildcharm=<C-Z>
cnoremap <expr> <Tab> wildmenumode() ? "\<Right>" : "\<C-Z>"
cnoremap <expr> <CR> wildmenumode() ? "\<C-Y>" : "\<CR>"
endif

" cloning/closing tabs {{{2
nnoremap <silent> <C-W>S <Cmd>:CloneBufTmp<CR>
nnoremap <silent> <C-W>C <Cmd>:tabclose<CR>
Expand Down

0 comments on commit f9b0a19

Please sign in to comment.