coc-java: Incorrect parameter completion
Versions
vim version: NVIM v0.4.3
node version: v10.16.0
coc.nvim version: 0.0.74-15f685206a
term: xterm-256color
platform: linux
Messages
[coc.nvim] Using java from /usr/lib/jvm/java-8-openjdk-amd64, version: 8
[coc.nvim] JDT Language Server starting at /home/user/Testing/Nvim/Vanilla
[coc.nvim] JDT Language Server started
Output channel: java
[Info - 6:09:01 PM] JDT Language Server started
[object Object]
Describe the bug
This is the result after completing parameter for a function:
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
int index = 0;
String element = "Hello World";
list.add(${1:index}, ${2:element});
}
}
I would expect instead:
list.add(index, element);
Reproduce the bug
- Create
mini.vim
with:
set runtimepath^=~/.local/share/nvim/plugged/coc.nvim
filetype plugin indent on
syntax on
set hidden
- Create
Main.java
with:
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
int index = 0;
String element = "Hello World";
}
}
- Type
list.
then select methodadd(int index, String element)
then press ENTER.
I believe this has happened after I’ve updated jdt.ls
with java.updateLanguageServer
.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (9 by maintainers)
Fixed on latest release branch of coc.nvim.
I’ve made a fix to disable insertTextFormat for resolved item.
Got it, should be bug of jdt.ls.
the insertTextFormat should be 2 for snippet. Old version of jdt.ls work as expected.
The latest jdt.ls milestone 0.50.0 is out and appears to cause this same completion issue. Could it be a compatibility issue between the coc language client and jdt.ls? I’ve tested both vscode-java and coc-java using the same jdt.ls server version 0.50.0. It works fine with vscode, but not with coc. I can see in the logs the capabilities request is slightly different between the two. Perhaps that difference is leading to the jdt.ls server not responding with the correct value for “insertTextFormat”? Or perhaps its some other client configuration sent to the server that is different and leading to the faulty result?
Temporary workaround:
In insert mode, CTRL+C replaces
list.add(${1:index})
tolist.add(index)
.<esc>
: escape in insert mode, go to normal mode<c-c>
: Ctrl-Cv
: visual mode<CR>
: enter:s/${[0-9]://g
: removes${[0-9]:
:s/}//g
: removes}
:nohl
: clear highightf(
: places cursor on first parenthesis