Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/143.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用vim+设置LSP(vim lsc)的明确方式;克马克?_C++_Vim_Cmake_Static Analysis_Clangd - Fatal编程技术网

C++ 使用vim+设置LSP(vim lsc)的明确方式;克马克?

C++ 使用vim+设置LSP(vim lsc)的明确方式;克马克?,c++,vim,cmake,static-analysis,clangd,C++,Vim,Cmake,Static Analysis,Clangd,我正在尝试使用vim+cmake设置LSP。我使用vim lsc插件作为客户端,使用clangd作为服务器 文件夹结构: 试验/ test.cpp 测试h CMakeLists.txt 测试h: #ifndef TEST_H #define TEST_H class Apple { public: int size; }; #endif test.cpp: #include <iostream> #include "test.h" int

我正在尝试使用vim+cmake设置LSP。我使用vim lsc插件作为客户端,使用clangd作为服务器

文件夹结构:

  • 试验/
  • test.cpp
  • 测试h
  • CMakeLists.txt
测试h:

#ifndef TEST_H
#define TEST_H

class Apple {
  public:
    int size;
};

#endif
test.cpp:

#include <iostream>
#include "test.h"

int main() {
    Apple apple;

    return 0;
}
~/.vimrc:

let g:lsc_server_commands = {'c': 'clangd', 'cpp': 'clangd'}
我用

mkdir build
cd build
cmake ..
make
这可以很好地编译,没有错误和警告

但是,在vim中编辑
test.cpp
时,vim lsc显示错误,未检测到用户定义的头文件和其中定义的类型。例如,在上述项目中,显示了以下两个错误:

test.cpp|3 col 10 error| 'test.h' file not found [pp_file_not_found]
test.cpp|6 col 5 error| Unknown type name 'Apple' [unknown_typename]
我如何设置它,以便正确标识项目中的标题

编辑:问题有所改变。我在顶层目录中添加了一个compile_commands.json文件,但没有效果。我怀疑这与windows上Git Bash中表示路径的方式有关

compile_commands.json具有如下所示的内部路径:

-IE:\\C:\\Test
如果在同一个文件中定义了该类,那么lsp协议似乎正在工作。叮当声不能在这样的路径上工作吗?有人能解释一下吗

-IE:\\C:\\Test