MaskRay / vscode-ccls

ccls plugin for Visual Studio Code
123 stars 37 forks source link

ccls reindex whenever I open emacs #83

Closed hisnawi closed 4 years ago

hisnawi commented 4 years ago

I have just started using ccls with lsp.

This is my emacs config:


(use-package lsp-mode
  :ensure t
  :commands lsp
  )
(use-package lsp-ui :ensure t :commands lsp-ui-mode)
(use-package company-lsp
  :ensure t :commands company-lsp
  :config (push 'company-lsp company-backends)
  )
(use-package ccls
  :ensure t
  :config
  (setq ccls-executable "/Users/xxx/gitrepos/ccls/Release/ccls")
  (setq lsp-prefer-flymake nil)
  (setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc))
  :hook ((c-mode c++-mode objc-mode cuda-mode) . (lambda () (require 'ccls) (lsp)))
  )

I also try to index the project before I open emacs for the first time (no indexing yet) using this command: ~/gitrepos/ccls/Release/ccls -index=./ --init="cat init.json"

This is the content of the init.json file:

{
    "cache": {
        "directory": "./.ccls-cache",
        "format": "json"
    },
    "index": {"blacklist":
              [
                  "^/Users/xxx/projectname/(dir1|dir2)/",
              ],
              "whitelist":
              [
              ]
             }
}

This places all the indexing information in the .ccls-cache/ directory.

when opening emacs and when switching to the buffer ccls::stderr I find that ccls is indexing the full project again, without even taking blacklists I have in init.json into consideration.

How do I stop it from automatically indexing and just use whatever is in .ccls-cache directory?

I also like to mention that I have .ccls file in the project directory that contains all the include directories in the project and other flags:

clang
%cpp -std=c++17 -Wno-c++11-extensions -Wno-c++11-narrowing -Wno-constant-logical-operand -Wno-enum-compare -Wno-extern-c-compat -Wno-unused-function -Wno-unused-variable -Wno-writable-strings -fno-rtti
-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
-I/...etc other file project specific include directories
MaskRay commented 4 years ago

https://github.com/MaskRay/ccls/wiki/FAQ#when-does-ccls-reindex-a-file https://github.com/MaskRay/ccls/wiki/Debugging#logs

hisnawi commented 4 years ago

Could you elaborate? I did the command line parsing just before I opened emacs, no file changes were made in between. Also what clang commands that might have changed you are referring to? Should my emacs ccls :confit change to reflect some identical clang commands as when using command line?

I am also willing to index only when opening emacs and not through the command line if I can get it to respect the blacklist I have. I am using this setup, yet when checking the ccls::stderr I still don't see the blacklist getting picked up in the "initialize.cc:290 I initializationOptions:" section.

(use-package ccls
  :ensure t
  :init
  ;;;###autoload
  (defvar +ccls-blacklist 
       ["^/Users/xxx/project/(dir1|dir2)/",
       "^/Users/xxx/project/dir3/(dir4|dir5)"])
  :config
  (setq ccls-sem-highlight-method 'font-lock)
  (ccls-use-default-rainbow-sem-highlight)
  (setq ccls-extra-init-params '(:index (:blacklist ,+ccls-blacklist)))
  (with-eval-after-load 'projectile
     (add-to-list 'projectile-globally-ignored-directories ".ccls-cache")
  )
  (setq ccls-executable "/Users/xxx/gitrepos/ccls/Release/ccls")
  (setq lsp-prefer-flymake nil)
  (setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc))
  :hook ((c-mode c++-mode objc-mode cuda-mode) . (lambda () (require 'ccls) (lsp)))
)
hisnawi commented 4 years ago

Ofter a deeper look I dont even find ccls-extra-init-params in ccls repo or ccls-emacs. Was this deprecated?