question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to add include path for language servers in coc-settings.json file?

See original GitHub issue

Hi there.

since I work in ros platform I want to add the headers of the ros(/opt/ros/kinetic/include/**) to my default include path of language servers for ros projects. with out this option, at the beginning of each project I must add a dummy ros node(is ros node means a cpp file), and compile with catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=YES to generate the compile_commands.json file to get access to ros headers in the completion list.

the contents of my coc-setting file, is as below:

{

"languageserver": {
    "clangd": {
      "command": "clangd",
      "rootPatterns": ["compile_flags.txt", "compile_commands.json"],
      "filetypes": ["c", "cpp", "objc", "objcpp"]
    },
    "cquery": {
      "command": "/home/amirrezasadeghi/ManBuildLibs/cquery/build/cquery",
      "args": ["--log-file=/tmp/cq.log"],
      "filetypes": ["c", "cpp"],
      "rootPatterns": ["compile_flags.txt", "compile_commands.json", ".git/", ".hg/"],
      "initializationOptions": {
        "cacheDirectory": "/tmp/cquery"
      }
    },
    "ccls": {
      "command": "ccls",
      "filetypes": ["c", "cpp", "objc", "objcpp"],
      "rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
      "initializationOptions": {
         "cache": {
           "directory": "/tmp/ccls"
         }
       }
    }
  },
  "clangd.semanticHighlighting": true
}

So my major question is how to add ros include path to these settings. I checked the wiki page of coc.nvim but can’t find any option for user include path. also, I checked the option of clangd and tried to add, "args":["-I/opt/ros/kinetic/include/"], to the corresponding block but it did not work. also, I added .cquery file, but still no effect on the list of the proposed headers.

sorry for long story, and thanks for your time.

Edit: it would be better to use the clangd LSP rather than ccls. because it is faster and has better documentation. thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
amirrezasadeqicommented, Apr 16, 2020

Hi there. thank you guys for your help and descriptions. finally, I found a way to make the procedure of adding include path like the procedure of VSCode. so I wrote a remote plugin in python(neovim_includePlug_draft.py.zip) which exports a Command(:IncludePath). by running this command, it prompts you to enter the include path then it automatically adds this path to compile options of the corresponding file in the compile_commands.json file. so without regeneration of the JSON file, you will have headers of the included path in your autocompletion. thank you all …

1reaction
sam-mccallcommented, Apr 12, 2020

Generally speaking clangd treats include paths as a per-project setting, and you should have a compile_commands.json file generated by your build system, or the simpler compile_flags.txt which could contain just -I/opt/ros/kinetic/include. http://clangd.llvm.org/installation.html#project-setup

If you don’t want to add this to every project directory, you can place the compile_flags.txt somewhere (/some/for/compile_flags.txt) and use the clangd flag -compile-commands-dir=/some/dir.

Be aware that using compile_flags.txt means background indexing won’t work, as it doesn’t provide the list of files to consider part of the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to add include path for language servers in coc-settings ...
I just solved it for ccls by defining a custom .ccls file and added a -I option pointing at my boost includes. That...
Read more >
coc-clangd - npm
This extension connects coc.nvim to the clangd language server. ... If you've configured clangd as a languageServer in coc-settings.json ...
Read more >
VSCode: How to add include path of project subDirectory?-C++
how to add include path for language servers in coc-settings.json file ? CMake project in Visual Studio: How to add additional include and...
Read more >
User Manual - rust-analyzer
The manual is written in AsciiDoc and includes some extra files which are generated ... Copy the server anywhere, then add the path...
Read more >
Settings Reference for Python - Visual Studio Code
Specifies what code files the language server analyzes for problems. Available values are workspace and openFilesOnly . include, [], Paths of directories or ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found