scalameta / coc-metals

Deprecated in favor of scalameta/nvim-metals
http://scalameta.org/metals/
Apache License 2.0
167 stars 24 forks source link

Some of the mappings in coc-mappings.vim are no longer accurate #412

Closed jsatk closed 3 years ago

jsatk commented 3 years ago

Describe the bug

Some of the mappings are no longer accurate or simply do not work out-of-the-box.

To Reproduce Steps to reproduce the behavior:

  1. I added the following to the top of coc-mappings.vim:
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin()

Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'coc-metals', {'do': 'yarn install --frozen-lockfile'}
  1. Open any scala project with vim -N -u path/to/coc-mappings.vim
  2. Witness that the following commands do not do as expected out of the box:
    " Use <c-space> to trigger completion.
    inoremap <silent><expr> <c-space> coc#refresh()
" Used to expand decorations in worksheets
nmap <Leader>ws <Plug>(coc-metals-expand-decoration)
" Remap for do codeAction of current line
xmap <leader>a  <Plug>(coc-codeaction-line)
nmap <leader>a  <Plug>(coc-codeaction-line)
" Fix autofix problem of current line
nmap <leader>qf  <Plug>(coc-fix-current)
" Trigger for code actions
" Make sure `"codeLens.enable": true` is set in your coc config
nnoremap <leader>cl :<C-u>call CocActionAsync('codeLensAction')<CR>

Expected behavior

I expect them to do what they say 😄.

Installation:

Search terms

mappings vimrc

ckipp01 commented 3 years ago

Thanks for pointing these out! So keep in mind that some of them won't work with Vim, only Neovim. For example the expand decoration and codelens ones won't work without Neovim. So maybe some clarity in the example mappings about which are Neovim specific would help as well.

jsatk commented 3 years ago

Thanks for pointing these out! So keep in mind that some of them won't work with Vim, only Neovim. For example the expand decoration and codelens ones won't work without Neovim. So maybe some clarity in the example mappings about which are Neovim specific would help as well.

That's good info. I didn't know that.

jsatk commented 3 years ago

So I figured out one big error I made in my above testing with the minimal vimrc. I did not re-map leader to my usual leader key of , and therefore none of the mappings that use leader worked. 🤦‍♂️

I retested in both Neovim & Vim and here's my findings.

" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()

For both Neovim & vim this bit still makes little sense to me as if you use Tab or the up & down it fully fills in the word and pressing Enter confirms your choice and makes the pop up go away. It's unclear to me what <c-space> actually does different than enter? And <c-space> doesn't seem to do anything if you use the default <c-n> and <c-p> to navigate up and down (which does not automatically complete the word like the other methods do). I feel like I'm missing something.

Everything else worked just fine once I realized I was a dummy using the wrong leader key.

ckipp01 commented 3 years ago

For both Neovim & vim this bit still makes little sense to me

So from the way I understand it this is useful if people turn completions off, forcing them to have to trigger them manually, with <c-space>. Same thing if you're at a completion position like List(1, 2, 3).ma@@ and you cancel the completion, you should still be able to <c-space> and get them to appear again... I think.

jsatk commented 3 years ago

For both Neovim & vim this bit still makes little sense to me

So from the way I understand it this is useful if people turn completions off, forcing them to have to trigger them manually, with <c-space>. Same thing if you're at a completion position like List(1, 2, 3).ma@@ and you cancel the completion, you should still be able to <c-space> and get them to appear again... I think.

I tried with both <c-e> to close out of the completion menu and <esc> and then a (to re-enter insert mode). In both instances <c-space> didn't do what I'd expect. It just repeats the phrase I just typed.

I made an (overly long... sorry) 2m video demoing it in a worksheet. http://i.jsatk.us/9lr3fh

Again, possible I'm missing something here.

ckipp01 commented 3 years ago

I tried with both <c-e> to close out of the completion menu and <esc> and then a (to re-enter insert mode). In both instances <c-space> didn't do what I'd expect. It just repeats the phrase I just typed.

I made an (overly long... sorry) 2m video demoing it in a worksheet. http://i.jsatk.us/9lr3fh

Again, possible I'm missing something here.

huh, I honestly have no idea then.