[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 7f2e894 11/69: Merge branch 'master' into jsonrpc
From: |
João Távora |
Subject: |
[elpa] externals/eglot 7f2e894 11/69: Merge branch 'master' into jsonrpc-refactor (using good ol' git merge) |
Date: |
Fri, 22 Jun 2018 11:54:55 -0400 (EDT) |
branch: externals/eglot
commit 7f2e894229fba7f829874de6c46ebe472f03b19d
Merge: 3265c1d 8e5acb1
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Merge branch 'master' into jsonrpc-refactor (using good ol' git merge)
---
eglot.el | 53 +++++++++++++++++++++++------------------------------
jrpc.el | 3 ++-
2 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/eglot.el b/eglot.el
index caf2e8c..b820dde 100644
--- a/eglot.el
+++ b/eglot.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2018 Free Software Foundation, Inc.
-;; Version: 0.2
+;; Version: 0.3
;; Author: João Távora <address@hidden>
;; Maintainer: João Távora <address@hidden>
;; URL: https://github.com/joaotavora/eglot
@@ -318,7 +318,7 @@ INTERACTIVE is t if called interactively."
"Dispatcher passed to `jrpc-connect'.
Builds a function from METHOD, passes it PROC, ID and PARAMS."
(let* ((handler-sym (intern (concat "eglot--server-" method))))
- (if (functionp handler-sym)
+ (if (functionp handler-sym) ;; FIXME: fails if params is array, not object
(apply handler-sym proc (append params (if id `(:id ,id))))
(jrpc-reply proc id
:error (jrpc-obj :code -32601 :message "Unimplemented")))))
@@ -371,11 +371,11 @@ Builds a function from METHOD, passes it PROC, ID and
PARAMS."
;;;
(defun eglot--error (format &rest args)
"Error out with FORMAT with ARGS."
- (error (apply #'format format args)))
+ (error "[eglot] %s" (apply #'format format args)))
(defun eglot--message (format &rest args)
"Message out with FORMAT with ARGS."
- (message (concat "[eglot] " (apply #'format format args))))
+ (message "[eglot] %s" (apply #'format format args)))
(defun eglot--warn (format &rest args)
"Warning message with FORMAT and ARGS."
@@ -406,14 +406,16 @@ Builds a function from METHOD, passes it PROC, ID and
PARAMS."
(point)))
(defun eglot--path-to-uri (path)
- "Urify PATH."
- (url-hexify-string (concat "file://" (file-truename path))
- url-path-allowed-chars))
+ "URIfy PATH."
+ (url-hexify-string
+ (concat "file://" (if (eq system-type 'windows-nt) "/") (file-truename
path))
+ url-path-allowed-chars))
(defun eglot--uri-to-path (uri)
"Convert URI to a file path."
(when (keywordp uri) (setq uri (substring (symbol-name uri) 1)))
- (url-filename (url-generic-parse-url (url-unhex-string uri))))
+ (let ((retval (url-filename (url-generic-parse-url (url-unhex-string uri)))))
+ (if (eq system-type 'windows-nt) (substring retval 1) retval)))
(defconst eglot--kind-names
`((1 . "Text") (2 . "Method") (3 . "Function") (4 . "Constructor")
@@ -443,14 +445,10 @@ Builds a function from METHOD, passes it PROC, ID and
PARAMS."
"Determine if current server is capable of FEAT."
(plist-get (eglot--capabilities (jrpc-current-process-or-lose)) feat))
-(cl-defmacro eglot--with-lsp-range ((start end) range &body body
- &aux (range-sym (cl-gensym)))
- "Bind LSP RANGE to START and END. Evaluate BODY."
- (declare (indent 2) (debug (sexp sexp &rest form)))
- `(let* ((,range-sym ,range)
- (,start (eglot--lsp-position-to-point (plist-get ,range-sym :start)))
- (,end (eglot--lsp-position-to-point (plist-get ,range-sym :end))))
- ,@body))
+(defun eglot--range-region (range)
+ "Return region (BEG . END) that represents LSP RANGE."
+ (cons (eglot--lsp-position-to-point (plist-get range :start))
+ (eglot--lsp-position-to-point (plist-get range :end))))
;;; Minor modes
@@ -627,18 +625,14 @@ Uses THING, FACE, DEFS and PREPEND."
(cl-defun eglot--server-textDocument/publishDiagnostics
(_process &key uri diagnostics)
"Handle notification publishDiagnostics"
- (let* ((obj (url-generic-parse-url uri))
- (filename (car (url-path-and-query obj)))
- (buffer (find-buffer-visiting filename)))
- (cond
- (buffer
+ (if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri))))
(with-current-buffer buffer
(cl-loop
for diag-spec across diagnostics
collect (cl-destructuring-bind (&key range severity _group
_code source message)
diag-spec
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
(flymake-make-diagnostic (current-buffer)
beg end
(cond ((<= severity 1) :error)
@@ -650,9 +644,8 @@ Uses THING, FACE, DEFS and PREPEND."
(funcall eglot--current-flymake-report-fn diags)
(setq eglot--unreported-diagnostics nil))
(t
- (setq eglot--unreported-diagnostics diags))))))
- (t
- (eglot--message "OK so %s isn't visited" filename)))))
+ (setq eglot--unreported-diagnostics diags)))))
+ (eglot--warn "Diagnostics received for unvisited %s" uri)))
(cl-defun eglot--register-unregister (proc jsonrpc-id things how)
"Helper for `eglot--server-client/registerCapability'.
@@ -898,8 +891,7 @@ DUMMY is ignored"
:textDocument/definition
(get-text-property
0 :textDocumentPositionParams identifier)))))
- (mapcar
- (jrpc-lambda (&key uri range)
+ (mapcar (jrpc-lambda (&key uri range)
(eglot--xref-make identifier uri (plist-get range :start)))
location-or-locations)))
@@ -984,7 +976,7 @@ DUMMY is ignored"
(defun eglot--hover-info (contents &optional range)
(concat (and range
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
(concat (buffer-substring beg end) ": ")))
(mapconcat #'eglot--format-markup
(append
@@ -1065,7 +1057,8 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(when-buffer-window
(mapcar
(jrpc-lambda (&key range _kind)
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end)
+ (eglot--range-region range)))
(let ((ov (make-overlay beg end)))
(overlay-put ov 'face 'highlight)
(overlay-put ov 'evaporate t)
@@ -1102,7 +1095,7 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(save-restriction
(widen)
(save-excursion
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
(goto-char beg) (delete-region beg end) (insert newText)))))
edits)
(eglot--message "%s: Performed %s edits" (current-buffer) (length edits)))
diff --git a/jrpc.el b/jrpc.el
index 44719d9..ce22e92 100644
--- a/jrpc.el
+++ b/jrpc.el
@@ -131,7 +131,7 @@ NAME is a name to give the inferior process or connection.
CONTACT is as explained in `jrpc-connect'. Returns a process
object."
(let* ((readable-name (format "JSON-RPC server (%s)" name)
)
- (buffer (get-buffer-create (format "*%s inferior*" readable-name)))
+ (buffer (get-buffer-create (format "*%s stderr*" readable-name)))
(proc
(cond ((processp contact) contact)
((integerp (cadr contact))
@@ -141,6 +141,7 @@ object."
(make-process :name readable-name
:command contact
:connection-type 'pipe
+ :coding 'no-conversion
:stderr (get-buffer-create (format "*%s stderr*"
name)))))))
(set-process-buffer proc buffer)
- [elpa] externals/eglot f4de5d7 01/69: Fix copyright header. Obviously not since 2003, (continued)
- [elpa] externals/eglot f4de5d7 01/69: Fix copyright header. Obviously not since 2003, João Távora, 2018/06/22
- [elpa] externals/eglot 5cda0ec 06/69: Fix a ridiculous bug when generating transient projects, João Távora, 2018/06/22
- [elpa] externals/eglot e5120aa 08/69: Add jrpc.el to Makefile, João Távora, 2018/06/22
- [elpa] externals/eglot 07359a2 15/69: Allow null timeouts and set default to 3 seconds, João Távora, 2018/06/22
- [elpa] externals/eglot 67d8335 17/69: jrpc.el should know nothing of mode-line updates, João Távora, 2018/06/22
- [elpa] externals/eglot 0e1a5f0 05/69: jrpc-connect is now passed a generic dispatching function, João Távora, 2018/06/22
- [elpa] externals/eglot 078a1a6 13/69: Add full "Commentary" section to jrpc.el, João Távora, 2018/06/22
- [elpa] externals/eglot 2f1d76d 03/69: Proper server shutdown when jrpc.el is used, João Távora, 2018/06/22
- [elpa] externals/eglot a2aa1ed 19/69: Robustify timer handling for jrpc-async-request, João Távora, 2018/06/22
- [elpa] externals/eglot 7769c07 16/69: Send message, then establish continuations, João Távora, 2018/06/22
- [elpa] externals/eglot 7f2e894 11/69: Merge branch 'master' into jsonrpc-refactor (using good ol' git merge),
João Távora <=
- [elpa] externals/eglot e5ba4f6 18/69: Automatically reply with error if dispatcher doesn't, João Távora, 2018/06/22
- [elpa] externals/eglot 33ae871 09/69: More flexible jrpc.el and improve eglot.el's doc, João Távora, 2018/06/22
- [elpa] externals/eglot 3265c1d 10/69: Simpler callback protocol for JSONRPC parameters and results, João Távora, 2018/06/22
- [elpa] externals/eglot e906d25 14/69: Overhaul JSON and JSRONRPC error handling, João Távora, 2018/06/22
- [elpa] externals/eglot 7cd94b9 12/69: Improve jrpc.el's doc (and change jrpc-request's protocol a tiny bit), João Távora, 2018/06/22
- [elpa] externals/eglot 489182d 24/69: New jsonrpc-error error type, João Távora, 2018/06/22
- [elpa] externals/eglot 5cea412 20/69: Fix typos and phrasing in commentary and docstrings, João Távora, 2018/06/22
- [elpa] externals/eglot c30f0f3 23/69: Get rid of jsonrpc.el customization group and timeout, João Távora, 2018/06/22
- [elpa] externals/eglot 5e8fe4c 26/69: Add jsonrpc-tests.el, João Távora, 2018/06/22
- [elpa] externals/eglot 05ff697 29/69: Document current API breaches a bit, João Távora, 2018/06/22