vim
vim copied to clipboard
c 头文件定位问题
比如类似下面的 c 代码, 假若想 \f d 定位到 SDL_Window 会失败
同样定位到 c 语言库函数 比如 qsort 中的源码也会失败
想问下这种大家一般是如何修正的呢 @skywind3000
防止看不到图片,贴下代码
#ifndef GAME_H
#define GAME_H
#include <SDL2/SDL.h>
#include <stdlib.h>
#define GAME_NAME "MELOBALL"
#define WIDTH 380
#define HEIGHT 640
#define FRAME_RATE 50 // 1秒 50 帧
#define MOVE_SPEED 10
#define BG_COLOR 0xffffffff
#define RECT_WIDTH 80
#define RECT_HEIGHT 10
#define RECT_COLOR 0x00885533
typedef struct {
SDL_Window *win;
SDL_Surface *scene;
int x;
int y;
} game;
void start_game();
#endif
当然我通过 手动指定路径可以解决定位跳转的问题, 类似:
set path+=/Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk/usr/include/
set path+=/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/
" to locate the SDL sourcefile
set path+=/usr/local/Cellar/sdl2/2.24.0/include/
但这种方式觉得还是蛮蠢的,因为当文件升级后需要再次更新该路径
而且是通过 vim 自身的: [-ctrl-i 的方式跳转过去的, \f d 依旧失败
请用 LSP 来实现符号定位。