[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot d0fb9d2 22/24: Merge branch 'cquery-support' into
From: |
João Távora |
Subject: |
[elpa] externals/eglot d0fb9d2 22/24: Merge branch 'cquery-support' into master |
Date: |
Sat, 26 May 2018 14:31:19 -0400 (EDT) |
branch: externals/eglot
commit d0fb9d2c503f67929d3dd36f2bb76afea4fb82ca
Merge: 1b5ed29 d40a458
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Merge branch 'cquery-support' into master
The conflicts in eglot.el where fixed by calling the new eglot--debug
helper coming from 'cquery-support'. This helper was converted to
allow a non-string format passed directly to eglot--log-event.
Also fixed some compilation warnings.
* eglot.el (eglot--debug): Allow non-string FORMAT to be a JSON
object. (eglot-handle-notification :$cquery/progress)
(eglot-handle-notification :$cquery/setInactiveRegions)
(eglot-handle-notification :$cquery/publishSemanticHighlighting):
Solve compilation warnings.
---
README.md | 4 ++++
eglot.el | 51 +++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 47 insertions(+), 8 deletions(-)
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 cc3fae1..8d34b1b 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/\
language-server/bin/php-language-server.php")))
"How the command `eglot' guesses the server to start.
@@ -422,7 +424,7 @@ INTERACTIVE is t if called interactively."
(defun eglot--process-sentinel (proc change)
"Called when PROC undergoes CHANGE."
(let ((server (process-get proc 'eglot-server)))
- (eglot--log-event server `(:message "Process state changed" :change
,change))
+ (eglot--debug server "Process state changed: %s" change)
(when (not (process-live-p proc))
(with-current-buffer (eglot-events-buffer server)
(let ((inhibit-read-only t))
@@ -587,7 +589,7 @@ originated."
(if id
(eglot--reply
server id :error `(:code -32601 :message "Method
unimplemented"))
- (eglot--log-event
+ (eglot--debug
server '(:error `(:message "Notification unimplemented")))))))
(continuations
(cancel-timer (cl-third continuations))
@@ -622,7 +624,7 @@ originated."
(defun eglot--call-deferred (server)
"Call SERVER's deferred actions, who may again defer themselves."
(when-let ((actions (hash-table-values (eglot--deferred-actions server))))
- (eglot--log-event server `(:maybe-run-deferred ,(mapcar #'caddr actions)))
+ (eglot--debug server `(:maybe-run-deferred ,(mapcar #'caddr actions)))
(mapc #'funcall (mapcar #'car actions))))
(cl-defmacro eglot--lambda (cl-lambda-list &body body)
@@ -658,7 +660,7 @@ happens, the original timer keeps counting). Return (ID
TIMER)."
(lambda ()
(remhash id (eglot--pending-continuations server))
(if timeout-fn (funcall timeout-fn)
- (eglot--log-event
+ (eglot--debug
server `(:timed-out ,method :id ,id :params
,params))))))))
(when deferred
(if (eglot-server-ready-p server deferred)
@@ -667,7 +669,7 @@ happens, the original timer keeps counting). Return (ID
TIMER)."
;; Otherwise, save in `eglot--deferred-actions' and exit non-locally
(unless old-id
;; Also, if it's the first deferring for this id, inform the log
- (eglot--log-event server `(:deferring ,method :id ,id :params
,params)))
+ (eglot--debug server `(:deferring ,method :id ,id :params ,params)))
(puthash (list deferred buf)
(list (lambda () (when (buffer-live-p buf)
(with-current-buffer buf
@@ -683,7 +685,7 @@ happens, the original timer keeps counting). Return (ID
TIMER)."
(puthash id (list
(or success-fn
(eglot--lambda (&rest _ignored)
- (eglot--log-event
+ (eglot--debug
server `(:message "success ignored" :id ,id))))
(or error-fn
(eglot--lambda (&key code message &allow-other-keys)
@@ -751,6 +753,11 @@ DEFERRED is passed to `eglot--async-request', which see."
(let ((warning-minimum-level :error))
(display-warning 'eglot (apply #'format format args) :warning)))
+(defun eglot--debug (server format &rest args)
+ "Debug message for SERVER with FORMAT and ARGS."
+ (eglot--log-event
+ server (if (stringp format)`(:message ,(format format args)) format)))
+
(defun eglot--pos-to-lsp-position (&optional pos)
"Convert point POS to LSP position."
(save-excursion
@@ -1012,7 +1019,7 @@ function with the server still running."
"Unreported diagnostics for this buffer.")
(cl-defmethod eglot-handle-notification
- (_server (_method (eql :textDocument/publishDiagnostics)) &key uri
diagnostics)
+ (server (_method (eql :textDocument/publishDiagnostics)) &key uri
diagnostics)
"Handle notification publishDiagnostics"
(if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri))))
(with-current-buffer buffer
@@ -1034,7 +1041,7 @@ function with the server still running."
(setq eglot--unreported-diagnostics nil))
(t
(setq eglot--unreported-diagnostics diags)))))
- (eglot--warn "Diagnostics received for unvisited %s" uri)))
+ (eglot--debug server "Diagnostics received for unvisited %s" uri)))
(cl-defun eglot--register-unregister (server jsonrpc-id things how)
"Helper for `registerCapability'.
@@ -1590,6 +1597,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
- [elpa] externals/eglot 17a3257 03/24: Do Rust's RLS hack properly with new class-based API, (continued)
- [elpa] externals/eglot 17a3257 03/24: Do Rust's RLS hack properly with new class-based API, João Távora, 2018/05/26
- [elpa] externals/eglot 3aa2958 06/24: Add a complex RLS test, João Távora, 2018/05/26
- [elpa] externals/eglot 07078da 08/24: Rework eglot-tests.el for better debuggability, João Távora, 2018/05/26
- [elpa] externals/eglot 0462130 15/24: New RLS tests, João Távora, 2018/05/26
- [elpa] externals/eglot e1d7ff3 09/24: Disable file-watching tests on Travis, João Távora, 2018/05/26
- [elpa] externals/eglot c8e7ab0 16/24: Don't rely on Flymake's idle timer for textDocument/didChange, João Távora, 2018/05/26
- [elpa] externals/eglot 99ca690 17/24: Simpify eglot--server-receive, João Távora, 2018/05/26
- [elpa] externals/eglot 1b5ed29 21/24: Really ensure eglot--shutdown deletes a process completely, João Távora, 2018/05/26
- [elpa] externals/eglot 897cbc3 24/24: * eglot.el (Version): Bump to 0.5, João Távora, 2018/05/26
- [elpa] externals/eglot ec10de2 23/24: Another unstable test on Travis, João Távora, 2018/05/26
- [elpa] externals/eglot d0fb9d2 22/24: Merge branch 'cquery-support' into master,
João Távora <=
- [elpa] externals/eglot 97db670 19/24: Get rid of eglot--obj, an uninteresting abstraction, João Távora, 2018/05/26
- [elpa] externals/eglot 5e3804b 20/24: Add a new test., João Távora, 2018/05/26
- [elpa] externals/eglot 94c008d 18/24: Cleanup deferred request mechanism with a readable log, João Távora, 2018/05/26
- [elpa] externals/eglot 18176f3 02/24: Use an EIEIO class to represent a server., João Távora, 2018/05/26
- [elpa] externals/eglot eccb7d1 10/24: Merge branch 'use-eieio-server-defclass', João Távora, 2018/05/26