Skip to content

eglot with ccls: M-. can only find and jump to func definitions if they are in buffers #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
renzhengeek opened this issue Apr 11, 2021 · 7 comments

Comments

@renzhengeek
Copy link

renzhengeek commented Apr 11, 2021

Hi all,
I'm excited that eglot+ccls works for my C project (linux kernel). It's much more convenient than TAGS, but after a while I found it fails to find func definitions that is not in current buffer, or not in other buffers (opened C/header files).

My config for c-mode in init.el:

(add-hook 'c-mode-hook 'eglot-ensure)                                                                                
                                                                                                                     
;(defun projectile-project-find-function (dir)                                                                       
;  (let* ((root (projectile-project-root dir)))                                                                      
;    (and root (cons 'transient root))))                                                                             
;(with-eval-after-load 'project                                                                                      
;  (add-to-list 'project-find-functions 'projectile-project-find-function)) 

I commented out projectile functions, otherwise emacs reports error that projectile-project-root is void.
According to ccls eglot doc:https://github.com/MaskRay/ccls/wiki/eglot), ccls defaults to use builtin project, so I think it probably doesn't matter.

I googled a lot, still fails to solve the problem. Am I missing something? Please help give some directions:-) Thanks!

@joaotavora
Copy link
Owner

I believe this is a problem with ccls and @MaskRay could help you with that. As an Eglot issue, this is missing many elements pointed to by the template that you probably deleted. I've reworked that template: if you try to create a new issue in Eglot you should be presented with more clear instructions on how to make an issue that I can help you with. It'll help you find the Events transcript and other important elements. Until then, I'm going to close this one, but we can keep discussing.

@MaskRay
Copy link
Contributor

MaskRay commented Apr 12, 2021

The likely issue is that you do not provide a compile_commands.json/.ccls so ccls does not know the initial set of files to index.
If neither compile_commands.json nor .ccls is provided, ccls can only find cross references for files where textDocument/open has been sent.

That seems like a usage error, unrelated to eglot.

@joaotavora
Copy link
Owner

Thanks @MaskRay.

@renzhengeek
Copy link
Author

@joaotavora Thanks! Will try @MaskRay 's suggestion later:-)

@renzhengeek
Copy link
Author

renzhengeek commented Apr 13, 2021

Hello @MaskRay ,

If neither compile_commands.json nor .ccls is provided, ccls can only find cross references for files where textDocument/open has been sent.

I'm very new to eglot and ccls. Is there any link to explain what they are and how to configure/make them?

That seems like a usage error, unrelated to eglot.

Thanks! But, I do follow the doc: https://github.com/MaskRay/ccls/wiki/eglot

@renzhengeek
Copy link
Author

renzhengeek commented Apr 14, 2021

I'm very new to eglot and ccls. Is there any link to explain what they are and how to configure/make them?
Aha, found and reading this doc:

https://github.com/MaskRay/ccls/wiki/Project-Setup#ccls-file

@renzhengeek
Copy link
Author

See: https://github.com/MaskRay/ccls/wiki/Project-Setup#ccls-examples
The .ccls config solves my problem:

clang
%c -std=c11
%cpp -std=c++2a
%h %hpp --include=Global.h
-Iinc
-DMACRO

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants