Skip to content

Instantly share code, notes, and snippets.

@mike-hearn
Last active December 11, 2018 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-hearn/0358d53b59405a17c90667f4ee7183d1 to your computer and use it in GitHub Desktop.
Save mike-hearn/0358d53b59405a17c90667f4ee7183d1 to your computer and use it in GitHub Desktop.
coc.nvim priority issue

This gist is intended to demo a weird priority display issue between coc-pyls and ultisnips in certain situations.

FROM fedora:29
RUN dnf install --refresh -y python3 neovim git nodejs python-pip
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
RUN dnf install -y yarn
RUN pip3 install poetry
RUN adduser testuser --uid 1000
USER testuser
ADD --chown=testuser init.vim coc-settings.json /home/testuser/.config/nvim/
RUN curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
WORKDIR /home/testuser
RUN nvim +PlugInstall +qa
RUN mkdir -p ~/.config/coc/extensions && cd ~/.config/coc/extensions && yarn add coc-pyls coc-ultisnips
RUN mkdir /home/testuser/code
WORKDIR /home/testuser/code
RUN poetry init -n && \
poetry add django && \
poetry add --dev --extras all python-language-server && \
poetry add --dev neovim
CMD /bin/bash
call plug#begin('~/.local/share/nvim/plugged')
Plug 'neoclide/coc.nvim', {'do': 'yarn install'}
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
call plug#end()
" if hidden not set, TextEdit might fail.
set hidden
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> for trigger completion.
inoremap <silent><expr> <c-k> coc#refresh()
" Use <cr> for confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` for navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K for show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Setup formatexpr specified filetype(s).
augroup mygroup
autocmd!
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
vmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Use `:Format` for format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` for fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add diagnostic info for https://github.com/itchyny/lightline.vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'cocstatus': 'coc#status'
\ },
\ }
" Shortcuts for denite interface
" Show extension list
nnoremap <silent> <space>e :<C-u>Denite coc-extension<cr>
" Show symbols of current buffer
nnoremap <silent> <space>o :<C-u>Denite coc-symbols<cr>
" Search symbols of current workspace
nnoremap <silent> <space>t :<C-u>Denite coc-workspace<cr>
" Show diagnostics of current workspace
nnoremap <silent> <space>a :<C-u>Denite coc-diagnostic<cr>
" Show available commands
nnoremap <silent> <space>c :<C-u>Denite coc-command<cr>
" Show available services
nnoremap <silent> <space>s :<C-u>Denite coc-service<cr>
" Show links of current buffer
nnoremap <silent> <space>l :<C-u>Denite coc-link<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment