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

Add a handle to control CCLS initialization #545

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add a handle to control CCLS initialization
Fixes #370

And it probably helps #544
  • Loading branch information
gagbo committed Sep 27, 2020
commit 392d1d381af83899c3968652f5d10b71c2513c05
25 changes: 25 additions & 0 deletions eglot-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,31 @@ Pass TIMEOUT to `eglot--with-timeout'."
(and (string= (eglot--path-to-uri "Cargo.toml") uri)
(= type 3))))))))))

(ert-deftest ccls-initialization-options ()
"Test ccls initialization."
(skip-unless (executable-find "ccls"))
(eglot--with-fixture
'(("project/main/" . (("main.cc" . "")))
("project/.git/" . nil))
(let ((root (file-name-as-directory default-directory))
(eglot-ccls-initialization-options '((:index . (:threads 1)))))
(with-current-buffer
(eglot--find-file-noselect "project/main/main.cc")
(eglot--sniffing (:client-requests c-reqs)
(should (eglot--tests-connect 10))
(eglot--wait-for (c-reqs 10)
(&key _id method params &allow-other-keys)
(when (string= method "initialize")
(let* ((initialization-options (plist-get params :initializationOptions))
(indexing-threads-opts
(plist-get
(plist-get initialization-options :index) :threads)))
(should (equal
indexing-threads-opts
(plist-get
(plist-get
eglot-ccls-initialization-options :index) :threads)))))))))))

(ert-deftest basic-diagnostics ()
"Test basic diagnostics."
(skip-unless (executable-find "pyls"))
Expand Down
15 changes: 14 additions & 1 deletion eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
(sh-mode . ("bash-language-server" "start"))
(php-mode . ("php" "vendor/felixfbecker/\
language-server/bin/php-language-server.php"))
((c++-mode c-mode) . ("ccls"))
((c++-mode c-mode) . (eglot-ccls "ccls"))
((caml-mode tuareg-mode reason-mode)
. ("ocaml-language-server" "--stdio"))
(ruby-mode
Expand Down Expand Up @@ -2713,6 +2713,19 @@ If INTERACTIVE, prompt user for details."
"Eclipse JDT breaks spec and replies with edits as arguments."
(mapc #'eglot--apply-workspace-edit arguments))


;;; ccls-specific
;;;
(defclass eglot-ccls (eglot-lsp-server) ()
:documentation "CCLS")

(defvar-local eglot-ccls-initialization-options nil
"Property list of initialization options sent to CCLS on start.")

(cl-defmethod eglot-initialization-options ((_server eglot-ccls))
"Passes through ccls initialization options."
eglot-ccls-initialization-options)

(provide 'eglot)
;;; eglot.el ends here

Expand Down