1

For some reason, the project I am working on names some of it's Cpp header files as *.x It looks like these files are not being indexed by Clangd and I end up with the following error whenever I try to use references, definitions on objects declared here.

[coc.nvim]: Error on notification "jumpDefinition": definition provider not found for current buffer, your language server doesn't support it.


clangd + coc, works for all other extension types like *.cpp, *.c, *.h, *.hpp. Is there any configuration file where I can add the *.x files as well

romainl
  • 186,200
  • 21
  • 280
  • 313
raving_sage
  • 13
  • 1
  • 5
  • File associations are usually configured on the client side, i.e. in the editor. For example, in VSCode there is a setting named `"files.associations"` that allows you to associate a filename pattern (e.g. `*.x`) with a file type (e.g. `c++`). I'm not familiar with neovim / coc, but hopefully it has something similar. – HighCommander4 Feb 06 '23 at 19:50
  • In addition, once you succeed at getting your editor to use clangd for `*.x` files, clangd may need help determining the correct language for them (because it supports multiple C-family languages, e.g. C, C++, Objective C), you can do this by adding `-x c++` to their compile commands using a clangd config file (see https://clangd.llvm.org/config.html#add). – HighCommander4 Feb 06 '23 at 19:58
  • Thanks @HighCommander4, I'll let you know if I find something – raving_sage Feb 08 '23 at 05:03
  • For now, I'm using this hack where I do set filetype=cpp manually for files with .x type. It seems to work – raving_sage May 22 '23 at 07:59
  • Turns out vim finds out the filetype using the extensions given in the $VIMRUNTIME/filetype.vim file. You can add whatever custom extension you have to this file for cpp to get the intended results. COC will get the details from the file_type while reading the file – raving_sage May 22 '23 at 08:14

0 Answers0