From: Josh Elsasser Date: Mon, 21 May 2018 19:27:05 +0000 (-0700) Subject: Add cquery support for c/c++ projects X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~537^2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e4039bba6d27d0746175a7f787364d1a3dcf2f87;p=emacs.git 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. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3d363444405..189ad1e5aae 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/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/\ language-server/bin/php-language-server.php"))) "How the command `eglot' guesses the server to start. @@ -1613,6 +1615,34 @@ Proceed? " (funcall (or eglot--current-flymake-report-fn #'ignore) eglot--unreported-diagnostics))))) + +;;; 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