Skip to content
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

Is there a way to reload the compile_commands.json? (Especially if one did not exist previously) #55

Closed
DougBeney opened this issue Jul 25, 2019 · 2 comments
Labels
question Further information is requested

Comments

@DougBeney
Copy link

DougBeney commented Jul 25, 2019

I am trying to reload ccls whenever the compile_commands.json file is changed.

Steps to Reproduce:

In this example, I create a really basic Qt5 project. Feel free to reproduce using a library/framework that you are more familiar with.

Step 1.: Create hello.cpp in empty directory with emacs:

#include <QString>
int main() { }

Result so far: flycheck should display an error on line 1. This is expected.

Step 2.: Generate a compile_commands.json and place it in the project root.

MyProject.pro:

QT += core gui widgets
TARGET = hello
SOURCES += hello.cpp

Commands:

mkdir build
cd build
qmake ../MyProject.pro
bear make # This generates the compile_commands.json
cp compile_commands.json ..

Step 3: Attempt to reload/restart lsp (or ccls) so your new compile_commands.json is picked up.

I have tried the Emacs functions lsp-restart-workspace and ccls-reload. I've even tried killing the ccls process to force a restart.

The only solution I have right now is to completely restart emacs.

My lsp config:

(use-package lsp-mode
  :hook ((c-mode
          c++-mode
          javascript-mode
          vue-mode
          css-mode) . lsp)
  :config
  (require 'lsp-clients) ;; Multiple language configurations out of the box
  (use-package ccls) ;; C/C++ language server

  (use-package lsp-ui
    :hook (lsp-mode . lsp-ui-mode)
    :config
    ;; Don't use flymake; we'll use flycheck.
    (setq lsp-prefer-flymake nil))

  (use-package company-lsp
    :init
    (push 'company-lsp company-backends)))
@DougBeney
Copy link
Author

I'm not sure what I did, differently, but it works fine now. My latest config is above. Will re-open if the issue comes up again and is reproducible.

@MaskRay
Copy link
Member

MaskRay commented Jul 26, 2019

https://github.com/MaskRay/ccls/wiki/FAQ#reload

  • Notification $ccls/reload ((ccls-reload)): reset global index and reload index files. This is useful if you have modified a common header file and you expect all opened files to be re-indexed. Note, this doesn't reload project files (compile_commands.json and .ccls).
  • Notification workspace/didChangeConfiguration: reload project files and re-index if necessary.
  • Restart the ccls process (`M-x lsp-restart-workspace). It is more heavyweight but you may get used to it if you also use it with other language servers.

@MaskRay MaskRay added the question Further information is requested label Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants