Closed elextr closed 1 year ago
This sounds as if the base directory weren't correctly set or compile_commands.json
weren't configured correctly:
compile_commands.json
under base_dir/build/compile_commands.json
? By default clangd expects it to be under build
.Tools->LSP Client->User configuration
under the C
section add rpc_log=stdout
and restart Geany from terminal. In the terminal you should start seeing messages coming from clangd and you may check if you see something suspicious.In Tools->LSP Client->User configuration under the C section add rpc_log=stdout
Sorry, I meant
show_server_stderr=true
Did you create a Geany project and set the base directory to the root of your project?
Yep.
Did you place compile_commands.json under base_dir/build/compile_commands.json? By default clangd expects it to be under build.
Yep, well thats where it was built by cmake, it looks ok to my inexpert gaze.
show_server_stderr=true
Ahhh, can't find clangd, ooops while fiddling trying to improve it I uninstalled the default one and installed a newer version, changing the command in lsp.conf
to clangd-12 and now its found.
Sorry it took so long, I have the same project open in geany-lsp and geany 2.0 and vscode and have typed the following 3 times because I got confused which window is which :-P Anyway this time for sure ...
So now with only the .cpp
file open:
.cpp
file, but not for classes declared in the .hpp
file or STL and does not mark anything (as expected). Unscoped autocomplete has to be triggered by ctrl+space..cpp
file that are in the symbols pane, nor .hpp
file, nor STL and marks with solid underline some code that might have warnings eg if(cp = '=')
which is indeed a whoops. Unscoped autocompletes happen at first character????.hpp
and .cpp
file and STL (even without .hpp
closed) but shows no warnings (its configuration IIRC). Unscoped autocompletes happen at first character.With both the .cpp
and .hpp
open:
.cpp
and .hpp
file (in the .cpp
file) , not for STL and marks nothingI just noticed that the symbols pane is different in geany-lsp to geany 2.0 and vscode.
Geany-lsp shows definitions of member functions inside the class, even though they are defined externally after the class declaration. Both Geany 2.0 and vscode show them as external definitions.
I created a simple (not even a template ... yet) meaningless project with tree:
foo
foo.geany
build
meson.build
inc
foo.hpp
src
meson.build
foo.cpp
except for foo.geany
and build
directory gisted here (note as gists can't have subdirs in names I used _
where /
should go).
It seems to display most of the behaviours in the post above.
@elextr Thanks! The problem was I didn't check correctly for the servers of filetypes that share the configuration with other filetype (the use=C
for the C++
filetype). I tested this mostly with Geany's C files which used directly the configured server and worked alright. Anyway, should be fixed now.
In general, in clangd output you should see something like
I[10:57:13.771] Debian clangd version 14.0.6
I[10:57:13.771] Features: linux+grpc
I[10:57:13.771] PID: 1725082
I[10:57:13.771] Working directory: /home/parallels/projects/geany-lsp
I[10:57:13.771] argv[0]: clangd
I[10:57:13.771] Starting LSP over stdin/stdout
I[10:57:13.771] <-- initialize(1)
I[10:57:13.772] --> reply:initialize(1) 0 ms
I[10:57:13.821] <-- textDocument/didOpen
I[10:57:13.822] <-- textDocument/semanticTokens/full(2)
I[10:57:13.822] <-- textDocument/didOpen
I[10:57:13.822] <-- textDocument/semanticTokens/full(3)
I[10:57:13.822] Loaded compilation database from /home/parallels/projects/foo/build/compile_commands.json
where Working directory
is set to your project's base dir, Loaded compilation database from
points to the right compile_commands.json
file, the log must contain <-- initialize
and --> reply:initialize
followed later by
I[10:58:30.415] <-- initialized
where Working directory is set to your project's base dir,
Eh, no, this one seems to be where you launched Geany from (and is inherited by the clangd process). It's unrelated to the base directory.
This is what I get for the foo
project I posted above
lex@fred77:~/geany_lsp/geany-lsp/bin$ ./geany -c ../config
I[20:08:31.217] Ubuntu clangd version 12.0.0-3ubuntu1~20.04.5
I[20:08:31.218] PID: 20004
I[20:08:31.219] Working directory: /home/lex/geany_lsp/geany-lsp/bin
I[20:08:31.219] argv[0]: clangd-12
I[20:08:31.220] Starting LSP over stdin/stdout
I[20:08:31.225] <-- initialize(1)
I[20:08:31.236] --> reply:initialize(1) 10 ms
I[20:08:31.236] <-- textDocument/didOpen
I[20:08:31.244] <-- textDocument/documentSymbol(2)
I[20:08:31.245] <-- textDocument/semanticTokens/full(3)
I[20:08:31.246] <-- textDocument/didOpen
I[20:08:31.246] <-- textDocument/documentSymbol(4)
I[20:08:31.246] <-- textDocument/semanticTokens/full(5)
I[20:08:31.246] <-- textDocument/documentSymbol(6)
I[20:08:31.246] <-- textDocument/semanticTokens/full(7)
I[20:08:31.247] Loaded compilation database from /home/lex/foo/build/compile_commands.json
I[20:08:31.247] Enqueueing 1 commands for indexing
I[20:08:31.254] ASTWorker building file /home/lex/foo/src/foo.cpp version 1 with command
[/home/lex/foo/build]
/usr/bin/c++ --driver-mode=g++ -Isrc/25a6634@@foo@exe -Isrc -I../src -I../inc -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -g -o src/25a6634@@foo@exe/foo.cpp.o -c ../src/foo.cpp -fsyntax-only -resource-dir=/usr/lib/llvm-12/lib/clang/12.0.0
I[20:08:31.257] ASTWorker building file /home/lex/foo/inc/foo.hpp version 1 with command inferred from ../src/foo.cpp
[/home/lex/foo/build]
/usr/bin/c++ --driver-mode=g++ -Isrc/25a6634@@foo@exe -Isrc -I../src -I../inc -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -g -c /home/lex/foo/inc/foo.hpp -fsyntax-only -resource-dir=/usr/lib/llvm-12/lib/clang/12.0.0
I[20:08:31.827] Indexed ../src/foo.cpp (13 symbols, 4089 refs, 173 files)
I[20:08:31.935] --> textDocument/publishDiagnostics
I[20:08:31.936] --> reply:textDocument/documentSymbol(2) 691 ms
I[20:08:31.936] --> reply:textDocument/semanticTokens/full(3) 690 ms
I[20:08:31.983] --> textDocument/publishDiagnostics
I[20:08:31.983] --> reply:textDocument/documentSymbol(4) 737 ms
I[20:08:31.984] --> reply:textDocument/semanticTokens/full(5) 737 ms
I[20:08:31.984] --> reply:textDocument/documentSymbol(6) 738 ms
I[20:08:31.984] --> reply:textDocument/semanticTokens/full(7) 738 ms
Yeah, the
I[10:58:30.415] <-- initialized
is missing there.
But did you try it with the latest master? It should be fixed now.
Ok, pulled, rebuilt, now get I[20:20:48.461] <-- initialized
and pretty class names :-)
... and std::string
is highlighted :-D
Great! Closing this one, eagerly awaiting other bug reports :-).
Yeehah, templates like make_unique()
work and auto types work :+1:
And types from the .hpp
are coloured even if its closed, so yeah the actual OP is fixed :-)
Yeehah, templates like make_unique() work and auto types work 👍
Not exactly my job but I'll happily take the credit for it :-).
Have made a Geany project in one of my C++ projects, it is Cmake, but it has the
compile_commands.json
and I get local types highlighted and autocomplete and good scope autocompletes for variables declared with them, but only if I have the.hpp
file open.And I get no highlighting, autocomplete or scope autocomplete for the C++ STL library.