0

I'm separating the functions from main.c to func1.c func2.c, then I'm using util.h to store the prototype (all name of all functions).

PROBLEM

when I try to go to implementation, lsp leading me into util.c, but i want to leading to func1.c

main.c

#include "util.h"

int main(){
  int x = fun||c1(); // here || is cursure location !
  int y = funct2();
  //...
}

util.c

#define TRUE 1
#define FALSE 0
int func1();
int func2();
//...

func1.c

int  func1(){
  //...
}

Makefile

all: main

main: func1.o func2.o ... main.o
    gcc func1.o func2.o ... main.o -o main

func1.o: func1.c util.h
    gcc func1.c

func2.o: func2.c util.h
    gcc func2.c
#...

my env:

i use:

  • neovim as ide
  • lspconfig plugin handle lsp
  • ccls/clangd is tow lsp for c/cpp
  • :lua vim.lsp.buf.implementation() go to implementation but lead me to util.h
  • :lua vim.lsp.buf.definition() go to definition but lead me to util.h too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.