GithubHelp home page GithubHelp logo

Comments (6)

MaskRay avatar MaskRay commented on June 16, 2024

Still waiting for melpa/melpa#5405

Before it is merged, you may use:

;; https://github.com/MaskRay/Config/blob/master/home/.config/doom/modules/private/my-cc/config.el
(use-package! ccls
  :load-path "~/Dev/Emacs/emacs-ccls"
  :init (add-hook 'c-mode-common-hook #'+ccls//enable)
  :config
  ;; overlay is slow
  ;; Use https://github.com/emacs-mirror/emacs/commits/feature/noverlay
  (setq ccls-sem-highlight-method 'font-lock)
  (ccls-use-default-rainbow-sem-highlight)
  (setq ccls-extra-init-params
        '(:completion (:detailedLabel t) :xref (:container t)
                      :diagnostics (:frequencyMs 5000)))

  (require 'projectile)
  (add-to-list 'projectile-globally-ignored-directories ".ccls-cache")

  (evil-set-initial-state 'ccls-tree-mode 'emacs)
  (set! :company-backend '(c-mode c++-mode) '(company-lsp))
  )

from emacs-ccls.

ramsayleung avatar ramsayleung commented on June 16, 2024

As you said, in order to use ccls, I have to download ccls to my .emacs.d, and load it manually. By the way, it seems set! is a customized macro, because I could not find any information about it. It seems what (set! :company-backend '(c-mode c++-mode) '(company-lsp)) means is when major mode are c-mode or c++-mode, setting company-backend to company-lsp. Thus I change it to :

;;; backends for lsp-mode
(use-package company-lsp
  :ensure t
  :defer t
  :init (progn
	  (add-hook 'lsp-mode-hook (lambda ()
				     (add-to-list 'company-backends 'company-lsp)))
	  ))

This statement adds company-lsp to company-backends when lsp-mode is enabled. Personally, I prefer

(with-eval-after-load 'projectile
  (add-to-list 'projectile-globally-ignored-directories ".ccls-cache")
  )

rather than

require 'projectile)
  (add-to-list 'projectile-globally-ignored-directories ".ccls-cache")

In the end, (add-to-list 'projectile-globally-ignored-directories ".ccls-cache") should change to (add-to-list 'projectile-globally-ignored-directories "*.ccls-cache"),or it only ignores top level directory.

from emacs-ccls.

MaskRay avatar MaskRay commented on June 16, 2024

As you said, in order to use ccls, I have to download ccls to my .emacs.d, and load it manually.

Yeah not very convenient for now..

(set! :company-backend '(c-mode c++-mode) '(company-lsp))

This a macro defined in doom-emacs (the Emacs distribution I use) https://github.com/hlissner/doom-emacs/blob/develop/core/core-lib.el#L238

It sets the buffer-local variable company-backends to (company-lsp) somehow.

(with-eval-after-load 'projectile

Thanks for your advice. Updated my config

should change to (add-to-list 'projectile-globally-ignored-directories "*.ccls-cache")

.ccls-cache should be sufficient.

  1. When a c-mode c++-mode file is opened
  2. The mode hook kicks in and initializes emacs-ccls
  3. emacs-ccls uses ccls-project-root-matchers to locate the project root
  4. lsp-mode spawns ccls (server) and and sends the initialize request to the ccls process, with rootUri (project root) in the parameter.
  5. The ccls server takes rootUri as the project root and creates .ccls-cache under it.

.ccls-cache will not appear in other directories so I do not bother using *.ccls-cache.

For larger C/C++ projects with subprojects, .ccls-root should be put in the parent project directory. I may not have explained it well, clarification (it is publicly editable) welcomed :)

from emacs-ccls.

ramsayleung avatar ramsayleung commented on June 16, 2024

Sorry for missing the FAQ, because I haven't set .ccls-root in the root project, so ccls just generates .ccls-cache for each subproject. Even though I am not familiar with ccls/emacs-ccls, I think your explanation is clear enough.

from emacs-ccls.

MaskRay avatar MaskRay commented on June 16, 2024

The PR has been merged.

https://melpa.org/#/ccls

from emacs-ccls.

ramsayleung avatar ramsayleung commented on June 16, 2024

Congrats!

from emacs-ccls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.