[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 85c5353 11/24: Add cquery support for C/C++ proje

From: João Távora
Subject: [elpa] externals/eglot 85c5353 11/24: Add cquery support for C/C++ projects
Date: Sat, 26 May 2018 14:31:15 -0400 (EDT)

branch: externals/eglot
commit 85c5353d2fc042e41da26840906e5529274e0d95
Author: Josh Elsasser <address@hidden>
Commit: Josh Elsasser <address@hidden>

    Add cquery support for C/C++ projects
    Implements minimal support for the core cquery language
    server. None of its extensions are implemented yet.
    * eglot.el (eglot-server-programs): Add cquery to list
    of guessed programs for c-mode and c++-mode.
    (eglot-initialization-options eglot-cquery): Specialize init
    options to pass cquery a cache directory and disable a flood
    of $cquery/progress messages.
    (eglot-handle-notification $cquery/publishSemanticHighlighting):
    (eglot-handle-notification $cquery/setInactiveRegions):
    (eglot-handle-notification $cquery/progress): New no-op functions
    to avoid filling logs with "unknown message" warnings.
    (eglot-cquery): New eglot-lsp-server subclass.
    * README.md: Mention cquery in the README.
 README.md |  4 ++++
 eglot.el  | 30 ++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/README.md b/README.md
index b87666c..3b95438 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ for the language of your choice. Otherwise, it prompts you to 
enter one:
 * Python's [pyls][pyls]
 * Bash's [bash-language-server][bash-language-server]
 * PHP's [php-language-server][php-language-server]
+* [cquery][cquery] for C/C++
 I'll add to this list as I test more servers. In the meantime you can
 customize `eglot-server-programs`:
@@ -196,5 +198,7 @@ Under the hood:
 [bash-language-server]: https://github.com/mads-hartmann/bash-language-server
 [php-language-server]: https://github.com/felixfbecker/php-language-server
 [company-mode]: https://github.com/company-mode/company-mode
+[cquery]: https://github.com/cquery-project/cquery
diff --git a/eglot.el b/eglot.el
index 3d36344..189ad1e 100644
--- a/eglot.el
+++ b/eglot.el
@@ -72,6 +72,8 @@
                                 (python-mode . ("pyls"))
                                 (js-mode . ("javascript-typescript-stdio"))
                                 (sh-mode . ("bash-language-server" "start"))
+                                (c++-mode . (eglot-cquery "cquery"))
+                                (c-mode . (eglot-cquery "cquery"))
                                 (php-mode . ("php" "vendor/felixfbecker/\
   "How the command `eglot' guesses the server to start.
@@ -1613,6 +1615,34 @@ Proceed? "
         (funcall (or eglot--current-flymake-report-fn #'ignore)
+;;; cquery-specific
+(defclass eglot-cquery (eglot-lsp-server) ()
+  :documentation "cquery's C/C++ langserver.")
+(cl-defmethod eglot-initialization-options ((server eglot-cquery))
+  "Passes through required cquery initialization options"
+  (let* ((root (car (project-roots (eglot--project server))))
+         (cache (expand-file-name ".cquery_cached_index/" root)))
+    (vector :cacheDirectory (file-name-as-directory cache)
+            :progressReportFrequencyMs -1)))
+(cl-defmethod eglot-handle-notification
+  ((server eglot-cquery) (_method (eql :$cquery/progress))
+   &rest counts &key activeThreads &allow-other-keys)
+  "No-op for noisy $cquery/progress extension")
+(cl-defmethod eglot-handle-notification
+  ((server eglot-cquery) (_method (eql :$cquery/setInactiveRegions))
+   &key uri inactiveRegions &allow-other-keys)
+  "No-op for unsupported $cquery/setInactiveRegions extension")
+(cl-defmethod eglot-handle-notification
+  ((server eglot-cquery) (_method (eql :$cquery/publishSemanticHighlighting))
+   &key uri symbols &allow-other-keys)
+  "No-op for unsupported $cquery/publishSemanticHighlighting extension")
 (provide 'eglot)
 ;;; eglot.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]