emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/eglot 12691c2 6/7: Make it work on Windows


From: João Távora
Subject: [elpa] externals/eglot 12691c2 6/7: Make it work on Windows
Date: Thu, 17 May 2018 09:11:36 -0400 (EDT)

branch: externals/eglot
commit 12691c24588e05aa3645f0d9b866859a5d59a910
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Make it work on Windows
    
    Apparently passing :coding 'no-conversion to make-process on windows
    is essential to receive any text at all in the process filter.
    
    Also needed to tweak uri-to-path and path-to-uri.
    
    Thanks to lsp-mode.el for these hints
    
    * eglot.el (eglot--make-process): Pass :coding 'no-conversion to
    make-process.
    (eglot--path-to-uri): Add a forward slash if windows-nt.
    (eglot--uri-to-path): Remove a forward slash if windows-nt.
    (eglot--server-textDocument/publishDiagnostics): Simplify and use
    eglot--uri-to-path.
---
 eglot.el | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/eglot.el b/eglot.el
index 01a6b5d..08c2f55 100644
--- a/eglot.el
+++ b/eglot.el
@@ -195,6 +195,7 @@ CONTACT is as `eglot--contact'.  Returns a process object."
             (make-process :name readable-name
                           :buffer buffer
                           :command contact
+                          :coding 'no-conversion
                           :connection-type 'pipe
                           :stderr (get-buffer-create (format "*%s stderr*"
                                                              name))))))
@@ -756,14 +757,16 @@ DEFERRED is passed to `eglot--async-request', which see."
                   (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")
@@ -989,11 +992,7 @@ called interactively."
 (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
@@ -1012,9 +1011,8 @@ called interactively."
                         (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'.



reply via email to

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