From 619fe68f6aa27550909503da48e9769418eb45a3 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Thu, 26 Oct 2023 16:03:53 +0200 Subject: [PATCH] do not select first result and handle enter smarter --- .config/nvim/coc-settings.json | 4 ++++ .config/nvim/init.vim | 24 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 .config/nvim/coc-settings.json diff --git a/.config/nvim/coc-settings.json b/.config/nvim/coc-settings.json new file mode 100644 index 0000000..f35f85e --- /dev/null +++ b/.config/nvim/coc-settings.json @@ -0,0 +1,4 @@ +{ +"suggest.enablePreselect": false, +"suggest.noselect": true +} diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 3d51d28..bf3b4ed 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -443,7 +443,26 @@ inoremap \ pumvisible() ? "\" : \ "\" inoremap pumvisible() ? "\" : "\" +let g:coc#disable_startup_autoselect = 1 +" confirms selection if any or just break line if none +function! EnterSelect() + " if the popup is visible and an option is not selected + if pumvisible() && complete_info()["selected"] == -1 + return "\\" + + " if the pum is visible and an option is selected + elseif pumvisible() + return coc#_select_confirm() + + " if the pum is not visible + else + return "\u\\=coc#on_enter()\" + endif +endfunction + +" makes confirm selection if any or just break line if none +inoremap EnterSelect() " Use to trigger completion. if has('nvim') inoremap pumvisible() ? coc#_select_confirm() @@ -452,11 +471,6 @@ else inoremap coc#refresh() endif -" Make auto-select the first completion item and notify coc.nvim to -" format on enter, could be remapped by other vim plugin -inoremap pumvisible() ? coc#_select_confirm() - \: "\u\\=coc#on_enter()\" - " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev)