Recommended way for checking if coc was loaded #5423
Answered
by
fannheyward
barrientosvctor
asked this question in
Q&A
-
|
I have Coc installed on my vimrc, but when I start it without coc installed or loaded. Errors messages and autocmds start appearing in vim making the user experience worse. Can you tell me a way to map my keymaps and config for coc only when it's already loaded? I tried using this approach but this causes the keymaps don't set to vim. ...
if exists("g:did_coc_loaded")
set nowritebackup
set updatetime=300
set signcolumn=yes
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
inoremap <silent><expr> <C-f> coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s)
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
augroup end
endifMy vimrc is one-file vim config, I'm using Vim 9.1 and Vim-Plug as package manager. |
Beta Was this translation helpful? Give feedback.
Answered by
fannheyward
Sep 4, 2025
Replies: 1 comment 1 reply
-
|
You can use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
barrientosvctor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
CocNvimInitcheck coc.nvim was started.