Skip to content

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

Closed

Description

@renzhengeek

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!

Activity

  1. joaotavora commented on Apr 12, 2021

    @joaotavora
    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.

  2. MaskRay commented on Apr 12, 2021

    @MaskRay
    Contributor

    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.

  3. joaotavora commented on Apr 12, 2021

    @joaotavora
    Owner

    Thanks @MaskRay.

  4. renzhengeek commented on Apr 13, 2021

    @renzhengeek
    Author

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

  5. renzhengeek commented on Apr 13, 2021

    @renzhengeek
    Author

    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

  6. renzhengeek commented on Apr 14, 2021

    @renzhengeek
    Author

    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

  7. renzhengeek commented on Apr 22, 2021

    @renzhengeek
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions