diff --git a/eglot-tests.el b/eglot-tests.el index c6d7ee2f..be5dbe8f 100644 --- a/eglot-tests.el +++ b/eglot-tests.el @@ -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")) diff --git a/eglot.el b/eglot.el index c752322b..83e12eca 100644 --- a/eglot.el +++ b/eglot.el @@ -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 @@ -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