clangd / coc-clangd

clangd extension for coc.nvim
Apache License 2.0
761 stars 34 forks source link

Intellisense issue with clangd coc.nvim extension #603

Closed ricciolino closed 1 year ago

ricciolino commented 1 year ago

Logs :CocCommand workspace.showOutput

I[16:09:46.558] clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520)
I[16:09:46.558] Features: linux+grpc
I[16:09:46.558] PID: 1411279
I[16:09:46.558] Working directory: /home/ricciolino/Desktop/tmp/test_c++
I[16:09:46.558] argv[0]: ../../../.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd
I[16:09:46.559] Starting LSP over stdin/stdout
I[16:09:46.560] <-- initialize(0)
I[16:09:46.560] --> reply:initialize(0) 0 ms
I[16:09:46.563] <-- initialized
I[16:09:46.564] <-- textDocument/didOpen
I[16:09:46.564] Failed to find compilation database for /home/ricciolino/Desktop/tmp/test_c++/main.cpp
I[16:09:46.564] ASTWorker building file /home/ricciolino/Desktop/tmp/test_c++/main.cpp version 1 with command clangd fallback
[/home/ricciolino/Desktop/tmp/test_c++]
/usr/bin/clang -resource-dir=/home/ricciolino/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/lib/clang/16 -- /home/ricciolino/Desktop/tmp/test_c++/main.cpp
I[16:09:46.565] --> textDocument/clangd.fileStatus
I[16:09:46.568] Built preamble of size 217116 for file /home/ricciolino/Desktop/tmp/test_c++/main.cpp version 1 in 0.00 seconds
I[16:09:46.568] --> workspace/semanticTokens/refresh(0)
I[16:09:46.568] --> textDocument/clangd.fileStatus
I[16:09:46.568] --> textDocument/clangd.fileStatus
I[16:09:46.568] <-- reply(0)
I[16:09:46.570] --> textDocument/publishDiagnostics
I[16:09:46.570] --> textDocument/clangd.fileStatus
I[16:09:46.764] <-- textDocument/documentLink(1)
I[16:09:46.764] --> reply:textDocument/documentLink(1) 0 ms
I[16:09:46.764] --> textDocument/clangd.fileStatus

System information clangd --version

> ~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd --version
clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu

:CocList extensions

* * coc-clangd 0.29.1 ~/.config/coc/extensions/node_modules/coc-clangd
* + coc-tsserver 2.1.3 ~/.config/coc/extensions/node_modules/coc-tsserver
* + coc-python 1.2.13 ~/.config/coc/extensions/node_modules/coc-python                         
* + coc-json 1.8.0 ~/.config/coc/extensions/node_modules/coc-json

Operating system: Ubuntu 22

I am trying to test the intellisense feature using this C++ snippet:

#include<iostream>
#include<string>

int main(void)
{
    std::string s;
    s.
    std::cout << "Hello!" << std::endl;
    return 0;
}

I expected that after typing s. on line number 7, the clangd coc.nvim extension gave me a rich list of possible methods from the std::string class. Actually I am not getting any suggestion. Why this?

sam-mccall commented 1 year ago

You're including standard library headers, maybe you don't have a standard library installed (in a standard place clang can find it)?

Are there any diagnostics shown? The log you posted didn't have any completion requests, was it truncated?

ricciolino commented 1 year ago

How can I tell clang where to search for the standard header files ? I am sure I have installed it because I can compile and run the code. The logs are not truncated, I don't know how to explicitly tell to coc plugin how to perform a completion request, I was thinking this could happen automatically once I start typing code similar to s. , expecting a request to take place in that moment, or am I wrong ?

fannheyward commented 1 year ago

Failed to find compilation database for /home/ricciolino/Desktop/tmp/test_c++/main.cpp

clangd needs compile_commands.json to understand your code, https://clangd.llvm.org/installation#project-setup

ricciolino commented 1 year ago

Here is my ~/.vim/coc-settings.json:

{
    "python.pythonPath": "python",
    "python.autoComplete.addBrackets": true,
    "python.formatting.provider": "autopep8",
    "clangd.path": "/usr/bin/clangd",
    "clangd.arguments": [
        "-I/usr/include/c++/11",
        "-I/usr/local/include"
    ]
}

Here is my compile_commands.json:

[
  {
    "directory": "/home/ricciolino/Desktop/tmp/test_c++",
    "file": "/home/ricciolino/Desktop/tmp/test_c++/main.cpp",
    "command": "g++ -std=c++11 -o /home/ricciolino/Desktop/tmp/test_c++/main /home/ricciolino/Desktop/tmp/test_c++/main.cpp"
  }
]

Now I am getting this error when open file main.cpp:

[coc.nvim] Server clangd failed to start: Error: Pending response rejected since connection got
[coc.nvim] clangd client: couldn't create connection to server.

Here is the output of :CocOpenLog:

2023-07-13T10:40:36.627 INFO (pid:1562968) [plugin] - coc.nvim initialized with node: v18.16.1 after 89
2023-07-13T10:40:36.632 INFO (pid:1562968) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T10:40:36.634 INFO (pid:1562968) [language-client-index] - Language server "clangd" started with 1562981
2023-07-13T10:40:36.645 INFO (pid:1562968) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T10:40:36.645 INFO (pid:1562968) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T10:40:36.645 ERROR (pid:1562968) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T10:40:36.646 INFO (pid:1562968) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T10:40:36.648 INFO (pid:1562968) [language-client-index] - Language server "clangd" started with 1562982
2023-07-13T10:40:36.658 INFO (pid:1562968) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T10:40:36.658 ERROR (pid:1562968) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T10:40:36.658 INFO (pid:1562968) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T10:40:36.658 ERROR (pid:1562968) [services] - Server clangd failed to start: jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T10:40:36.660 INFO (pid:1562968) [language-client-index] - Language server "clangd" started with 1562983
2023-07-13T10:40:36.670 INFO (pid:1562968) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T10:40:36.670 ERROR (pid:1562968) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T10:40:36.670 INFO (pid:1562968) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T10:40:36.672 INFO (pid:1562968) [language-client-index] - Language server "clangd" started with 1562984
2023-07-13T10:40:36.682 ERROR (pid:1562968) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T10:42:48.284 INFO (pid:1562968) [attach] - receive notification: highlight []
2023-07-13T10:43:01.319 INFO (pid:1562968) [attach] - receive notification: openLog []
2023-07-13T10:43:01.623 INFO (pid:1562968) [attach] - receive notification: highlight []
fannheyward commented 1 year ago

Your clangd failed to start. You've set clangd.path in coc-settings.json, what's the output of /usr/bin/clangd --version?

ricciolino commented 1 year ago
> /usr/bin/clangd --version
Ubuntu clangd version 14.0.0-1ubuntu1
Features: linux+grpc
Platform: x86_64-pc-linux-gnu

I installed clangd using apt package manager (Ubuntu 22), I also tried installing it from inside Vim editor using :CocCommand clangd.install command, but same error persist.

fannheyward commented 1 year ago

Set clangd.path to ~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd and try again.

ricciolino commented 1 year ago

I already did it, same error occurs.

fannheyward commented 1 year ago
  1. remove clangd.path from your coc-settings.json
  2. remove ~/.config/coc/extensions/coc-clangd-data
  3. open an C/C++ file, run :CocCommand clangd.install to re-install clangd
ricciolino commented 1 year ago

Just done all three steps. Same error occur. Here is the Log:

  code: -32097,
  data: undefined
}
2023-07-13T11:40:24.855 INFO (pid:1602326) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T11:40:24.857 INFO (pid:1602326) [language-client-index] - Language server "clangd" started with 1602340
2023-07-13T11:40:24.859 ERROR (pid:1602326) [language-client] - Sending request failed.
2023-07-13T11:40:24.859 INFO (pid:1602326) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T11:40:24.859 ERROR (pid:1602326) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T11:40:24.859 INFO (pid:1602326) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T11:40:24.859 ERROR (pid:1602326) [services] - Server clangd failed to start: jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T11:40:24.861 INFO (pid:1602326) [language-client-index] - Language server "clangd" started with 1602341
2023-07-13T11:40:24.862 INFO (pid:1602326) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T11:40:24.862 ERROR (pid:1602326) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T11:40:24.862 INFO (pid:1602326) [services] - LanguageClient clangd state change: starting => stopped
2023-07-13T11:40:24.864 INFO (pid:1602326) [language-client-index] - Language server "clangd" started with 1602342
2023-07-13T11:40:24.865 ERROR (pid:1602326) [language-client-client] - Server clangd initialization failed. jh [Error]: Pending response rejected since connection got disposed
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:51:4592)
    at Object.dispose (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:241:6209)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15575)
    at Nd.handleConnectionClosed (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:248:3561)
    at t (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:244:15224)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230)
    at Qe (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:25:6504)
    at yT.invoke (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:14460)
    at lc.fire (/home/ricciolino/.vim/plugged/coc.nvim/build/index.js:24:15230) {
  code: -32097,
  data: undefined
}
2023-07-13T11:40:29.796 INFO (pid:1602326) [attach] - receive notification: highlight []
2023-07-13T11:40:35.281 INFO (pid:1602326) [attach] - receive notification: openLog []
fannheyward commented 1 year ago

From your first logs, https://github.com/clangd/coc-clangd/issues/603#issue-1801101819, clangd runs as expected, but now clangd failed to start.

~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd --version ok?

Make sure you're using the correct clangd.

ricciolino commented 1 year ago

" ~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd --version ok? " Yes it's ok:

> ~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd --version
clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu

Yeah from my first comment clangd was ok because I didn't have these lines added to coc-settings.json file:

    "clangd.arguments": [
        "-I/usr/include/c++/11",
        "-I/usr/local/include"
    ]

Removing those lines, I have a clean Log when open a cpp file:

2023-07-13T11:56:57.632 INFO (pid:1614357) [plugin] - coc.nvim initialized with node: v18.16.1 after 88
2023-07-13T11:56:57.637 INFO (pid:1614357) [services] - LanguageClient clangd state change: stopped => starting
2023-07-13T11:56:57.639 INFO (pid:1614357) [language-client-index] - Language server "clangd" started with 1614370
2023-07-13T11:56:57.643 INFO (pid:1614357) [services] - LanguageClient clangd state change: starting => running
2023-07-13T11:56:57.646 INFO (pid:1614357) [services] - service clangd started
2023-07-13T11:56:59.958 INFO (pid:1614357) [attach] - receive notification: openLog []

But still see errors of this kind: • 'iostream' file not found (clang pp_file_not_found)Use of undeclared identifier 'std' (clang undeclared_var_use)

fannheyward commented 1 year ago

clangd.arguments is args passed to clangd, something like --background-index, check clangd --help. You can't pass includes to this.

Remove the clangd.arguments configurations, and setup compile_commands.json for your project.

Close for now because isn't coc-clangd's issue.

ricciolino commented 1 year ago

I configured now compile_commands.json like this:

"command": "g++ -std=c++11 -I/usr/local/include -I/usr/include/c++/11 -o /home/ricciolino/Desktop/tmp/test_c++/main /home/ricciolino/Desktop/tmp/test_c++/main.cpp"

And coc-settings.json like this:

    "clangd.path": "~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd",
    "clangd.arguments": [
        "--background-index",
        "--completion-style=detailed",
        "--header-insertion=iwyu",
        "--suggest-missing-includes"
    ]

Still no lucky, it doesn not work.

fannheyward commented 1 year ago

How do you generate compile_commands.json? You can use bear to generate it. https://clangd.llvm.org/installation#project-setup

https://clang.llvm.org/docs/JSONCompilationDatabase.html

ricciolino commented 1 year ago

Now I tried to generate using bear:

bear -- g++ -std=c++11 -I/usr/local/include -I/usr/include/c++/11 -o /home/ricciolino/Desktop/tmp/test_c++/main /home/ricciolino/Desktop/tmp/test_c++/main.cpp

And the generated compile_command.json is this one:

> cat compile_commands.json 
[
  {
    "arguments": [
      "/usr/bin/g++",
      "-c",
      "-std=c++11",
      "-I/usr/local/include",
      "-I/usr/include/c++/11",
      "-o",
      "/home/ricciolino/Desktop/tmp/test_c++/main",
      "/home/ricciolino/Desktop/tmp/test_c++/main.cpp"
    ],
    "directory": "/home/ricciolino/Desktop/tmp/test_c++",
    "file": "/home/ricciolino/Desktop/tmp/test_c++/main.cpp",
    "output": "/home/ricciolino/Desktop/tmp/test_c++/main"
  }
]

But opening main.cpp still error messages appear.

fannheyward commented 1 year ago

@sam-mccall can you take a look?

ricciolino commented 1 year ago

Hey guys! I think I solved !!!! I just realized that I was missing this "include" path: /usr/include/x86_64-linux-gnu/c++/11

So I re-run bear for generating the compile_commands.json file like this: bear -- g++ -std=c++11 -I/usr/local/include -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -o /home/ricciolino/Desktop/tmp/test_c++/main /home/ricciolino/Desktop/tmp/test_c++/main.cpp

And now the autocomplete suggestions work as expected (I think :) ): image