Describe the bug
:call CocAction('codeLens') displays an error message [coc.nvim] Source id of codelens not found"
To Reproduce
~/.config/nvim/coc-settings.json:
{
"languageserver": {
"ccls": {
"command": "ccls",
"filetypes": ["c", "cpp", "objc", "objcpp"]
}
}
}
cd /tmp/d; git initecho 'int a;' > a.ccnvim a.cc:call CocAction('codeLens')Expected behavior
textDocument/codeLen result is rendered somewhere
Additional context
sysdig -As9999 --unbuffered -p '%evt.buffer' "proc.exe contains ccls and fd.type=unix":
Content-Length: 113
{"jsonrpc":"2.0","id":16,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///tmp/d/a.cc"}}}
Content-Length: 239
{"jsonrpc":"2.0","id":16,"result":[{"range":{"start":{"line":0,"character":4},"end":{"line":0,"character":5}},"command":{"title":"0 ref","command":"ccls.xref","arguments":["{\"usr\":16721564935990383768,\"kind\":4,\"field\":\"uses\"}"]}}]}
Note it encodes a JSON string as the only element of "arguments" (to make VSCode happy):
"arguments":["{\"usr\":16721564935990383768,\"kind\":4,\"field\":\"uses\"}"]
/tmp/coc-nvim.log log entry:
2018-11-23T21:19:51.601 ERROR (pid:17076) [codelens] - Cannot read property 'command' of null
The command not exists, an extension could help to regist custom command.
Does it make sense to postpone the error reporting to when the user actually clicks the button (tricks the command)?
My supposed interaction is:
textDocument/codeLens{"jsonrpc":"2.0","id":16,"result":[{"range":{"start":{"line":0,"character":4},"end":{"line":0,"character":5}},"command":{"title":"0 ref","command":"ccls.xref","arguments":["{\"usr\":16721564935990383768,\"kind\":4,\"field\":\"uses\"}"]}}]}
range and command.title are rendered even if the server does not know the actual command. In this particular case, "title": "0 ref" means the declaration has 0 references. The title is more important than whether the command is rendered as a clickable button.0 refs button (code lens). As there is no extension to handle the command ccls.xref, coc.nvim can bail out and print an error message in this step, instead of sending{"title":"0 ref","command":"ccls.xref","arguments":["{\"usr\":16721564935990383768,\"kind\":4,\"field\":\"uses\"}"]}
Here is how CodeLens is rendered in vscode-ccls. These "* refs" are clickable buttons, but whether they are clickable does not matter too much. coc.nvim can print an error message as the command is not supported by an extension.

I feel it is distracting as it takes too much vertical space. emacs-ccls puts all lenses at the line end by default.
Coc will use set_virtual_text of neovim for codeLenes feature.
Most helpful comment
Coc will use
set_virtual_textof neovim for codeLenes feature.