Skip to content

Cursor jumps upward on automatic imports #37

@CaptainQuirk

Description

@CaptainQuirk

Hi,

I've a new workstation for some weeks now and I noticed that every time I choose a suggestion for a class in the autocomplete menu, the auto import feature works well, the cursor ends up a column after the completed suggestion, like expected, but on the line above the one I'm typing.

I'm on Vim 9.1, inside tmux < Terminal < WSL 2

My coc configuration is the following :

let g:coc_disable_transparent_cursor=1
let g:coc_disable_startup_warning=1
let g:coc_node_path='/home/linuxbrew/.linuxbrew/bin/node'

let g:coc_global_extensions = ['coc-json', 'coc-yaml', 'coc-tsserver', 'coc-phpactor']

" GoTo code navigation.
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)

function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  elseif (coc#rpc#ready())
    call CocActionAsync('doHover')
  else
    execute '!' . &keywordprg . " " . expand('<cword>')
  endif
endfunction

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>

" Remap keys for applying codeAction to the current buffer.
nmap <leader><Tab>a  <Plug>(coc-codeaction)
nmap <leader><Tab>c  <Plug>(coc-codeaction-cursor)

" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR   :call     CocActionAsync('runCommand', 'editor.action.organizeImport')

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')

" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>i  <Plug>(coc-codeaction-selected)
nmap <leader>i  <Plug>(coc-codeaction-selected)

nmap <silent><nowait> [g <Plug>(coc-diagnostic-prev)
nmap <silent><nowait> ]g <Plug>(coc-diagnostic-next)

" Show commands.
nnoremap <silent><nowait> <space>c  :<C-u>CocList commands<cr>

" Find symbol of current document.
nnoremap <silent><nowait> <space>o  :<C-u>CocList outline<cr>

inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1):
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"

inoremap <silent><expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<C-g>u\<CR>"

And I have the following settings specific to phpactor

let g:phpactorBranch = "develop"

autocmd FileType php let b:coc_disabled_sources = ['around', 'buffer', 'snippets']

nnoremap <leader>i :PhpactorImportClass<CR>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions