Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Cmake integration

I have a cmake project. I want to do the following easily

  • search the declaration, definition and references of any variable, function, etc. under the cursor, which may be declared in an external header file whose path is added using INCLUDE_DIRECTORIES in CMakeLists.txt
  • rename a variable, function, etc. that is declared in the project

How can I set this up?

like image 284
Ujjwal Rajput Avatar asked Oct 16 '22 13:10

Ujjwal Rajput


1 Answers

You can try to use vim plugin cmake4vim in order to integrate CMake to Vim. This plugin helps to work with cmake targets and allows to generate compilation database file (compile_commands.json). A lot of plugins use this file for code completion, jump to definition and etc. (for example YCM)

Also you can use vim lsp plugins (for example vim-lsp) these plugins use language servers for code completion, refactoring and another good features.

But CMake project integration (cmake cache generation, project compilation, etc.) and search the declaration, definition and etc are different tasks. And different plugins and tools solve these tasks.

like image 188
Ilya Avatar answered Nov 06 '22 08:11

Ilya