emacs-lsp / emacs-ccls

Emacs client for ccls, a C/C++ language server
200 stars 29 forks source link

[question] Disable ccls on a per-project basis #85

Closed pmatos closed 4 years ago

pmatos commented 4 years ago

Is there a way to disable ccls on a per-project basis?

MaskRay commented 4 years ago

Hi, apologies for my slow response. This is more of a lsp-mode question. Instead of calling lsp for every C/C++/ObjC/cuda file, you can write a function to check whether the current file should call lsp. For example, I place the following function into c-mode-local-vars-hook:

;;;###autoload
(defvar +lsp-blacklist nil)

;;;###autoload
(defun +ccls|enable ()
  (when (and buffer-file-name (--all? (not (string-match-p it buffer-file-name)) +lsp-blacklist))
    (require 'ccls)
    (setq-local lsp-ui-sideline-show-symbol nil)
    (when (string-match-p "/llvm" buffer-file-name)
      (setq-local lsp-enable-file-watchers nil))
    (if +my-use-eglot (call-interactively #'eglot) (lsp))))