In my Neovim 0.5.0 setup configured with ccls as LSP for C, the following seem to work:
- Diagnostic
- Go to definition
- Go to references
- Hover
- ....
e.g.:
vim.cmd("nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>")
vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>")
vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>")
vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>")
....
and most of the remaining ccls capabilities.
But those mappings/commands:
vim.cmd("nnoremap <silent> g1 <cmd>lua vim.lsp.buf.incoming_calls()<CR>")
vim.cmd("nnoremap <silent> g2 <cmd>lua vim.lsp.buf.outgoing_calls()<CR>")
doesn't seem to work. Neovim reports:
method textDocument/prepareCallHierarchy is not supported by any of the servers registered for the current buffer
Anyway, vim-ccls reports for all of its commands:
vim-ccls: nvim-lspconfig error: no result from ccls
when executing them (with or without a word under the cursor).
Neovim version:
NVIM v0.5.0-dev+1384-gf2906a466
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe /DWIN32 /D_WINDOWS /W3 /MD /Zi /O2 /Ob1 /DNDEBUG /W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -D_WIN32_WINNT=0x0600 -DINCLUDE_GENERATED_DECLARATIONS -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -ID:/a/neovim/neovim/build/config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/nvim-deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include
Compilato da runneradmin@fv-az152-886
Features: -acl +iconv +tui
See ":help feature-compile"
file vimrc di sistema: "$VIM\sysinit.vim"
$VIM di riserva: "C:/Program Files/nvim/share/nvim"
Run :checkhealth for more info
LspInfo output:
Configured servers: graphql, html, rust_analyzer, yamlls, svelte, vhdl_tool, ccls, efm, ahk_lsp, terraformls, angularls, texlab, pyright, cssls, vimls, vhdl_ls, solargraph, elixirls, intelephense, dockerls, elmls, dartls, vuels, gopls, bashls, kotlin_language_server, jsonls, tsserver, sumneko_lua, emmet_ls
Neovim logs at: C:\Users\Username\AppData\Local\Temp\nvim/lsp.log
1 client(s) attached to this buffer: ccls
Client: ccls (id 1)
root: C:\Work\Projects\Git\ACounter\testlut
filetypes: c, cpp, objc, objcpp
cmd: ccls --log-file=ccls.log -v=1
1 active client(s):
Client: ccls (id 1)
root: C:\Work\Projects\Git\ACounter\testlut
filetypes: c, cpp, objc, objcpp
cmd: ccls --log-file=ccls.log -v=1
Clients that match the filetype cpp:
Config: ccls
cmd: ccls --log-file=ccls.log -v=1
cmd is executable: True
identified root: C:\Work\Projects\Git\ACounter\testlut
custom handlers:
compile_commands.json:
[
{
"directory": "C:/Work/Projects/Git/ACounter/testlut/Build_Unix",
"command": "C:/msys64/mingw64/bin/c++.exe -std=gnu++17 -Weverything -o CMakeFiles/testlut.dir/main.cpp.obj -c C:/Work/Projects/Git/ACounter/testlut/main.cpp",
"file": "C:/Work/Projects/Git/ACounter/testlut/main.cpp"
}
]
LSP Config .lua setting:
require'lspconfig'.ccls.setup {
cmd = {"ccls", "--log-file=ccls.log", "-v=1"},
root_dir = require('lspconfig/util').root_pattern("compile_commands.json", "compile_flags.txt", ".ccls"),
on_attach = require'lsp'.common_on_attach,
}
ccls_log_file_content:
07/06/2021 16:30:00 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>133_handle_locations", "params": {"derived": false, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 11, "line": 45}}}]
07/06/2021 16:30:05 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>133_handle_tree", "params": {"levels": 1, "derived": false, "hierarchy": true, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 11, "line": 45}}}]
07/06/2021 16:30:09 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>133_handle_tree", "params": {"levels": 1, "callee": false, "hierarchy": true, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 11, "line": 45}}}]
07/06/2021 16:30:25 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>133_handle_locations", "params": {"derived": false, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:30:28 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>133_handle_tree", "params": {"levels": 1, "derived": false, "hierarchy": true, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:30:32 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>133_handle_tree", "params": {"levels": 1, "callee": false, "hierarchy": true, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:30:35 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>133_handle_tree", "params": {"levels": 1, "callee": true, "hierarchy": true, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:30:38 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>133_handle_locations", "params": {"callee": true, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:30:41 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>133_handle_locations", "params": {"callee": false, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:30:45 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>133_handle_locations", "params": {"derived": true, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 23, "line": 758}}}]
07/06/2021 16:47:16 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>136_handle_locations", "params": {"derived": false, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 13, "line": 295}}}]
07/06/2021 16:47:22 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>136_handle_tree", "params": {"levels": 1, "callee": false, "hierarchy": true, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 16, "line": 296}}}]
07/06/2021 16:56:04 | ["Outgoing", {"method": "$ccls/inheritance", "handler": "<SNR>139_handle_locations", "params": {"derived": false, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 21, "line": 296}}}]
07/06/2021 16:58:05 | ["Outgoing", {"method": "$ccls/call", "handler": "<SNR>139_handle_locations", "params": {"callee": false, "hierarchy": false, "textDocument": {"uri": "file://C:/Work/Projects/Git/ACounter/testlut/main.cpp"}, "position": {"character": 18, "line": 295}}}]
ccls log file:
16:50:14 D:\CodeBlocks\ccls\src\messages\initialize.cc:274 I initialize in directory C:/Work/Projects/Git/ACounter/testlut with uri file:///C:/Work/Projects/Git/ACounter/testlut
16:50:14 D:\CodeBlocks\ccls\src\messages\initialize.cc:297 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"","cache":{"directory":".ccls-cache","format":"binary","hierarchicalPath":false,"retainInMemory":2},"capabilities":{"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"foldingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}},"clang":{"excludeArgs":[],"extraArgs":[],"pathMappings":[],"resourceDir":""},"client":{"diagnosticsRelatedInformation":true,"hierarchicalDocumentSymbolSupport":true,"linkSupport":true,"snippetSupport":true},"codeLens":{"localVariables":true},"completion":{"caseSensitivity":2,"detailedLabel":true,"dropOldRequests":true,"duplicateOptional":true,"filterAndSort":true,"include":{"blacklist":[],"maxPathSize":30,"suffixWhitelist":[".h",".hpp",".hh",".inc"],"whitelist":[]},"maxNum":100,"placeholder":true},"diagnostics":{"blacklist":[],"onChange":1000,"onOpen":0,"onSave":0,"spellChecking":true,"whitelist":[]},"highlight":{"largeFileSize":2097152,"lsRanges":false,"blacklist":[],"whitelist":[]},"index":{"blacklist":[],"comments":2,"initialNoLinkage":false,"initialBlacklist":[],"initialWhitelist":[],"maxInitializerLines":5,"multiVersion":0,"multiVersionBlacklist":[],"multiVersionWhitelist":[],"name":{"suppressUnwrittenScope":false},"onChange":false,"parametersInDeclarations":true,"threads":0,"trackDependency":2,"whitelist":[]},"request":{"timeout":5000},"session":{"maxNum":10},"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"maxNum":2000}}
16:50:14 D:\CodeBlocks\ccls\src\messages\initialize.cc:329 I use -resource-dir=D:\CodeBlocks\llvm-11.0.1-install\lib\clang\11.0.1
16:50:14 D:\CodeBlocks\ccls\src\messages\initialize.cc:361 I workspace folder: C:/Work/Projects/Git/ACounter/testlut/
16:50:14 D:\CodeBlocks\ccls\src\project.cc:426 I loaded C:/Work/Projects/Git/ACounter/testlut/compile_commands.json
16:50:14 D:\CodeBlocks\ccls\src\messages\initialize.cc:386 I start 8 indexers
16:50:14 D:\CodeBlocks\ccls\src\messages\initialize.cc:394 I dispatch initial index requests
16:50:14 D:\CodeBlocks\ccls\src\pipeline.cc:493 I loaded project. Refresh semantic highlight for all working file.
16:50:14 D:\CodeBlocks\ccls\src\pipeline.cc:298 I load cache for C:/Work/Projects/Git/ACounter/testlut/main.cpp
16:50:14 D:\CodeBlocks\ccls\src\sema_manager.cc:763 I create session for C:/Work/Projects/Git/ACounter/testlut/main.cpp
C:/msys64/mingw64/bin/c++.exe --driver-mode=g++ -std=gnu++17 -Weverything -o CMakeFiles/testlut.dir/main.cpp.obj -c C:/Work/Projects/Git/ACounter/testlut/main.cpp -working-directory=C:/Work/Projects/Git/ACounter/testlut/Build_Unix
Neovim LSP log file:
[ START ] 2021-06-07T16:49:11+0200 ] LSP logging initiated
[ START ] 2021-06-07T16:50:07+0200 ] LSP logging initiated
[ WARN ] 2021-06-07T16:50:26+0200 ] ...\MEGA\Portable\Neovim\share\nvim\runtime\lua\vim\lsp.lua:86 ] "method textDocument/prepareCallHierarchy is not supported by any of the servers registered for the current buffer"
[ WARN ] 2021-06-07T16:50:28+0200 ] ...\MEGA\Portable\Neovim\share\nvim\runtime\lua\vim\lsp.lua:86 ] "method textDocument/prepareCallHierarchy is not supported by any of the servers registered for the current buffer"