neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.15k stars 953 forks source link

<CR> can not confirm in vimwiki and folding codes failed #5021

Closed Kaiser-Yang closed 1 month ago

Kaiser-Yang commented 1 month ago

Problem 1

I can not use <CR> to confirm a completion, when I am in a vimwiki file.

I've uploaded an issue at vimwiki. The issue and my configurations are here.

Problem 2

I follow the example to add Fold command:

" Add `:Fold` command to fold current buffer
command! -nargs=? Fold :call     CocAction('fold', <f-args>)
nnoremap <leader>f :<C-u>Fold<CR>

And I use coc-clangd. When I use <leader>f, it gives me as the following: image

And I asked gpt, it told me that I should add those:

" set fold method for folding code.
set foldmethod=expr
set foldexpr=CocFoldExpr()
set foldlevel=99

But this does not work. Some configurations about coc-clangd:

{
    // enable semantic highlight
    "semanticTokens.enable": true,
    // highest priority to remove the delay of semantic highlight
    "semanticTokens.highlightPriority": 4096,
    // don't show by default
    "inlayHint.display": false,
    // clangd's snippets are trash, don't use this
    "clangd.disableSnippetCompletion": true,
}
fannheyward commented 1 month ago

For problem 1, what's the output of :verbose imap <cr>?

For problem 2, clangd didn't support foldingRange that needed to do folding.

Kaiser-Yang commented 1 month ago

For problem 1, what's the output of :verbose imap <cr>?

For problem 2, clangd didn't support foldingRange that needed to do folding.

The output of :verbose imap <CR> in a vimwiki file: image

fannheyward commented 1 month ago

Your <CR> mapping was conflict with auto-pairs. You can disable auto-pairs' mapping with let g:AutoPairsMapCR = 0.

Kaiser-Yang commented 1 month ago

For problem 1, what's the output of :verbose imap <cr>?

For problem 2, clangd didn't support foldingRange that needed to do folding.

Your <CR> mapping was conflict with auto-pairs. You can disable auto-pairs' mapping with let g:AutoPairsMapCR = 0.

Thank you for your replies. I think it has nothing to do with auto-pairs's mapping, because when in other files (such as a C/C++ file) the auto-pairs' mapping is still here.

But, luckily, I think I've found the solution for the problem 2 throuth adding those at my configurations of vimwiki:

" close lists_return
let g:vimwiki_key_mappings = { 'lists_return': 0, }

" remap lists_return
autocmd FileType vimwiki inoremap <silent><buffer><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
              \: "\<C-]>\<Esc>:VimwikiReturn 3 5\<CR>"
autocmd FileType vimwiki inoremap <silent><buffer> <S-CR>
              \ <Esc>:VimwikiReturn 2 2<CR>