[elpa] master c5788f7: Fix loading of yasnippet-classic-snippets

2018-05-14 Thread Noam Postavsky
branch: master
commit c5788f7a09d365df7431528b7711dd5171eb9ea5
Author: Noam Postavsky 
Commit: Noam Postavsky 

Fix loading of yasnippet-classic-snippets

* packages/yasnippet-classic-snippets/yasnippet-classic-snippets.el:
Don't require yasnippet.  Handle old single string format of
yas-snippet-dirs.  Make sure yasnippet-classic-snippets-dir is
actually defined when we use it.  Bump version to 1.0.1.
---
 .../yasnippet-classic-snippets.el| 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/packages/yasnippet-classic-snippets/yasnippet-classic-snippets.el 
b/packages/yasnippet-classic-snippets/yasnippet-classic-snippets.el
index 9ef6f4e..b0a3864 100644
--- a/packages/yasnippet-classic-snippets/yasnippet-classic-snippets.el
+++ b/packages/yasnippet-classic-snippets/yasnippet-classic-snippets.el
@@ -2,8 +2,9 @@
 
 ;; Copyright (C) 2018 Free Software Foundation, Inc.
 
+;; Maintainer: Noam Postavsky 
 ;; Keywords: snippets
-;; Version: 1.0.0
+;; Version: 1.0.1
 ;; Package-Requires: ((yasnippet "0.9.1"))
 ;; Keywords: convenience, snippets
 
@@ -28,18 +29,23 @@
 
 ;;; Code:
 
-(require 'yasnippet)
-
 (defconst yasnippet-classic-snippets-dir
   (expand-file-name
"snippets"
(file-name-directory (or load-file-name buffer-file-name
 
-;;;###autoload
 (eval-after-load 'yasnippet
-  '(unless (memq 'yasnippet-classic-snippets-dir yas-snippet-dirs)
-(add-to-list 'yas-snippet-dirs 'yasnippet-classic-snippets-dir t)
-(yas-load-directory yasnippet-classic-snippets-dir)))
+  '(progn
+ (when (stringp yas-snippet-dirs)
+   ;; In case the user set the old format.
+   (setq yas-snippet-dirs (list yas-snippet-dirs)))
+ (unless (memq 'yasnippet-classic-snippets-dir yas-snippet-dirs)
+   ;; Prepare for future snippet reloads.
+   (add-to-list 'yas-snippet-dirs 'yasnippet-classic-snippets-dir t)
+   ;; And get our snippets ready now.
+   (yas-load-directory yasnippet-classic-snippets-dir t
+
+;;;###autoload (eval-after-load 'yasnippet '(require 
'yasnippet-classic-snippets))
 
 (provide 'yasnippet-classic-snippets)
 



[elpa] externals/elpa 931093e 032/139: Don't clutter UI with warnings

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 931093e24b7c9788474ff7173f9cfcb76d2f667a
Author: João Távora 
Commit: João Távora 

Don't clutter UI with warnings

* eglot.el (warnings): require it.
(eglot--warn): set warning-minimum-level
---
 eglot.el | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index c7bb5d4..6e5954c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -31,6 +31,7 @@
 (require 'url-util)
 (require 'pcase)
 (require 'compile) ; for some faces
+(require 'warnings)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -623,9 +624,10 @@ running.  INTERACTIVE is t if called interactively."
 
 (defun eglot--warn (format &rest args)
   "Warning message with FORMAT and ARGS."
-  (display-warning 'eglot
-   (apply #'format format args)
-   :warning))
+  (let ((warning-minimum-level :error))
+(display-warning 'eglot
+ (apply #'format format args)
+ :warning)))
 
 
 



[elpa] externals/elpa c948713 035/139: Auto-reconnect on unexpected connection loss

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit c948713b050fe209572b362799ae688d1c0629f6
Author: João Távora 
Commit: João Távora 

Auto-reconnect on unexpected connection loss

* eglot.el (eglot-reconnect): Only quit if indeed not quit
already.
(eglot-new-process): Burn the command in the bootstrap fn.
(eglot--process-sentinel): Automatically reconnect if closed
unexpectedly.
(eglot--warn): Also message to *Messages*
---
 eglot.el | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/eglot.el b/eglot.el
index aa23252..71dab80 100644
--- a/eglot.el
+++ b/eglot.el
@@ -162,7 +162,8 @@ Call SUCCESS-FN with no args if all goes well."
   "Reconnect to PROCESS.
 INTERACTIVE is t if called interactively."
   (interactive (list (eglot--current-process-or-lose) t))
-  (eglot-quit-server process 'sync interactive)
+  (when (process-live-p process)
+(eglot-quit-server process 'sync interactive))
   (eglot--connect (eglot--short-name process)
   (eglot--bootstrap-fn process)
   (lambda ()
@@ -174,7 +175,12 @@ INTERACTIVE is t if called interactively."
   (interactive (list t))
   (let ((project (project-current)))
 (unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
-(let ((current-process (eglot--current-process)))
+(let ((current-process (eglot--current-process))
+  (command (let ((probe (cdr (assoc major-mode eglot-executables
+ (unless probe
+   (eglot--error "Don't know how to start EGLOT for %s 
buffers"
+ major-mode))
+ probe)))
   (cond ((and current-process
   (process-live-p current-process))
  (eglot--message "(new-process) Reconnecting instead")
@@ -187,11 +193,7 @@ INTERACTIVE is t if called interactively."
   (lambda (name)
 (eglot-make-local-process
  name
- (let ((probe (cdr (assoc major-mode eglot-executables
-   (unless probe
- (eglot--error "Don't know how to start EGLOT for %s 
buffers"
-   major-mode))
-   probe)))
+ command))
   (lambda ()
 (eglot--message "Connected")
 (dolist (buffer (buffer-list))
@@ -221,8 +223,10 @@ INTERACTIVE is t if called interactively."
(eglot--message "(sentinel) Moribund process exited with status %s"
(process-exit-status process)))
   (t
-   (eglot--warn "(sentinel) Process unexpectedly changed to %s"
-change)))
+   (eglot--warn
+"(sentinel) Reconnecting after process unexpectedly changed to %s."
+change)
+   (eglot-reconnect process)))
 (delete-process process)))
 
 (defun eglot--process-filter (proc string)
@@ -633,6 +637,7 @@ running.  INTERACTIVE is t if called interactively."
 
 (defun eglot--warn (format &rest args)
   "Warning message with FORMAT and ARGS."
+  (apply #'eglot--message (concat "(warning) " format) args)
   (let ((warning-minimum-level :error))
 (display-warning 'eglot
  (apply #'format format args)



[elpa] externals/elpa c222c3b 019/139: Lay groundwork for uniform treatment of network connections

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit c222c3bc547ad03764385b2d651297e7c45926dd
Author: João Távora 
Commit: João Távora 

Lay groundwork for uniform treatment of network connections

* eglot.el (eglot--connect): New helper.
(eglot-new-process): Use it.
(pcase): Require it.
---
 eglot.el | 62 --
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/eglot.el b/eglot.el
index 9e5f6c2..cd213e7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -29,6 +29,7 @@
 (require 'project)
 (require 'url-parse)
 (require 'url-util)
+(require 'pcase)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -97,12 +98,27 @@
 major-mode))
 probe))
 
+(defun eglot--connect (name filter sentinel)
+  "Helper for `eglot-new-process'.
+NAME is a name to give the inferior process or connection.
+FILTER and SENTINEL are filter and sentinel.
+Should return a list of (PROCESS BUFFER)."
+  (let ((proc (make-process :name name
+:buffer (get-buffer-create
+ (format "*%s inferior*" name))
+:command (eglot--command 'error)
+:connection-type 'pipe
+:filter filter
+:sentinel sentinel
+:stderr (get-buffer-create (format "*%s stderr*"
+   name)
+(list proc (process-buffer proc
+
 (defun eglot-new-process (&optional interactive)
   "Start a new EGLOT process and initialize it.
 INTERACTIVE is t if called interactively."
   (interactive (list t))
-  (let ((project (project-current))
-(command (eglot--command 'errorp)))
+  (let ((project (project-current)))
 (unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
 (let ((current-process (eglot--current-process)))
   (when (and current-process
@@ -114,30 +130,24 @@ INTERACTIVE is t if called interactively."
  (car (project-roots (project-current))
(good-name
 (format "EGLOT server (%s)" short-name)))
-  (with-current-buffer (get-buffer-create
-(format "*%s inferior*" good-name))
-(let* ((proc
-(make-process :name good-name
-  :buffer (current-buffer)
-  :command command
-  :connection-type 'pipe
-  :filter 'eglot--process-filter
-  :sentinel 'eglot--process-sentinel
-  :stderr (get-buffer-create (format "*%s stderr*"
- good-name
-   (inhibit-read-only t))
-  (setf (eglot--short-name proc) short-name)
-  (puthash (project-current) proc eglot--processes-by-project)
-  (erase-buffer)
-  (let ((marker (point-marker)))
-(set-marker-insertion-type marker nil)
-(setf (eglot--message-mark proc) marker))
-  (read-only-mode t)
-  (with-current-buffer (eglot-events-buffer proc)
-(let ((inhibit-read-only t))
-  (insert
-   (format "\n---\n"
-  (eglot--protocol-initialize proc interactive))
+  (pcase-let ((`(,proc ,buffer)
+   (eglot--connect good-name
+   'eglot--process-filter
+   'eglot--process-sentinel)))
+(with-current-buffer buffer
+  (let ((inhibit-read-only t))
+(setf (eglot--short-name proc) short-name)
+(puthash (project-current) proc eglot--processes-by-project)
+(erase-buffer)
+(let ((marker (point-marker)))
+  (set-marker-insertion-type marker nil)
+  (setf (eglot--message-mark proc) marker))
+(read-only-mode t)
+(with-current-buffer (eglot-events-buffer proc)
+  (let ((inhibit-read-only t))
+(insert
+ (format "\n---\n"
+(eglot--protocol-initialize proc interactive)))
 
 (defun eglot--process-sentinel (process change)
   (with-current-buffer (process-buffer process)



[elpa] externals/elpa 92bf3a0 038/139: Signal textDocument/didClose

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 92bf3a0485b4af11c0915bd3467e21c7b4bfe21a
Author: João Távora 
Commit: João Távora 

Signal textDocument/didClose

* eglot.el (eglot-editing-mode): Signal didClose.
(eglot--signalDidClose): New.
---
 eglot.el | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 12e7fef..8584440 100644
--- a/eglot.el
+++ b/eglot.el
@@ -671,6 +671,7 @@ running.  INTERACTIVE is t if called interactively."
 (eglot-mode 1)
 (add-hook 'after-change-functions 'eglot--after-change nil t)
 (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
+(add-hook 'kill-buffer-hook 'eglot--signalDidClose nil t)
 (flymake-mode 1)
 (if (eglot--current-process)
 (eglot--signalDidOpen)
@@ -679,7 +680,8 @@ running.  INTERACTIVE is t if called interactively."
 (eglot--warn "No process"
(t
 (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
-(remove-hook 'after-change-functions 'eglot--after-change t
+(remove-hook 'after-change-functions 'eglot--after-change t)
+(remove-hook 'kill-buffer-hook 'eglot--signalDidClose t
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil
@@ -832,6 +834,12 @@ running.  INTERACTIVE is t if called interactively."
  (eglot--obj :textDocument
  (eglot--current-buffer-TextDocumentItem
 
+(defun eglot--signalDidClose ()
+  (eglot--notify (eglot--current-process-or-lose)
+ :textDocument/didClose
+ (eglot--obj :textDocument
+ (eglot--current-buffer-TextDocumentItem
+
 (defun eglot--maybe-signal-didChange ()
   (when eglot--recent-changes
 (save-excursion



[elpa] externals/elpa 3403f86 027/139: Correctly report what we currently are capable of

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 3403f86ea50bc7562b02df86509f7ca70e14c22e
Author: João Távora 
Commit: João Távora 

Correctly report what we currently are capable of

Which is almost nothing.

* eglot.el (eglot--protocol-initialize): Clean up.
---
 eglot.el | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/eglot.el b/eglot.el
index db594f4..1f2737e 100644
--- a/eglot.el
+++ b/eglot.el
@@ -459,20 +459,23 @@ INTERACTIVE is t if caller was called interactively."
   (eglot--request
process
:initialize
-   `(:processId  ,(emacs-pid)
- :rootPath  ,(concat 
-  (expand-file-name (car (project-roots
-  (project-current)
- :initializationOptions  []
- :capabilities (:workspace (:executeCommand 
(:dynamicRegistration t))
-   :textDocument (:synchronization 
(:didSave t
+   (eglot--obj :processId  (emacs-pid)
+   :rootPath  (concat
+   (expand-file-name (car (project-roots
+   (project-current)
+   :initializationOptions  []
+   :capabilities
+   (eglot--obj
+:workspace (eglot--obj)
+:textDocument (eglot--obj
+   :publishDiagnostics `(:relatedInformation t
:success-fn (cl-function
 (lambda (&key capabilities)
   (setf (eglot--capabilities process) capabilities)
   (when interactive
 (setf (eglot--status process) nil)
 (eglot--message
- "So yeah I got lots (%d) of capabilities"
+ "Server reports %d capabilities"
  (length capabilities)))
 
 (defun eglot-quit-server (process &optional sync interactive)



[elpa] externals/elpa c95a0a4 041/139: Multiple servers per project are possible

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit c95a0a40d75a7446f093cc8e9a70702e26a16ea3
Author: João Távora 
Commit: João Távora 

Multiple servers per project are possible

A server manages a specific major-mode within a project.

* eglot.el (eglot--processes-by-project): Add docstring.
(eglot--current-process): Search new eglot--processes-by-project
format.
(eglot--major-mode): New variable.
(eglot--moribund, eglot--project): Update docstring.
(eglot--project-short-name, eglot--all-major-modes): New helpers.
(eglot--connect): Rework.
(eglot-new-process): Rework severely.
(eglot--command-history): New variable.
(eglot--process-sentinel): Use new
eglot--processes-by-project. Update mode line.
(eglot-editing-mode): Don't start processes, just suggest it.
---
 eglot.el | 123 ---
 1 file changed, 95 insertions(+), 28 deletions(-)

diff --git a/eglot.el b/eglot.el
index cd546a3..10af6c5 100644
--- a/eglot.el
+++ b/eglot.el
@@ -42,7 +42,8 @@
 (python-mode . ("pyls")))
   "Alist mapping major modes to server executables.")
 
-(defvar eglot--processes-by-project (make-hash-table :test #'equal))
+(defvar eglot--processes-by-project (make-hash-table :test #'equal)
+  "Keys are projects.  Values are lists of processes.")
 
 (defvar eglot-editing-mode) ; forward decl
 (defvar eglot-mode) ; forward decl
@@ -53,9 +54,13 @@
 (defun eglot--current-process ()
   "The current logical EGLOT process."
   (or eglot--special-buffer-process
-  (let ((cur (project-current)))
-(and cur
- (gethash cur eglot--processes-by-project)
+  (let* ((cur (project-current))
+ (processes
+  (and cur
+   (gethash cur eglot--processes-by-project
+(cl-find major-mode
+ processes
+ :key #'eglot--major-mode
 
 (defun eglot--current-process-or-lose ()
   "Return the current EGLOT process or error."
@@ -91,6 +96,9 @@ after setting it."
 (eglot--define-process-var eglot--short-name nil
   "A short name for the process" t)
 
+(eglot--define-process-var eglot--major-mode nil
+  "The major-mode this server is managing.")
+
 (eglot--define-process-var eglot--expected-bytes nil
   "How many bytes declared by server")
 
@@ -104,10 +112,10 @@ after setting it."
   "Holds list of capabilities that server reported")
 
 (eglot--define-process-var eglot--moribund nil
-  "Non-nil if process is about to exit")
+  "Non-nil if server is about to exit")
 
 (eglot--define-process-var eglot--project nil
-  "The project the process belongs to.")
+  "The project the server belongs to.")
 
 (eglot--define-process-var eglot--spinner `(nil nil t)
   "\"Spinner\" used by some servers.
@@ -122,6 +130,20 @@ A list (WHAT SERIOUS-P)." t)
 Must be a function of one arg, a name, returning a process
 object.")
 
+(defun eglot--project-short-name (project)
+  "Give PROJECT a short name."
+  (file-name-base
+   (directory-file-name
+(car (project-roots project)
+
+(defun eglot--all-major-modes ()
+  "Return all know major modes."
+  (let ((retval))
+(mapatoms (lambda (sym)
+(when (plist-member (symbol-plist sym) 'derived-mode-parent)
+  (push sym retval
+retval))
+
 (defun eglot-make-local-process (name command)
   "Make a local LSP process from COMMAND.
 NAME is a name to give the inferior process or connection.
@@ -140,17 +162,22 @@ Returns a process object."
   name)
 proc))
 
-(defun eglot--connect (project short-name bootstrap-fn &optional success-fn)
-  "Make a connection with PROJECT, SHORT-NAME and BOOTSTRAP-FN.
-Call SUCCESS-FN with no args if all goes well."
+(defun eglot--connect (project managed-major-mode
+   short-name bootstrap-fn &optional success-fn)
+  "Make a connection for PROJECT, SHORT-NAME and MANAGED-MAJOR-MODE.
+Use BOOTSTRAP-FN to make the actual process object.  Call
+SUCCESS-FN with no args if all goes well."
   (let* ((proc (funcall bootstrap-fn short-name))
  (buffer (process-buffer proc)))
 (setf (eglot--bootstrap-fn proc) bootstrap-fn
-  (eglot--project proc) project)
+  (eglot--project proc) project
+  (eglot--major-mode proc) managed-major-mode)
 (with-current-buffer buffer
   (let ((inhibit-read-only t))
 (setf (eglot--short-name proc) short-name)
-(puthash (project-current) proc eglot--processes-by-project)
+(push proc
+  (gethash (project-current)
+   eglot--processes-by-project))
 (erase-buffer)
 (read-only-mode t)
 (with-current-buffer (eglot-events-buffer proc)
@@ -173,24 +200,63 @@ INTERACTIVE is t if called interactively."
 (eglot-quit-server process 'sync interactive))
   (eglot--connect
(eglot--project process)
+   (eglot--maj

[elpa] externals/elpa 17e0ca4 047/139: Fix Flymake diagnostic positions

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 17e0ca499e34638d5a52b4daf6b01e06fed3610c
Author: João Távora 
Commit: João Távora 

Fix Flymake diagnostic positions

It's better not to use flymake-diag-region here.

* eglot.el (eglot--textDocument/publishDiagnostics):
Calculate position by hand.
---
 eglot.el | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/eglot.el b/eglot.el
index 86c0a4c..bb0427a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -637,10 +637,13 @@ running.  INTERACTIVE is t if called interactively."
   (with-current-buffer buffer
 (cl-flet ((pos-at
(pos-plist)
-   (car (flymake-diag-region
- (current-buffer)
- (plist-get pos-plist :line)
- (plist-get pos-plist :character)
+   (save-excursion
+ (goto-char (point-min))
+ (forward-line (plist-get pos-plist :line))
+ (forward-char
+  (min (plist-get pos-plist :character)
+   (- (line-end-position)
+  (line-beginning-position)))
   (cl-loop for diag-spec across diagnostics
collect (cl-destructuring-bind (&key range severity
 _code _source message)



[elpa] externals/elpa 1514e0f 052/139: Fix a couple of Rust-related edge cases

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 1514e0f4709c915426748ca764900edfb38f8acc
Author: João Távora 
Commit: João Távora 

Fix a couple of Rust-related edge cases

* eglot.el (eglot--server-window/progress): Allow other keys.
(eglot--server-textDocument/publishDiagnostics): Allow :group in diagnostic
spec.
---
 eglot.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 1bf0d56..e7fe18c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -843,7 +843,7 @@ running.  INTERACTIVE is t if called interactively."
   (line-beginning-position
  (point
   (cl-loop for diag-spec across diagnostics
-   collect (cl-destructuring-bind (&key range severity
+   collect (cl-destructuring-bind (&key range severity _group
 _code _source message)
diag-spec
  (cl-destructuring-bind (&key start end)
@@ -1002,7 +1002,7 @@ Calls REPORT-FN maybe if server publishes diagnostics in 
time."
 ;;; Rust-specific
 ;;;
 (cl-defun eglot--server-window/progress
-(process &key id done title )
+(process &key id done title &allow-other-keys)
   "Handle notification window/progress"
   (setf (eglot--spinner process) (list id title done)))
 



[elpa] externals/elpa 2b61a3b 048/139: Delete two useless forward declarations

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 2b61a3bf70d340c1f865cde91cc1228cdb13af1f
Author: João Távora 
Commit: João Távora 

Delete two useless forward declarations

* eglot.el (eglot-mode, eglot-editing-mode-map): Remove forward decls.
---
 eglot.el | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/eglot.el b/eglot.el
index bb0427a..f25c7bd 100644
--- a/eglot.el
+++ b/eglot.el
@@ -46,9 +46,6 @@
 (defvar eglot--processes-by-project (make-hash-table :test #'equal)
   "Keys are projects.  Values are lists of processes.")
 
-(defvar eglot-editing-mode) ; forward decl
-(defvar eglot-mode) ; forward decl
-
 (defvar-local eglot--special-buffer-process nil
   "Current buffer's eglot process.")
 
@@ -643,7 +640,8 @@ running.  INTERACTIVE is t if called interactively."
  (forward-char
   (min (plist-get pos-plist :character)
(- (line-end-position)
-  (line-beginning-position)))
+  (line-beginning-position
+ (point
   (cl-loop for diag-spec across diagnostics
collect (cl-destructuring-bind (&key range severity
 _code _source message)



[elpa] externals/elpa f1b6485 053/139: Trim some edges and add a bunch of boring RPC methods

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit f1b648592e01229b18fc8dfae6e69b1149620326
Author: João Távora 
Commit: João Távora 

Trim some edges and add a bunch of boring RPC methods

* eglot.el (eglot--connect): Don't call eglot--protocol-initialize.
(eglot--process-filter): Break long line.
(eglot--process-receive): Also pass id to handler if a server request.
(eglot--log): New helper.
(eglot-editing-mode): Manage before-revert-hook,
after-revert-hook, before-save-hook, after-save-hook.
(eglot--protocol-initialize): Removed.
(eglot--server-window/showMessage): Simplify.
(eglot--server-window/showMessageRequest)
(eglot--server-window/logMessage, eglot--server-telemetry/event):
New handlers.
(eglot--signal-textDocument/willSave)
(eglot--signal-textDocument/didSave): New notifications.
(eglot--signal-textDocument/didOpen)
(eglot--signal-textDocument/didClose): Check
eglot--buffer-open-count.
(eglot--buffer-open-count): New var.
---
 eglot.el | 135 +++
 1 file changed, 102 insertions(+), 33 deletions(-)

diff --git a/eglot.el b/eglot.el
index e7fe18c..ebc07d2 100644
--- a/eglot.el
+++ b/eglot.el
@@ -198,13 +198,26 @@ SUCCESS-FN with no args if all goes well."
   (let ((inhibit-read-only t))
 (insert
  (format "\n---\n"
-(eglot--protocol-initialize
+(eglot--request
  proc
+ :initialize
+ (eglot--obj :processId  (emacs-pid)
+ :rootPath  (concat
+ (expand-file-name (car (project-roots
+ (project-current)
+ :initializationOptions  []
+ :capabilities
+ (eglot--obj
+  :workspace (eglot--obj)
+  :textDocument (eglot--obj
+ :publishDiagnostics `(:relatedInformation 
t
+ :success-fn
  (cl-function
   (lambda (&key capabilities)
 (setf (eglot--capabilities proc) capabilities)
 (setf (eglot--status proc) nil)
-(when success-fn (funcall success-fn proc)
+(when success-fn (funcall success-fn proc))
+(eglot--notify proc :initialized nil
 
 (defvar eglot--command-history nil
   "History of COMMAND arguments to `eglot'.")
@@ -347,7 +360,8 @@ INTERACTIVE is t if called interactively."
;;
(setq expected-bytes
  (and (search-forward-regexp
-   "\\(?:.*: .*\r\n\\)*Content-Length: 
*\\([[:digit:]]+\\)\r\n\\(?:.*: .*\r\n\\)*\r\n"
+   "\\(?:.*: .*\r\n\\)*Content-Length: \
+*\\([[:digit:]]+\\)\r\n\\(?:.*: .*\r\n\\)*\r\n"
(+ (point) 100)
t)
   (string-to-number (match-string 1
@@ -454,11 +468,15 @@ identifier.  ERROR is non-nil if this is an error."
  (t
   (apply (cl-first continuations) (plist-get message 
:result)
   (t
+   ;; a server notification or a server request
(let* ((method (plist-get message :method))
   (handler-sym (intern (concat "eglot--server-"
method
  (if (functionp handler-sym)
- (apply handler-sym proc (plist-get message :params))
+ (apply handler-sym proc (append
+  (plist-get message :params)
+  (let ((id (plist-get message :id)))
+(if id `(:id ,id)
(eglot--warn "No implemetation for notification %s yet"
 method)))
 
@@ -587,6 +605,10 @@ identifier.  ERROR is non-nil if this is an error."
   "Message out with FORMAT with ARGS."
   (message (concat "[eglot] " (apply #'format format args
 
+(defun eglot--log (format &rest args)
+  "Log out with FORMAT with ARGS."
+  (message (concat "[eglot-log] " (apply #'format format args
+
 (defun eglot--warn (format &rest args)
   "Warning message with FORMAT and ARGS."
   (apply #'eglot--message (concat "(warning) " format) args)
@@ -614,15 +636,22 @@ identifier.  ERROR is non-nil if this is an error."
 (add-hook 'before-change-functions 'eglot--before-change nil t)
 (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
 (add-hook 'kill-buffer-hook 'eglot--signal-textDocument/didClose nil t)
+(add-hook 'before-revert-hook 'eglot--signal-textDocument/didClose nil t)
+(add-hook 'after-revert-hook 'eglot--signal-textDocument/didOpen nil t)
+(add-hook 'before-save-hook 'eglot--signal-textDocument/w

[elpa] externals/elpa 9ff97a6 079/139: Increase request timeout length to 10 seconds

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 9ff97a648244d4d08d6670b2204692ae49753f1b
Author: João Távora 
Commit: João Távora 

Increase request timeout length to 10 seconds

* eglot.el (eglot-request-timeout): New var.
(eglot--request): Use it.
---
 eglot.el | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index 1d72b4c..cd48519 100644
--- a/eglot.el
+++ b/eglot.el
@@ -48,8 +48,11 @@
 
 (defface eglot-mode-line
   '((t (:inherit font-lock-constant-face :weight bold)))
-  "Face for package-name in EGLOT's mode line."
-  :group 'eglot)
+  "Face for package-name in EGLOT's mode line.")
+
+(defcustom eglot-request-timeout 10
+  "How many seconds to way for a reply from the server."
+  :type :integer)
 
 
 ;;; Process management
@@ -617,7 +620,7 @@ is a symbol saying if this is a client or server 
originated."
 (catch catch-tag
   (let ((timeout-timer
  (run-with-timer
-  5 nil
+  eglot-request-timeout nil
   (if async-p
   (lambda ()
 (remhash id (eglot--pending-continuations process))



[elpa] externals/elpa 95187cf 058/139: Connect to LSP server via TCP

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 95187cfcecbfafb090c530808e2f6932cf9d860e
Author: João Távora 
Commit: João Távora 

Connect to LSP server via TCP

* eglot.el (eglot--make-process): Rename from
eglot-make-local-process.
(eglot): Fix docstring and rework.
(eglot--bootstrap-fn): Remove
(eglot--contact): New process-local var.
(eglot--connect): Take CONTACT arg.
(eglot--reconnect): Rework.
---
 eglot.el | 137 ++-
 1 file changed, 73 insertions(+), 64 deletions(-)

diff --git a/eglot.el b/eglot.el
index ac52b9a..c5a0c0f 100644
--- a/eglot.el
+++ b/eglot.el
@@ -133,30 +133,40 @@ A list (ID WHAT DONE-P)." t)
   "Status as declared by the server.
 A list (WHAT SERIOUS-P)." t)
 
-(eglot--define-process-var eglot--bootstrap-fn nil
-  "Function for returning processes/connetions to LSP servers.
-Must be a function of one arg, a name, returning a process
-object.")
+(eglot--define-process-var eglot--contact nil
+  "Method used to contact a server.
+Either a list of strings (a shell command and arguments), or a
+list of a single string of the form :")
 
 (eglot--define-process-var eglot--buffer-open-count (make-hash-table)
   "Keeps track of didOpen/didClose notifs for each buffer.")
 
-(defun eglot-make-local-process (name command)
-  "Make a local LSP process from COMMAND.
+(defun eglot--make-process (name contact)
+  "Make a process from CONTACT.
 NAME is a name to give the inferior process or connection.
-Returns a process object."
+CONTACT is as `eglot--contact'.  Returns a process object."
   (let* ((readable-name (format "EGLOT server (%s)" name))
+ (buffer (get-buffer-create
+  (format "*%s inferior*" readable-name)))
+ (singleton (and (null (cdr contact)) (car contact)))
  (proc
-  (make-process
-   :name readable-name
-   :buffer (get-buffer-create
-(format "*%s inferior*" readable-name))
-   :command command
-   :connection-type 'pipe
-   :filter 'eglot--process-filter
-   :sentinel 'eglot--process-sentinel
-   :stderr (get-buffer-create (format "*%s stderr*"
-  name)
+  (if (and
+   singleton
+   (string-match "^[\s\t]*\\(.*\\):\\([[:digit:]]+\\)[\s\t]*$"
+ singleton))
+  (open-network-stream readable-name
+   buffer
+   (match-string 1 singleton)
+   (string-to-number (match-string 2 
singleton)))
+(make-process
+ :name readable-name
+ :buffer buffer
+ :command contact
+ :connection-type 'pipe
+ :stderr (get-buffer-create (format "*%s stderr*"
+name))
+(set-process-filter proc #'eglot--process-filter)
+(set-process-sentinel proc #'eglot--process-sentinel)
 proc))
 
 (defmacro eglot--obj (&rest what)
@@ -180,13 +190,12 @@ Returns a process object."
 retval))
 
 (defun eglot--connect (project managed-major-mode
-   short-name bootstrap-fn &optional success-fn)
-  "Make a connection for PROJECT, SHORT-NAME and MANAGED-MAJOR-MODE.
-Use BOOTSTRAP-FN to make the actual process object.  Call
+   short-name contact &optional success-fn)
+  "Connect for PROJECT, MANAGED-MAJOR-MODE, SHORT-NAME and CONTACT.
 SUCCESS-FN with no args if all goes well."
-  (let* ((proc (funcall bootstrap-fn short-name))
+  (let* ((proc (eglot--make-process short-name contact))
  (buffer (process-buffer proc)))
-(setf (eglot--bootstrap-fn proc) bootstrap-fn
+(setf (eglot--contact proc) contact
   (eglot--project proc) project
   (eglot--major-mode proc) managed-major-mode)
 (with-current-buffer buffer
@@ -226,15 +235,17 @@ SUCCESS-FN with no args if all goes well."
   "History of COMMAND arguments to `eglot'.")
 
 (defun eglot (managed-major-mode command &optional interactive)
-  ;; FIXME: Later make this function also connect to TCP servers by
-  ;; overloading semantics on COMMAND.
   "Start a Language Server Protocol server.
 Server is started with COMMAND and manages buffers of
 MANAGED-MAJOR-MODE for the current project.
 
 COMMAND is a list of strings, an executable program and
-optionally its arguments.  MANAGED-MAJOR-MODE is an Emacs major
-mode.
+optionally its arguments.  If the first and only string in the
+list is of the form \":\" it is taken as an
+indication to connect to a server instead of starting one.  This
+is also know as the server's \"contact\".
+
+MANAGED-MAJOR-MODE is an Emacs major mode.
 
 With a prefix arg, prompt for MANAGED-MAJOR-MODE and COMMAND,
 else guess them from current context and `eglot-executables'.
@@ -257,47 +268,45 @@ INTERACTIVE is t if 

[elpa] externals/elpa 39e8b9e 081/139: Add (dummy) tests and Travis CI integration

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 39e8b9e46e9d59f6995ec1415c6663f03b9fa032
Author: João Távora 
Commit: João Távora 

Add (dummy) tests and Travis CI integration

* .travis.yml: New file.

* Makefile: New file.

* README.md: Add Travis badge.

* eglot-tests.el: New file with a dummy test.
---
 .travis.yml| 19 +++
 Makefile   | 35 +++
 README.md  |  1 +
 eglot-tests.el | 32 
 4 files changed, 87 insertions(+)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000..7a89327
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,19 @@
+language: generic
+sudo: false
+
+env:
+  global:
+- EGLOT_TESTING=t # For kicks, so I don't forget this syntax
+  matrix:
+- EMACS_VERSION=26-prerelease
+
+install:
+  - curl -LO 
https://github.com/npostavs/emacs-travis/releases/download/bins/emacs-bin-${EMACS_VERSION}.tar.gz
+  - tar -xaf emacs-bin-${EMACS_VERSION}.tar.gz -C /
+  # Configure $PATH: Emacs installed to /tmp/emacs
+  - export PATH=/tmp/emacs/bin:${PATH}
+  - emacs --version
+
+script:
+  - make check
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 000..7b85351
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,35 @@
+### Makefile for EGLOT
+### 
+# Variables
+#
+EMACS=emacs
+
+LOAD_PATH=-L .
+
+ELFILES := eglot.el eglot-tests.el
+ELCFILES := $(ELFILES:.el=.elc)
+
+all: compile
+
+# Compilation
+#
+%.elc: %.el
+   $(EMACS) -Q $(LOAD_PATH) --batch -f batch-byte-compile $<
+
+compile: $(ELCFILES)
+
+# Automated tests
+#
+check: compile
+
+check: SELECTOR=t
+check: compile
+   $(EMACS) -Q --batch $(LOAD_PATH)\
+   -l eglot-tests  \
+   -f ert-run-tests-batch-and-exit \
+
+# Cleanup
+#
+clean:
+   find . -iname '*.elc' -exec rm {} \;
+.PHONY: all compile clean check
diff --git a/README.md b/README.md
index 0314664..955ef54 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+[![Build 
Status](https://travis-ci.org/joaotavora/eglot.png)](https://travis-ci.org/joaotavora/eglot)
 Eglot
 -
 
diff --git a/eglot-tests.el b/eglot-tests.el
new file mode 100644
index 000..0f29519
--- /dev/null
+++ b/eglot-tests.el
@@ -0,0 +1,32 @@
+;;; eglot-tests.el --- Tests for eglot.el-*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2018  João Távora
+
+;; Author: João Távora 
+;; Keywords: tests
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see .
+
+;;; Commentary:
+
+;; Tests for eglot.el
+
+;;; Code:
+(require 'eglot)
+(require 'ert)
+
+(ert-deftest dummy () "A dummy test" (should t))
+
+(provide 'eglot-tests)
+;;; eglot-tests.el ends here



[elpa] externals/elpa 714e5be 086/139: Half-baked textDocument/hover support

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 714e5be3080d5bef55e5b3143d3d1d3dd593a508
Author: João Távora 
Commit: João Távora 

Half-baked textDocument/hover support

* eglot.el (eglot--format-markup): New helper.
(eglot--managed-mode): Handle eldoc-documentation-function.
(eglot-eldoc-function): New function.

* README.md: update
---
 README.md |  2 +-
 eglot.el  | 42 --
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index f70d15f..611839b 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ server. To skip the guess and always be prompted use `C-u M-x 
eglot`.
 - [ ] textDocument/documentSymbol
 - [ ] textDocument/executeCommand
 - [ ] textDocument/format
-- [ ] textDocument/hover
+- [x] textDocument/hover
 - [ ] textDocument/rename
 - [x] textDocument/references
 - [ ] textDocument/signatureHelp
diff --git a/eglot.el b/eglot.el
index 3bed8d9..2c97f2f 100644
--- a/eglot.el
+++ b/eglot.el
@@ -772,6 +772,23 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (13 . "Enum") (14 . "Keyword") (15 . "Snippet") (16 . "Color")
 (17 . "File") (18 . "Reference")))
 
+(defun eglot--format-markup (markup)
+  "Format MARKUP according to LSP's spec."
+  (cond ((stringp markup)
+ (with-temp-buffer
+   (ignore-errors (funcall 'markdown-mode))
+   (font-lock-ensure)
+   (insert markup)
+   (string-trim (buffer-string
+(t
+ (with-temp-buffer
+   (ignore-errors (funcall (intern (concat
+(plist-get markup :language)
+"-mode" 
+   (insert (plist-get markup :value))
+   (font-lock-ensure)
+   (buffer-string)
+
 
 ;;; Minor modes
 ;;;
@@ -796,7 +813,10 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (add-hook 'after-save-hook 'eglot--signal-textDocument/didSave nil t)
 (add-hook 'xref-backend-functions 'eglot-xref-backend nil t)
 (add-hook 'completion-at-point-functions #'eglot-completion-at-point nil t)
-(flymake-mode 1))
+(add-function :before-until (local 'eldoc-documentation-function)
+  #'eglot-eldoc-function)
+(flymake-mode 1)
+(eldoc-mode 1))
(t
 (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
 (remove-hook 'after-change-functions 'eglot--after-change t)
@@ -806,7 +826,9 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (remove-hook 'before-save-hook 'eglot--signal-textDocument/willSave t)
 (remove-hook 'after-save-hook 'eglot--signal-textDocument/didSave t)
 (remove-hook 'xref-backend-functions 'eglot-xref-backend t)
-(remove-hook 'completion-at-point-functions #'eglot-completion-at-point 
t
+(remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
+(remove-function (local 'eldoc-documentation-function)
+ #'eglot-eldoc-function
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil
@@ -1410,6 +1432,22 @@ DUMMY is ignored"
 (get-text-property 0 :sortText a)
 (get-text-property 0 :sortText b)
 
+(defun eglot-eldoc-function ()
+  "EGLOT's `eldoc-documentation-function' function."
+  (eglot--request (eglot--current-process-or-lose)
+  :textDocument/hover
+  (eglot--obj
+   :textDocument (eglot--current-buffer-TextDocumentIdentifier)
+   :position (eglot--pos-to-lsp-position))
+  :success-fn (eglot--lambda (&key contents _range)
+(eldoc-message
+ (mapconcat #'eglot--format
+(if (vectorp contents)
+contents
+  (list contents))
+"\n"
+  nil)
+
 
 ;;; Dynamic registration
 ;;;



[elpa] externals/elpa af14364 093/139: Only request stuff that server says it's capable of

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit af143643bbdb0764812c7f4a8e342ce5f9b20c7c
Author: João Távora 
Commit: João Távora 

Only request stuff that server says it's capable of

* eglot.el (eglot--server-capable): New helper.
(eglot-xref-backend)
(xref-backend-identifier-completion-table)
(xref-backend-references, xref-backend-apropos)
(eglot-completion-at-point, eglot-eldoc-function): Use it.
---
 eglot.el | 98 +++-
 1 file changed, 53 insertions(+), 45 deletions(-)

diff --git a/eglot.el b/eglot.el
index 02439df..7cc3756 100644
--- a/eglot.el
+++ b/eglot.el
@@ -740,6 +740,10 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
(font-lock-ensure)
(buffer-string)
 
+(defun eglot--server-capable (feat)
+  "Determine if current server is capable of FEAT."
+  (plist-get (eglot--capabilities (eglot--current-process-or-lose)) feat))
+
 
 ;;; Minor modes
 ;;;
@@ -1158,7 +1162,9 @@ Calls REPORT-FN maybe if server publishes diagnostics in 
time."
   ;; make the server report new diagnostics.
   (eglot--signal-textDocument/didChange))
 
-(defun eglot-xref-backend () "EGLOT xref backend." 'eglot)
+(defun eglot-xref-backend ()
+  "EGLOT xref backend."
+  (when (eglot--server-capable :definitionProvider) 'eglot))
 
 (defvar eglot--xref-known-symbols nil)
 
@@ -1179,26 +1185,27 @@ DUMMY is ignored"
(plist-get position :character
 
 (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql eglot)))
-  (let ((proc (eglot--current-process-or-lose))
-(text-id (eglot--current-buffer-TextDocumentIdentifier)))
-(completion-table-with-cache
- (lambda (string)
-   (setq eglot--xref-known-symbols
- (eglot--mapply
-  (eglot--lambda (&key name kind location containerName)
-(propertize name
-:position (plist-get
-   (plist-get location :range)
-   :start)
-:locations (list location)
-:textDocument text-id
-:kind kind
-:containerName containerName))
-  (eglot--sync-request proc
-   :textDocument/documentSymbol
-   (eglot--obj
-:textDocument text-id
-   (all-completions string eglot--xref-known-symbols)
+  (when (eglot--server-capable :documentSymbolProvider)
+(let ((proc (eglot--current-process-or-lose))
+  (text-id (eglot--current-buffer-TextDocumentIdentifier)))
+  (completion-table-with-cache
+   (lambda (string)
+ (setq eglot--xref-known-symbols
+   (eglot--mapply
+(eglot--lambda (&key name kind location containerName)
+  (propertize name
+  :position (plist-get
+ (plist-get location :range)
+ :start)
+  :locations (list location)
+  :textDocument text-id
+  :kind kind
+  :containerName containerName))
+(eglot--sync-request proc
+ :textDocument/documentSymbol
+ (eglot--obj
+  :textDocument text-id
+ (all-completions string eglot--xref-known-symbols))
 
 (cl-defmethod xref-backend-identifier-at-point ((_backend (eql eglot)))
   (let ((symatpt (symbol-at-point)))
@@ -1226,6 +1233,7 @@ DUMMY is ignored"
  location-or-locations)))
 
 (cl-defmethod xref-backend-references ((_backend (eql eglot)) identifier)
+  (unless (eglot--server-capable :referencesProvider) (cl-return nil))
   (let* ((identifier (if (get-text-property 0 :position identifier)
  identifier
(car (member identifier eglot--xref-known-symbols
@@ -1234,8 +1242,7 @@ DUMMY is ignored"
  (textDocument
   (and identifier (get-text-property 0 :textDocument identifier
 (unless (and position textDocument)
-  (eglot--error "Sorry, can't discover where %s is in the workspace"
-identifier))
+  (eglot--error "Don't know where %s is in the workspace" identifier))
 (eglot--mapply
  (eglot--lambda (&key uri range)
(eglot--xref-make identifier uri (plist-get range :start)))
@@ -1249,21 +1256,21 @@ DUMMY is ignored"
:context (eglot--obj :includeDeclaration t))
 
 (cl-defmethod xref-backend-apropos ((_backend (eql eglot)) pattern)
-  (eglot--mapply
-   (eglot--lambda (&key name location &allow-other-keys)
- (let ((range (plist-get location :range))
- 

[elpa] externals/elpa e9b5e54 077/139: ETOOMANYLAMBDAS

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit e9b5e548be6f49bc81b6499d247b56f8b02bd635
Author: João Távora 
Commit: João Távora 

ETOOMANYLAMBDAS

* eglot.el (eglot--sync-request): Remove a lambda.
---
 eglot.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index d6ecdfe..321307d 100644
--- a/eglot.el
+++ b/eglot.el
@@ -663,9 +663,8 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
  (lambda (&key code message &allow-other-keys)
(eglot--error "Oops: %s: %s" code message)))
   :timeout-fn (lambda ()
-(lambda ()
-  (eglot--error
-   "Tired of waiting for reply to sync 
request")))
+(eglot--error
+ "Tired of waiting for reply to sync request"))
   :async-p nil))
 
 (cl-defun eglot--notify (process method params)



[elpa] externals/elpa d431d41 088/139: Fix bug in hover support

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit d431d4109918500ff9a99782b45d975709f1d6be
Author: João Távora 
Commit: João Távora 

Fix bug in hover support

* eldoc.el (eglot-eldoc-function): Use eglot--format-markup.
(subr-x): Require it.
(eglot--format-markup): Pacify byte-compiler.
---
 eglot.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8e92725..9d7b16d 100644
--- a/eglot.el
+++ b/eglot.el
@@ -34,6 +34,7 @@
 (require 'warnings)
 (require 'flymake)
 (require 'xref)
+(require 'subr-x)
 
 
 ;;; User tweakable stuff
@@ -763,7 +764,7 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
   "Format MARKUP according to LSP's spec."
   (cond ((stringp markup)
  (with-temp-buffer
-   (ignore-errors (funcall 'markdown-mode))
+   (ignore-errors (funcall (intern "markdown-mode"))) ;escape 
bytecompiler
(font-lock-ensure)
(insert markup)
(string-trim (buffer-string
@@ -1428,7 +1429,7 @@ DUMMY is ignored"
:position (eglot--pos-to-lsp-position))
   :success-fn (eglot--lambda (&key contents _range)
 (eldoc-message
- (mapconcat #'eglot--format
+ (mapconcat #'eglot--format-markup
 (if (vectorp contents)
 contents
   (list contents))



[elpa] externals/elpa 1356844 097/139: Fix odd bugs

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 1356844979c82e7a1b62055314a6a4326fed1576
Author: João Távora 
Commit: João Távora 

Fix odd bugs

* eglot.el (eglot--process-receive, eglot--request): Set status to
actual error message.
(eglot--managed-mode): Manage imenu-create-index-function
correctly.
(eglot--mode-line-format): Print error status.
---
 eglot.el | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/eglot.el b/eglot.el
index 9ce7e26..807df98 100644
--- a/eglot.el
+++ b/eglot.el
@@ -495,7 +495,7 @@ is a symbol saying if this is a client or server 
originated."
  (not method)
  (gethash id (eglot--pending-continuations 
proc)
 (eglot--log-event proc message 'server)
-(when err (setf (eglot--status proc) '("error" t)))
+(when err (setf (eglot--status proc) `(,err t)))
 (cond (method
;; a server notification or a server request
(let* ((handler-sym (intern (concat "eglot--server-"
@@ -566,7 +566,7 @@ response."
  (error-fn (or error-fn
(cl-function
 (lambda (&key code message &allow-other-keys)
-  (setf (eglot--status process) '("error" t))
+  (setf (eglot--status process) `(,message t))
   (eglot--warn
"(request) Request id=%s errored with code=%s: %s"
id code message)
@@ -780,7 +780,7 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (add-hook 'completion-at-point-functions #'eglot-completion-at-point nil t)
 (add-function :before-until (local 'eldoc-documentation-function)
   #'eglot-eldoc-function)
-(advice-add imenu-create-index-function :around #'eglot-imenu)
+(add-function :around (local imenu-create-index-function) #'eglot-imenu)
 (flymake-mode 1)
 (eldoc-mode 1))
(t
@@ -795,7 +795,7 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
 (remove-function (local 'eldoc-documentation-function)
  #'eglot-eldoc-function)
-(advice-remove imenu-create-index-function #'eglot-imenu
+(remove-function (local imenu-create-index-function) #'eglot-imenu
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil
@@ -870,9 +870,10 @@ Uses THING, FACE, DEFS and PREPEND."
  (mouse-3 eglot-reconnect "reconnect to server")))
  ,@(when serious-p
  `("/" ,(eglot--mode-line-props
- status 'compilation-mode-line-fail
+ "error" 'compilation-mode-line-fail
  '((mouse-1 eglot-events-buffer "go to events buffer")
-   (mouse-3 eglot-clear-status  "clear this status")
+   (mouse-3 eglot-clear-status  "clear this status"))
+ (format "An error occured: %s\n" status
  ,@(when (and doing (not done-p))
  `("/" ,(eglot--mode-line-props
  doing 'compilation-mode-line-run
@@ -881,7 +882,8 @@ Uses THING, FACE, DEFS and PREPEND."
  `("/" ,(eglot--mode-line-props
  (format "%d" pending) 'warning
  '((mouse-1 eglot-events-buffer "go to events buffer")
-   (mouse-3 eglot-clear-status  "clear this 
status"))
+   (mouse-3 eglot-clear-status  "clear this status"))
+ (format "%d pending requests\n" pending)
 
 (add-to-list 'mode-line-misc-info `(eglot-mode (" [" eglot--mode-line-format 
"] ")))
 



[elpa] externals/elpa 24466a9 096/139: When killing server, always wait 3 seconds

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 24466a958563daf2803edc1f4b732c3e2412a06c
Author: João Távora 
Commit: João Távora 

When killing server, always wait 3 seconds

* eglot.el (eglot--request): Accept TIMEOUT param.
---
 eglot.el | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/eglot.el b/eglot.el
index 2e409ef..9ce7e26 100644
--- a/eglot.el
+++ b/eglot.el
@@ -552,10 +552,12 @@ is a symbol saying if this is a client or server 
originated."
 (cl-defun eglot--request (process
   method
   params
-  &key success-fn error-fn timeout-fn (async-p t))
+  &key success-fn error-fn timeout-fn (async-p t)
+  (timeout eglot-request-timeout))
   "Make a request to PROCESS, expecting a reply.
 Return the ID of this request, unless ASYNC-P is nil, in which
-case never returns locally."
+case never returns locally.  Wait TIMEOUT seconds for a
+response."
   (let* ((id (eglot--next-request-id))
  (timeout-fn (or timeout-fn
  (lambda ()
@@ -583,7 +585,7 @@ case never returns locally."
 (catch catch-tag
   (let ((timeout-timer
  (run-with-timer
-  eglot-request-timeout nil
+  timeout nil
   (if async-p
   (lambda ()
 (remhash id (eglot--pending-continuations process))
@@ -912,10 +914,12 @@ running.  INTERACTIVE is t if called interactively."
:success-fn brutal
:async-p (not sync)
:error-fn brutal
-   :timeout-fn brutal))
+   :timeout-fn brutal
+   :timeout 3))
  :error-fn brutal
  :async-p (not sync)
- :timeout-fn brutal)))
+ :timeout-fn brutal
+ :timeout 3)))
 
 (cl-defun eglot--server-window/showMessage (_process &key type message)
   "Handle notification window/showMessage"



[elpa] externals/elpa 889ef20 085/139: Tweak the async request engine.

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 889ef20069d7d6511ce7f8f5b13928f3e7100eb5
Author: João Távora 
Commit: João Távora 

Tweak the async request engine.

* eglot.el (eglot--request): Return the continuation id.
(eglot--lambda): Move up in the file.
(eglot--sync-request): Use a catch-tag.
---
 eglot.el | 44 ++--
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/eglot.el b/eglot.el
index 068e2ca..3bed8d9 100644
--- a/eglot.el
+++ b/eglot.el
@@ -593,7 +593,9 @@ is a symbol saying if this is a client or server 
originated."
   method
   params
   &key success-fn error-fn timeout-fn (async-p t))
-  "Make a request to PROCESS, expecting a reply."
+  "Make a request to PROCESS, expecting a reply.
+Return the ID of this request, unless ASYNC-P is nil, in which
+case never returns locally."
   (let* ((id (eglot--next-request-id))
  (timeout-fn
   (or timeout-fn
@@ -658,22 +660,34 @@ is a symbol saying if this is a client or server 
originated."
 (when (memq timeout-timer timer-list)
   (eglot--message
"(request) Last-change cancelling timer for continuation %s" id)
-  (cancel-timer timeout-timer
+  (cancel-timer timeout-timer))
+;; Finally, return the id.
+id))
+
+(cl-defmacro eglot--lambda (cl-lambda-list &body body)
+  (declare (indent 1) (debug (sexp &rest form)))
+  `(cl-function
+(lambda ,cl-lambda-list
+  ,@body)))
 
 (defun eglot--sync-request (proc method params)
   "Like `eglot--request' for PROC, METHOD and PARAMS, but synchronous.
 Meaning only return locally if successful, otherwise exit non-locally."
   (let* ((timeout-error-sym (cl-gensym))
- (retval (eglot--request proc method params
- :success-fn (lambda (&rest args)
-   (if (vectorp (car args))
-   (car args)
- args))
- :error-fn (cl-function
-(lambda (&key code message 
&allow-other-keys)
-  (eglot--error "Oops: %s: %s" 
code message)))
- :timeout-fn (lambda () timeout-error-sym)
- :async-p nil)))
+ (catch-tag (make-symbol "eglot--sync-request-catch-tag"))
+ (retval
+  (catch catch-tag
+(eglot--request proc method params
+:success-fn (lambda (&rest args)
+  (throw catch-tag (if (vectorp (car 
args))
+   (car args)
+ args)))
+:error-fn (eglot--lambda
+  (&key code message &allow-other-keys)
+(eglot--error "Oops: %s: %s" code 
message))
+:timeout-fn (lambda ()
+  (throw catch-tag timeout-error-sym))
+:async-p nil
 ;; FIXME: There's maybe an emacs bug here. Because timeout-fn runs
 ;; in a timer, the better and obvious choice of throwing the erro
 ;; in the lambda is not quitting the `accept-process-output'
@@ -741,12 +755,6 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
   "Apply FUN to every element of SEQ."
   (mapcar (lambda (e) (apply fun e)) seq))
 
-(cl-defmacro eglot--lambda (cl-lambda-list &body body)
-  (declare (indent 1) (debug (sexp &rest form)))
-  `(cl-function
-(lambda ,cl-lambda-list
-  ,@body)))
-
 (defun eglot--path-to-uri (path)
   "Urify PATH."
   (url-hexify-string



[elpa] externals/elpa 9af84a2 124/139: Prepare to sumbit to GNU ELPA

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 9af84a283fa3d5247be413d8300b1aa23e6c0124
Author: João Távora 
Commit: João Távora 

Prepare to sumbit to GNU ELPA

* eglot.el: Update headers.
---
 eglot.el | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eglot.el b/eglot.el
index 635ca26..e33e540 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1,12 +1,13 @@
 ;;; eglot.el --- Client for Language Server Protocol (LSP) servers  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2017  João Távora
+;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
 
 ;; Version: 0.1
-;; Author: João Távora
-;; Url: https://github.com/joaotavora/eglot
+;; Author: João Távora 
+;; Maintainer: João Távora 
+;; URL: https://github.com/joaotavora/eglot
 ;; Keywords: convenience, languages
-;; Package-Requires: ((emacs "26.1"))
+;; Package-Requires: ((emacs "26.1") (json-mode "1.6.0"))
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by



[elpa] externals/elpa d40f9ac 094/139: Half-decent imenu support via textDocument/documentSymbol

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit d40f9ac8af850b95868bf810dd67b3c5009bf598
Author: João Távora 
Commit: João Távora 

Half-decent imenu support via textDocument/documentSymbol

* README.md: Update capability

* eglot.el (eglot--lsp-position-to-point): New function.
(eglot--managed-mode): Handle imenu-create-index-function.
(eglot--server-textDocument/publishDiagnostics): Use
eglot--lsp-position-to-point.
(eglot-imenu): New function.
(eglot--client-capabilities): Capable of documentSymbol.
---
 README.md |  2 +-
 eglot.el  | 96 ---
 2 files changed, 62 insertions(+), 36 deletions(-)

diff --git a/README.md b/README.md
index 611839b..fef2d16 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ server. To skip the guess and always be prompted use `C-u M-x 
eglot`.
 - [ ] completionItem/resolve
 - [x] textDocument/definition
 - [ ] textDocument/documentHighlight
-- [ ] textDocument/documentSymbol
+- [x] textDocument/documentSymbol
 - [ ] textDocument/executeCommand
 - [ ] textDocument/format
 - [x] textDocument/hover
diff --git a/eglot.el b/eglot.el
index 7cc3756..d7ea329 100644
--- a/eglot.el
+++ b/eglot.el
@@ -193,10 +193,11 @@ CONTACT is as `eglot--contact'.  Returns a process 
object."
 :willSave t
 :willSaveWaitUntil :json-false
 :didSave t)
-  :completion `(:dynamicRegistration :json-false)
-  :hover  `(:dynamicRegistration :json-false)
-  :references `(:dynamicRegistration :json-false)
-  :definition `(:dynamicRegistration :json-false)
+  :completion `(:dynamicRegistration :json-false)
+  :hover  `(:dynamicRegistration :json-false)
+  :references `(:dynamicRegistration :json-false)
+  :definition `(:dynamicRegistration :json-false)
+  :documentSymbol `(:dynamicRegistration :json-false)
   :publishDiagnostics `(:relatedInformation :json-false))
:experimental (eglot--obj)))
 
@@ -703,6 +704,17 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (- (goto-char (or pos (point)))
(line-beginning-position)
 
+(defun eglot--lsp-position-to-point (pos-plist)
+  "Convert LSP position POS-PLIST to Emacs point."
+  (save-excursion (goto-char (point-min))
+  (forward-line (plist-get pos-plist :line))
+  (forward-char
+   (min (plist-get pos-plist :character)
+(- (line-end-position)
+   (line-beginning-position
+  (point)))
+
+
 (defun eglot--mapply (fun seq)
   "Apply FUN to every element of SEQ."
   (mapcar (lambda (e) (apply fun e)) seq))
@@ -766,6 +778,7 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (add-hook 'completion-at-point-functions #'eglot-completion-at-point nil t)
 (add-function :before-until (local 'eldoc-documentation-function)
   #'eglot-eldoc-function)
+(advice-add imenu-create-index-function :around #'eglot-imenu)
 (flymake-mode 1)
 (eldoc-mode 1))
(t
@@ -779,7 +792,8 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 (remove-hook 'xref-backend-functions 'eglot-xref-backend t)
 (remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
 (remove-function (local 'eldoc-documentation-function)
- #'eglot-eldoc-function
+ #'eglot-eldoc-function)
+(advice-remove imenu-create-index-function #'eglot-imenu
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil
@@ -956,36 +970,28 @@ running.  INTERACTIVE is t if called interactively."
 (cond
  (buffer
   (with-current-buffer buffer
-(cl-flet ((pos-at (pos-plist)
-  (save-excursion (goto-char (point-min))
-  (forward-line (plist-get pos-plist 
:line))
-  (forward-char
-   (min (plist-get pos-plist 
:character)
-(- (line-end-position)
-   (line-beginning-position
-  (point
-  (cl-loop for diag-spec across diagnostics
-   collect (cl-destructuring-bind (&key range severity _group
-_code source message)
-   diag-spec
- (cl-destructuring-bind (&key start end)
- range
-   (let* ((be

[elpa] externals/elpa 72895ca 006/139: Handle notifications

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 72895ca4565db0ffa5d076718729072d47465f55
Author: João Távora 
Commit: João Távora 

Handle notifications
---
 eglot.el | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 5ca6833..6e3a136 100644
--- a/eglot.el
+++ b/eglot.el
@@ -287,8 +287,13 @@
  (t
   (apply (first continuations) (plist-get message :result)
   (t
-   (eglot--debug "No implemetation for notification %s yet"
- (plist-get message :method))
+   (let* ((method (plist-get message :method))
+  (handler-sym (intern (concat "eglot--"
+  method
+ (if (functionp handler-sym)
+ (apply handler-sym proc (plist-get message :params))
+   (eglot--debug "No implemetation for notification %s yet"
+ method)))
 
 (defvar eglot--expect-carriage-return nil)
 
@@ -391,6 +396,14 @@
   (length all)))
 
 (defun eglot--debug (format &rest args)
+
+;;; Notifications
+;;;
+(cl-defun eglot--textDocument/publishDiagnostics
+(_process &key uri diagnostics)
+  "Handle notification publishDiagnostics"
+  (eglot--message "So yeah I got %s for %s"
+  diagnostics uri))
   (display-warning 'eglot
  (apply #'format format args)
  :debug))



[elpa] branch externals/elpa created (now 4c0bfc3)

2018-05-14 Thread Jo�o T�vora
capitaomorte pushed a change to branch externals/elpa.

at  4c0bfc3   Support didChangeWatchedFiles with dynamic registration

This branch includes the following new commits:

   new  d90efdf   Initial commit
   new  3a8f9a1   Remove a couple of comments
   new  2775dea   Rename eglot--continuations eglot--pending-continuations
   new  3489176   Add a mode-line construct and some minor fanciness
   new  a4f99e0   Introduce and use `eglot--current-process-or-lose'
   new  72895ca   Handle notifications
   new  0222e7e   Improve `eglot--current-process'
   new  6f0a8df   Organize a bit
   new  c417eb4   Cancel timeouts when process dies unexpectedly
   new  bc011d0   Minor cleanup
   new  dfab9a0   Experimental diagnostic overlays
   new  0ec7801   Simplify `eglot--protocol-initialize`
   new  e60c7fc   Overhaul async mechanism safety
   new  e1d36d2   Fix some byte-compilation warnings
   new  efd14d6   Fix mode line
   new  8bd634c   Start working on this again
   new  4f246b5   * eglot.el (eglot-mode-map): Move up before minor mode.
   new  6f6f01d   Doc fixes
   new  c222c3b   Lay groundwork for uniform treatment of network 
connections
   new  16be2fc   Fix parser to accept multiple messages in one chunk
   new  1dc2a9f   Implement spinners and RLS's window/progress
   new  b4dd4f8   Report server status in the mode-line
   new  8e6488f   Don't switch to possibly dead buffer in sentinel
   new  7c82a03   Start experimenting with python
   new  328c7ae   Auto update mode-line after setting some process 
properties
   new  6689a15   Add eglot-clear-status interactive command
   new  3403f86   Correctly report what we currently are capable of
   new  95983c9   Change status to error everytime an error is found
   new  7ec0dcf   Events buffer uses eglot-mode, source buffers use 
eglot-editing-mode
   new  63f2208   Less obstrusive flymake stuff for now
   new  e8f859e   Rework commands for connecting and reconnecting
   new  931093e   Don't clutter UI with warnings
   new  75495dc   Slightly more user friendly start
   new  22dc2f7   Ready to start fixing flymake integration
   new  c948713   Auto-reconnect on unexpected connection loss
   new  b511b7d   Redesign and simplify parser
   new  be52e1e   Rework connection restarting again
   new  92bf3a0   Signal textDocument/didClose
   new  fdb4de1   Simplify flymake integration
   new  88e3655   Appease checkdoc.el
   new  c95a0a4   Multiple servers per project are possible
   new  0e95167   Watch for files opened under umbrella of existing process
   new  cc183a6   Fix assorted bugs
   new  f7f77e1   Make M-x eglot the main entry point
   new  d2eca65   Fix another Flymake sync bug
   new  51ff863   Must re-announce didOpen after reconnect
   new  17e0ca4   Fix Flymake diagnostic positions
   new  2b61a3b   Delete two useless forward declarations
   new  46bb1c0   Reorganize file
   new  a3545fb   Rename RPC methods for clarity
   new  9665a3e   Fix textDocument/didChange
   new  1514e0f   Fix a couple of Rust-related edge cases
   new  f1b6485   Trim some edges and add a bunch of boring RPC methods
   new  9d404c9   Update README.md
   new  b1554fc   * eglot.el (eglot--process-receive): Skip null method 
notifs.
   new  29d4103   Fix mode-line mouse-clicks from outside selected window
   new  f76f04e   More correctly keep track of didOpen/didClose per buffer
   new  95187cf   Connect to LSP server via TCP
   new  eebd32b   When user declines to reconnect, first quit existing 
server
   new  b69302c   Make M-x eglot's interactive spec a separate function
   new  4d4b85d   eglot-editing-mode becomes eglot--managed-mode
   new  7d0bf64   Workaround RLS's regusal to treat nil as empty json object
   new  c2862f4   Don't auto-reconnect if last attempt lasted less than 3 
seconds
   new  f8bfb7e   Handle requests from server correctly
   new  df5d76d   Reply to client/registerCapability (don't handle it yet)
   new  ea918ab   Include source info in diagnostics
   new  e7ffc31   Make reported capabilities into its own function
   new  b657b32   Use rootUri instead of rootPath
   new  79a2a1e   Be quite explicit about our lack of capabilities right now
   new  a199c8e   Honour textDocumentSync
   new  8160cd4   Handle dynamic registration in general (but nothing 
specific yet)
   new  9882bf2   Cleanup mistake with TextDocumentItem and 
TextDocumentIdentifier
   new  e86f9b4   New helper eglot--sync-request
   new  ff5a03d   Very basic xref support
   new  193c57d   Half-decent xref support
   new  571b08f   Fix the odd bug here and there
   new  e9b5e54   ETOOMANYLAMBDAS
   new  1add335   Workaround two suspected Emacs bugs
   new  9ff97a6   Inc

[elpa] externals/elpa 3489176 004/139: Add a mode-line construct and some minor fanciness

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 348917660aab0ecef794561160fd95a0fdf820dd
Author: João Távora 
Commit: João Távora 

Add a mode-line construct and some minor fanciness
---
 eglot.el | 126 ---
 1 file changed, 112 insertions(+), 14 deletions(-)

diff --git a/eglot.el b/eglot.el
index 166f23c..92c1216 100644
--- a/eglot.el
+++ b/eglot.el
@@ -64,6 +64,9 @@
 (eglot--define-process-var eglot--message-mark nil
   "Point where next unread message starts")
 
+(eglot--define-process-var eglot--short-name nil
+  "A short name")
+
 (eglot--define-process-var eglot--expected-bytes nil
   "How many bytes declared by server")
 
@@ -92,25 +95,29 @@
   (and timeout-fn
`((cl-function ,timeout-fn)
 
-(defun eglot--command ()
-  (cdr (assoc major-mode eglot-executables)))
+(defun eglot--command (&optional errorp)
+  (let ((probe (cdr (assoc major-mode eglot-executables
+(unless (or (not errorp)
+probe)
+  (eglot--error "Don't know how to start EGLOT for %s buffers"
+major-mode))
+probe))
 
-(defun eglot-new-process (&optional interactive)
+(defun eglot-new-process (&optional _interactive)
   "Starts a new EGLOT process and initializes it"
   (interactive (list t))
   (let ((project (project-current))
-(command (eglot--command)))
-(unless command (eglot--error "Cannot work without an LSP executable"))
+(command (eglot--command 'errorp)))
 (unless project (eglot--error "Cannot work without a current project!"))
 (let ((current-process (eglot--current-process)))
   (when (and current-process
  (process-live-p current-process))
 (eglot-quit-server current-process 'sync)))
-(let ((good-name
-   (format "EGLOT server (%s)"
-   (file-name-base
-(directory-file-name
- (car (project-roots (project-current
+(let* ((short-name (file-name-base
+(directory-file-name
+ (car (project-roots (project-current))
+   (good-name
+(format "EGLOT server (%s)" short-name)))
   (with-current-buffer (get-buffer-create
 (format "*%s inferior*" good-name))
 (let* ((proc
@@ -123,6 +130,7 @@
   :stderr (get-buffer-create (format "*%s stderr*"
  good-name
(inhibit-read-only t))
+  (setf (eglot--short-name proc) short-name)
   (puthash (project-current) proc eglot--processes-by-project)
   (erase-buffer)
   (let ((marker (point-marker)))
@@ -133,9 +141,7 @@
 (let ((inhibit-read-only t))
   (insert
(format "\n---\n"
-  (eglot--protocol-initialize proc)
-  (when interactive
-(display-buffer (eglot-events-buffer proc
+  (eglot--protocol-initialize proc))
 
 (defun eglot-quit-server (process &optional sync)
   (interactive (list (eglot--current-process)))
@@ -246,7 +252,7 @@
buffer))
buffer
 (when interactive
-  (pop-to-buffer buffer))
+  (display-buffer buffer))
 buffer))
 
 (defun eglot--log-event (proc type message)
@@ -295,6 +301,10 @@
 (defun eglot--next-request-id ()
   (setq eglot--next-request-id (1+ eglot--next-request-id)))
 
+(defun eglot-forget-pending-continuations (process)
+  (interactive (eglot--current-process))
+  (clrhash (eglot--pending-continuations process)))
+
 (defun eglot--call-with-request (process
   async-p
   method
@@ -389,5 +399,93 @@
  (apply #'format format args)
  :warning))
 
+
+
+;;; Mode line
+;;;
+
+
+(defface eglot-mode-line
+  '((t (:inherit font-lock-constant-face :weight bold)))
+  "Face for package-name in EGLOT's mode line."
+  :group 'eglot)
+
+(define-minor-mode eglot-mode
+  "Minor mode for buffers where EGLOT is possible")
+
+(defvar eglot-menu)
+
+(defvar eglot-mode-map (make-sparse-keymap))
+
+(easy-menu-define eglot-menu eglot-mode-map "SLY"
+  `("EGLOT" ))
+
+(defvar eglot--mode-line-format
+  `(:eval (eglot--mode-line-format)))
+
+(put 'eglot--mode-line-format 'risky-local-variable t)
+
+(defun eglot--mode-line-format ()
+  (let* ((proc (eglot--current-process))
+ (name (and proc
+(process-live-p proc)
+(eglot--short-name proc)))
+ (pending (and proc
+   (hash-table-count
+(eglot--pending-continuations proc
+ (format-number (lambda (n) (cond ((and n (not (zerop n)))
+   (format "%d" n))
+  (n "-")
+   

[elpa] externals/elpa 0625b6c 123/139: (eglot--xref-make): Fix Use of cl-destructuring-bind.

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 0625b6c639bac70da71e35c3870896e731c6ebc7
Author: João Távora 
Commit: João Távora 

(eglot--xref-make): Fix Use of cl-destructuring-bind.
---
 eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 4c5d53e..635ca26 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1176,7 +1176,7 @@ DUMMY is ignored"
 
 (defun eglot--xref-make (name uri position)
   "Like `xref-make' but with LSP's NAME, URI and POSITION."
-  (cl-destructuring-bind (line character) position
+  (cl-destructuring-bind (&key line character) position
 (xref-make name (xref-make-file-location
  (eglot--uri-to-path uri)
  ;; F!@(#*&#$)CKING OFF-BY-ONE again



[elpa] externals/elpa 42177d0 107/139: New "deferred requests" that wait until server is ready

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 42177d02d765c039a1343f5f6966dc50ec278c21
Author: João Távora 
Commit: João Távora 

New "deferred requests" that wait until server is ready

Calling textDocument/hover or textDocument/documentHighlight before
the server has had a chance to process a textDocument/didChange is
normally useless. The matter is worse for servers like RLS which only
become ready much later and send a special notif for it (see
https://github.com/rust-lang-nursery/rls/issues/725).

So, keeping the same coding style add a DEFERRED arg to eglot--request
that makes it maybe not run the function immediately. Add a bunch of
logic for probing readiness of servers.

* README.md: Update

* eglot.el (eglot--deferred-actions): New process-local var.
(eglot--process-filter): Call deferred actions.
(eglot--request): Rewrite.
(eglot--sync-request): Rewrite.
(eglot--call-deferred, eglot--ready-predicates)
(eglot--server-ready-p): New helpers.
(eglot--signal-textDocument/didChange): Set spinner and call
deferred actions.
(eglot-completion-at-point): Pass DEFERRED to eglot-sync-request.
(eglot-eldoc-function): Pass DEFERRED to eglot-request
(eglot--rls-probably-ready-for-p): New helper.
(rust-mode-hook): Add eglot--setup-rls-idiosyncrasies
(eglot--setup-rls-idiosyncrasies): New helper.
---
 README.md |  10 +--
 eglot.el  | 237 +++---
 2 files changed, 140 insertions(+), 107 deletions(-)

diff --git a/README.md b/README.md
index faf2dea..66f2131 100644
--- a/README.md
+++ b/README.md
@@ -111,19 +111,21 @@ User-visible differences:
 - Automatically restarts frequently crashing servers (like RLS).
 - Server-initiated edits are confirmed with the user.
 - Diagnostics work out-of-the-box (no `flycheck.el` needed).
+- Smoother/more responsive (read below).

 Under the hood:
 
 - Message parser is much much simpler.
-- Easier to read and maintain elisp. Yeah I know, *extremely
-  subjective*, so judge for yourself.
+- Defers signature requests like `textDocument/hover` until server is
+  ready. Also sends `textDocument/didChange` for groups of edits, not
+  one per each tiny change.
+- Easier to read and maintain elisp. Yeah I know, *very subjective*,
+  so judge for yourself.
 - About 1k LOC lighter.
 - Development doesn't require Cask, just Emacs.
 - Project support doesn't need `projectile.el`, uses Emacs's `project.el`
 - Requires the upcoming Emacs 26
 - Contained in one file
-- Sends `textDocument/didChange` for groups of edits, not one per each
-  tiny change.
 - Its missing tests! This is *not good*
 
 [lsp]: https://microsoft.github.io/language-server-protocol/
diff --git a/eglot.el b/eglot.el
index d5eae03..9a0b824 100644
--- a/eglot.el
+++ b/eglot.el
@@ -135,6 +135,10 @@ A list (WHAT SERIOUS-P)." t)
 Either a list of strings (a shell command and arguments), or a
 list of a single string of the form :")
 
+(eglot--define-process-var eglot--deferred-actions
+(make-hash-table :test #'equal)
+  "Actions deferred to when server is thought to be ready.")
+
 (defun eglot--make-process (name managed-major-mode contact)
   "Make a process from CONTACT.
 NAME is a name to give the inferior process or connection.
@@ -442,7 +446,8 @@ INTERACTIVE is t if called interactively."
   (throw done 
:waiting-for-more-bytes-in-this-message
   ;; Saved parsing state for next visit to this filter
   ;;
-  (setf (eglot--expected-bytes proc) expected-bytes))
+  (setf (eglot--expected-bytes proc) expected-bytes
+(eglot--call-deferred proc)))
 
 (defun eglot-events-buffer (process &optional interactive)
   "Display events buffer for current LSP connection PROCESS.
@@ -549,110 +554,118 @@ is a symbol saying if this is a client or server 
originated."
   (interactive (list (eglot--current-process-or-lose)))
   (setf (eglot--status process) nil))
 
-(cl-defun eglot--request (process
-  method
-  params
-  &key success-fn error-fn timeout-fn (async-p t)
-  (timeout eglot-request-timeout))
-  "Make a request to PROCESS, expecting a reply.
-Return the ID of this request, unless ASYNC-P is nil, in which
-case never returns locally.  Wait TIMEOUT seconds for a
-response."
-  (let* ((id (eglot--next-request-id))
- (timeout-fn (or timeout-fn
- (lambda ()
-   (eglot--warn
-"(request) Tired of waiting for reply to %s" id
- (error-fn (or error-fn
-   (cl-function
-(lambda (&key code message &allow-other-keys)
-  (setf (eglot--status process) `(,message t))
-  (eglot--warn
-   "(request) Request id=%s errore

[elpa] externals/elpa bbc64b4 087/139: Clean up client capabilities

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit bbc64b4530734f7837d050094b755706cd34aadd
Author: João Távora 
Commit: João Távora 

Clean up client capabilities

* eglot.el (eglot--client-capabilities): Clean up client
capabilities.
---
 eglot.el | 21 -
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/eglot.el b/eglot.el
index 2c97f2f..8e92725 100644
--- a/eglot.el
+++ b/eglot.el
@@ -215,23 +215,10 @@ CONTACT is as `eglot--contact'.  Returns a process 
object."
 :willSave t
 :willSaveWaitUntil :json-false
 :didSave t)
-  :completion nil
-  :hover nil
-  :signatureHelp nil
-  :references nil
-  :documentHighlight nil
-  :documentSymbol nil
-  :formatting nil
-  :rangeFormatting nil
-  :onTypeFormatting nil
-  :definition nil
-  :typeDefinition nil
-  :implementation nil
-  :codeAction nil
-  :codeLens nil
-  :documentLink nil
-  :colorProvider nil
-  :rename nil
+  :completion `(:dynamicRegistration :json-false)
+  :hover  `(:dynamicRegistration :json-false)
+  :references `(:dynamicRegistration :json-false)
+  :definition `(:dynamicRegistration :json-false)
   :publishDiagnostics `(:relatedInformation :json-false))
:experimental (eglot--obj)))
 



[elpa] externals/elpa 7c82a03 024/139: Start experimenting with python

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 7c82a033d690d587fe39c088d9aef67c005ae270
Author: João Távora 
Commit: João Távora 

Start experimenting with python

* eglot.el (eglot-executables): Add pyls.
---
 eglot.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 22ff031..ff71a2f 100644
--- a/eglot.el
+++ b/eglot.el
@@ -37,7 +37,8 @@
   :prefix "eglot-"
   :group 'applications)
 
-(defvar eglot-executables '((rust-mode . ("rls")))
+(defvar eglot-executables '((rust-mode . ("rls"))
+(python-mode . ("pyls")))
   "Alist mapping major modes to server executables.")
 
 (defvar eglot--processes-by-project (make-hash-table :test #'equal))



[elpa] externals/elpa 1fb2bcb 132/139: Ask server for textDocument/signatureHelp if it supports it

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 1fb2bcbde95d89edd9df638869d679e42b416b4c
Author: João Távora 
Commit: João Távora 

Ask server for textDocument/signatureHelp if it supports it

* eglot.el (eglot--client-capabilities): Capable of signature Help.
(eglot--sig-info): Helper for eglot-eldoc-function.
(eglot-eldoc-function): Send textDocument/signatureHelp

* README.md: Update to mention textDocument/signatureHelp
---
 README.md |  2 +-
 eglot.el  | 97 ---
 2 files changed, 69 insertions(+), 30 deletions(-)

diff --git a/README.md b/README.md
index 4dfe0a6..39ec752 100644
--- a/README.md
+++ b/README.md
@@ -103,7 +103,7 @@ either:
 - [x] textDocument/completion
 - [x] completionItem/resolve (works quite well with 
[company-mode][company-mode])
 - [x] textDocument/hover
-- [ ] textDocument/signatureHelp
+- [x] textDocument/signatureHelp (fancy stuff with Python's [pyls[pyls]])
 - [x] textDocument/definition
 - [ ] textDocument/typeDefinition (3.6.0)
 - [ ] textDocument/implementation (3.6.0)
diff --git a/eglot.el b/eglot.el
index f6eabe1..2e872dc 100644
--- a/eglot.el
+++ b/eglot.el
@@ -211,6 +211,7 @@ CONTACT is as `eglot--contact'.  Returns a process object."
 :didSave t)
   :completion `(:dynamicRegistration :json-false)
   :hover  `(:dynamicRegistration :json-false)
+  :signatureHelp  `(:dynamicRegistration :json-false)
   :references `(:dynamicRegistration :json-false)
   :definition `(:dynamicRegistration :json-false)
   :documentSymbol `(:dynamicRegistration :json-false)
@@ -1330,6 +1331,28 @@ DUMMY is ignored"
 (contents
  (list contents "\n")))
 
+(defun eglot--sig-info (sigs active-sig active-param)
+  (cl-loop
+   for (sig . moresigs) on (append sigs nil) for i from 0
+   concat (cl-destructuring-bind (&key label _documentation parameters) sig
+(let (active-doc)
+  (concat
+   (propertize (replace-regexp-in-string "(.*$" "(" label)
+   'face 'font-lock-function-name-face)
+   (cl-loop
+for (param . moreparams) on (append parameters nil) for j from 0
+concat (cl-destructuring-bind (&key label documentation) param
+ (when (and (eql j active-param) (eql i active-sig))
+   (setq label (propertize
+label
+'face 
'eldoc-highlight-function-argument))
+   (when documentation
+ (setq active-doc (concat label ": " 
documentation
+ label)
+if moreparams concat ", " else concat ")")
+   (when active-doc (concat "\n" active-doc)
+   when moresigs concat "\n"))
+
 (defun eglot-help-at-point ()
   "Request \"hover\" information for the thing at point."
   (interactive)
@@ -1342,35 +1365,51 @@ DUMMY is ignored"
 (insert (eglot--hover-info contents range))
 
 (defun eglot-eldoc-function ()
-  "EGLOT's `eldoc-documentation-function' function."
-  (let ((buffer (current-buffer))
-(proc (eglot--current-process-or-lose))
-(position-params (eglot--TextDocumentPositionParams)))
-(when (eglot--server-capable :hoverProvider)
-  (eglot--async-request
-   proc :textDocument/hover position-params
-   :success-fn (eglot--lambda (&key contents range)
- (when (get-buffer-window buffer)
-   (with-current-buffer buffer
- (eldoc-message (eglot--hover-info contents range)
-   :deferred :textDocument/hover))
-(when (eglot--server-capable :documentHighlightProvider)
-  (eglot--async-request
-   proc :textDocument/documentHighlight position-params
-   :success-fn (lambda (highlights)
- (mapc #'delete-overlay eglot--highlights)
- (setq eglot--highlights
-   (when (get-buffer-window buffer)
- (with-current-buffer buffer
-   (eglot--mapply
-(eglot--lambda (&key range _kind)
-  (eglot--with-lsp-range (beg end) range
-(let ((ov (make-overlay beg end)))
-  (overlay-put ov 'face 'highlight)
-  (overlay-put ov 'evaporate t)
-  ov)))
-highlights)
-   :deferred :textDocument/documentHighlight)))
+  "EGLOT's `eldoc-documentation-function' function.
+If SKIP-SIGNATURE, don't try to send textDocument/sign

[elpa] externals/elpa 41f5922 137/139: Now send willSaveWaitUntil

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 41f5922c1b396c54b1ff2e74ed804328f361c9df
Author: João Távora 
Commit: João Távora 

Now send willSaveWaitUntil

* eglot.el (eglot--client-capabilities): Report willSaveWaitUntil.
(eglot--server-workspace/applyEdit): Fix docstring.
(eglot--signal-textDocument/willSave): Send willSaveWaitUntil
(eglot--signal-textDocument/didOpen)
(eglot--signal-textDocument/didClose): Don't eglot--obj.
(eglot--apply-text-edits): Simplify. Use current buffer.
(eglot--apply-workspace-edit): Use new eglot--apply-text-edits.
---
 README.md |  6 +++---
 eglot.el  | 70 ++-
 2 files changed, 36 insertions(+), 40 deletions(-)

diff --git a/README.md b/README.md
index e5a2394..056065c 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ either:
 (define-key eglot-mode-map (kbd "") 'xref-find-definitions)
 ```
 
-# Supported Protocol features
+# Supported Protocol features (3.6)
 
 ## General
 - [x] initialize
@@ -85,14 +85,14 @@ either:
 - [ ] workspace/didChangeConfiguration
 - [ ] workspace/configuration (3.6.0)
 - [ ] workspace/didChangeWatchedFiles
-- [x] workspace/symbol
+- [x] workspace/symbol is
 - [x] workspace/applyEdit
 
 ## Text Synchronization
 - [x] textDocument/didOpen
 - [x] textDocument/didChange (incremental or full)
 - [x] textDocument/willSave
-- [ ] textDocument/willSaveWaitUntil
+- [x] textDocument/willSaveWaitUntil
 - [x] textDocument/didSave
 - [x] textDocument/didClose
 
diff --git a/eglot.el b/eglot.el
index 6dc2213..eab7ce7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -203,9 +203,7 @@ CONTACT is as `eglot--contact'.  Returns a process object."
:textDocument (eglot--obj
   :synchronization (eglot--obj
 :dynamicRegistration :json-false
-:willSave t
-:willSaveWaitUntil :json-false
-:didSave t)
+:willSave t :willSaveWaitUntil t :didSave 
t)
   :completion `(:dynamicRegistration :json-false)
   :hover  `(:dynamicRegistration :json-false)
   :signatureHelp  `(:dynamicRegistration :json-false)
@@ -1023,7 +1021,7 @@ called interactively."
 
 (cl-defun eglot--server-workspace/applyEdit
 (proc &key id _label edit)
-  "Handle notification client/registerCapability"
+  "Handle server request workspace/applyEdit"
   (condition-case err
   (progn
 (eglot--apply-workspace-edit edit 'confirm)
@@ -1127,26 +1125,27 @@ Records START, END and PRE-CHANGE-LENGTH locally."
 (defun eglot--signal-textDocument/didOpen ()
   "Send textDocument/didOpen to server."
   (setq eglot--recent-changes (cons [] []))
-  (eglot--notify (eglot--current-process-or-lose)
- :textDocument/didOpen
- (eglot--obj :textDocument
- (eglot--TextDocumentItem
+  (eglot--notify
+   (eglot--current-process-or-lose)
+   :textDocument/didOpen `(:textDocument ,(eglot--TextDocumentItem
 
 (defun eglot--signal-textDocument/didClose ()
   "Send textDocument/didClose to server."
-  (eglot--notify (eglot--current-process-or-lose)
- :textDocument/didClose
- (eglot--obj :textDocument
- (eglot--TextDocumentIdentifier
+  (eglot--notify
+   (eglot--current-process-or-lose)
+   :textDocument/didClose `(:textDocument ,(eglot--TextDocumentIdentifier
 
 (defun eglot--signal-textDocument/willSave ()
   "Send textDocument/willSave to server."
-  (eglot--notify
-   (eglot--current-process-or-lose)
-   :textDocument/willSave
-   (eglot--obj
-:reason 1 ; Manual, emacs laughs in the face of auto-save muahahahaha
-:textDocument (eglot--TextDocumentIdentifier
+  (let ((proc (eglot--current-process-or-lose))
+(params `(:reason 1 :textDocument ,(eglot--TextDocumentIdentifier
+(eglot--notify proc :textDocument/willSave params)
+(ignore-errors
+  (let ((eglot-request-timeout 0.5))
+(when (plist-get :willSaveWaitUntil
+ (eglot--server-capable :textDocumentSync))
+  (eglot--apply-text-edits
+   (eglot--request proc :textDocument/willSaveWaituntil params)))
 
 (defun eglot--signal-textDocument/didSave ()
   "Send textDocument/didSave to server."
@@ -1426,22 +1425,20 @@ If SKIP-SIGNATURE, don't try to send 
textDocument/signatureHelp."
  entries))
 (funcall oldfun)))
 
-(defun eglot--apply-text-edits (buffer edits &optional version)
-  "Apply the EDITS for BUFFER."
-  (with-current-buffer buffer
-(unless (or (not version)
-(equal version eglot--versioned-identifier))
-  (eglot--error "Edits on `%s' require version %d, you have %d"
-buffer version eglot--versioned-identifier))
-(eglot--mapply
- (eglot--

[elpa] externals/elpa a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose'

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit a4f99e09d3a4eaafb1d59875f0d314549a104137
Author: João Távora 
Commit: João Távora 

Introduce and use `eglot--current-process-or-lose'
---
 eglot.el | 83 +++-
 1 file changed, 45 insertions(+), 38 deletions(-)

diff --git a/eglot.el b/eglot.el
index 92c1216..5ca6833 100644
--- a/eglot.el
+++ b/eglot.el
@@ -45,12 +45,16 @@
   (eglot--error "No current project, so no process"))
 (gethash cur eglot--processes-by-project)))
 
+(defun eglot--current-process-or-lose ()
+  (or (eglot--current-process)
+  (eglot--error "No current EGLOT process")))
+
 (defmacro eglot--define-process-var (var-sym initval &optional doc)
   (declare (indent 2))
   `(progn
  (put ',var-sym 'function-documentation ,doc)
  (defun ,var-sym (&optional process)
-   (let* ((proc (or process (eglot--current-process)))
+   (let* ((proc (or process (eglot--current-process-or-lose)))
   (probe (process-get proc ',var-sym)))
  (or probe
  (let ((def ,initval))
@@ -58,7 +62,7 @@
def
  (gv-define-setter ,var-sym (to-store &optional process)
(let ((prop ',var-sym))
- `(let ((proc (or ,process (eglot--current-process
+ `(let ((proc (or ,process (eglot--current-process-or-lose
 (process-put proc ',prop ,to-store))
 
 (eglot--define-process-var eglot--message-mark nil
@@ -103,7 +107,7 @@
 major-mode))
 probe))
 
-(defun eglot-new-process (&optional _interactive)
+(defun eglot-new-process (&optional interactive)
   "Starts a new EGLOT process and initializes it"
   (interactive (list t))
   (let ((project (project-current))
@@ -141,10 +145,10 @@
 (let ((inhibit-read-only t))
   (insert
(format "\n---\n"
-  (eglot--protocol-initialize proc))
+  (eglot--protocol-initialize proc interactive))
 
 (defun eglot-quit-server (process &optional sync)
-  (interactive (list (eglot--current-process)))
+  (interactive (list (eglot--current-process-or-lose)))
   (eglot--message "Asking server to terminate")
   (eglot--request
   process
@@ -238,7 +242,7 @@
  )))
 
 (defun eglot-events-buffer (process &optional interactive)
-  (interactive (list (eglot--current-process) t))
+  (interactive (list (eglot--current-process-or-lose) t))
   (let* ((probe (eglot--events-buffer process))
  (buffer (or (and (buffer-live-p probe)
   probe)
@@ -302,7 +306,7 @@
   (setq eglot--next-request-id (1+ eglot--next-request-id)))
 
 (defun eglot-forget-pending-continuations (process)
-  (interactive (eglot--current-process))
+  (interactive (eglot--current-process-or-lose))
   (clrhash (eglot--pending-continuations process)))
 
 (defun eglot--call-with-request (process
@@ -350,38 +354,41 @@
   (accept-process-output nil 0.01))
 
 
-(defun eglot--protocol-initialize (process)
+(defun eglot--protocol-initialize (process interactive)
   (eglot--request
-process
-:initialize
-`(:processId  ,(emacs-pid)
-  :rootPath  ,(concat "" ;; FIXME RLS doesn't like "file://"
-  (expand-file-name (car (project-roots
-  
(project-current)
-  :initializationOptions  []
-  :capabilities (:workspace (:executeCommand 
(:dynamicRegistration t))
-:textDocument (:synchronization 
(:didSave t)))
-  )
-(lambda (&key capabilities)
-  (cl-destructuring-bind
-  (&rest all
- &key
- _textDocumentSync
- _hoverProvider
- _completionProvider
- _definitionProvider
- _referencesProvider
- _documentHighlightProvider
- _documentSymbolProvider
- _workspaceSymbolProvider
- _codeActionProvider
- _documentFormattingProvider
- _documentRangeFormattingProvider
- _renameProvider
- _executeCommandProvider
- )
-  capabilities
-(message "so yeah I got lots (%d) of capabilities" (length all))
+   process
+   :initialize
+   `(:processId  ,(emacs-pid)
+ :rootPath  ,(concat "" ;; FIXME RLS doesn't like "file://"
+ (expand-file-name (car (project-roots
+ 
(project-current)
+ :initializationOptions  []
+ :capabilities (:workspace (:executeCommand 
(:dynamicRegistration t))
+   :textDocument (:synchronization 
(:didSave t
+   (lambda (&key capabilities

[elpa] externals/elpa 6f6f01d 018/139: Doc fixes

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 6f6f01d15ee5558bf951181b1f872154dd405aae
Author: João Távora 
Commit: João Távora 

Doc fixes

* eglot.el (eglot-mode-map): Move up before minor mode.
---
 eglot.el | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8356f8e..9e5f6c2 100644
--- a/eglot.el
+++ b/eglot.el
@@ -36,12 +36,12 @@
   :group 'applications)
 
 (defvar eglot-executables '((rust-mode . ("rls")))
-  "Alist mapping major modes to server executables")
+  "Alist mapping major modes to server executables.")
 
 (defvar eglot--processes-by-project (make-hash-table :test #'equal))
 
 (defun eglot--current-process ()
-  "The current logical EGLOT process"
+  "The current logical EGLOT process."
   (let ((cur (project-current)))
 (and cur
  (gethash cur eglot--processes-by-project
@@ -98,7 +98,8 @@
 probe))
 
 (defun eglot-new-process (&optional interactive)
-  "Starts a new EGLOT process and initializes it"
+  "Start a new EGLOT process and initialize it.
+INTERACTIVE is t if called interactively."
   (interactive (list t))
   (let ((project (project-current))
 (command (eglot--command 'errorp)))
@@ -226,12 +227,14 @@
  )))
 
 (defmacro eglot--obj (&rest what)
-  "Make an object suitable for `json-encode'"
+  "Make WHAT a suitable argument for `json-encode'."
   ;; FIXME: maybe later actually do something, for now this just fixes
   ;; the indenting of literal plists.
   `(list ,@what))
 
 (defun eglot-events-buffer (process &optional interactive)
+  "Display events buffer for current LSP connection PROCESS.
+INTERACTIVE is t if called interactively."
   (interactive (list (eglot--current-process-or-lose) t))
   (let* ((probe (eglot--events-buffer process))
  (buffer (or (and (buffer-live-p probe)
@@ -264,7 +267,7 @@
   "A list of variables with saved values on every request.")
 
 (defvar eglot--environment nil
-  "Dynamically bound alist of symbol and values")
+  "Dynamically bound alist of symbol and values.")
 
 (defun eglot--process-receive (proc message)
   "Process MESSAGE from PROC."
@@ -325,6 +328,7 @@
   (setq eglot--next-request-id (1+ eglot--next-request-id)))
 
 (defun eglot-forget-pending-continuations (process)
+  "Stop waiting for responses from the current LSP PROCESS."
   (interactive (eglot--current-process-or-lose))
   (clrhash (eglot--pending-continuations process)))
 
@@ -641,7 +645,7 @@ running.  INTERACTIVE is t if called interactively."
(" [" eglot--mode-line-format "] ")))
 
 (defvar eglot--recent-changes nil
-  "List of recent changes as collected by `eglot--after-change'")
+  "List of recent changes as collected by `eglot--after-change'.")
 
 (defvar-local eglot--versioned-identifier 0)
 



[elpa] externals/eglot c222c3b 019/139: Lay groundwork for uniform treatment of network connections

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit c222c3bc547ad03764385b2d651297e7c45926dd
Author: João Távora 
Commit: João Távora 

Lay groundwork for uniform treatment of network connections

* eglot.el (eglot--connect): New helper.
(eglot-new-process): Use it.
(pcase): Require it.
---
 eglot.el | 62 --
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/eglot.el b/eglot.el
index 9e5f6c2..cd213e7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -29,6 +29,7 @@
 (require 'project)
 (require 'url-parse)
 (require 'url-util)
+(require 'pcase)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -97,12 +98,27 @@
 major-mode))
 probe))
 
+(defun eglot--connect (name filter sentinel)
+  "Helper for `eglot-new-process'.
+NAME is a name to give the inferior process or connection.
+FILTER and SENTINEL are filter and sentinel.
+Should return a list of (PROCESS BUFFER)."
+  (let ((proc (make-process :name name
+:buffer (get-buffer-create
+ (format "*%s inferior*" name))
+:command (eglot--command 'error)
+:connection-type 'pipe
+:filter filter
+:sentinel sentinel
+:stderr (get-buffer-create (format "*%s stderr*"
+   name)
+(list proc (process-buffer proc
+
 (defun eglot-new-process (&optional interactive)
   "Start a new EGLOT process and initialize it.
 INTERACTIVE is t if called interactively."
   (interactive (list t))
-  (let ((project (project-current))
-(command (eglot--command 'errorp)))
+  (let ((project (project-current)))
 (unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
 (let ((current-process (eglot--current-process)))
   (when (and current-process
@@ -114,30 +130,24 @@ INTERACTIVE is t if called interactively."
  (car (project-roots (project-current))
(good-name
 (format "EGLOT server (%s)" short-name)))
-  (with-current-buffer (get-buffer-create
-(format "*%s inferior*" good-name))
-(let* ((proc
-(make-process :name good-name
-  :buffer (current-buffer)
-  :command command
-  :connection-type 'pipe
-  :filter 'eglot--process-filter
-  :sentinel 'eglot--process-sentinel
-  :stderr (get-buffer-create (format "*%s stderr*"
- good-name
-   (inhibit-read-only t))
-  (setf (eglot--short-name proc) short-name)
-  (puthash (project-current) proc eglot--processes-by-project)
-  (erase-buffer)
-  (let ((marker (point-marker)))
-(set-marker-insertion-type marker nil)
-(setf (eglot--message-mark proc) marker))
-  (read-only-mode t)
-  (with-current-buffer (eglot-events-buffer proc)
-(let ((inhibit-read-only t))
-  (insert
-   (format "\n---\n"
-  (eglot--protocol-initialize proc interactive))
+  (pcase-let ((`(,proc ,buffer)
+   (eglot--connect good-name
+   'eglot--process-filter
+   'eglot--process-sentinel)))
+(with-current-buffer buffer
+  (let ((inhibit-read-only t))
+(setf (eglot--short-name proc) short-name)
+(puthash (project-current) proc eglot--processes-by-project)
+(erase-buffer)
+(let ((marker (point-marker)))
+  (set-marker-insertion-type marker nil)
+  (setf (eglot--message-mark proc) marker))
+(read-only-mode t)
+(with-current-buffer (eglot-events-buffer proc)
+  (let ((inhibit-read-only t))
+(insert
+ (format "\n---\n"
+(eglot--protocol-initialize proc interactive)))
 
 (defun eglot--process-sentinel (process change)
   (with-current-buffer (process-buffer process)



[elpa] externals/elpa 589e1ea 138/139: Remove an unused variable

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 589e1ea7a38c765ede6f3c17dae76d0502e96290
Author: João Távora 
Commit: João Távora 

Remove an unused variable

* eglot.el (eglot--expect-carriage-return): Get rid of this.
---
 eglot.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index eab7ce7..9b0f290 100644
--- a/eglot.el
+++ b/eglot.el
@@ -532,8 +532,6 @@ is a symbol saying if this is a client or server 
originated."
   (eglot--call-deferred proc)
   (force-mode-line-update t
 
-(defvar eglot--expect-carriage-return nil)
-
 (defun eglot--process-send (proc message)
   "Send MESSAGE to PROC (ID is optional)."
   (let ((json (json-encode message)))
@@ -542,7 +540,7 @@ is a symbol saying if this is a client or server 
originated."
   json))
 (eglot--log-event proc message 'client)))
 
-(defvar eglot--next-request-id 0)
+(defvar eglot--next-request-id 0 "ID for next request.")
 
 (defun eglot--next-request-id ()
   "Compute the next id for a client request."



[elpa] externals/elpa d90efdf 001/139: Initial commit

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit d90efdf04024eab75f189790cd38678a7cad3b43
Author: João Távora 
Commit: João Távora 

Initial commit
---
 .gitignore |  40 
 LICENSE| 674 +
 README.md  |  13 ++
 eglot.el   | 393 +++
 4 files changed, 1120 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..0a94baa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+ChangeLog
+*.x86f
+*.fasl*
+*.dfsl
+*.lx64fsl
+*.dx64fsl
+*.elc
+*.cls
+*~
+\#*\#
+.\#*
+.DS_Store
+# for the doc
+#
+doc/*.html
+doc/html
+doc/contributors.texi
+doc/*.info
+doc/*.pdf
+doc/*.ps
+doc/*.dvi
+doc/*.aux
+doc/*.cp
+doc/*.cps
+doc/*.fn
+doc/*.fns
+doc/*.ky
+doc/*.kys
+doc/*.log
+doc/*.pg
+doc/*.toc
+doc/*.tp
+doc/*.vr
+doc/*.op
+doc/*.ops
+doc/*.pgs
+doc/*.vrs
+doc/*.tgz
+doc/gh-pages
+/dist/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000..9cecc1d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+   TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any

[elpa] externals/elpa 46bb1c0 049/139: Reorganize file

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 46bb1c0e38e8f437f5ea490562413d0c51c0219b
Author: João Távora 
Commit: João Távora 

Reorganize file

* eglot.el (eglot-mode-line): Move up.
(eglot-make-local-process, eglot--all-major-modes, eglot--obj)
(eglot--project-short-name, eglot--all-major-modes)
(eglot-reconnect, eglot--maybe-activate-editing-mode)
(eglot--protocol-initialize)
(eglot--window/showMessage, eglot--current-flymake-report-fn)
(eglot--unreported-diagnostics)
(eglot--textDocument/publishDiagnostics, eglot--signalDidOpen)
(eglot--signalDidClose): Move around.
(eglot-quit-server): Renamed to eglot-shutdown.
(eglot-shutdown): New function
---
 eglot.el | 391 ---
 1 file changed, 198 insertions(+), 193 deletions(-)

diff --git a/eglot.el b/eglot.el
index f25c7bd..7d44e6d 100644
--- a/eglot.el
+++ b/eglot.el
@@ -34,6 +34,8 @@
 (require 'warnings)
 (require 'flymake)
 
+
+;;; User tweakable stuff
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
   :prefix "eglot-"
@@ -43,6 +45,13 @@
 (python-mode . ("pyls")))
   "Alist mapping major modes to server executables.")
 
+(defface eglot-mode-line
+  '((t (:inherit font-lock-constant-face :weight bold)))
+  "Face for package-name in EGLOT's mode line."
+  :group 'eglot)
+
+
+;;; Process management
 (defvar eglot--processes-by-project (make-hash-table :test #'equal)
   "Keys are projects.  Values are lists of processes.")
 
@@ -129,20 +138,6 @@ A list (WHAT SERIOUS-P)." t)
 Must be a function of one arg, a name, returning a process
 object.")
 
-(defun eglot--project-short-name (project)
-  "Give PROJECT a short name."
-  (file-name-base
-   (directory-file-name
-(car (project-roots project)
-
-(defun eglot--all-major-modes ()
-  "Return all know major modes."
-  (let ((retval))
-(mapatoms (lambda (sym)
-(when (plist-member (symbol-plist sym) 'derived-mode-parent)
-  (push sym retval
-retval))
-
 (defun eglot-make-local-process (name command)
   "Make a local LSP process from COMMAND.
 NAME is a name to give the inferior process or connection.
@@ -161,6 +156,26 @@ Returns a process object."
   name)
 proc))
 
+(defmacro eglot--obj (&rest what)
+  "Make WHAT a suitable argument for `json-encode'."
+  ;; FIXME: maybe later actually do something, for now this just fixes
+  ;; the indenting of literal plists.
+  `(list ,@what))
+
+(defun eglot--project-short-name (project)
+  "Give PROJECT a short name."
+  (file-name-base
+   (directory-file-name
+(car (project-roots project)
+
+(defun eglot--all-major-modes ()
+  "Return all know major modes."
+  (let ((retval))
+(mapatoms (lambda (sym)
+(when (plist-member (symbol-plist sym) 'derived-mode-parent)
+  (push sym retval
+retval))
+
 (defun eglot--connect (project managed-major-mode
short-name bootstrap-fn &optional success-fn)
   "Make a connection for PROJECT, SHORT-NAME and MANAGED-MAJOR-MODE.
@@ -191,23 +206,6 @@ SUCCESS-FN with no args if all goes well."
 (setf (eglot--status proc) nil)
 (when success-fn (funcall success-fn proc)
 
-(defun eglot-reconnect (process &optional interactive)
-  "Reconnect to PROCESS.
-INTERACTIVE is t if called interactively."
-  (interactive (list (eglot--current-process-or-lose) t))
-  (when (process-live-p process)
-(eglot-quit-server process 'sync interactive))
-  (eglot--connect
-   (eglot--project process)
-   (eglot--major-mode process)
-   (eglot--short-name process)
-   (eglot--bootstrap-fn process)
-   (lambda (proc)
- (eglot--message "Reconnected!")
- (dolist (buffer (buffer-list))
-   (with-current-buffer buffer
- (eglot--maybe-activate-editing-mode proc))
-
 (defvar eglot--command-history nil
   "History of COMMAND arguments to `eglot'.")
 
@@ -285,6 +283,23 @@ buffers in project %s."
  (with-current-buffer buffer
(eglot--maybe-activate-editing-mode proc))
 
+(defun eglot-reconnect (process &optional interactive)
+  "Reconnect to PROCESS.
+INTERACTIVE is t if called interactively."
+  (interactive (list (eglot--current-process-or-lose) t))
+  (when (process-live-p process)
+(eglot-shutdown process 'sync interactive))
+  (eglot--connect
+   (eglot--project process)
+   (eglot--major-mode process)
+   (eglot--short-name process)
+   (eglot--bootstrap-fn process)
+   (lambda (proc)
+ (eglot--message "Reconnected!")
+ (dolist (buffer (buffer-list))
+   (with-current-buffer buffer
+ (eglot--maybe-activate-editing-mode proc))
+
 (defun eglot--process-sentinel (process change)
   "Called with PROCESS undergoes CHANGE."
   (eglot--debug "(sentinel) Process state changed to %s" change)
@@ -370,12 +385,6 @@ buffers 

[elpa] externals/elpa 8448d9b 133/139: Work with any old directory, no formal project needed

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 8448d9b03b2813971093fd8420e739ee0b1856dd
Author: João Távora 
Commit: João Távora 

Work with any old directory, no formal project needed

Actually, uses a "transient project" which project-current returns if
desperate.

* README.md: Update

* eglot.el (eglot--current-process)
(eglot--current-process-or-lose): Simplify.
(eglot): Maybe prompt user for project.
---
 README.md | 10 +-
 eglot.el  | 18 ++
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/README.md b/README.md
index 39ec752..4683951 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,12 @@ Eglot
 (add-to-list 'load-path "/path/to/eglot")
 (require 'eglot) ; Requires emacs 26!
 
-;; Now find some project file inside some Git-controlled dir
+;; Now find some source file, any source file
 M-x eglot
 ```
 
 *That's it*. If you're lucky, this guesses the LSP executable to start
-for the language of your choice, or it prompts you to enter one:
+for the language of your choice. Otherwise, it prompts you to enter one:
 
 `M-x eglot` currently guesses and works out-of-the-box with:
 
@@ -29,9 +29,9 @@ customize `eglot-server-programs`:
 (add-to-list 'eglot-server-programs '(fancy-mode . ("fancy-language-server" 
"--args"")))
 ```
 
-Let me know how well it works and I'll add it to the list, or submit a
-PR.  You can also enter a `server:port` pattern to connect to an LSP
-server. To skip the guess and always be prompted use `C-u M-x eglot`.
+Let me know how well it works and we can add it to the list.  You can
+also enter a `server:port` pattern to connect to an LSP server. To
+skip the guess and always be prompted use `C-u M-x eglot`.
 
 # Commands and keybindings
 
diff --git a/eglot.el b/eglot.el
index 2e872dc..c1b63ea 100644
--- a/eglot.el
+++ b/eglot.el
@@ -24,8 +24,7 @@
 
 ;;; Commentary:
 
-;; M-x eglot in some file under some .git controlled dir should get
-;; you started, but see README.md.
+;; Simply M-x eglot should be enough to get you started, but see README.md.
 
 ;;; Code:
 
@@ -79,15 +78,13 @@ lasted more than that many seconds."
 
 (defun eglot--current-process ()
   "The current logical EGLOT process."
-  (let* ((cur (project-current))
- (processes (and cur (gethash cur eglot--processes-by-project
-(cl-find major-mode processes :key #'eglot--major-mode)))
+  (let* ((probe (or (project-current) (cons 'transient default-directory
+(cl-find major-mode (gethash probe eglot--processes-by-project)
+ :key #'eglot--major-mode)))
 
 (defun eglot--current-process-or-lose ()
   "Return the current EGLOT process or error."
-  (or (eglot--current-process)
-  (eglot--error "No current EGLOT process%s"
-(if (project-current) "" " (Also no current project)"
+  (or (eglot--current-process) (eglot--error "No current EGLOT process")))
 
 (defmacro eglot--define-process-var
 (var-sym initval &optional doc)
@@ -326,11 +323,8 @@ MANAGED-MAJOR-MODE.
 
 INTERACTIVE is t if called interactively."
   (interactive (eglot--interactive))
-  (let* ((project (project-current))
+  (let* ((project (project-current 'maybe))
  (short-name (eglot--project-short-name project)))
-(unless project (eglot--error "Cannot work without a current project!"))
-(unless command (eglot--error "Don't know how to start EGLOT for %s 
buffers"
-  major-mode))
 (let ((current-process (eglot--current-process)))
   (if (and (process-live-p current-process)
interactive



[elpa] externals/elpa d1cdcf1 119/139: Friendlier M-x eglot

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit d1cdcf163849ca1a7bfcbc3287f4e2c28cae77af
Author: João Távora 
Commit: João Távora 

Friendlier M-x eglot

* eglot.el (eglot-server-programs): Renamed from eglot-executables
(eglot--interactive): Redesign
(eglot): Docstring.
(eglot--connect): Now a synchronous gig.
(eglot--interactive): Friendlier.
(eglot): Improve docstring, rework a bit.
(eglot-reconnect): Rework a bit.
(eglot--process-sentinel): Insert "byebye" ruler here.

* README.md: Update
---
 README.md |  39 ++---
 eglot.el  | 140 +++---
 2 files changed, 94 insertions(+), 85 deletions(-)

diff --git a/README.md b/README.md
index 66f2131..c2931be 100644
--- a/README.md
+++ b/README.md
@@ -12,17 +12,25 @@ Eglot
 M-x eglot
 ```
 
-*That's it*. Either this guesses the LSP executable to start for the
-language of your choice, or it prompts you to enter the program.
+*That's it*. If you're lucky, this guesses the LSP executable to start
+for the language of your choice, or it prompts you to enter one:
 
-If you have these programs installed, `M-x eglot` works out-of-the-box
-with:
+`M-x eglot` currently guesses and works out-of-the-box with:
 
 * Javascript's [javascript-typescript-stdio][javascript-typescript-langserver]
 * Rust's [rls][rls]
 * Python's [pyls][pyls]
+* Bash's [bash-language-server][bash-language-server]
 
-You can also enter a `server:port` pattern to connect to an LSP
+I'll add more as I test more features. In the meantime you can
+customize `eglot-server-programs`:
+
+```lisp
+(add-to-list 'eglot-server-programs '(fancy-mode . ("fancy-language-server" 
"--args"")))
+```
+
+Let me know how well it works and I'll add it to the list, or submit a
+PR.  You can also enter a `server:port` pattern to connect to an LSP
 server. To skip the guess and always be prompted use `C-u M-x eglot`.
 
 # Supported Protocol features
@@ -89,21 +97,22 @@ server. To skip the guess and always be prompted use `C-u 
M-x eglot`.
 
 # Differences to lsp-mode.el
 
-Eglot is **really beta** and may currently underperform
-[lsp-mode.el][emacs-lsp], which is more mature and has a host of
-[plugins][emacs-lsp-plugins] for bells and whistles.  If you think the 
minimalist approach
-of `eglot.el` is not for you, you could be better served with
-`lsp-mode.el` for now.
+Eglot is **beta**. It may currently underperform
+[lsp-mode.el][emacs-lsp], both in functionality and correctness. That
+other extension is much more mature and has a host of
+[plugins][emacs-lsp-plugins] for bells and whistles.  If you don't
+like the minimalist approach of `eglot.el`, you could be better served
+with `lsp-mode.el` for now.
 
 User-visible differences:
 
-- Single entry point `M-x eglot`, not `M-x eglot-`. Also no
-  `eglot-` extra packages.
+- Single and friendly entry point `M-x eglot`, not `M-x
+  eglot-`. Also no `eglot-` extra packages.
 - No "whitelisting" or "blacklisting" directories to languages. `M-x
   eglot` starts servers to handle major modes inside a specific
   project. Uses Emacs's built-in `project.el` library to discover
-  projects. Automatically detects current and future opened files under that
-  project and syncs with server.
+  projects. Automatically detects current and future opened files
+  under that project and syncs with server.
 - Easy way to quit/restart a server, just middle/right click on the
   connection name.
 - Pretty interactive mode-line section for live tracking of server
@@ -134,6 +143,6 @@ Under the hood:
 [javascript-typescript-langserver]: 
https://github.com/sourcegraph/javascript-typescript-langserver
 [emacs-lsp]: https://github.com/emacs-lsp/lsp-mode
 [emacs-lsp-plugins]: https://github.com/emacs-lsp
-
+[bash-language-server]: https://github.com/mads-hartmann/bash-language-server
 

diff --git a/eglot.el b/eglot.el
index b2709a6..22799cc 100644
--- a/eglot.el
+++ b/eglot.el
@@ -47,9 +47,10 @@
   :prefix "eglot-"
   :group 'applications)
 
-(defvar eglot-executables '((rust-mode . ("rls"))
-(python-mode . ("pyls"))
-(js-mode . ("javascript-typescript-stdio")))
+(defvar eglot-server-programs '((rust-mode . ("rls"))
+(python-mode . ("pyls"))
+(js-mode . ("javascript-typescript-stdio"))
+(sh-mode . ("bash-language-server" "start")))
   "Alist mapping major modes to server executables.")
 
 (defface eglot-mode-line
@@ -204,10 +205,8 @@ CONTACT is as `eglot--contact'.  Returns a process object."
   :publishDiagnostics `(:relatedInformation :json-false))
:experimental (eglot--obj)))
 
-(defun eglot--connect (project managed-major-mode
-   short-name contact &optional success-fn)
-  "Connect for PROJECT, MANAGED-MAJOR-MODE, SHORT-NAME and CONTACT.
-SUCCESS-FN with no args if all goes well."
+(defun

[elpa] externals/eglot 4f246b5 017/139: * eglot.el (eglot-mode-map): Move up before minor mode.

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 4f246b5965c45830690dcb8e42bf639b8dfad0b1
Author: João Távora 
Commit: João Távora 

* eglot.el (eglot-mode-map): Move up before minor mode.
---
 eglot.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8da6267..8356f8e 100644
--- a/eglot.el
+++ b/eglot.el
@@ -550,6 +550,8 @@ running.  INTERACTIVE is t if called interactively."
   "Face for package-name in EGLOT's mode line."
   :group 'eglot)
 
+(defvar eglot-mode-map (make-sparse-keymap))
+
 (define-minor-mode eglot-mode
   "Minor mode for buffers where EGLOT is possible"
   nil
@@ -567,9 +569,7 @@ running.  INTERACTIVE is t if called interactively."
 
 (defvar eglot-menu)
 
-(defvar eglot-mode-map (make-sparse-keymap))
-
-(easy-menu-define eglot-menu eglot-mode-map "SLY"
+(easy-menu-define eglot-menu eglot-mode-map "EGLOT"
   `("EGLOT" ))
 
 (defvar eglot--mode-line-format



[elpa] externals/elpa 8e6488f 023/139: Don't switch to possibly dead buffer in sentinel

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 8e6488f2dbdb55708fb2743aa9e86d583b8f9148
Author: João Távora 
Commit: João Távora 

Don't switch to possibly dead buffer in sentinel

* eglot.el (eglot--process-sentinel): Don't with-current-buffer.
---
 eglot.el | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/eglot.el b/eglot.el
index 44023b7..22ff031 100644
--- a/eglot.el
+++ b/eglot.el
@@ -153,24 +153,23 @@ INTERACTIVE is t if called interactively."
 (eglot--protocol-initialize proc interactive)))
 
 (defun eglot--process-sentinel (process change)
-  (with-current-buffer (process-buffer process)
-(eglot--debug "(sentinel) Process state changed to %s" change)
-(when (not (process-live-p process))
-  ;; Remember to cancel all timers
-  ;;
-  (maphash (lambda (id quad)
- (cl-destructuring-bind (_success _error timeout _env) quad
-   (eglot--message
-"(sentinel) Cancelling timer for continuation %s" id)
-   (cancel-timer timeout)))
-   (eglot--pending-continuations process))
-  (cond ((eglot--moribund process)
- (eglot--message "(sentinel) Moribund process exited with status 
%s"
- (process-exit-status process)))
-(t
- (eglot--warn "(sentinel) Process unexpectedly changed to %s"
-  change)))
-  (delete-process process
+  (eglot--debug "(sentinel) Process state changed to %s" change)
+  (when (not (process-live-p process))
+;; Remember to cancel all timers
+;;
+(maphash (lambda (id quad)
+   (cl-destructuring-bind (_success _error timeout _env) quad
+ (eglot--message
+  "(sentinel) Cancelling timer for continuation %s" id)
+ (cancel-timer timeout)))
+ (eglot--pending-continuations process))
+(cond ((eglot--moribund process)
+   (eglot--message "(sentinel) Moribund process exited with status %s"
+   (process-exit-status process)))
+  (t
+   (eglot--warn "(sentinel) Process unexpectedly changed to %s"
+change)))
+(delete-process process)))
 
 (defun eglot--process-filter (proc string)
   "Called when new data STRING has arrived for PROC."
@@ -371,7 +370,8 @@ identifier.  ERROR is non-nil if this is an error."
  (error-fn
   (or error-fn
   (cl-function
-   (lambda (&key code message)
+   (lambda (&key data code message &allow-other-keys)
+ (setf (eglot--status process) '("error" t))
  (eglot--warn
   "(request) Request id=%s errored with code=%s: %s"
   id code message)
@@ -446,9 +446,9 @@ INTERACTIVE is t if caller was called interactively."
process
:initialize
`(:processId  ,(emacs-pid)
- :rootPath  ,(concat "file://"
- (expand-file-name (car (project-roots
- 
(project-current)
+ :rootPath  ,(concat 
+  (expand-file-name (car (project-roots
+  (project-current)
  :initializationOptions  []
  :capabilities (:workspace (:executeCommand 
(:dynamicRegistration t))
:textDocument (:synchronization 
(:didSave t



[elpa] externals/elpa b69302c 060/139: Make M-x eglot's interactive spec a separate function

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit b69302c4795be8d783f853488824626a08241778
Author: João Távora 
Commit: João Távora 

Make M-x eglot's interactive spec a separate function

* eglot.el (eglot--interactive): New function.
(eglot): Rework a little.
---
 eglot.el | 104 ---
 1 file changed, 53 insertions(+), 51 deletions(-)

diff --git a/eglot.el b/eglot.el
index 3d0c044..ec7f3e6 100644
--- a/eglot.el
+++ b/eglot.el
@@ -234,6 +234,39 @@ SUCCESS-FN with no args if all goes well."
 (defvar eglot--command-history nil
   "History of COMMAND arguments to `eglot'.")
 
+(defun eglot--interactive ()
+  "Helper for `eglot'."
+  (let* ((managed-major-mode
+  (cond
+   ((or current-prefix-arg
+(not buffer-file-name))
+(intern
+ (completing-read
+  "[eglot] Start a server to manage buffers of what major mode? "
+  (mapcar #'symbol-name
+  (eglot--all-major-modes)) nil t
+  (symbol-name major-mode) nil
+  (symbol-name major-mode) nil)))
+   (t major-mode)))
+ (guessed-command
+  (cdr (assoc managed-major-mode eglot-executables
+(list
+ managed-major-mode
+ (let ((prompt
+(cond (current-prefix-arg
+   "[eglot] Execute program (or connect to :) ")
+  ((null guessed-command)
+   (format "[eglot] Sorry, couldn't guess for `%s'!\n\
+Execute program (or connect to :) "
+   managed-major-mode)
+   (if prompt
+   (split-string-and-unquote
+(read-shell-command prompt
+(combine-and-quote-strings guessed-command)
+'eglot-command-history))
+ guessed-command))
+ t)))
+
 (defun eglot (managed-major-mode command &optional interactive)
   "Start a Language Server Protocol server.
 Server is started with COMMAND and manages buffers of
@@ -251,64 +284,33 @@ With a prefix arg, prompt for MANAGED-MAJOR-MODE and 
COMMAND,
 else guess them from current context and `eglot-executables'.
 
 INTERACTIVE is t if called interactively."
-  (interactive
-   (let* ((managed-major-mode
-   (cond
-((or current-prefix-arg
- (not buffer-file-name))
- (intern
-  (completing-read
-   "[eglot] Start a server to manage buffers of what major mode? "
-   (mapcar #'symbol-name
-   (eglot--all-major-modes)) nil t
-   (symbol-name major-mode) nil
-   (symbol-name major-mode) nil)))
-(t major-mode)))
-  (guessed-command
-   (cdr (assoc managed-major-mode eglot-executables
- (list
-  managed-major-mode
-  (let ((prompt
- (cond (current-prefix-arg
-"[eglot] Execute program (or connect to :) ")
-   ((null guessed-command)
-(format "[eglot] Sorry, couldn't guess for `%s'!\n\
-Execute program (or connect to :) "
-managed-major-mode)
-(if prompt
-(split-string-and-unquote
- (read-shell-command prompt
- (combine-and-quote-strings guessed-command)
- 'eglot-command-history))
-  guessed-command))
-  t)))
+  (interactive (eglot--interactive))
   (let* ((project (project-current))
  (short-name (eglot--project-short-name project)))
 (unless project (eglot--error "Cannot work without a current project!"))
 (unless command (eglot--error "Don't know how to start EGLOT for %s 
buffers"
   major-mode))
 (let ((current-process (eglot--current-process)))
-  (cond ((and (process-live-p current-process)
-  interactive
-  (y-or-n-p "[eglot] Live process found, reconnect instead? "))
- (eglot-reconnect current-process interactive))
-(t
- (when (process-live-p current-process)
-   (eglot-shutdown current-process 'sync))
- (eglot--connect
-  project
-  managed-major-mode
-  short-name
-  command
-  (lambda (proc)
-(eglot--message "Connected! Process `%s' now managing `%s' \
+  (if (and (process-live-p current-process)
+   interactive
+   (y-or-n-p "[eglot] Live process found, reconnect instead? "))
+  (eglot-reconnect current-process interactive)
+(when (process-live-p current-process)
+  (eglot-shutdown current-process 'sync))
+(eglot--connect
+ project
+ managed-major-mode
+ short-name
+ command
+ (lambda (proc)
+   (eglot--message "Connected! Process `%s' now managing `%s

[elpa] externals/elpa b657b32 068/139: Use rootUri instead of rootPath

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit b657b328692c1315754aa2246b456469cdc77107
Author: João Távora 
Commit: João Távora 

Use rootUri instead of rootPath

* eglot.el (eglot--connect)
(eglot--current-buffer-VersionedTextDocumentIdentifier): Use
eglot--uri.
(eglot--uri): New function.
---
 eglot.el | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/eglot.el b/eglot.el
index b305ca3..8e39591 100644
--- a/eglot.el
+++ b/eglot.el
@@ -221,9 +221,9 @@ SUCCESS-FN with no args if all goes well."
  proc
  :initialize
  (eglot--obj :processId  (emacs-pid)
- :rootPath  (concat
- (expand-file-name (car (project-roots
- (project-current)
+ :rootUri  (eglot--uri
+(expand-file-name (car (project-roots
+(project-current)
  :initializationOptions  []
  :capabilities (eglot--client-capabilities))
  :success-fn
@@ -666,6 +666,8 @@ identifier.  ERROR is non-nil if this is a JSON-RPC error."
  (apply #'format format args)
  :warning)))
 
+(defun eglot--uri (path) "Add file:// to PATH." (concat "file://" path))
+
 
 ;;; Minor modes
 ;;;
@@ -988,10 +990,10 @@ running.  INTERACTIVE is t if called interactively."
 (defun eglot--current-buffer-VersionedTextDocumentIdentifier ()
   "Compute VersionedTextDocumentIdentifier object for current buffer."
   (eglot--obj :uri
-  (concat "file://"
-  (url-hexify-string
-   (file-truename buffer-file-name)
-   url-path-allowed-chars))
+  (eglot--uri
+   (url-hexify-string
+(file-truename buffer-file-name)
+url-path-allowed-chars))
   ;; FIXME: later deal with workspaces
   :version eglot--versioned-identifier))
 



[elpa] externals/elpa 16be2fc 020/139: Fix parser to accept multiple messages in one chunk

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 16be2fc884f6a450a31245789ec05969ae396177
Author: João Távora 
Commit: João Távora 

Fix parser to accept multiple messages in one chunk

* eglot.el (eglot--process-filter): Redesign slightly.
(eglot--message-mark): Remove. don't need this.
---
 eglot.el | 130 +++
 1 file changed, 64 insertions(+), 66 deletions(-)

diff --git a/eglot.el b/eglot.el
index cd213e7..ab13b3a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -69,9 +69,6 @@
  `(let ((proc (or ,process (eglot--current-process-or-lose
 (process-put proc ',prop ,to-store))
 
-(eglot--define-process-var eglot--message-mark nil
-  "Point where next unread message starts")
-
 (eglot--define-process-var eglot--short-name nil
   "A short name for the process")
 
@@ -139,9 +136,6 @@ INTERACTIVE is t if called interactively."
 (setf (eglot--short-name proc) short-name)
 (puthash (project-current) proc eglot--processes-by-project)
 (erase-buffer)
-(let ((marker (point-marker)))
-  (set-marker-insertion-type marker nil)
-  (setf (eglot--message-mark proc) marker))
 (read-only-mode t)
 (with-current-buffer (eglot-events-buffer proc)
   (let ((inhibit-read-only t))
@@ -170,71 +164,75 @@ INTERACTIVE is t if called interactively."
   (delete-process process
 
 (defun eglot--process-filter (proc string)
+  "Called when new data STRING has arrived for PROC."
   (when (buffer-live-p (process-buffer proc))
 (with-current-buffer (process-buffer proc)
-  (let ((moving (= (point) (process-mark proc)))
-(inhibit-read-only t)
+  (let ((inhibit-read-only t)
 (pre-insertion-mark (copy-marker (process-mark proc)))
-(expected-bytes (eglot--expected-bytes proc))
-(message-mark (eglot--message-mark proc)))
-(save-excursion
-  ;; Insert the text, advancing the process marker.
-  (goto-char (process-mark proc))
-  (insert string)
-  (set-marker (process-mark proc) (point)))
-(if moving (goto-char (process-mark proc)))
-
-;; check for new message header
+(expected-bytes (eglot--expected-bytes proc)))
+;; Insert the text, advancing the process marker.
+(goto-char (process-mark proc))
+(insert string)
+(set-marker (process-mark proc) (point))
+
+;; goto point just before insertion
 ;;
-(save-excursion
-  (goto-char pre-insertion-mark)
-  (let* ((match (search-forward-regexp
- "\\(?:.*: .*\r\n\\)*Content-Length: 
\\([[:digit:]]+\\)\r\n\\(?:.*: .*\r\n\\)*\r\n"
- (+ (point) 100)
- t))
- (new-expected-bytes (and match
-  (string-to-number (match-string 
1)
-(when new-expected-bytes
-  (when expected-bytes
-(eglot--warn
- (concat "Unexpectedly starting new message but %s bytes "
- "reportedly remaining from previous one")
- expected-bytes))
-  (set-marker message-mark (point))
-  (setf (eglot--expected-bytes proc) new-expected-bytes)
-  (setq expected-bytes new-expected-bytes
-
-;; check for message body
+(goto-char pre-insertion-mark)
+
+;; loop for each message (more than one might have arrived)
 ;;
-(let ((available-bytes (- (position-bytes (process-mark proc))
-  (position-bytes message-mark
-  (cond ((not expected-bytes)
- (eglot--warn
-  "Skipping %s bytes of unexpected garbage from process %s"
-  available-bytes
-  proc)
- (set-marker message-mark (process-mark proc)))
-((>= available-bytes
- expected-bytes)
- (let* ((message-end (byte-to-position
-  (+ (position-bytes message-mark)
- expected-bytes
-   (unwind-protect
-   (save-excursion
- (save-restriction
-   (goto-char message-mark)
-   (narrow-to-region message-mark
- message-end)
-   (eglot--process-receive
-proc
-(let ((json-object-type 'plist))
-  (json-read)
- (set-marker message-mark message-end)
- (setf (eglot--expected-bytes proc) nil
-(t
- ;; just adding some stuff to the end that doesn't yet
-  

[elpa] externals/elpa 95983c9 028/139: Change status to error everytime an error is found

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 95983c9b526da4258c862d55f27099ec4f2350ee
Author: João Távora 
Commit: João Távora 

Change status to error everytime an error is found

* eglot.el (eglot--process-receive): Also set error status.
(eglot--request): Fix a compilation warning.
---
 eglot.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 1f2737e..457f316 100644
--- a/eglot.el
+++ b/eglot.el
@@ -317,6 +317,8 @@ identifier.  ERROR is non-nil if this is an error."
   message
   response-id
   err)
+(when err
+  (setf (eglot--status proc) '("error" t)))
 (cond ((and response-id
 (not continuations))
(eglot--warn "Ooops no continuation for id %s" response-id))
@@ -384,7 +386,7 @@ identifier.  ERROR is non-nil if this is an error."
  (error-fn
   (or error-fn
   (cl-function
-   (lambda (&key data code message &allow-other-keys)
+   (lambda (&key code message &allow-other-keys)
  (setf (eglot--status process) '("error" t))
  (eglot--warn
   "(request) Request id=%s errored with code=%s: %s"



[elpa] externals/eglot 0222e7e 007/139: Improve `eglot--current-process'

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 0222e7e88be45a86f0428e9b4a38ea6974c6337f
Author: João Távora 
Commit: João Távora 

Improve `eglot--current-process'
---
 eglot.el | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eglot.el b/eglot.el
index 6e3a136..c7f8774 100644
--- a/eglot.el
+++ b/eglot.el
@@ -41,13 +41,14 @@
 (defun eglot--current-process ()
   "The current logical EGLOT process"
   (let ((cur (project-current)))
-(unless cur
-  (eglot--error "No current project, so no process"))
-(gethash cur eglot--processes-by-project)))
+(and cur
+ (gethash cur eglot--processes-by-project
 
 (defun eglot--current-process-or-lose ()
   (or (eglot--current-process)
-  (eglot--error "No current EGLOT process")))
+  (eglot--error "No current EGLOT process%s"
+(if (project-current) ""
+  " (Also no current project)"
 
 (defmacro eglot--define-process-var (var-sym initval &optional doc)
   (declare (indent 2))



[elpa] externals/elpa 75495dc 033/139: Slightly more user friendly start

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 75495dcb2ce2d1e4e0ee3ebfab990b8f1731ac01
Author: João Távora 
Commit: João Távora 

Slightly more user friendly start

* eglot.el (eglot-new-process): signal DidOpen for every file in project.
(eglot-editing-mode): Offer to start process.
---
 eglot.el | 35 ---
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/eglot.el b/eglot.el
index 6e5954c..d3428a7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -193,7 +193,17 @@ INTERACTIVE is t if called interactively."
major-mode))
probe)))
   (lambda ()
-(eglot--message "Connected"
+(eglot--message "Connected")
+(dolist (buffer (buffer-list))
+  (with-current-buffer buffer
+(if (and buffer-file-name
+ (cl-some
+  (lambda (root)
+(string-prefix-p
+ (expand-file-name root)
+ (expand-file-name buffer-file-name)))
+  (project-roots project)))
+(eglot--signalDidOpen)))
 
 (defun eglot--process-sentinel (process change)
   "Called with PROCESS undergoes CHANGE."
@@ -647,16 +657,19 @@ running.  INTERACTIVE is t if called interactively."
   nil
   nil
   eglot-mode-map
-  (cond (eglot-editing-mode
- (eglot-mode 1)
- (add-hook 'after-change-functions 'eglot--after-change nil t)
- (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
- (if (eglot--current-process)
- (eglot--signalDidOpen)
-   (eglot--warn "No process")))
-(t
- (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
- (remove-hook 'after-change-functions 'eglot--after-change t
+  (cond
+   (eglot-editing-mode
+(eglot-mode 1)
+(add-hook 'after-change-functions 'eglot--after-change nil t)
+(add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
+(if (eglot--current-process)
+(eglot--signalDidOpen)
+  (if (y-or-n-p "No process, try to start one with `eglot-new-process'? ")
+  (eglot-new-process t)
+(eglot--warn "No process"
+   (t
+(remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
+(remove-hook 'after-change-functions 'eglot--after-change t
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil



[elpa] branch externals/elpa deleted (was 4c0bfc3)

2018-05-14 Thread Jo�o T�vora
capitaomorte pushed a change to branch externals/elpa.

   was  4c0bfc3   Support didChangeWatchedFiles with dynamic registration

This change permanently discards the following revisions:

  discards  4c0bfc3   Support didChangeWatchedFiles with dynamic registration
  discards  589e1ea   Remove an unused variable
  discards  41f5922   Now send willSaveWaitUntil
  discards  9bf3166   Don't define a menu if nothing to show there for now
  discards  49fb02f   Use RLS in Travis CI and add actual tests
  discards  dc08e8e   Fix automatic project creation
  discards  8448d9b   Work with any old directory, no formal project needed
  discards  1fb2bcb   Ask server for textDocument/signatureHelp if it supports 
it
  discards  418412b   Fix copyright header. Obviously not since 2003
  discards  77856c2   Reinstate the catch/loop/throw idiom in eglot-request
  discards  29f6b4c   Tweak README.md
  discards  764347d   New command eglot-help-at-point and a README update
  discards  29f58a6   Get rid of catch/loop/throw idiom (suggested by Thien-Thi 
Nguyen)
  discards  56cf02d   Rework autoreconnection logic
  discards  9577dfc   Duh, json.el is in Emacs, and json-mode.el is useless here
  discards  9af84a2   Prepare to sumbit to GNU ELPA
  discards  0625b6c   (eglot--xref-make): Fix Use of cl-destructuring-bind.
  discards  3e0f1c3   Misc little adjustments for readability
  discards  ef80455   Support :completionItem/resolve
  discards  ab575d2   Rename functions. eglot--request is now the synchronous 
one
  discards  d1cdcf1   Friendlier M-x eglot
  discards  c7bd095   Improve eglot-eldoc-function
  discards  d0b7773   Reduce log chatter
  discards  c7b9002   Only call deferred actions after a full message has been 
received
  discards  581608f   Resist server failure during synchronous requests
  discards  f89f859   Simplify mode-line updating logic
  discards  54fc885   More RLS-specifics: update Flymake diags when indexing 
done
  discards  05c67ee   Adjust flymake integration
  discards  23b79e0   Shorten summary line to appease package-lint.el
  discards  458bc69   More correctly setup rust-mode-related autoloads
  discards  3dcbc30   Add minimal headers, commentary and autoloads
  discards  bfd82b5   Fancier RLS spinner
  discards  42177d0   New "deferred requests" that wait until server is ready
  discards  5ce9ab0   Call eglot-eldoc-function after completion finishes
  discards  8a80fb7   Simplify `eglot-shutdown`
  discards  56c2e1d   Get rid of eglot-mode
  discards  d33a9b5   Simplify eglot--signal-textDocument/didChange
  discards  71e47d2   Fix odd bugs and tweak stuff
  discards  ecd334f   Update README
  discards  6e76b08   Support workspace/applyEdit
  discards  3a6c637   Support textDocument/rename
  discards  37b7329   Reasonable textDocument/documentHighlight support
  discards  1356844   Fix odd bugs
  discards  24466a9   When killing server, always wait 3 seconds
  discards  dda11dd   Try to fix some textDocument/completion bugs
  discards  d40f9ac   Half-decent imenu support via textDocument/documentSymbol
  discards  af14364   Only request stuff that server says it's capable of
  discards  e63dad0   Simplify mode-line code with a helper.
  discards  e964abe   Get rid of eglot--buffer-open-count
  discards  fceb6bb   Get rid of eglot--special-buffer-process
  discards  f257d63   * eglot.el: Reformat to shave off some lines.
  discards  d431d41   Fix bug in hover support
  discards  bbc64b4   Clean up client capabilities
  discards  714e5be   Half-baked textDocument/hover support
  discards  889ef20   Tweak the async request engine.
  discards  fc6879f   Explain why didOpen on after-revert-hook is a bad idea
  discards  c4ffabc   Half-decent completion support
  discards  d254f97   Solve another textDocument/didChange bug
  discards  39e8b9e   Add (dummy) tests and Travis CI integration
  discards  a7ddce6   Support javascript's javascript-typescript-langserver
  discards  9ff97a6   Increase request timeout length to 10 seconds
  discards  1add335   Workaround two suspected Emacs bugs
  discards  e9b5e54   ETOOMANYLAMBDAS
  discards  571b08f   Fix the odd bug here and there
  discards  193c57d   Half-decent xref support
  discards  ff5a03d   Very basic xref support
  discards  e86f9b4   New helper eglot--sync-request
  discards  9882bf2   Cleanup mistake with TextDocumentItem and 
TextDocumentIdentifier
  discards  8160cd4   Handle dynamic registration in general (but nothing 
specific yet)
  discards  a199c8e   Honour textDocumentSync
  discards  79a2a1e   Be quite explicit about our lack of capabilities right now
  discards  b657b32   Use rootUri instead of rootPath
  discards  e7ffc31   Make reported capabilities into its own function
  discards  ea918ab   Include source info in diagnostics
  discards  df5d76d   Reply to client/registerCapability (don't handle it yet)
  discards  f8bfb7e   Handle requests from server correctly
  discards  c2862f4   Don't auto-reconnect if last attempt la

[elpa] externals/elpa 1dc2a9f 021/139: Implement spinners and RLS's window/progress

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 1dc2a9fe3521586b15f90ed74d06f586fe478dfd
Author: João Távora 
Commit: João Távora 

Implement spinners and RLS's window/progress

* eglot.el (eglot--window/progress): New.
(eglot--mode-line-format): Rework.
(eglot--snpinner): New var.
(compile): require it.
---
 eglot.el | 107 ++-
 1 file changed, 64 insertions(+), 43 deletions(-)

diff --git a/eglot.el b/eglot.el
index ab13b3a..e5d6937 100644
--- a/eglot.el
+++ b/eglot.el
@@ -30,6 +30,7 @@
 (require 'url-parse)
 (require 'url-util)
 (require 'pcase)
+(require 'compile) ; for some faces
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -87,6 +88,10 @@
 (eglot--define-process-var eglot--moribund nil
   "Non-nil if process is about to exit")
 
+(eglot--define-process-var eglot--spinner `(nil nil t)
+  "\"Spinner\" used by some servers.
+A list (ID WHAT DONE-P).")
+
 (defun eglot--command (&optional errorp)
   (let ((probe (cdr (assoc major-mode eglot-executables
 (unless (or (not errorp)
@@ -591,17 +596,15 @@ running.  INTERACTIVE is t if called interactively."
 
 (defun eglot--mode-line-format ()
   "Compose the mode-line format spec."
-  (let* ((proc (eglot--current-process))
- (name (and proc
-(process-live-p proc)
-(eglot--short-name proc)))
- (pending (and proc
-   (hash-table-count
-(eglot--pending-continuations proc
- (format-number (lambda (n) (cond ((and n (not (zerop n)))
-   (format "%d" n))
-  (n "-")
-  (t "*")
+  (pcase-let* ((proc (eglot--current-process))
+   (name (and proc
+  (process-live-p proc)
+  (eglot--short-name proc)))
+   (pending (and proc
+ (hash-table-count
+  (eglot--pending-continuations proc
+   (`(,_id ,what ,done-p) (and proc
+   (eglot--spinner
 (append
  `((:propertize "eglot"
 face eglot-mode-line
@@ -612,41 +615,51 @@ running.  INTERACTIVE is t if called interactively."
 mouse-face mode-line-highlight
 help-echo "mouse-1: pop-up EGLOT menu"
 ))
- (if name
- `(" "
-   (:propertize
-,name
-face eglot-mode-line
-keymap ,(let ((map (make-sparse-keymap)))
-  (define-key map [mode-line mouse-1] 'eglot-events-buffer)
-  (define-key map [mode-line mouse-2] 'eglot-quit-server)
-  (define-key map [mode-line mouse-3] 'eglot-new-process)
-  map)
-mouse-face mode-line-highlight
-help-echo ,(concat "mouse-1: events buffer\n"
-   "mouse-2: quit server\n"
-   "mouse-3: new process"))
-   "/"
-   (:propertize
-,(funcall format-number pending)
-help-echo ,(if name
-   (format
-"%s pending events outgoing\n%s"
+ (when name
+   `(":"
+ (:propertize
+  ,name
+  face eglot-mode-line
+  keymap ,(let ((map (make-sparse-keymap)))
+(define-key map [mode-line mouse-1] 'eglot-events-buffer)
+(define-key map [mode-line mouse-2] 'eglot-quit-server)
+(define-key map [mode-line mouse-3] 'eglot-new-process)
+map)
+  mouse-face mode-line-highlight
+  help-echo ,(concat "mouse-1: go to events buffer\n"
+ "mouse-2: quit server\n"
+ "mouse-3: new process"))
+ ,@(when (and what (not done-p))
+ `("/"
+   (:propertize
+,what
+help-echo ,(concat "mouse-1: go to events buffer")
+mouse-face mode-line-highlight
+face compilation-mode-line-run
+keymap ,(let ((map (make-sparse-keymap)))
+  (define-key map [mode-line mouse-1]
+'eglot-events-buffer)
+  map
+ ,@(when (cl-plusp pending)
+ `("/"
+   (:propertize
+(format "%d" pending)
+help-echo ,(format
+"%s unanswered requests\n%s"
 pending
 (concat "mouse-1: go to events buffer"
 "mouse-3: forget pending continuations"))
- "No current connection")
-mouse-face mode-li

[elpa] externals/eglot e1d36d2 014/139: Fix some byte-compilation warnings

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit e1d36d27a2b6566fdd8cf16d0fcd2a9ec033a65d
Author: João Távora 
Commit: João Távora 

Fix some byte-compilation warnings
---
 eglot.el | 82 
 1 file changed, 46 insertions(+), 36 deletions(-)

diff --git a/eglot.el b/eglot.el
index af9904a..0a52da7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -27,6 +27,7 @@
 (require 'json)
 (require 'cl-lib)
 (require 'project)
+(require 'url-parse)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -211,8 +212,10 @@
(goto-char message-mark)
(narrow-to-region message-mark
  message-end)
-  (eglot--process-receive proc 
(let ((json-object-type 'plist))
-   (json-read)
+   (eglot--process-receive
+proc
+(let ((json-object-type 'plist))
+  (json-read)
(set-marker message-mark message-end)
(setf (eglot--expected-bytes proc) nil)))
 (t
@@ -258,21 +261,21 @@
 (not continuations))
(eglot--warn "Ooops no continuation for id %s" response-id))
   (continuations
-   (cancel-timer (third continuations))
+   (cancel-timer (cl-third continuations))
(remhash response-id
 (eglot--pending-continuations))
(cond (err
-  (apply (second continuations) err))
+  (apply (cl-second continuations) err))
  (t
-  (apply (first continuations) (plist-get message :result)
+  (apply (cl-first continuations) (plist-get message 
:result)
   (t
(let* ((method (plist-get message :method))
   (handler-sym (intern (concat "eglot--"
-  method
+   method
  (if (functionp handler-sym)
  (apply handler-sym proc (plist-get message :params))
(eglot--debug "No implemetation for notification %s yet"
- method)))
+ method)))
 
 (defvar eglot--expect-carriage-return nil)
 
@@ -294,9 +297,9 @@
   (clrhash (eglot--pending-continuations process)))
 
 (cl-defun eglot--request (process
-   method
-   params
-   &key success-fn error-fn timeout-fn (async-p t))
+  method
+  params
+  &key success-fn error-fn timeout-fn (async-p t))
   (let* ((id (eglot--next-request-id))
  (timeout-fn
   (or timeout-fn
@@ -363,6 +366,9 @@
 ;;; Requests
 ;;;
 (defun eglot--protocol-initialize (process interactive)
+  "Initialize LSP protocol.
+PROCESS is a connected process (network or local).
+INTERACTIVE is t if caller was called interactively."
   (eglot--request
process
:initialize
@@ -385,7 +391,7 @@
 (defun eglot-quit-server (process &optional sync interactive)
   "Politely ask the server PROCESS to quit.
 If SYNC, don't leave this function with the server still
-running."
+running.  INTERACTIVE is t if called interactively."
   (interactive (list (eglot--current-process-or-lose) t t))
   (when interactive
 (eglot--message "(eglot-quit-server) Asking %s politely to terminate"
@@ -437,47 +443,50 @@ running."
 (forward-line (plist-get pos-plist :line))
 (forward-char (plist-get pos-plist :character))
 (point
-  (loop for diag across diagnostics
-do (cl-destructuring-bind (&key range severity
-_code _source message)
-   diag
- (cl-destructuring-bind (&key start end)
- range
-   (let* ((begin-pos (pos-at start))
-  (end-pos (pos-at end))
-  (ov (make-overlay begin-pos
-end-pos
-buffer)))
- (push ov eglot--diagnostic-overlays)
- (overlay-put ov 'face
-  (case severity
-(1 'flymake-errline)
-(2 'flymake-warnline)))
- (overlay-put ov 'help-echo
-  message)
- (overlay-put ov 'eglot--diagnostic diag
+  (cl-loop for diag across diagnostics
+   do (cl-destructu

[elpa] externals/eglot 8bd634c 016/139: Start working on this again

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 8bd634ce9d5058e2db36dcf250bb909cc96eeaeb
Author: João Távora 
Commit: João Távora 

Start working on this again

* eglot.el (url-util): Require it.
(eglot--process-sentinel): pending continuations now are quads (added env).
(eglot--process-filter): Unwind message markers correctly if handling fails.
(eglot--obj): Simple macro.
(eglot--log-event): Add some info to logged event.
(eglot--environment-vars, eglot--environment): Helper vars.
(eglot--process-receive): Improve.
(eglot--process-send): Niver log.
(eglot--request): Use eglot--obj. Add environment.
(eglot--notify): New helper.
(eglot--protocol-initialize): RLS must like file://
(eglot--current-flymake-report-fn): New var.
(eglot--textDocument/publishDiagnostics): Use flymake from Emacs 26.
(eglot-mode): Proper minor mode.
(eglot--recent-changes, eglot--versioned-identifier): New stuff.
(eglot--current-buffer-versioned-identifier)
(eglot--current-buffer-VersionedTextDocumentIdentifier)
(eglot--current-buffer-TextDocumentItem, eglot--after-change)
(eglot--signalDidOpen, eglot--maybe-signal-didChange): New stuff.
(eglot-flymake-backend): More or less a flymake backend function.
---
 eglot.el | 267 ---
 1 file changed, 204 insertions(+), 63 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8946692..8da6267 100644
--- a/eglot.el
+++ b/eglot.el
@@ -28,6 +28,7 @@
 (require 'cl-lib)
 (require 'project)
 (require 'url-parse)
+(require 'url-util)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -143,8 +144,8 @@
 (when (not (process-live-p process))
   ;; Remember to cancel all timers
   ;;
-  (maphash (lambda (id triplet)
- (cl-destructuring-bind (_success _error timeout) triplet
+  (maphash (lambda (id quad)
+ (cl-destructuring-bind (_success _error timeout _env) quad
(eglot--message
 "(sentinel) Cancelling timer for continuation %s" id)
(cancel-timer timeout)))
@@ -185,7 +186,7 @@
 (when new-expected-bytes
   (when expected-bytes
 (eglot--warn
- (concat "Unexpectedly starting new message but %s bytes"
+ (concat "Unexpectedly starting new message but %s bytes "
  "reportedly remaining from previous one")
  expected-bytes))
   (set-marker message-mark (point))
@@ -207,22 +208,29 @@
  (let* ((message-end (byte-to-position
   (+ (position-bytes message-mark)
  expected-bytes
-   (save-excursion
- (save-restriction
-   (goto-char message-mark)
-   (narrow-to-region message-mark
- message-end)
-   (eglot--process-receive
-proc
-(let ((json-object-type 'plist))
-  (json-read)
-   (set-marker message-mark message-end)
-   (setf (eglot--expected-bytes proc) nil)))
+   (unwind-protect
+   (save-excursion
+ (save-restriction
+   (goto-char message-mark)
+   (narrow-to-region message-mark
+ message-end)
+   (eglot--process-receive
+proc
+(let ((json-object-type 'plist))
+  (json-read)
+ (set-marker message-mark message-end)
+ (setf (eglot--expected-bytes proc) nil
 (t
  ;; just adding some stuff to the end that doesn't yet
  ;; complete the message
  )))
 
+(defmacro eglot--obj (&rest what)
+  "Make an object suitable for `json-encode'"
+  ;; FIXME: maybe later actually do something, for now this just fixes
+  ;; the indenting of literal plists.
+  `(list ,@what))
+
 (defun eglot-events-buffer (process &optional interactive)
   (interactive (list (eglot--current-process-or-lose) t))
   (let* ((probe (eglot--events-buffer process))
@@ -241,22 +249,39 @@
   (display-buffer buffer))
 buffer))
 
-(defun eglot--log-event (proc type message)
+(defun eglot--log-event (proc type message id error)
   (with-current-buffer (eglot-events-buffer proc)
 (let ((inhibit-read-only t))
   (goto-char (point-max))
-  (insert (format "%s: \n%s\n" type (pp-to-string message))
+  (insert (format "%s%s%s:\n%s\n"
+  type
+  (if id (format " (id:%s)" id) "")
+  (

[elpa] externals/eglot 7c82a03 024/139: Start experimenting with python

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 7c82a033d690d587fe39c088d9aef67c005ae270
Author: João Távora 
Commit: João Távora 

Start experimenting with python

* eglot.el (eglot-executables): Add pyls.
---
 eglot.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 22ff031..ff71a2f 100644
--- a/eglot.el
+++ b/eglot.el
@@ -37,7 +37,8 @@
   :prefix "eglot-"
   :group 'applications)
 
-(defvar eglot-executables '((rust-mode . ("rls")))
+(defvar eglot-executables '((rust-mode . ("rls"))
+(python-mode . ("pyls")))
   "Alist mapping major modes to server executables.")
 
 (defvar eglot--processes-by-project (make-hash-table :test #'equal))



[elpa] externals/elpa 0222e7e 007/139: Improve `eglot--current-process'

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 0222e7e88be45a86f0428e9b4a38ea6974c6337f
Author: João Távora 
Commit: João Távora 

Improve `eglot--current-process'
---
 eglot.el | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eglot.el b/eglot.el
index 6e3a136..c7f8774 100644
--- a/eglot.el
+++ b/eglot.el
@@ -41,13 +41,14 @@
 (defun eglot--current-process ()
   "The current logical EGLOT process"
   (let ((cur (project-current)))
-(unless cur
-  (eglot--error "No current project, so no process"))
-(gethash cur eglot--processes-by-project)))
+(and cur
+ (gethash cur eglot--processes-by-project
 
 (defun eglot--current-process-or-lose ()
   (or (eglot--current-process)
-  (eglot--error "No current EGLOT process")))
+  (eglot--error "No current EGLOT process%s"
+(if (project-current) ""
+  " (Also no current project)"
 
 (defmacro eglot--define-process-var (var-sym initval &optional doc)
   (declare (indent 2))



[elpa] externals/eglot d2eca65 045/139: Fix another Flymake sync bug

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit d2eca65b86acea1e7ce293f737806affec8f89c4
Author: João Távora 
Commit: João Távora 

Fix another Flymake sync bug

* eglot.el (eglot-flymake-backend): Only report unreported sometimes.
(eglot--maybe-activate-editing-mode): Start flymake explicitly
when didOpen.
(eglot--textDocument/publishDiagnostics): No need to set
unreported-diagnostics to nil.
(flymake): Require it.
---
 eglot.el | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/eglot.el b/eglot.el
index ccf4b72..3561da2 100644
--- a/eglot.el
+++ b/eglot.el
@@ -32,6 +32,7 @@
 (require 'pcase)
 (require 'compile) ; for some faces
 (require 'warnings)
+(require 'flymake)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -657,12 +658,11 @@ running.  INTERACTIVE is t if called interactively."
   message
into diags
finally
-   (if (null eglot--current-flymake-report-fn)
-   (setq eglot--unreported-diagnostics
- diags)
- (funcall eglot--current-flymake-report-fn
-  diags)
- (setq eglot--unreported-diagnostics nil))
+   (if eglot--current-flymake-report-fn
+   (funcall eglot--current-flymake-report-fn
+diags)
+ (setq eglot--unreported-diagnostics
+   diags))
  (t
   (eglot--message "OK so %s isn't visited" filename)
 
@@ -724,7 +724,8 @@ that case, also signal textDocument/didOpen."
 (and proc (eq proc cur)))
 (unless eglot-editing-mode
   (eglot-editing-mode 1))
-(eglot--signalDidOpen)
+(eglot--signalDidOpen)
+(flymake-start)
 
 (add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
 
@@ -947,10 +948,11 @@ Records START, END and LENGTH locally."
 (defun eglot-flymake-backend (report-fn &rest _more)
   "An EGLOT Flymake backend.
 Calls REPORT-FN maybe if server publishes diagnostics in time."
-  ;; Call immediately with anything unreported (this will clear any
-  ;; pending diags)
-  (funcall report-fn eglot--unreported-diagnostics)
-  (setq eglot--unreported-diagnostics nil)
+  ;; Maybe call immediately if anything unreported (this will clear
+  ;; any pending diags)
+  (when eglot--unreported-diagnostics
+(funcall report-fn eglot--unreported-diagnostics)
+(setq eglot--unreported-diagnostics nil))
   ;; Setup so maybe it's called later, too.
   (setq eglot--current-flymake-report-fn report-fn)
   ;; Take this opportunity to signal a didChange that might eventually



[elpa] externals/elpa f76f04e 057/139: More correctly keep track of didOpen/didClose per buffer

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit f76f04e1226dc6a3ebe7b913ee9c6ddaef73634e
Author: João Távora 
Commit: João Távora 

More correctly keep track of didOpen/didClose per buffer

* eglot.el (eglot--buffer-open-count): Now a process-local var.
(eglot--signal-textDocument/didOpen, eglot--signal-textDocument/didClose):
Use it.
---
 eglot.el | 42 +++---
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/eglot.el b/eglot.el
index bdd339d..ac52b9a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -138,6 +138,9 @@ A list (WHAT SERIOUS-P)." t)
 Must be a function of one arg, a name, returning a process
 object.")
 
+(eglot--define-process-var eglot--buffer-open-count (make-hash-table)
+  "Keeps track of didOpen/didClose notifs for each buffer.")
+
 (defun eglot-make-local-process (name command)
   "Make a local LSP process from COMMAND.
 NAME is a name to give the inferior process or connection.
@@ -1026,26 +1029,35 @@ Records START, END and PRE-CHANGE-LENGTH locally."
   (setq eglot--recent-before-changes nil
 eglot--recent-after-changes nil))
 
-(defvar-local eglot--buffer-open-count 0)
 (defun eglot--signal-textDocument/didOpen ()
   "Send textDocument/didOpen to server."
-  (cl-incf eglot--buffer-open-count)
-  (when (> eglot--buffer-open-count 1)
-(error "Too many textDocument/didOpen notifs for %s" (current-buffer)))
-  (eglot--notify (eglot--current-process-or-lose)
- :textDocument/didOpen
- (eglot--obj :textDocument
- (eglot--current-buffer-TextDocumentItem
+  (let* ((proc (eglot--current-process-or-lose))
+ (count (1+ (or (gethash (current-buffer)
+ (eglot--buffer-open-count proc))
+0
+(when (> count 1)
+  (eglot--error "Too many textDocument/didOpen notifs for %s" 
(current-buffer)))
+(setf (gethash (current-buffer) (eglot--buffer-open-count proc))
+  count)
+(eglot--notify proc
+   :textDocument/didOpen
+   (eglot--obj :textDocument
+   (eglot--current-buffer-TextDocumentItem)
 
 (defun eglot--signal-textDocument/didClose ()
   "Send textDocument/didClose to server."
-  (cl-decf eglot--buffer-open-count)
-  (when (< eglot--buffer-open-count 0)
-(error "Too many textDocument/didClose notifs for %s" (current-buffer)))
-  (eglot--notify (eglot--current-process-or-lose)
- :textDocument/didClose
- (eglot--obj :textDocument
- (eglot--current-buffer-TextDocumentItem
+  (let* ((proc (eglot--current-process-or-lose))
+ (count (1- (or (gethash (current-buffer)
+ (eglot--buffer-open-count proc))
+0
+(when (< count 0)
+  (eglot--error "Too many textDocument/didClose notifs for %s" 
(current-buffer)))
+(setf (gethash (current-buffer) (eglot--buffer-open-count proc))
+  count)
+(eglot--notify proc
+   :textDocument/didClose
+   (eglot--obj :textDocument
+   (eglot--current-buffer-TextDocumentItem)
 
 (defun eglot--signal-textDocument/willSave ()
   "Send textDocument/willSave to server."



[elpa] externals/elpa 2775dea 003/139: Rename eglot--continuations eglot--pending-continuations

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 2775deaf534eab2b919ef99fc7da957987a02092
Author: João Távora 
Commit: João Távora 

Rename eglot--continuations eglot--pending-continuations
---
 eglot.el | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/eglot.el b/eglot.el
index f2ef418..166f23c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -67,7 +67,7 @@
 (eglot--define-process-var eglot--expected-bytes nil
   "How many bytes declared by server")
 
-(eglot--define-process-var eglot--continuations (make-hash-table)
+(eglot--define-process-var eglot--pending-continuations (make-hash-table)
   "A hash table of request ID to continuation lambdas")
 
 (eglot--define-process-var eglot--events-buffer nil
@@ -264,12 +264,14 @@
   (let* ((response-id (plist-get message :id))
  (err (plist-get message :error))
  (continuations (and response-id
- (gethash response-id (eglot--continuations)
+ (gethash response-id 
(eglot--pending-continuations)
 (cond ((and response-id
 (not continuations))
(eglot--warn "Ooops no continuation for id %s" response-id))
   (continuations
(cancel-timer (third continuations))
+   (remhash response-id
+(eglot--pending-continuations))
(cond (err
   (apply (second continuations) err))
  (t
@@ -303,7 +305,7 @@
  (timeout-fn (or timeout-fn
  (lambda ()
(eglot--warn "Tired of waiting for reply to %s" id)
-   (remhash id (eglot--continuations process)
+   (remhash id (eglot--pending-continuations 
process)
  (error-fn (or error-fn
(cl-function
 (lambda (&key code message)
@@ -330,7 +332,7 @@
  timeout-fn
(lambda ()
  (throw catch-tag (apply 
timeout-fn))
-   (eglot--continuations process))
+   (eglot--pending-continuations process))
   (unless async-p
 (while t
   (unless (eq (process-status process) 'open)



[elpa] externals/elpa e7ffc31 067/139: Make reported capabilities into its own function

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit e7ffc31b9d7cc792241e3d077d2b7bb51e21ad84
Author: João Távora 
Commit: João Távora 

Make reported capabilities into its own function

* eglot.el (eglot--client-capabilities): New function.
(eglot--connect): Use it.
---
 eglot.el | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/eglot.el b/eglot.el
index 10435a1..b305ca3 100644
--- a/eglot.el
+++ b/eglot.el
@@ -189,6 +189,13 @@ CONTACT is as `eglot--contact'.  Returns a process object."
   (push sym retval
 retval))
 
+(defun eglot--client-capabilities ()
+  "What the EGLOT LSP client supports."
+  (eglot--obj
+   :workspace (eglot--obj)
+   :textDocument (eglot--obj
+  :publishDiagnostics `(:relatedInformation nil
+
 (defun eglot--connect (project managed-major-mode
short-name contact &optional success-fn)
   "Connect for PROJECT, MANAGED-MAJOR-MODE, SHORT-NAME and CONTACT.
@@ -218,11 +225,7 @@ SUCCESS-FN with no args if all goes well."
  (expand-file-name (car (project-roots
  (project-current)
  :initializationOptions  []
- :capabilities
- (eglot--obj
-  :workspace (eglot--obj)
-  :textDocument (eglot--obj
- :publishDiagnostics `(:relatedInformation 
t
+ :capabilities (eglot--client-capabilities))
  :success-fn
  (cl-function
   (lambda (&key capabilities)



[elpa] externals/elpa b511b7d 036/139: Redesign and simplify parser

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit b511b7d2da0e48a460bbcf4e7e9380a7253aa5d1
Author: João Távora 
Commit: João Távora 

Redesign and simplify parser

Fix horrible bugs. This is the correct way.

* eglot.el (eglot--process-filter): Redesign.
---
 eglot.el | 106 ---
 1 file changed, 47 insertions(+), 59 deletions(-)

diff --git a/eglot.el b/eglot.el
index 71dab80..b9aa94c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -234,71 +234,59 @@ INTERACTIVE is t if called interactively."
   (when (buffer-live-p (process-buffer proc))
 (with-current-buffer (process-buffer proc)
   (let ((inhibit-read-only t)
-(pre-insertion-mark (copy-marker (process-mark proc)))
 (expected-bytes (eglot--expected-bytes proc)))
 ;; Insert the text, advancing the process marker.
-(goto-char (process-mark proc))
-(insert string)
-(set-marker (process-mark proc) (point))
-
-;; goto point just before insertion
 ;;
-(goto-char pre-insertion-mark)
-
-;; loop for each message (more than one might have arrived)
+(save-excursion
+  (goto-char (process-mark proc))
+  (insert string)
+  (set-marker (process-mark proc) (point)))
+;; Loop (more than one message might have arrived)
 ;;
 (catch 'done
   (while t
-(let* ((match (search-forward-regexp
-   "\\(?:.*: .*\r\n\\)*Content-Length: 
\\([[:digit:]]+\\)\r\n\\(?:.*: .*\r\n\\)*\r\n"
-   (+ (point) 100)
-   t))
-   (new-expected-bytes (and match
-(string-to-number (match-string 
1)
-  (when new-expected-bytes
-(when expected-bytes
-  (eglot--warn
-   (concat "Unexpectedly starting new message but %s bytes "
-   "reportedly remaining from previous one")
-   expected-bytes))
-(setf (eglot--expected-bytes proc) new-expected-bytes)
-(setq expected-bytes new-expected-bytes)))
-
-;; check for message body
-;;
-(let ((available-bytes (- (position-bytes (process-mark proc))
-  (position-bytes (point)
-  (cond ((not expected-bytes) ; previous search didn't match
- (eglot--warn
-  "Skipping %s bytes of unexpected garbage from process %s"
-  available-bytes
-  proc)
- (goto-char (process-mark proc))
- (throw 'done :skipping-garbage))
-((>= available-bytes
- expected-bytes)
- (let* ((message-end (byte-to-position
-  (+ (position-bytes (point))
- expected-bytes
-   (unwind-protect
-   (save-restriction
- (narrow-to-region (point)
-   message-end)
- (let* ((json-object-type 'plist)
-(json-message (json-read)))
-   ;; process in another buffer, shielding
-   ;; buffer from tamper
-   (with-temp-buffer
- (eglot--process-receive proc json-message
- (goto-char message-end)
- (setf (eglot--expected-bytes proc) nil
-   expected-bytes nil)))
- (when (= (point) (process-mark proc))
-   (throw 'done :clean-done)))
-(t
- ;; just adding some stuff to the end that doesn't yet
- ;; complete the message
- (throw 'done :waiting-for-more-bytes))
+(cond ((not expected-bytes)
+   ;; Starting a new message
+   ;;
+   (setq expected-bytes
+ (and (search-forward-regexp
+   "\\(?:.*: .*\r\n\\)*Content-Length: 
*\\([[:digit:]]+\\)\r\n\\(?:.*: .*\r\n\\)*\r\n"
+   (+ (point) 100)
+   t)
+  (string-to-number (match-string 1
+   (unless expected-bytes
+ (throw 'done :waiting-for-new-message)))
+  (t
+   ;; Attempt to complete a message body
+   ;;
+   (let ((available-bytes (- (position-bytes (process-mark 
proc))
+ (position-bytes (point)
+

[elpa] externals/elpa bc011d0 010/139: Minor cleanup

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit bc011d00523eca1434e5300710de82c4c63deb65
Author: João Távora 
Commit: João Távora 

Minor cleanup
---
 eglot.el | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/eglot.el b/eglot.el
index 5699775..479e87a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -117,6 +117,7 @@
 (let ((current-process (eglot--current-process)))
   (when (and current-process
  (process-live-p current-process))
+(eglot--message "Asking current process to terminate first")
 (eglot-quit-server current-process 'sync)))
 (let* ((short-name (file-name-base
 (directory-file-name
@@ -148,7 +149,6 @@
(format "\n---\n"
   (eglot--protocol-initialize proc interactive))
 
-
 (defun eglot--process-sentinel (process change)
   (with-current-buffer (process-buffer process)
 (eglot--debug "Process state changed to %s" change)
@@ -353,8 +353,7 @@
 
 
 ;;; Requests
-;;; 
-
+;;;
 (defun eglot--protocol-initialize (process interactive)
   (eglot--request
process
@@ -445,8 +444,6 @@
 
 ;;; Mode line
 ;;;
-
-
 (defface eglot-mode-line
   '((t (:inherit font-lock-constant-face :weight bold)))
   "Face for package-name in EGLOT's mode line."



[elpa] externals/elpa efd14d6 015/139: Fix mode line

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit efd14d6d201102c8941d31e7c98f1eb5f33d3520
Author: João Távora 
Commit: João Távora 

Fix mode line

* eglot.el (mode-line-misc-info): conditionalize to eglot-mode
---
 eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 0a52da7..8946692 100644
--- a/eglot.el
+++ b/eglot.el
@@ -572,7 +572,7 @@ running.  INTERACTIVE is t if called interactively."
   map)))
 
 (add-to-list 'mode-line-misc-info
- `(t
+ `(eglot-mode
(" [" eglot--mode-line-format "] ")))
 
 (provide 'eglot)



[elpa] externals/eglot 63f2208 030/139: Less obstrusive flymake stuff for now

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 63f2208f0c61313f9eceb94219b4fab2ff84a373
Author: João Távora 
Commit: João Távora 

Less obstrusive flymake stuff for now

* eglot.el (eglot--after-change, eglot-flymake-backend): Fix.
---
 eglot.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 9742f88..fe63a29 100644
--- a/eglot.el
+++ b/eglot.el
@@ -775,7 +775,8 @@ running.  INTERACTIVE is t if called interactively."
 (defun eglot--after-change (start end length)
   (cl-incf eglot--versioned-identifier)
   (push (list start end length) eglot--recent-changes)
-  (eglot--message "start is %s, end is %s, length is %s" start end length))
+  ;; (eglot--message "start is %s, end is %s, length is %s" start end length)
+  )
 
 (defun eglot--signalDidOpen ()
   (eglot--notify (eglot--current-process-or-lose)
@@ -816,6 +817,9 @@ running.  INTERACTIVE is t if called interactively."
 (setq eglot--recent-changes nil)))
 
 (defun eglot-flymake-backend (report-fn &rest _more)
+  "An EGLOT Flymake backend.
+Calls REPORT-FN maybe if server publishes diagnostics in time."
+  ;; FIXME: perhaps should call it immediately?
   (setq eglot--current-flymake-report-fn report-fn)
   (eglot--maybe-signal-didChange))
 



[elpa] externals/elpa 6f0a8df 008/139: Organize a bit

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 6f0a8dffc75c053df1f4e952ee0826df5195c798
Author: João Távora 
Commit: João Távora 

Organize a bit
---
 eglot.el | 50 ++
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/eglot.el b/eglot.el
index c7f8774..e3b288b 100644
--- a/eglot.el
+++ b/eglot.el
@@ -148,25 +148,6 @@
(format "\n---\n"
   (eglot--protocol-initialize proc interactive))
 
-(defun eglot-quit-server (process &optional sync)
-  (interactive (list (eglot--current-process-or-lose)))
-  (eglot--message "Asking server to terminate")
-  (eglot--request
-  process
-  :shutdown
-  nil
-  (lambda (&rest _anything)
-(eglot--message "Now asking server to exit")
-(process-put process 'eglot--moribund t)
-(eglot--process-send process
-  `(:jsonrpc  "2.0"
-  :method  :exit)))
-  :async-p (not sync)
-  :timeout-fn (lambda ()
-(eglot--warn "Brutally deleting existing process %s"
-  process)
-(process-put process 'eglot--moribund t)
-(delete-process process
 
 (defun eglot--process-sentinel (process change)
   (with-current-buffer (process-buffer process)
@@ -359,6 +340,9 @@
 (eglot--error "Process %s died unexpectedly" process))
   (accept-process-output nil 0.01))
 
+
+;;; Requests
+;;; 
 
 (defun eglot--protocol-initialize (process interactive)
   (eglot--request
@@ -366,6 +350,7 @@
:initialize
`(:processId  ,(emacs-pid)
  :rootPath  ,(concat "" ;; FIXME RLS doesn't like "file://"
+ "file://"
  (expand-file-name (car (project-roots
  
(project-current)
  :initializationOptions  []
@@ -396,7 +381,26 @@
   "So yeah I got lots (%d) of capabilities"
   (length all)))
 
-(defun eglot--debug (format &rest args)
+(defun eglot-quit-server (process &optional sync)
+  (interactive (list (eglot--current-process-or-lose)))
+  (eglot--message "Asking server to terminate")
+  (eglot--request
+  process
+  :shutdown
+  nil
+  (lambda (&rest _anything)
+(eglot--message "Now asking server to exit")
+(process-put process 'eglot--moribund t)
+(eglot--process-send process
+  `(:jsonrpc  "2.0"
+  :method  :exit)))
+  :async-p (not sync)
+  :timeout-fn (lambda ()
+(eglot--warn "Brutally deleting existing process %s"
+  process)
+(process-put process 'eglot--moribund t)
+(delete-process process
+
 
 ;;; Notifications
 ;;;
@@ -405,6 +409,12 @@
   "Handle notification publishDiagnostics"
   (eglot--message "So yeah I got %s for %s"
   diagnostics uri))
+
+
+;;; Helpers
+;;;
+(defun
+eglot--debug (format &rest args)
   (display-warning 'eglot
  (apply #'format format args)
  :debug))



[elpa] externals/eglot e8f859e 031/139: Rework commands for connecting and reconnecting

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit e8f859e77e5e6109efdc62ee257b261c54137aca
Author: João Távora 
Commit: João Távora 

Rework commands for connecting and reconnecting

* eglot.el (eglot--current-process-or-lose): Add doc.
(eglot--command): Remove.
(eglot--bootstrap-fn): New process-local variable.
(eglot--connect): Redesign.
(eglot-make-local-process): New function.
(eglot-reconnect): New interactive command.
(eglot-new-process): Redesign.
(eglot--process-sentinel): Add doc.
(eglot--protocol-initialize): Rework.
(eglot--mode-line-format): Use eglot-reconnect.
---
 eglot.el | 139 +--
 1 file changed, 81 insertions(+), 58 deletions(-)

diff --git a/eglot.el b/eglot.el
index fe63a29..c7bb5d4 100644
--- a/eglot.el
+++ b/eglot.el
@@ -54,6 +54,7 @@
  (gethash cur eglot--processes-by-project)
 
 (defun eglot--current-process-or-lose ()
+  "Return the current EGLOT process or error."
   (or (eglot--current-process)
   (eglot--error "No current EGLOT process%s"
 (if (project-current) ""
@@ -109,29 +110,62 @@ A list (ID WHAT DONE-P)." t)
   "Status as declared by the server.
 A list (WHAT SERIOUS-P)." t)
 
-(defun eglot--command (&optional errorp)
-  (let ((probe (cdr (assoc major-mode eglot-executables
-(unless (or (not errorp)
-probe)
-  (eglot--error "Don't know how to start EGLOT for %s buffers"
-major-mode))
-probe))
+(eglot--define-process-var eglot--bootstrap-fn nil
+  "Function for returning processes/connetions to LSP servers.
+Must be a function of one arg, a name, returning a process
+object.")
 
-(defun eglot--connect (name filter sentinel)
-  "Helper for `eglot-new-process'.
+(defun eglot-make-local-process (name command)
+  "Make a local LSP process from COMMAND.
 NAME is a name to give the inferior process or connection.
-FILTER and SENTINEL are filter and sentinel.
-Should return a list of (PROCESS BUFFER)."
-  (let ((proc (make-process :name name
-:buffer (get-buffer-create
- (format "*%s inferior*" name))
-:command (eglot--command 'error)
-:connection-type 'pipe
-:filter filter
-:sentinel sentinel
-:stderr (get-buffer-create (format "*%s stderr*"
-   name)
-(list proc (process-buffer proc
+Returns a process object."
+  (let* ((readable-name (format "EGLOT server (%s)" name))
+ (proc
+  (make-process
+   :name readable-name
+   :buffer (get-buffer-create
+(format "*%s inferior*" readable-name))
+   :command command
+   :connection-type 'pipe
+   :filter 'eglot--process-filter
+   :sentinel 'eglot--process-sentinel
+   :stderr (get-buffer-create (format "*%s stderr*"
+  name)
+proc))
+
+(defun eglot--connect (short-name bootstrap-fn &optional success-fn)
+  "Make a connection with SHORT-NAME and BOOTSTRAP-FN.
+Call SUCCESS-FN with no args if all goes well."
+  (let* ((proc (funcall bootstrap-fn short-name))
+ (buffer (process-buffer proc)))
+(setf (eglot--bootstrap-fn proc) bootstrap-fn)
+(with-current-buffer buffer
+  (let ((inhibit-read-only t))
+(setf (eglot--short-name proc) short-name)
+(puthash (project-current) proc eglot--processes-by-project)
+(erase-buffer)
+(read-only-mode t)
+(with-current-buffer (eglot-events-buffer proc)
+  (let ((inhibit-read-only t))
+(insert
+ (format "\n---\n"
+(eglot--protocol-initialize
+ proc
+ (cl-function
+  (lambda (&key capabilities)
+(setf (eglot--capabilities proc) capabilities)
+(setf (eglot--status proc) nil)
+(when success-fn (funcall success-fn)
+
+(defun eglot-reconnect (process &optional interactive)
+  "Reconnect to PROCESS.
+INTERACTIVE is t if called interactively."
+  (interactive (list (eglot--current-process-or-lose) t))
+  (eglot-quit-server process 'sync interactive)
+  (eglot--connect (eglot--short-name process)
+  (eglot--bootstrap-fn process)
+  (lambda ()
+(eglot--message "Reconnected"
 
 (defun eglot-new-process (&optional interactive)
   "Start a new EGLOT process and initialize it.
@@ -140,32 +174,28 @@ INTERACTIVE is t if called interactively."
   (let ((project (project-current)))
 (unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
 (let ((current-process (eglot--current-process)))
-  (when (and current-process
-   

[elpa] externals/elpa f7f77e1 044/139: Make M-x eglot the main entry point

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit f7f77e19871dbfd6effda076e0557b90e34d2db2
Author: João Távora 
Commit: João Távora 

Make M-x eglot the main entry point

* eglot.el (eglot-new-process): Removed
(eglot): Rename from eglot-new-process.
(eglot-editing-mode): Mention M-x eglot

* README.md: Use M-x eglot
---
 README.md | 2 +-
 eglot.el  | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 7cf96f9..7a747fd 100644
--- a/README.md
+++ b/README.md
@@ -9,5 +9,5 @@ Coming soon.
 (add-to-list 'load-path "/path/to/eglot")
 (require 'eglot)
 
-M-x eglot-new-process
+M-x eglot
 ```
diff --git a/eglot.el b/eglot.el
index 5c014f3..ccf4b72 100644
--- a/eglot.el
+++ b/eglot.el
@@ -208,9 +208,9 @@ INTERACTIVE is t if called interactively."
  (eglot--message "Reconnected!"
 
 (defvar eglot--command-history nil
-  "History of COMMAND arguments to `eglot-new-process'.")
+  "History of COMMAND arguments to `eglot'.")
 
-(defun eglot-new-process (managed-major-mode command &optional interactive)
+(defun eglot (managed-major-mode command &optional interactive)
   ;; FIXME: Later make this function also connect to TCP servers by
   ;; overloading semantics on COMMAND.
   "Start a Language Server Protocol server.
@@ -252,7 +252,7 @@ INTERACTIVE is t if called interactively."
   (let* ((project (project-current))
  (short-name (eglot--project-short-name project)))
 (unless project (eglot--error
- "(new-process) Cannot work without a current project!"))
+ "Cannot work without a current project!"))
 (let ((current-process (eglot--current-process))
   (command
(or command
@@ -742,7 +742,7 @@ that case, also signal textDocument/didOpen."
 (flymake-mode 1)
 (if (eglot--current-process)
 (eglot--signalDidOpen)
-  (eglot--warn "No process, start one with `M-x eglot-new-process'")))
+  (eglot--warn "No process, start one with `M-x eglot'")))
(t
 (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
 (remove-hook 'after-change-functions 'eglot--after-change t)



[elpa] externals/elpa 63f2208 030/139: Less obstrusive flymake stuff for now

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 63f2208f0c61313f9eceb94219b4fab2ff84a373
Author: João Távora 
Commit: João Távora 

Less obstrusive flymake stuff for now

* eglot.el (eglot--after-change, eglot-flymake-backend): Fix.
---
 eglot.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 9742f88..fe63a29 100644
--- a/eglot.el
+++ b/eglot.el
@@ -775,7 +775,8 @@ running.  INTERACTIVE is t if called interactively."
 (defun eglot--after-change (start end length)
   (cl-incf eglot--versioned-identifier)
   (push (list start end length) eglot--recent-changes)
-  (eglot--message "start is %s, end is %s, length is %s" start end length))
+  ;; (eglot--message "start is %s, end is %s, length is %s" start end length)
+  )
 
 (defun eglot--signalDidOpen ()
   (eglot--notify (eglot--current-process-or-lose)
@@ -816,6 +817,9 @@ running.  INTERACTIVE is t if called interactively."
 (setq eglot--recent-changes nil)))
 
 (defun eglot-flymake-backend (report-fn &rest _more)
+  "An EGLOT Flymake backend.
+Calls REPORT-FN maybe if server publishes diagnostics in time."
+  ;; FIXME: perhaps should call it immediately?
   (setq eglot--current-flymake-report-fn report-fn)
   (eglot--maybe-signal-didChange))
 



[elpa] externals/eglot d90efdf 001/139: Initial commit

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit d90efdf04024eab75f189790cd38678a7cad3b43
Author: João Távora 
Commit: João Távora 

Initial commit
---
 .gitignore |  40 
 LICENSE| 674 +
 README.md  |  13 ++
 eglot.el   | 393 +++
 4 files changed, 1120 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..0a94baa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+ChangeLog
+*.x86f
+*.fasl*
+*.dfsl
+*.lx64fsl
+*.dx64fsl
+*.elc
+*.cls
+*~
+\#*\#
+.\#*
+.DS_Store
+# for the doc
+#
+doc/*.html
+doc/html
+doc/contributors.texi
+doc/*.info
+doc/*.pdf
+doc/*.ps
+doc/*.dvi
+doc/*.aux
+doc/*.cp
+doc/*.cps
+doc/*.fn
+doc/*.fns
+doc/*.ky
+doc/*.kys
+doc/*.log
+doc/*.pg
+doc/*.toc
+doc/*.tp
+doc/*.vr
+doc/*.op
+doc/*.ops
+doc/*.pgs
+doc/*.vrs
+doc/*.tgz
+doc/gh-pages
+/dist/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000..9cecc1d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+   TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to an

[elpa] externals/eglot 3a8f9a1 002/139: Remove a couple of comments

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 3a8f9a18d415b190d50db31ba5572f1a7979f37f
Author: João Távora 
Commit: João Távora 

Remove a couple of comments
---
 eglot.el | 2 --
 1 file changed, 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index f667eca..f2ef418 100644
--- a/eglot.el
+++ b/eglot.el
@@ -36,7 +36,6 @@
 (defvar eglot-executables '((rust-mode . ("rls")))
   "Alist mapping major modes to server executables")
 
-;;; TODO: Soon to be per-project
 (defvar eglot--processes-by-project (make-hash-table :test #'equal))
 
 (defun eglot--current-process ()
@@ -279,7 +278,6 @@
(eglot--debug "No implemetation for notification %s yet"
  (plist-get message :method))
 
-;; (setq json-encoding-pretty-print nil) ; for debug
 (defvar eglot--expect-carriage-return nil)
 
 (defun eglot--process-send (proc message)



[elpa] externals/elpa 3a8f9a1 002/139: Remove a couple of comments

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 3a8f9a18d415b190d50db31ba5572f1a7979f37f
Author: João Távora 
Commit: João Távora 

Remove a couple of comments
---
 eglot.el | 2 --
 1 file changed, 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index f667eca..f2ef418 100644
--- a/eglot.el
+++ b/eglot.el
@@ -36,7 +36,6 @@
 (defvar eglot-executables '((rust-mode . ("rls")))
   "Alist mapping major modes to server executables")
 
-;;; TODO: Soon to be per-project
 (defvar eglot--processes-by-project (make-hash-table :test #'equal))
 
 (defun eglot--current-process ()
@@ -279,7 +278,6 @@
(eglot--debug "No implemetation for notification %s yet"
  (plist-get message :method))
 
-;; (setq json-encoding-pretty-print nil) ; for debug
 (defvar eglot--expect-carriage-return nil)
 
 (defun eglot--process-send (proc message)



[elpa] externals/elpa 9d404c9 054/139: Update README.md

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 9d404c98d7de60f02278cfd1ef84416792690169
Author: João Távora 
Commit: João Távora 

Update README.md
---
 README.md | 40 ++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 7a747fd..8809421 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,47 @@ Eglot
 
 *E*macs Poly*glot*. An Emacs client to Language Server Protocol servers.
 
-Coming soon.
-
 ```
 (add-to-list 'load-path "/path/to/eglot")
 (require 'eglot)
 
 M-x eglot
 ```
+
+*That's it*. Either this guesses the local LSP program to start for
+the language of your choice or it prompts you for such a thing. You
+can also enter a `server:port` pattern to connect to an LSP server. To
+skip the guess and always be prompted use `C-u M-x eglot`.
+
+## Differences to lsp-mode.el
+
+This is really beta and currently does less than
+[lsp-mode.el](https://github.com/emacs-lsp/lsp-mode) which is more
+mature. Though I think `eglot.el` will eventually beat it, you could
+be better served with `lsp-mode.el` for now.
+
+User-visible differences:
+
+- Single entry point, `M-x eglot` to enable LSP in a project.
+  Automatically detects current and future opened files under that
+  project and syncs with server.
+- Easy way to restart a server
+- Pretty interactive mode-line section for live tracking of server
+  communication.
+   
+Differences under the hood:
+
+- Message parser is much much simpler
+- Easier to read and maintain elisp. Yeah I know, subjective... But
+  judge for yourself.
+- No external dependencies apart from Emacs (no `flycheck.el`, no
+  `projectile.el`, no Cask, etc).
+- Uses project.el, flymake.el
+- Requires the upcoming emacs 26
+- Contained in one file
+- send `textDocument/didChange` for groups of edits, not one per each
+  tiny change. 
+- Its missing tests! This is *not good*
+
+
+   



[elpa] externals/elpa 0e95167 042/139: Watch for files opened under umbrella of existing process

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 0e951677e486a48a1ec583382d77e04b8a457d37
Author: João Távora 
Commit: João Távora 

Watch for files opened under umbrella of existing process

* eglot.el (eglot--connect): Call success-fn with a proc.
(eglot-reconnect): Adapt to new eglot--connect.
(eglot-new-process): Call eglot--maybe-activate-editing-mode
(eglot--maybe-activate-editing-mode): New function.
(find-file-hook): Add it here.
---
 eglot.el | 42 +-
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/eglot.el b/eglot.el
index 10af6c5..f4ac858 100644
--- a/eglot.el
+++ b/eglot.el
@@ -190,7 +190,7 @@ SUCCESS-FN with no args if all goes well."
   (lambda (&key capabilities)
 (setf (eglot--capabilities proc) capabilities)
 (setf (eglot--status proc) nil)
-(when success-fn (funcall success-fn)
+(when success-fn (funcall success-fn proc)
 
 (defun eglot-reconnect (process &optional interactive)
   "Reconnect to PROCESS.
@@ -203,8 +203,8 @@ INTERACTIVE is t if called interactively."
(eglot--major-mode process)
(eglot--short-name process)
(eglot--bootstrap-fn process)
-   (lambda ()
- (eglot--message "Reconnected"
+   (lambda (_proc)
+ (eglot--message "Reconnected!"
 
 (defvar eglot--command-history nil
   "History of COMMAND arguments to `eglot-new-process'.")
@@ -273,21 +273,15 @@ INTERACTIVE is t if called interactively."
(eglot-make-local-process
 name
 command))
- (lambda ()
-   (eglot--message "Connected. Managing `%s' buffers in project %s."
-   managed-major-mode short-name)
+ (lambda (proc)
+   (eglot--message "Connected! Process `%s' now managing `%s'\
+buffers in project %s."
+   proc
+   managed-major-mode
+   short-name)
(dolist (buffer (buffer-list))
  (with-current-buffer buffer
-   (when(and buffer-file-name
- (cl-some
-  (lambda (root)
-(string-prefix-p
- (expand-file-name root)
- (expand-file-name buffer-file-name)))
-  (project-roots project)))
- (unless eglot-editing-mode
-   (eglot-editing-mode 1))
- (eglot--signalDidOpen)))
+   (eglot--maybe-activate-editing-mode proc))
 
 (defun eglot--process-sentinel (process change)
   "Called with PROCESS undergoes CHANGE."
@@ -706,7 +700,7 @@ running.  INTERACTIVE is t if called interactively."
 
 
 
-;;; Mode line
+;;; Minor modes and mode-line
 ;;;
 (defface eglot-mode-line
   '((t (:inherit font-lock-constant-face :weight bold)))
@@ -717,6 +711,20 @@ running.  INTERACTIVE is t if called interactively."
 
 (defvar eglot-editing-mode-map (make-sparse-keymap))
 
+(defun eglot--maybe-activate-editing-mode (&optional proc)
+  "Maybe activate mode function `eglot-editing-mode'.
+If PROC is supplied, do it only if BUFFER is managed by it.  In
+that case, also signal textDocument/didOpen."
+  (when buffer-file-name
+(let ((cur (eglot--current-process)))
+  (when (or (and (null proc) cur)
+(and proc (eq proc cur)))
+(unless eglot-editing-mode
+  (eglot-editing-mode 1))
+(eglot--signalDidOpen)
+
+(add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
+
 (define-minor-mode eglot-editing-mode
   "Minor mode for source buffers where EGLOT helps you edit."
   nil



[elpa] externals/elpa dfab9a0 011/139: Experimental diagnostic overlays

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit dfab9a08a6b6af099c21f9cd8a99f5a00d81cb4e
Author: João Távora 
Commit: João Távora 

Experimental diagnostic overlays
---
 eglot.el | 40 ++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 479e87a..cd91d78 100644
--- a/eglot.el
+++ b/eglot.el
@@ -414,11 +414,47 @@
 
 ;;; Notifications
 ;;;
+(defvar-local eglot--diagnostic-overlays nil)
+
 (cl-defun eglot--textDocument/publishDiagnostics
 (_process &key uri diagnostics)
   "Handle notification publishDiagnostics"
-  (eglot--message "So yeah I got %s for %s"
-  diagnostics uri))
+  (let* ((obj (url-generic-parse-url uri))
+(filename (car (url-path-and-query obj)))
+ (buffer (find-buffer-visiting filename)))
+(cond
+ (buffer
+  (with-current-buffer buffer
+(eglot--message "OK so add some %s diags" (length diagnostics))
+(mapc #'delete-overlay eglot--diagnostic-overlays)
+(setq eglot--diagnostic-overlays nil)
+(cl-flet ((pos-at (pos-plist)
+  (save-excursion
+(goto-char (point-min))
+(forward-line (plist-get pos-plist :line))
+(forward-char (plist-get pos-plist :character))
+(point
+  (loop for diag across diagnostics
+do (cl-destructuring-bind (&key range severity
+_code _source message)
+   diag
+ (cl-destructuring-bind (&key start end)
+ range
+   (let* ((begin-pos (pos-at start))
+  (end-pos (pos-at end))
+  (ov (make-overlay begin-pos
+end-pos
+buffer)))
+ (push ov eglot--diagnostic-overlays)
+ (overlay-put ov 'face
+  (case severity
+(1 'flymake-errline)
+(2 'flymake-warnline)))
+ (overlay-put ov 'help-echo
+  message)
+ (overlay-put ov 'eglot--diagnostic diag
+ (t
+  (eglot--message "OK so %s isn't visited" filename)
 
 
 ;;; Helpers



[elpa] externals/elpa cc183a6 043/139: Fix assorted bugs

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit cc183a6c62567bf7fb6303e133455ad9c8da7479
Author: João Távora 
Commit: João Távora 

Fix assorted bugs

* eglot.el (eglot--special-buffer-process): Must be buffer-local.
(eglot--define-process-var): Fix disaster waiting to happen.
(eglot--process-receive): Explicitly pass PROC to
eglot--pending-continuations.
(eglot--textDocument/publishDiagnostics): Clear unreported diagnostics
---
 eglot.el | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/eglot.el b/eglot.el
index f4ac858..5c014f3 100644
--- a/eglot.el
+++ b/eglot.el
@@ -48,7 +48,7 @@
 (defvar eglot-editing-mode) ; forward decl
 (defvar eglot-mode) ; forward decl
 
-(defvar eglot--special-buffer-process nil
+(defvar-local eglot--special-buffer-process nil
   "Current buffer's eglot process.")
 
 (defun eglot--current-process ()
@@ -78,13 +78,14 @@ after setting it."
   (declare (indent 2))
   `(progn
  (put ',var-sym 'function-documentation ,doc)
- (defun ,var-sym (&optional process)
-   (let* ((proc (or process (eglot--current-process-or-lose)))
-  (probe (process-get proc ',var-sym)))
- (or probe
- (let ((def ,initval))
-   (process-put proc ',var-sym def)
-   def
+ (defun ,var-sym (proc)
+   (let* ((plist (process-plist proc))
+  (probe (plist-member plist ',var-sym)))
+ (if probe
+ (cadr probe)
+   (let ((def ,initval))
+ (process-put proc ',var-sym def)
+ def
  (gv-define-setter ,var-sym (to-store &optional process)
(let* ((prop ',var-sym))
  ,(let ((form '(let ((proc (or ,process 
(eglot--current-process-or-lose
@@ -417,7 +418,8 @@ identifier.  ERROR is non-nil if this is an error."
   (let* ((response-id (plist-get message :id))
  (err (plist-get message :error))
  (continuations (and response-id
- (gethash response-id 
(eglot--pending-continuations)
+ (gethash response-id
+  (eglot--pending-continuations proc)
 (eglot--log-event proc
   (cond ((not response-id)
  'server-notification)
@@ -436,7 +438,7 @@ identifier.  ERROR is non-nil if this is an error."
   (continuations
(cancel-timer (cl-third continuations))
(remhash response-id
-(eglot--pending-continuations))
+(eglot--pending-continuations proc))
(cond (err
   (apply (cl-second continuations) err))
  (t
@@ -655,11 +657,12 @@ running.  INTERACTIVE is t if called interactively."
   message
into diags
finally
-   (if eglot--current-flymake-report-fn
-   (funcall eglot--current-flymake-report-fn
-diags)
- (setq eglot--unreported-diagnostics
-   diags))
+   (if (null eglot--current-flymake-report-fn)
+   (setq eglot--unreported-diagnostics
+ diags)
+ (funcall eglot--current-flymake-report-fn
+  diags)
+ (setq eglot--unreported-diagnostics nil))
  (t
   (eglot--message "OK so %s isn't visited" filename)
 



[elpa] externals/eglot f7f77e1 044/139: Make M-x eglot the main entry point

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit f7f77e19871dbfd6effda076e0557b90e34d2db2
Author: João Távora 
Commit: João Távora 

Make M-x eglot the main entry point

* eglot.el (eglot-new-process): Removed
(eglot): Rename from eglot-new-process.
(eglot-editing-mode): Mention M-x eglot

* README.md: Use M-x eglot
---
 README.md | 2 +-
 eglot.el  | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 7cf96f9..7a747fd 100644
--- a/README.md
+++ b/README.md
@@ -9,5 +9,5 @@ Coming soon.
 (add-to-list 'load-path "/path/to/eglot")
 (require 'eglot)
 
-M-x eglot-new-process
+M-x eglot
 ```
diff --git a/eglot.el b/eglot.el
index 5c014f3..ccf4b72 100644
--- a/eglot.el
+++ b/eglot.el
@@ -208,9 +208,9 @@ INTERACTIVE is t if called interactively."
  (eglot--message "Reconnected!"
 
 (defvar eglot--command-history nil
-  "History of COMMAND arguments to `eglot-new-process'.")
+  "History of COMMAND arguments to `eglot'.")
 
-(defun eglot-new-process (managed-major-mode command &optional interactive)
+(defun eglot (managed-major-mode command &optional interactive)
   ;; FIXME: Later make this function also connect to TCP servers by
   ;; overloading semantics on COMMAND.
   "Start a Language Server Protocol server.
@@ -252,7 +252,7 @@ INTERACTIVE is t if called interactively."
   (let* ((project (project-current))
  (short-name (eglot--project-short-name project)))
 (unless project (eglot--error
- "(new-process) Cannot work without a current project!"))
+ "Cannot work without a current project!"))
 (let ((current-process (eglot--current-process))
   (command
(or command
@@ -742,7 +742,7 @@ that case, also signal textDocument/didOpen."
 (flymake-mode 1)
 (if (eglot--current-process)
 (eglot--signalDidOpen)
-  (eglot--warn "No process, start one with `M-x eglot-new-process'")))
+  (eglot--warn "No process, start one with `M-x eglot'")))
(t
 (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
 (remove-hook 'after-change-functions 'eglot--after-change t)



[elpa] externals/elpa b1554fc 055/139: * eglot.el (eglot--process-receive): Skip null method notifs.

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit b1554fc921f8d91870373cf9d3a089afc3f0f63d
Author: João Távora 
Commit: João Távora 

* eglot.el (eglot--process-receive): Skip null method notifs.
---
 eglot.el | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index ebc07d2..693535a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -477,8 +477,11 @@ identifier.  ERROR is non-nil if this is an error."
   (plist-get message :params)
   (let ((id (plist-get message :id)))
 (if id `(:id ,id)
-   (eglot--warn "No implemetation for notification %s yet"
-method)))
+   ;; pyls keeps on sending nil notifs for each notif we
+   ;; send it, just ignore these.
+   (unless (null method)
+ (eglot--warn "No implemetation for notification %s yet"
+  method
 
 (defvar eglot--expect-carriage-return nil)
 



[elpa] externals/elpa 22dc2f7 034/139: Ready to start fixing flymake integration

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 22dc2f7ba341b66bc904afa0ffa75b7da86a413e
Author: João Távora 
Commit: João Távora 

Ready to start fixing flymake integration

* eglot.el (eglot-editing-mode): Turn on flymake-mode.
(eglot-flymake-backend): Always start by reporting no diagnostics.
(eglot--textDocument/publishDiagnostics): No annoying message.
---
 eglot.el | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index d3428a7..aa23252 100644
--- a/eglot.el
+++ b/eglot.el
@@ -573,7 +573,6 @@ running.  INTERACTIVE is t if called interactively."
   (eglot--warn "outdated publishDiagnostics report from server"))
  (buffer
   (with-current-buffer buffer
-(eglot--message "OK so add some %s diags" (length diagnostics))
 (cl-flet ((pos-at
(pos-plist)
(car (flymake-diag-region
@@ -662,6 +661,7 @@ running.  INTERACTIVE is t if called interactively."
 (eglot-mode 1)
 (add-hook 'after-change-functions 'eglot--after-change nil t)
 (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
+(flymake-mode 1)
 (if (eglot--current-process)
 (eglot--signalDidOpen)
   (if (y-or-n-p "No process, try to start one with `eglot-new-process'? ")
@@ -857,7 +857,10 @@ running.  INTERACTIVE is t if called interactively."
 (defun eglot-flymake-backend (report-fn &rest _more)
   "An EGLOT Flymake backend.
 Calls REPORT-FN maybe if server publishes diagnostics in time."
-  ;; FIXME: perhaps should call it immediately?
+  ;; call immediately with no diagnostics, this just means we don't
+  ;; have them yet (and also clears any pending ones).
+  ;;
+  (funcall report-fn nil)
   (setq eglot--current-flymake-report-fn report-fn)
   (eglot--maybe-signal-didChange))
 



[elpa] externals/elpa 328c7ae 025/139: Auto update mode-line after setting some process properties

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 328c7aeb9dc0ede8334be6b520545abeb0db308a
Author: João Távora 
Commit: João Távora 

Auto update mode-line after setting some process properties

* eglot.el (eglot--define-process-var): Rework.
(eglot--short-name, eglot--spinner, eglot--status): Update mode-line
after setting it.
---
 eglot.el | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/eglot.el b/eglot.el
index ff71a2f..1a82cc5 100644
--- a/eglot.el
+++ b/eglot.el
@@ -55,7 +55,12 @@
 (if (project-current) ""
   " (Also no current project)"
 
-(defmacro eglot--define-process-var (var-sym initval &optional doc)
+(defmacro eglot--define-process-var
+(var-sym initval &optional doc mode-line-update-p)
+  "Define VAR-SYM as a generalized process-local variable.
+INITVAL is the default value.  DOC is the documentation.
+MODE-LINE-UPDATE-P says to also force a mode line update
+after setting it."
   (declare (indent 2))
   `(progn
  (put ',var-sym 'function-documentation ,doc)
@@ -67,12 +72,15 @@
(process-put proc ',var-sym def)
def
  (gv-define-setter ,var-sym (to-store &optional process)
-   (let ((prop ',var-sym))
- `(let ((proc (or ,process (eglot--current-process-or-lose
-(process-put proc ',prop ,to-store))
+   (let* ((prop ',var-sym))
+ ,(let ((form '(let ((proc (or ,process 
(eglot--current-process-or-lose
+ (process-put proc ',prop ,to-store
+(if mode-line-update-p
+`(backquote (prog1 ,form (force-mode-line-update t)))
+  `(backquote ,form)))
 
 (eglot--define-process-var eglot--short-name nil
-  "A short name for the process")
+  "A short name for the process" t)
 
 (eglot--define-process-var eglot--expected-bytes nil
   "How many bytes declared by server")
@@ -91,11 +99,11 @@
 
 (eglot--define-process-var eglot--spinner `(nil nil t)
   "\"Spinner\" used by some servers.
-A list (ID WHAT DONE-P).")
+A list (ID WHAT DONE-P)." t)
 
 (eglot--define-process-var eglot--status `(:unknown nil)
   "Status as declared by the server.
-A list (WHAT SERIOUS-P).")
+A list (WHAT SERIOUS-P)." t)
 
 (defun eglot--command (&optional errorp)
   (let ((probe (cdr (assoc major-mode eglot-executables



[elpa] externals/eglot a3545fb 050/139: Rename RPC methods for clarity

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit a3545fbf2a0e896b7129a49d3eafe1f4c0dee98b
Author: João Távora 
Commit: João Távora 

Rename RPC methods for clarity

* eglot.el (eglot--process-receive): Search for RPC server methods
under `eglot--server-'
(eglot-editing-mode, eglot--maybe-activate-editing-mode): Use new
signal names.
(eglot--server-window/showMessage): Rename from
eglot--window/showMessage.
(eglot--server-textDocument/publishDiagnostics): Renamed from
eglot--textDocument/publishDiagnostics.
(eglot--current-buffer-versioned-identifier): Remove.
(eglot--current-buffer-VersionedTextDocumentIdentifier): Use
eglot--versioned-identifier.
(eglot--signal-textDocument/didChange): Renamed from
eglot--maybe-signal-didChange.
(eglot--signal-textDocument/didOpen): Renamed from
eglot--signalDidOpen.
(eglot--signal-textDocument/didClose): Rename from
eglot--signalDidClose.
(eglot-flymake-backend): Call eglot--signal-textDocument/didChange.
(eglot--server-window/progress): Rename from
eglot--window/progress.
---
 eglot.el | 36 
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/eglot.el b/eglot.el
index 7d44e6d..469d3f7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -455,12 +455,12 @@ identifier.  ERROR is non-nil if this is an error."
   (apply (cl-first continuations) (plist-get message 
:result)
   (t
(let* ((method (plist-get message :method))
-  (handler-sym (intern (concat "eglot--"
+  (handler-sym (intern (concat "eglot--server-"
method
  (if (functionp handler-sym)
  (apply handler-sym proc (plist-get message :params))
-   (eglot--debug "No implemetation for notification %s yet"
- method)))
+   (eglot--warn "No implemetation for notification %s yet"
+method)))
 
 (defvar eglot--expect-carriage-return nil)
 
@@ -612,15 +612,15 @@ identifier.  ERROR is non-nil if this is an error."
 (eglot-mode 1)
 (add-hook 'after-change-functions 'eglot--after-change nil t)
 (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
-(add-hook 'kill-buffer-hook 'eglot--signalDidClose nil t)
+(add-hook 'kill-buffer-hook 'eglot--signal-textDocument/didClose nil t)
 (flymake-mode 1)
 (if (eglot--current-process)
-(eglot--signalDidOpen)
+(eglot--signal-textDocument/didOpen)
   (eglot--warn "No process, start one with `M-x eglot'")))
(t
 (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
 (remove-hook 'after-change-functions 'eglot--after-change t)
-(remove-hook 'kill-buffer-hook 'eglot--signalDidClose t
+(remove-hook 'kill-buffer-hook 'eglot--signal-textDocument/didClose t
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil
@@ -643,7 +643,7 @@ that case, also signal textDocument/didOpen."
 (and proc (eq proc cur)))
 (unless eglot-editing-mode
   (eglot-editing-mode 1))
-(eglot--signalDidOpen)
+(eglot--signal-textDocument/didOpen)
 (flymake-start)
 
 (add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
@@ -805,7 +805,7 @@ running.  INTERACTIVE is t if called interactively."
  :async-p (not sync)
  :timeout-fn brutal)))
 
-(cl-defun eglot--window/showMessage
+(cl-defun eglot--server-window/showMessage
 (process &key type message)
   "Handle notification window/showMessage"
   (when (<= 1 type)
@@ -821,7 +821,7 @@ running.  INTERACTIVE is t if called interactively."
 (defvar-local eglot--unreported-diagnostics nil
   "Unreported diagnostics for this buffer.")
 
-(cl-defun eglot--textDocument/publishDiagnostics
+(cl-defun eglot--server-textDocument/publishDiagnostics
 (_process &key uri diagnostics)
   "Handle notification publishDiagnostics"
   (let* ((obj (url-generic-parse-url uri))
@@ -873,11 +873,6 @@ running.  INTERACTIVE is t if called interactively."
 
 (defvar-local eglot--versioned-identifier 0)
 
-(defun eglot--current-buffer-versioned-identifier ()
-  "Return a VersionedTextDocumentIdentifier."
-  ;; FIXME: later deal with workspaces
-  eglot--versioned-identifier)
-
 (defun eglot--current-buffer-VersionedTextDocumentIdentifier ()
   "Compute VersionedTextDocumentIdentifier object for current buffer."
   (eglot--obj :uri
@@ -885,7 +880,8 @@ running.  INTERACTIVE is t if called interactively."
   (url-hexify-string
(file-truename buffer-file-name)
url-path-allowed-chars))
-  :version (eglot--current-buffer-versioned-identifier)))
+  ;; FIXME: later deal with workspaces
+  :version eglot--versioned-identifier))
 
 (defun eglot

[elpa] externals/elpa 8bd634c 016/139: Start working on this again

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 8bd634ce9d5058e2db36dcf250bb909cc96eeaeb
Author: João Távora 
Commit: João Távora 

Start working on this again

* eglot.el (url-util): Require it.
(eglot--process-sentinel): pending continuations now are quads (added env).
(eglot--process-filter): Unwind message markers correctly if handling fails.
(eglot--obj): Simple macro.
(eglot--log-event): Add some info to logged event.
(eglot--environment-vars, eglot--environment): Helper vars.
(eglot--process-receive): Improve.
(eglot--process-send): Niver log.
(eglot--request): Use eglot--obj. Add environment.
(eglot--notify): New helper.
(eglot--protocol-initialize): RLS must like file://
(eglot--current-flymake-report-fn): New var.
(eglot--textDocument/publishDiagnostics): Use flymake from Emacs 26.
(eglot-mode): Proper minor mode.
(eglot--recent-changes, eglot--versioned-identifier): New stuff.
(eglot--current-buffer-versioned-identifier)
(eglot--current-buffer-VersionedTextDocumentIdentifier)
(eglot--current-buffer-TextDocumentItem, eglot--after-change)
(eglot--signalDidOpen, eglot--maybe-signal-didChange): New stuff.
(eglot-flymake-backend): More or less a flymake backend function.
---
 eglot.el | 267 ---
 1 file changed, 204 insertions(+), 63 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8946692..8da6267 100644
--- a/eglot.el
+++ b/eglot.el
@@ -28,6 +28,7 @@
 (require 'cl-lib)
 (require 'project)
 (require 'url-parse)
+(require 'url-util)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -143,8 +144,8 @@
 (when (not (process-live-p process))
   ;; Remember to cancel all timers
   ;;
-  (maphash (lambda (id triplet)
- (cl-destructuring-bind (_success _error timeout) triplet
+  (maphash (lambda (id quad)
+ (cl-destructuring-bind (_success _error timeout _env) quad
(eglot--message
 "(sentinel) Cancelling timer for continuation %s" id)
(cancel-timer timeout)))
@@ -185,7 +186,7 @@
 (when new-expected-bytes
   (when expected-bytes
 (eglot--warn
- (concat "Unexpectedly starting new message but %s bytes"
+ (concat "Unexpectedly starting new message but %s bytes "
  "reportedly remaining from previous one")
  expected-bytes))
   (set-marker message-mark (point))
@@ -207,22 +208,29 @@
  (let* ((message-end (byte-to-position
   (+ (position-bytes message-mark)
  expected-bytes
-   (save-excursion
- (save-restriction
-   (goto-char message-mark)
-   (narrow-to-region message-mark
- message-end)
-   (eglot--process-receive
-proc
-(let ((json-object-type 'plist))
-  (json-read)
-   (set-marker message-mark message-end)
-   (setf (eglot--expected-bytes proc) nil)))
+   (unwind-protect
+   (save-excursion
+ (save-restriction
+   (goto-char message-mark)
+   (narrow-to-region message-mark
+ message-end)
+   (eglot--process-receive
+proc
+(let ((json-object-type 'plist))
+  (json-read)
+ (set-marker message-mark message-end)
+ (setf (eglot--expected-bytes proc) nil
 (t
  ;; just adding some stuff to the end that doesn't yet
  ;; complete the message
  )))
 
+(defmacro eglot--obj (&rest what)
+  "Make an object suitable for `json-encode'"
+  ;; FIXME: maybe later actually do something, for now this just fixes
+  ;; the indenting of literal plists.
+  `(list ,@what))
+
 (defun eglot-events-buffer (process &optional interactive)
   (interactive (list (eglot--current-process-or-lose) t))
   (let* ((probe (eglot--events-buffer process))
@@ -241,22 +249,39 @@
   (display-buffer buffer))
 buffer))
 
-(defun eglot--log-event (proc type message)
+(defun eglot--log-event (proc type message id error)
   (with-current-buffer (eglot-events-buffer proc)
 (let ((inhibit-read-only t))
   (goto-char (point-max))
-  (insert (format "%s: \n%s\n" type (pp-to-string message))
+  (insert (format "%s%s%s:\n%s\n"
+  type
+  (if id (format " (id:%s)" id) "")
+  (i

[elpa] externals/elpa f8bfb7e 064/139: Handle requests from server correctly

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit f8bfb7e26aed285167d9a41ed986894b2646ebae
Author: João Távora 
Commit: João Távora 

Handle requests from server correctly

* eglot.el (eglot--process-receive): Redesign.
(eglot--process-send): Take REPLY arg. Discover if message is error.
(eglot--reply): new function
(eglot--log-event): Tweak docstring.
(eglot--process-receive): Reply with -32601 if unimplemented.
(eglot--server-window/showMessageRequest)
(eglot--server-client/registerCapability): Use eglot--reply
---
 eglot.el | 95 ++--
 1 file changed, 50 insertions(+), 45 deletions(-)

diff --git a/eglot.el b/eglot.el
index df03d04..332f1fe 100644
--- a/eglot.el
+++ b/eglot.el
@@ -460,7 +460,7 @@ INTERACTIVE is t if called interactively."
   "Log an eglot-related event.
 PROC is the current process.  TYPE is an identifier.  MESSAGE is
 a JSON-like plist or anything else.  ID is a continuation
-identifier.  ERROR is non-nil if this is an error."
+identifier.  ERROR is non-nil if this is a JSON-RPC error."
   (with-current-buffer (eglot-events-buffer proc)
 (let ((inhibit-read-only t))
   (goto-char (point-max))
@@ -475,53 +475,49 @@ identifier.  ERROR is non-nil if this is an error."
 
 (defun eglot--process-receive (proc message)
   "Process MESSAGE from PROC."
-  (let* ((response-id (plist-get message :id))
+  (let* ((id (plist-get message :id))
+ (method (plist-get message :method))
  (err (plist-get message :error))
- (continuations (and response-id
- (gethash response-id
-  (eglot--pending-continuations proc)
+ (continuations (and id
+ (not method)
+ (gethash id (eglot--pending-continuations 
proc)
 (eglot--log-event proc
-  (cond ((not response-id)
- 'server-notification)
-((not continuations)
- 'unexpected-server-reply)
-(t
- 'server-reply))
+  (cond ((and method id)   'server-request)
+(method'server-notification)
+(continuations 'server-reply)
+;; pyls keeps on sending these
+(t 'unexpected-server-thingy))
   message
-  response-id
+  id
   err)
-(when err
-  (setf (eglot--status proc) '("error" t)))
-(cond ((and response-id
-(not continuations))
-   (eglot--warn "Ooops no continuation for id %s" response-id))
-  (continuations
-   (cancel-timer (cl-third continuations))
-   (remhash response-id
-(eglot--pending-continuations proc))
-   (cond (err
-  (apply (cl-second continuations) err))
- (t
-  (apply (cl-first continuations) (plist-get message 
:result)
-  (t
+(when err (setf (eglot--status proc) '("error" t)))
+(cond (method
;; a server notification or a server request
-   (let* ((method (plist-get message :method))
-  (handler-sym (intern (concat "eglot--server-"
+   (let* ((handler-sym (intern (concat "eglot--server-"
method
  (if (functionp handler-sym)
  (apply handler-sym proc (append
   (plist-get message :params)
-  (let ((id (plist-get message :id)))
-(if id `(:id ,id)
-   ;; pyls keeps on sending nil notifs for each notif we
-   ;; send it, just ignore these.
-   (unless (null method)
- (eglot--warn "No implemetation for notification %s yet"
-  method
+  (if id `(:id ,id
+   (eglot--warn "No implementation of method %s yet"
+method)
+   (when id
+ (eglot--reply
+  proc id
+  :error (eglot--obj :code -32601
+ :message "Method unimplemented"))
+  (continuations
+   (cancel-timer (cl-third continuations))
+   (remhash id (eglot--pending-continuations proc))
+   (if err
+   (apply (cl-second continuations) err)
+ (apply (cl-first continuations) (plist-get message :result
+  (id
+   (eglot--warn "Ooops no continuation for id %s" id)
 
 (defvar eglot--expect-carriage-return nil)
 
-(de

[elpa] externals/elpa ea918ab 066/139: Include source info in diagnostics

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit ea918abb952c3e624e57681a9b313df32ddcd014
Author: João Távora 
Commit: João Távora 

Include source info in diagnostics

* eglot.el (eglot--server-textDocument/publishDiagnostics):
Include source info.
---
 eglot.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index d073be2..10435a1 100644
--- a/eglot.el
+++ b/eglot.el
@@ -936,7 +936,7 @@ running.  INTERACTIVE is t if called interactively."
  (point
   (cl-loop for diag-spec across diagnostics
collect (cl-destructuring-bind (&key range severity _group
-_code _source message)
+_code source message)
diag-spec
  (cl-destructuring-bind (&key start end)
  range
@@ -951,7 +951,7 @@ running.  INTERACTIVE is t if called interactively."
  :warning)
 (t
  :note))
-  message
+  (concat source ": " message)
into diags
finally
(if eglot--current-flymake-report-fn



[elpa] externals/elpa b4dd4f8 022/139: Report server status in the mode-line

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit b4dd4f850e4af8b202b47c3a6a2c0664ebbeaa30
Author: João Távora 
Commit: João Távora 

Report server status in the mode-line

* eglot.el (eglot--status): New var.
(eglot--log-event): Try to be more useful for other stuff.
(eglot--protocol-initialize): Set status to nil on
successful connect.
(eglot--window/showMessage): Set status to error if needed.
(eglot--mode-line-format): Display status if serious.
---
 eglot.el | 57 +++--
 1 file changed, 47 insertions(+), 10 deletions(-)

diff --git a/eglot.el b/eglot.el
index e5d6937..44023b7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -92,6 +92,10 @@
   "\"Spinner\" used by some servers.
 A list (ID WHAT DONE-P).")
 
+(eglot--define-process-var eglot--status `(:unknown nil)
+  "Status as declared by the server.
+A list (WHAT SERIOUS-P).")
+
 (defun eglot--command (&optional errorp)
   (let ((probe (cdr (assoc major-mode eglot-executables
 (unless (or (not errorp)
@@ -265,15 +269,22 @@ INTERACTIVE is t if called interactively."
   (display-buffer buffer))
 buffer))
 
-(defun eglot--log-event (proc type message id error)
+(defun eglot--log-event (proc type message &optional id error)
+  "Log an eglot-related event.
+PROC is the current process.  TYPE is an identifier.  MESSAGE is
+a JSON-like plist or anything else.  ID is a continuation
+identifier.  ERROR is non-nil if this is an error."
   (with-current-buffer (eglot-events-buffer proc)
 (let ((inhibit-read-only t))
   (goto-char (point-max))
-  (insert (format "%s%s%s:\n%s\n"
-  type
-  (if id (format " (id:%s)" id) "")
-  (if error " ERROR" "")
-  (pp-to-string message))
+  (let ((msg (format "%s%s%s:\n%s\n"
+ type
+ (if id (format " (id:%s)" id) "")
+ (if error " ERROR" "")
+ (pp-to-string message
+(when error
+  (setq msg (propertize msg 'face 'error)))
+(insert msg)
 
 (defvar eglot--environment-vars
   '(eglot--current-flymake-report-fn)
@@ -445,6 +456,7 @@ INTERACTIVE is t if caller was called interactively."
 (lambda (&key capabilities)
   (setf (eglot--capabilities process) capabilities)
   (when interactive
+(setf (eglot--status process) nil)
 (eglot--message
  "So yeah I got lots (%d) of capabilities"
  (length capabilities)))
@@ -535,6 +547,16 @@ running.  INTERACTIVE is t if called interactively."
  (t
   (eglot--message "OK so %s isn't visited" filename)
 
+(cl-defun eglot--window/showMessage
+(process &key type message)
+  "Handle notification window/showMessage"
+  (when (<= 1 type)
+(setf (eglot--status process) '("error" t))
+(eglot--log-event process
+  (propertize "server-error" 'face 'error)
+  message))
+  (eglot--message "Server reports (type=%s): %s" type message))
+
 
 ;;; Helpers
 ;;;
@@ -603,8 +625,12 @@ running.  INTERACTIVE is t if called interactively."
(pending (and proc
  (hash-table-count
   (eglot--pending-continuations proc
-   (`(,_id ,what ,done-p) (and proc
-   (eglot--spinner
+   (`(,_id ,doing ,done-p)
+(and proc
+ (eglot--spinner proc)))
+   (`(,status ,serious-p)
+(and proc
+ (eglot--status proc
 (append
  `((:propertize "eglot"
 face eglot-mode-line
@@ -629,10 +655,21 @@ running.  INTERACTIVE is t if called interactively."
   help-echo ,(concat "mouse-1: go to events buffer\n"
  "mouse-2: quit server\n"
  "mouse-3: new process"))
- ,@(when (and what (not done-p))
+ ,@(when serious-p
+ `("/"
+   (:propertize
+,status
+help-echo ,(concat "mouse-1: go to events buffer")
+mouse-face mode-line-highlight
+face compilation-mode-line-fail
+keymap ,(let ((map (make-sparse-keymap)))
+  (define-key map [mode-line mouse-1]
+'eglot-events-buffer)
+  map
+ ,@(when (and doing (not done-p))
  `("/"
(:propertize
-,what
+,doing
 help-echo ,(concat "mouse-1: go to events buffer")
 mouse-face mode-line-highlight
 face compilation-mode-line-run



[elpa] externals/elpa e60c7fc 013/139: Overhaul async mechanism safety

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit e60c7fce4048e8080a770013b0fbf8c26a5e5d54
Author: João Távora 
Commit: João Távora 

Overhaul async mechanism safety
---
 eglot.el | 172 +++
 1 file changed, 95 insertions(+), 77 deletions(-)

diff --git a/eglot.el b/eglot.el
index b59ee02..af9904a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -84,24 +84,8 @@
 (eglot--define-process-var eglot--capabilities :unreported
   "Holds list of capabilities that server reported")
 
-(cl-defmacro eglot--request (process
-  method
-  params
-  success-fn
-  &key
-  error-fn
-  timeout-fn
-  (async-p t))
-  (append `(eglot--call-with-request
-,process
-,async-p
-,method
-,params
-(cl-function ,success-fn))
-  (and error-fn
-   `((cl-function ,error-fn)))
-  (and timeout-fn
-   `((cl-function ,timeout-fn)
+(eglot--define-process-var eglot--moribund nil
+  "Non-nil if process is about to exit")
 
 (defun eglot--command (&optional errorp)
   (let ((probe (cdr (assoc major-mode eglot-executables
@@ -116,12 +100,12 @@
   (interactive (list t))
   (let ((project (project-current))
 (command (eglot--command 'errorp)))
-(unless project (eglot--error "Cannot work without a current project!"))
+(unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
 (let ((current-process (eglot--current-process)))
   (when (and current-process
  (process-live-p current-process))
-(eglot--message "Asking current process to terminate first")
-(eglot-quit-server current-process 'sync)))
+(eglot--message "(new-process) Asking current process to terminate 
first")
+(eglot-quit-server current-process 'sync interactive)))
 (let* ((short-name (file-name-base
 (directory-file-name
  (car (project-roots (project-current))
@@ -154,20 +138,23 @@
 
 (defun eglot--process-sentinel (process change)
   (with-current-buffer (process-buffer process)
-(eglot--debug "Process state changed to %s" change)
+(eglot--debug "(sentinel) Process state changed to %s" change)
 (when (not (process-live-p process))
   ;; Remember to cancel all timers
   ;;
-  (maphash (lambda (id v) 
- (cl-destructuring-bind (_success _error timeout) v
-   (eglot--message "Cancelling timer for continuation %s" id)
+  (maphash (lambda (id triplet)
+ (cl-destructuring-bind (_success _error timeout) triplet
+   (eglot--message
+"(sentinel) Cancelling timer for continuation %s" id)
(cancel-timer timeout)))
(eglot--pending-continuations process))
-  (cond ((process-get process 'eglot--moribund)
- (eglot--message "Process exited with status %s"
+  (cond ((eglot--moribund process)
+ (eglot--message "(sentinel) Moribund process exited with status 
%s"
  (process-exit-status process)))
 (t
- (eglot--warn "Process unexpectedly changed to %s" change))
+ (eglot--warn "(sentinel) Process unexpectedly changed to %s"
+  change)))
+  (delete-process process
 
 (defun eglot--process-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
@@ -306,35 +293,44 @@
   (interactive (eglot--current-process-or-lose))
   (clrhash (eglot--pending-continuations process)))
 
-(defun eglot--call-with-request (process
-  async-p
-  method
-  params
-  success-fn
-  &optional error-fn timeout-fn)
+(cl-defun eglot--request (process
+   method
+   params
+   &key success-fn error-fn timeout-fn (async-p t))
   (let* ((id (eglot--next-request-id))
- (timeout-fn (or timeout-fn
- (lambda ()
-   (eglot--warn "Tired of waiting for reply to %s" id)
-   (remhash id (eglot--pending-continuations 
process)
- (error-fn (or error-fn
-   (cl-function
-(lambda (&key code message)
-  (eglot--warn "Request id=%s errored with code=%s: %s"
-id code message)
+ (timeout-fn
+  (or timeout-fn
+  (lambda ()
+(eglot--warn
+ "(request) Tired of waiting for reply to %s" id)
+(rem

[elpa] externals/elpa 6689a15 026/139: Add eglot-clear-status interactive command

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 6689a1588366a5d461207b11130b167e14a1dcf4
Author: João Távora 
Commit: João Távora 

Add eglot-clear-status interactive command

* eglot.el (eglot-clear-status): New
(eglot-forget-pending-continuations): Fix bug.
(eglot--mode-line-format): Add link to eglot-clear-status.
---
 eglot.el | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 1a82cc5..db594f4 100644
--- a/eglot.el
+++ b/eglot.el
@@ -361,9 +361,14 @@ identifier.  ERROR is non-nil if this is an error."
 
 (defun eglot-forget-pending-continuations (process)
   "Stop waiting for responses from the current LSP PROCESS."
-  (interactive (eglot--current-process-or-lose))
+  (interactive (list (eglot--current-process-or-lose)))
   (clrhash (eglot--pending-continuations process)))
 
+(defun eglot-clear-status (process)
+  "Clear most recent error message from PROCESS."
+  (interactive (list (eglot--current-process-or-lose)))
+  (setf (eglot--status process) nil))
+
 (cl-defun eglot--request (process
   method
   params
@@ -668,12 +673,15 @@ running.  INTERACTIVE is t if called interactively."
  `("/"
(:propertize
 ,status
-help-echo ,(concat "mouse-1: go to events buffer")
+help-echo ,(concat "mouse-1: go to events buffer\n"
+   "mouse-3: clear this status")
 mouse-face mode-line-highlight
 face compilation-mode-line-fail
 keymap ,(let ((map (make-sparse-keymap)))
   (define-key map [mode-line mouse-1]
 'eglot-events-buffer)
+  (define-key map [mode-line mouse-3]
+'eglot-clear-status)
   map
  ,@(when (and doing (not done-p))
  `("/"



[elpa] externals/elpa df5d76d 065/139: Reply to client/registerCapability (don't handle it yet)

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit df5d76d6a0f3b0f72a1cf11b73c349aa5d990f5a
Author: João Távora 
Commit: João Távora 

Reply to client/registerCapability (don't handle it yet)

* eglot.el (eglot--server-client/registerCapability): New
function.
---
 eglot.el | 13 +
 1 file changed, 13 insertions(+)

diff --git a/eglot.el b/eglot.el
index 332f1fe..d073be2 100644
--- a/eglot.el
+++ b/eglot.el
@@ -962,6 +962,19 @@ running.  INTERACTIVE is t if called interactively."
  (t
   (eglot--message "OK so %s isn't visited" filename)
 
+(cl-defun eglot--server-client/registerCapability
+(proc &key id registrations)
+  "Handle notification client/registerCapability"
+  (mapc (lambda (reg)
+  (apply (cl-function
+  (lambda (&key _id _method _registerOptions)
+;;; TODO: handle this
+))
+ reg))
+registrations)
+  (eglot--reply proc id :error (eglot--obj :code -32601
+   :message "sorry :-(")))
+
 (defvar eglot--recent-before-changes nil
   "List of recent changes as collected by `eglot--before-change'.")
 (defvar eglot--recent-after-changes nil



[elpa] externals/elpa 51ff863 046/139: Must re-announce didOpen after reconnect

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 51ff863284138721d4c66ae2232df0696d097f44
Author: João Távora 
Commit: João Távora 

Must re-announce didOpen after reconnect

* eglot.el (eglot-reconnect): Also call
eglot--maybe-activate-editing-mode for all buffers.
---
 eglot.el | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 3561da2..86c0a4c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -205,8 +205,11 @@ INTERACTIVE is t if called interactively."
(eglot--major-mode process)
(eglot--short-name process)
(eglot--bootstrap-fn process)
-   (lambda (_proc)
- (eglot--message "Reconnected!"
+   (lambda (proc)
+ (eglot--message "Reconnected!")
+ (dolist (buffer (buffer-list))
+   (with-current-buffer buffer
+ (eglot--maybe-activate-editing-mode proc))
 
 (defvar eglot--command-history nil
   "History of COMMAND arguments to `eglot'.")



[elpa] externals/eglot 88e3655 040/139: Appease checkdoc.el

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 88e36555fab9375000aca7dccf37d7e0d3a8861a
Author: João Távora 
Commit: João Távora 

Appease checkdoc.el

* eglot.el (eglot--process-send, eglot--next-request-id)
(eglot--current-buffer-VersionedTextDocumentIdentifier)
(eglot--current-buffer-TextDocumentItem)
(eglot--after-change, eglot--signalDidOpen)
(eglot--signalDidClose, eglot--maybe-signal-didChange):
Add docstring.
---
 eglot.el | 9 +
 1 file changed, 9 insertions(+)

diff --git a/eglot.el b/eglot.el
index 8bb0729..cd546a3 100644
--- a/eglot.el
+++ b/eglot.el
@@ -390,6 +390,7 @@ identifier.  ERROR is non-nil if this is an error."
 (defvar eglot--expect-carriage-return nil)
 
 (defun eglot--process-send (id proc message)
+  "Send MESSAGE to PROC (ID is optional)."
   (let* ((json (json-encode message))
  (to-send (format "Content-Length: %d\r\n\r\n%s"
   (string-bytes json)
@@ -403,6 +404,7 @@ identifier.  ERROR is non-nil if this is an error."
 (defvar eglot--next-request-id 0)
 
 (defun eglot--next-request-id ()
+  "Compute the next id for a client request."
   (setq eglot--next-request-id (1+ eglot--next-request-id)))
 
 (defun eglot-forget-pending-continuations (process)
@@ -789,6 +791,7 @@ running.  INTERACTIVE is t if called interactively."
   eglot--versioned-identifier)
 
 (defun eglot--current-buffer-VersionedTextDocumentIdentifier ()
+  "Compute VersionedTextDocumentIdentifier object for current buffer."
   (eglot--obj :uri
   (concat "file://"
   (url-hexify-string
@@ -797,6 +800,7 @@ running.  INTERACTIVE is t if called interactively."
   :version (eglot--current-buffer-versioned-identifier)))
 
 (defun eglot--current-buffer-TextDocumentItem ()
+  "Compute TextDocumentItem object for current buffer."
   (append
(eglot--current-buffer-VersionedTextDocumentIdentifier)
(eglot--obj :languageId (cdr (assoc major-mode
@@ -808,24 +812,29 @@ running.  INTERACTIVE is t if called interactively."
  (buffer-substring-no-properties (point-min) (point-max))
 
 (defun eglot--after-change (start end length)
+  "Hook onto `after-change-functions'.
+Records START, END and LENGTH locally."
   (cl-incf eglot--versioned-identifier)
   (push (list start end length) eglot--recent-changes)
   ;; (eglot--message "start is %s, end is %s, length is %s" start end length)
   )
 
 (defun eglot--signalDidOpen ()
+  "Send textDocument/didOpen to server."
   (eglot--notify (eglot--current-process-or-lose)
  :textDocument/didOpen
  (eglot--obj :textDocument
  (eglot--current-buffer-TextDocumentItem
 
 (defun eglot--signalDidClose ()
+  "Send textDocument/didClose to server."
   (eglot--notify (eglot--current-process-or-lose)
  :textDocument/didClose
  (eglot--obj :textDocument
  (eglot--current-buffer-TextDocumentItem
 
 (defun eglot--maybe-signal-didChange ()
+  "Send textDocument/didChange to server."
   (when eglot--recent-changes
 (save-excursion
   (save-restriction



[elpa] externals/elpa 3a6c637 099/139: Support textDocument/rename

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 3a6c63723370e71b992d21019fbf863d569d024a
Author: João Távora 
Commit: João Távora 

Support textDocument/rename

* README.md: Mention rename support.

* eglot.el (eglot--uri-to-path): Handle uri hidden in keywords.
(eglot--apply-text-edits): New helper.
(eglot-rename): New interactive command.
(eglot--client-capabilities): Add rename capability.
---
 README.md |  2 +-
 eglot.el  | 58 ++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 5838bc5..a8d1c8b 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ server. To skip the guess and always be prompted use `C-u M-x 
eglot`.
 - [ ] textDocument/executeCommand
 - [ ] textDocument/format
 - [x] textDocument/hover
-- [ ] textDocument/rename
+- [x] textDocument/rename
 - [x] textDocument/references
 - [ ] textDocument/signatureHelp
 - [x] workspace/symbol
diff --git a/eglot.el b/eglot.el
index c5c99f2..9ba87ef 100644
--- a/eglot.el
+++ b/eglot.el
@@ -199,6 +199,7 @@ CONTACT is as `eglot--contact'.  Returns a process object."
   :definition `(:dynamicRegistration :json-false)
   :documentSymbol `(:dynamicRegistration :json-false)
   :documentHighlight  `(:dynamicRegistration :json-false)
+  :rename `(:dynamicRegistration :json-false)
   :publishDiagnostics `(:relatedInformation :json-false))
:experimental (eglot--obj)))
 
@@ -729,6 +730,7 @@ Meaning only return locally if successful, otherwise exit 
non-locally."
 
 (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
 
 (defconst eglot--kind-names
@@ -1368,6 +1370,62 @@ DUMMY is ignored"
  entries))
 (funcall oldfun)))
 
+(defun eglot--apply-text-edits (uri edits proc &optional version)
+  "Apply the EDITS for buffer of URI and return it."
+  (let* ((path (eglot--uri-to-path uri))
+ (buffer (and path
+  (find-file-noselect path
+(unless buffer
+  (eglot--error "Can't find `%s' to perform server edits"))
+(with-current-buffer buffer
+  (unless (eq proc (eglot--current-process))
+(eglot--error "Buffer `%s' for `%s' isn't managed by %s"
+  (current-buffer) uri proc))
+  (unless (or (not version)
+  (equal version eglot--versioned-identifier))
+(eglot--error "Edits on `%s' require version %d, you have %d"
+  uri version eglot--versioned-identifier))
+  (eglot--mapply
+   (eglot--lambda (&key range newText)
+ (save-restriction
+   (widen)
+   (save-excursion
+ (let ((start (eglot--lsp-position-to-point (plist-get range 
:start
+   (goto-char start)
+   (delete-region start
+  (eglot--lsp-position-to-point (plist-get range 
:end)))
+   (insert newText)
+   edits)
+  (eglot--message "%s: %s edits" (current-buffer) (length edits)))
+buffer))
+
+(defun eglot-rename (newname)
+  "Rename the current symbol to NEWNAME."
+  (interactive
+   (list
+(read-from-minibuffer (format "Rename `%s' to: " (symbol-at-point)
+  (unless (eglot--server-capable :renameProvider)
+(eglot--error "Server can't rename!"))
+  (let* ((proc (eglot--current-process-or-lose))
+ (workspace-edit
+  (eglot--sync-request proc
+   :textDocument/rename
+   (append
+
(eglot--current-buffer-TextDocumentPositionParams)
+(eglot--obj :newName newname
+ performed)
+(cl-destructuring-bind (&key changes documentChanges)
+workspace-edit
+  (cl-loop for change on documentChanges
+   do (push
+   (cl-destructuring-bind (&key textDocument edits) change
+ (cl-destructuring-bind (&key uri version) textDocument
+   (eglot--apply-text-edits uri edits proc version)))
+   performed))
+  (cl-loop for (uri edits) on changes by #'cddr
+   do (push (eglot--apply-text-edits uri edits proc)
+performed)
+
 
 ;;; Dynamic registration
 ;;;



[elpa] externals/elpa d33a9b5 103/139: Simplify eglot--signal-textDocument/didChange

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit d33a9b5ad9245cb594eb16e927f19741c4ef6a92
Author: João Távora 
Commit: João Távora 

Simplify eglot--signal-textDocument/didChange

* eglot.el (eglot--recent-before-changes)
(eglot--recent-after-changes): Delete.
(eglot--recent-changes): New var.
(eglot--outstanding-edits-p, eglot--before-change)
(eglot--after-change): Rewrite.
(eglot--signal-textDocument/didChange): Rewrite.
(eglot--signal-textDocument/didOpen): Initialize
buffer-local eglot--recent-changes here.
---
 eglot.el | 108 +++
 1 file changed, 46 insertions(+), 62 deletions(-)

diff --git a/eglot.el b/eglot.el
index 546671e..3eb43ce 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1043,17 +1043,12 @@ running.  INTERACTIVE is t if called interactively."
(eglot--obj :code -32001
:message (format "%s" err))
 
-(defvar eglot--recent-before-changes nil
-  "List of recent changes as collected by `eglot--before-change'.")
-(defvar eglot--recent-after-changes nil
-  "List of recent changes as collected by `eglot--after-change'.")
-
-(defvar-local eglot--versioned-identifier 0)
-
 (defun eglot--current-buffer-TextDocumentIdentifier ()
   "Compute TextDocumentIdentifier object for current buffer."
   (eglot--obj :uri (eglot--path-to-uri buffer-file-name)))
 
+(defvar-local eglot--versioned-identifier 0)
+
 (defun eglot--current-buffer-VersionedTextDocumentIdentifier ()
   "Compute VersionedTextDocumentIdentifier object for current buffer."
   (append (eglot--current-buffer-TextDocumentIdentifier)
@@ -1077,78 +1072,67 @@ running.  INTERACTIVE is t if called interactively."
   (eglot--obj :textDocument (eglot--current-buffer-TextDocumentIdentifier)
   :position (eglot--pos-to-lsp-position)))
 
+(defvar-local eglot--recent-changes nil
+  "Recent buffer changes as collected by `eglot--before-change'.")
+
+(defun eglot--outstanding-edits-p ()
+  "Non-nil if there are outstanding edits."
+  (cl-plusp (+ (length (car eglot--recent-changes))
+   (length (cdr eglot--recent-changes)
+
 (defun eglot--before-change (start end)
   "Hook onto `before-change-functions'.
 Records START and END, crucially convert them into
 LSP (line/char) positions before that information is
 lost (because the after-change thingy doesn't know if newlines
 were deleted/added)"
-  (push (list (eglot--pos-to-lsp-position start)
-  (eglot--pos-to-lsp-position end))
-eglot--recent-before-changes))
+  (setf (car eglot--recent-changes)
+(vconcat (car eglot--recent-changes)
+ `[(,(eglot--pos-to-lsp-position start)
+,(eglot--pos-to-lsp-position end))])))
 
 (defun eglot--after-change (start end pre-change-length)
   "Hook onto `after-change-functions'.
 Records START, END and PRE-CHANGE-LENGTH locally."
   (cl-incf eglot--versioned-identifier)
-  (push (list start end pre-change-length
-  (buffer-substring-no-properties start end))
-eglot--recent-after-changes))
+  (setf (cdr eglot--recent-changes)
+(vconcat (cdr eglot--recent-changes)
+ `[(,pre-change-length
+,(buffer-substring-no-properties start end))])))
 
 (defun eglot--signal-textDocument/didChange ()
   "Send textDocument/didChange to server."
-  (unwind-protect
-  (when (or eglot--recent-before-changes
-eglot--recent-after-changes)
-(let* ((proc (eglot--current-process-or-lose))
-   (sync-kind (plist-get (eglot--capabilities proc)
- :textDocumentSync))
-   (emacs-messup
-(/= (length eglot--recent-before-changes)
-(length eglot--recent-after-changes)))
-   (full-sync-p (or (eq sync-kind 1) emacs-messup)))
-  (when emacs-messup
-(unless (eq sync-kind 1)
-  (eglot--warn "Using full sync because before: %s and after: %s"
-   eglot--recent-before-changes
-   eglot--recent-after-changes)))
-  (save-restriction
-(widen)
-(unless (or (not sync-kind)
-(eq sync-kind 0))
-  (eglot--notify
-   proc
-   :textDocument/didChange
-   (eglot--obj
-:textDocument
-(eglot--current-buffer-VersionedTextDocumentIdentifier)
-:contentChanges
-(if full-sync-p
-(vector
- (eglot--obj
-  :text (buffer-substring-no-properties (point-min)
-(point-max
-  (apply
-   #'vector
-   (mapcar
-(pcase-lambda (`(,before-start-position
- ,before-end

[elpa] externals/eglot eebd32b 059/139: When user declines to reconnect, first quit existing server

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit eebd32ba393c2f2ca786241f376d218725d16270
Author: João Távora 
Commit: João Távora 

When user declines to reconnect, first quit existing server

* eglot.el (eglot): Rework reconnection logic.
---
 eglot.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index c5a0c0f..3d0c044 100644
--- a/eglot.el
+++ b/eglot.el
@@ -293,13 +293,15 @@ Execute program (or connect to :) "
   (y-or-n-p "[eglot] Live process found, reconnect instead? "))
  (eglot-reconnect current-process interactive))
 (t
+ (when (process-live-p current-process)
+   (eglot-shutdown current-process 'sync))
  (eglot--connect
   project
   managed-major-mode
   short-name
   command
   (lambda (proc)
-(eglot--message "Connected! Process `%s' now managing `%s'\
+(eglot--message "Connected! Process `%s' now managing `%s' \
 buffers in project %s."
 proc
 managed-major-mode



[elpa] externals/eglot 931093e 032/139: Don't clutter UI with warnings

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit 931093e24b7c9788474ff7173f9cfcb76d2f667a
Author: João Távora 
Commit: João Távora 

Don't clutter UI with warnings

* eglot.el (warnings): require it.
(eglot--warn): set warning-minimum-level
---
 eglot.el | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index c7bb5d4..6e5954c 100644
--- a/eglot.el
+++ b/eglot.el
@@ -31,6 +31,7 @@
 (require 'url-util)
 (require 'pcase)
 (require 'compile) ; for some faces
+(require 'warnings)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -623,9 +624,10 @@ running.  INTERACTIVE is t if called interactively."
 
 (defun eglot--warn (format &rest args)
   "Warning message with FORMAT and ARGS."
-  (display-warning 'eglot
-   (apply #'format format args)
-   :warning))
+  (let ((warning-minimum-level :error))
+(display-warning 'eglot
+ (apply #'format format args)
+ :warning)))
 
 
 



[elpa] externals/elpa 23b79e0 111/139: Shorten summary line to appease package-lint.el

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 23b79e07da6c62e7f056c6cc5b6b676e43b8017c
Author: João Távora 
Commit: João Távora 

Shorten summary line to appease package-lint.el
---
 eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index fbddf16..21ec247 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1,4 +1,4 @@
-;;; eglot.el --- A client for Language Server Protocol (LSP) servers  -*- 
lexical-binding: t; -*-
+;;; eglot.el --- Client for Language Server Protocol (LSP) servers  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2017  João Távora
 



[elpa] externals/elpa e1d36d2 014/139: Fix some byte-compilation warnings

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit e1d36d27a2b6566fdd8cf16d0fcd2a9ec033a65d
Author: João Távora 
Commit: João Távora 

Fix some byte-compilation warnings
---
 eglot.el | 82 
 1 file changed, 46 insertions(+), 36 deletions(-)

diff --git a/eglot.el b/eglot.el
index af9904a..0a52da7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -27,6 +27,7 @@
 (require 'json)
 (require 'cl-lib)
 (require 'project)
+(require 'url-parse)
 
 (defgroup eglot nil
   "Interaction with Language Server Protocol servers"
@@ -211,8 +212,10 @@
(goto-char message-mark)
(narrow-to-region message-mark
  message-end)
-  (eglot--process-receive proc 
(let ((json-object-type 'plist))
-   (json-read)
+   (eglot--process-receive
+proc
+(let ((json-object-type 'plist))
+  (json-read)
(set-marker message-mark message-end)
(setf (eglot--expected-bytes proc) nil)))
 (t
@@ -258,21 +261,21 @@
 (not continuations))
(eglot--warn "Ooops no continuation for id %s" response-id))
   (continuations
-   (cancel-timer (third continuations))
+   (cancel-timer (cl-third continuations))
(remhash response-id
 (eglot--pending-continuations))
(cond (err
-  (apply (second continuations) err))
+  (apply (cl-second continuations) err))
  (t
-  (apply (first continuations) (plist-get message :result)
+  (apply (cl-first continuations) (plist-get message 
:result)
   (t
(let* ((method (plist-get message :method))
   (handler-sym (intern (concat "eglot--"
-  method
+   method
  (if (functionp handler-sym)
  (apply handler-sym proc (plist-get message :params))
(eglot--debug "No implemetation for notification %s yet"
- method)))
+ method)))
 
 (defvar eglot--expect-carriage-return nil)
 
@@ -294,9 +297,9 @@
   (clrhash (eglot--pending-continuations process)))
 
 (cl-defun eglot--request (process
-   method
-   params
-   &key success-fn error-fn timeout-fn (async-p t))
+  method
+  params
+  &key success-fn error-fn timeout-fn (async-p t))
   (let* ((id (eglot--next-request-id))
  (timeout-fn
   (or timeout-fn
@@ -363,6 +366,9 @@
 ;;; Requests
 ;;;
 (defun eglot--protocol-initialize (process interactive)
+  "Initialize LSP protocol.
+PROCESS is a connected process (network or local).
+INTERACTIVE is t if caller was called interactively."
   (eglot--request
process
:initialize
@@ -385,7 +391,7 @@
 (defun eglot-quit-server (process &optional sync interactive)
   "Politely ask the server PROCESS to quit.
 If SYNC, don't leave this function with the server still
-running."
+running.  INTERACTIVE is t if called interactively."
   (interactive (list (eglot--current-process-or-lose) t t))
   (when interactive
 (eglot--message "(eglot-quit-server) Asking %s politely to terminate"
@@ -437,47 +443,50 @@ running."
 (forward-line (plist-get pos-plist :line))
 (forward-char (plist-get pos-plist :character))
 (point
-  (loop for diag across diagnostics
-do (cl-destructuring-bind (&key range severity
-_code _source message)
-   diag
- (cl-destructuring-bind (&key start end)
- range
-   (let* ((begin-pos (pos-at start))
-  (end-pos (pos-at end))
-  (ov (make-overlay begin-pos
-end-pos
-buffer)))
- (push ov eglot--diagnostic-overlays)
- (overlay-put ov 'face
-  (case severity
-(1 'flymake-errline)
-(2 'flymake-warnline)))
- (overlay-put ov 'help-echo
-  message)
- (overlay-put ov 'eglot--diagnostic diag
+  (cl-loop for diag across diagnostics
+   do (cl-destructur

[elpa] externals/elpa fdb4de1 039/139: Simplify flymake integration

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit fdb4de165885d4ff777a40dcaca289452545db8d
Author: João Távora 
Commit: João Távora 

Simplify flymake integration

And get rid of the ridiculous environment thingy

* eglot.el (eglot--process-sentinel): Continuations are triplets.
(eglot--environment-vars, eglot--environment): Remove.
(eglot--process-receive): Simplify.
(eglot--unreported-diagnostics): New variable.
(eglot--textDocument/publishDiagnostics): Simplify.
(eglot-flymake-backend): Report unreported diagnostics.
---
 eglot.el | 58 +++---
 1 file changed, 23 insertions(+), 35 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8584440..8bb0729 100644
--- a/eglot.el
+++ b/eglot.el
@@ -229,8 +229,8 @@ INTERACTIVE is t if called interactively."
   (when (not (process-live-p process))
 ;; Remember to cancel all timers
 ;;
-(maphash (lambda (id quad)
-   (cl-destructuring-bind (_success _error timeout _env) quad
+(maphash (lambda (id triplet)
+   (cl-destructuring-bind (_success _error timeout) triplet
  (eglot--message
   "(sentinel) Cancelling timer for continuation %s" id)
  (cancel-timer timeout)))
@@ -349,13 +349,6 @@ identifier.  ERROR is non-nil if this is an error."
   (setq msg (propertize msg 'face 'error)))
 (insert msg)
 
-(defvar eglot--environment-vars
-  '(eglot--current-flymake-report-fn)
-  "A list of variables with saved values on every request.")
-
-(defvar eglot--environment nil
-  "Dynamically bound alist of symbol and values.")
-
 (defun eglot--process-receive (proc message)
   "Process MESSAGE from PROC."
   (let* ((response-id (plist-get message :id))
@@ -388,13 +381,9 @@ identifier.  ERROR is non-nil if this is an error."
   (t
(let* ((method (plist-get message :method))
   (handler-sym (intern (concat "eglot--"
-   method)))
-  (eglot--environment (cl-fourth continuations)))
+   method
  (if (functionp handler-sym)
- (cl-progv
- (mapcar #'car eglot--environment)
- (mapcar #'cdr eglot--environment)
-   (apply handler-sym proc (plist-get message :params)))
+ (apply handler-sym proc (plist-get message :params))
(eglot--debug "No implemetation for notification %s yet"
  method)))
 
@@ -476,9 +465,7 @@ identifier.  ERROR is non-nil if this is an error."
error-fn
  (lambda (&rest args)
(throw catch-tag (apply error-fn args
-   timeout-timer
-   (cl-loop for var in eglot--environment-vars
-collect (cons var (symbol-value var
+   timeout-timer)
  (eglot--pending-continuations process))
 (unless async-p
   (unwind-protect
@@ -563,23 +550,18 @@ running.  INTERACTIVE is t if called interactively."
 
 ;;; Notifications
 ;;;
-(defvar eglot--current-flymake-report-fn nil)
+(defvar-local eglot--current-flymake-report-fn nil
+  "Current flymake report function for this buffer")
+(defvar-local eglot--unreported-diagnostics nil
+  "Unreported diagnostics for this buffer.")
 
 (cl-defun eglot--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))
- (report-fn (cdr (assoc 'eglot--current-flymake-report-fn
-eglot--environment
+ (buffer (find-buffer-visiting filename)))
 (cond
- ((not eglot--current-flymake-report-fn)
-  (eglot--warn "publishDiagnostics called but no report-fn"))
- ((and report-fn
-   (not (eq report-fn
-eglot--current-flymake-report-fn)))
-  (eglot--warn "outdated publishDiagnostics report from server"))
  (buffer
   (with-current-buffer buffer
 (cl-flet ((pos-at
@@ -607,9 +589,12 @@ running.  INTERACTIVE is t if called interactively."
  :note))
   message
into diags
-   finally (funcall
-eglot--current-flymake-report-fn
-diags)
+   finally
+   (if eglot--current-flymake-report-fn
+   (funcall eglot--current-flymake-report-fn
+diags)
+ (setq eglot--unreported-diagnostics
+   diags))
  (t
 

[elpa] externals/elpa 4f246b5 017/139: * eglot.el (eglot-mode-map): Move up before minor mode.

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 4f246b5965c45830690dcb8e42bf639b8dfad0b1
Author: João Távora 
Commit: João Távora 

* eglot.el (eglot-mode-map): Move up before minor mode.
---
 eglot.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8da6267..8356f8e 100644
--- a/eglot.el
+++ b/eglot.el
@@ -550,6 +550,8 @@ running.  INTERACTIVE is t if called interactively."
   "Face for package-name in EGLOT's mode line."
   :group 'eglot)
 
+(defvar eglot-mode-map (make-sparse-keymap))
+
 (define-minor-mode eglot-mode
   "Minor mode for buffers where EGLOT is possible"
   nil
@@ -567,9 +569,7 @@ running.  INTERACTIVE is t if called interactively."
 
 (defvar eglot-menu)
 
-(defvar eglot-mode-map (make-sparse-keymap))
-
-(easy-menu-define eglot-menu eglot-mode-map "SLY"
+(easy-menu-define eglot-menu eglot-mode-map "EGLOT"
   `("EGLOT" ))
 
 (defvar eglot--mode-line-format



[elpa] externals/elpa a199c8e 070/139: Honour textDocumentSync

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit a199c8ef754434b6210cbd56f7dcef5f04e686c2
Author: João Távora 
Commit: João Távora 

Honour textDocumentSync

* eglot.el (eglot--signal-textDocument/didChange): Honour textDocumentSync
---
 eglot.el | 72 +---
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/eglot.el b/eglot.el
index 5701422..68fe3e2 100644
--- a/eglot.el
+++ b/eglot.el
@@ -251,7 +251,9 @@ SUCCESS-FN with no args if all goes well."
 (eglot--request
  proc
  :initialize
- (eglot--obj :processId  (emacs-pid)
+ (eglot--obj :processId (unless (eq (process-type proc)
+'network)
+  (emacs-pid))
  :rootUri  (eglot--uri
 (expand-file-name (car (project-roots
 (project-current)
@@ -1070,44 +1072,44 @@ Records START, END and PRE-CHANGE-LENGTH locally."
   "Send textDocument/didChange to server."
   (when (and eglot--recent-before-changes
  eglot--recent-after-changes)
-(save-excursion
+(let* ((proc (eglot--current-process-or-lose))
+   (sync-kind (plist-get (eglot--capabilities proc) 
:textDocumentSync)))
   (save-restriction
 (widen)
-(if (/= (length eglot--recent-before-changes)
-(length eglot--recent-after-changes))
-(eglot--notify
- (eglot--current-process-or-lose)
- :textDocument/didChange
- (eglot--obj
-  :textDocument 
(eglot--current-buffer-VersionedTextDocumentIdentifier)
-  :contentChanges
-  (vector
-   (eglot--obj
-:text (buffer-substring-no-properties (point-min) 
(point-max))
-  (let ((combined (cl-mapcar 'append
- eglot--recent-before-changes
- eglot--recent-after-changes)))
-(eglot--notify
- (eglot--current-process-or-lose)
- :textDocument/didChange
- (eglot--obj
-  :textDocument 
(eglot--current-buffer-VersionedTextDocumentIdentifier)
-  :contentChanges
+(unless (or (not sync-kind)
+(eq sync-kind 0))
+  (eglot--notify
+   proc
+   :textDocument/didChange
+   (eglot--obj
+:textDocument
+(eglot--current-buffer-VersionedTextDocumentIdentifier)
+:contentChanges
+(if (or (eq sync-kind 1)
+(/= (length eglot--recent-before-changes)
+(length eglot--recent-after-changes)))
+(vector
+ (eglot--obj
+  :text (buffer-substring-no-properties (point-min) 
(point-max
   (apply
#'vector
-   (mapcar (pcase-lambda (`(,before-start-position
-,before-end-position
-,after-start
-,after-end
-,len))
- (eglot--obj
-  :range
-  (eglot--obj
-   :start before-start-position
-   :end before-end-position)
-  :rangeLength len
-  :text (buffer-substring-no-properties after-start 
after-end)))
-   (reverse combined))
+   (mapcar
+(pcase-lambda (`(,before-start-position
+ ,before-end-position
+ ,after-start
+ ,after-end
+ ,len))
+  (eglot--obj
+   :range
+   (eglot--obj
+:start before-start-position
+:end before-end-position)
+   :rangeLength len
+   :text (buffer-substring-no-properties after-start 
after-end)))
+(reverse
+ (cl-mapcar 'append
+eglot--recent-before-changes
+eglot--recent-after-changes)))
   (setq eglot--recent-before-changes nil
 eglot--recent-after-changes nil))
 



[elpa] externals/elpa be52e1e 037/139: Rework connection restarting again

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit be52e1ee6a39c6f775a308c229c7a75ac28485bd
Author: João Távora 
Commit: João Távora 

Rework connection restarting again

Quitting a process removes it from the project.

* eglot.el (eglot-editing-mode,eglot-mode): Forward declare.
(eglot--project): New process-local var.
(eglot--connect): Takes a project.
(eglot-new-process): Rework.
(eglot--sentinel): Remove proc from eglot--processes-by-project.
---
 eglot.el | 85 ++--
 1 file changed, 51 insertions(+), 34 deletions(-)

diff --git a/eglot.el b/eglot.el
index b9aa94c..12e7fef 100644
--- a/eglot.el
+++ b/eglot.el
@@ -44,6 +44,9 @@
 
 (defvar eglot--processes-by-project (make-hash-table :test #'equal))
 
+(defvar eglot-editing-mode) ; forward decl
+(defvar eglot-mode) ; forward decl
+
 (defvar eglot--special-buffer-process nil
   "Current buffer's eglot process.")
 
@@ -103,6 +106,9 @@ after setting it."
 (eglot--define-process-var eglot--moribund nil
   "Non-nil if process is about to exit")
 
+(eglot--define-process-var eglot--project nil
+  "The project the process belongs to.")
+
 (eglot--define-process-var eglot--spinner `(nil nil t)
   "\"Spinner\" used by some servers.
 A list (ID WHAT DONE-P)." t)
@@ -134,12 +140,13 @@ Returns a process object."
   name)
 proc))
 
-(defun eglot--connect (short-name bootstrap-fn &optional success-fn)
-  "Make a connection with SHORT-NAME and BOOTSTRAP-FN.
+(defun eglot--connect (project short-name bootstrap-fn &optional success-fn)
+  "Make a connection with PROJECT, SHORT-NAME and BOOTSTRAP-FN.
 Call SUCCESS-FN with no args if all goes well."
   (let* ((proc (funcall bootstrap-fn short-name))
  (buffer (process-buffer proc)))
-(setf (eglot--bootstrap-fn proc) bootstrap-fn)
+(setf (eglot--bootstrap-fn proc) bootstrap-fn
+  (eglot--project proc) project)
 (with-current-buffer buffer
   (let ((inhibit-read-only t))
 (setf (eglot--short-name proc) short-name)
@@ -164,48 +171,57 @@ INTERACTIVE is t if called interactively."
   (interactive (list (eglot--current-process-or-lose) t))
   (when (process-live-p process)
 (eglot-quit-server process 'sync interactive))
-  (eglot--connect (eglot--short-name process)
-  (eglot--bootstrap-fn process)
-  (lambda ()
-(eglot--message "Reconnected"
+  (eglot--connect
+   (eglot--project process)
+   (eglot--short-name process)
+   (eglot--bootstrap-fn process)
+   (lambda ()
+ (eglot--message "Reconnected"
 
 (defun eglot-new-process (&optional interactive)
   "Start a new EGLOT process and initialize it.
 INTERACTIVE is t if called interactively."
   (interactive (list t))
   (let ((project (project-current)))
-(unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
+(unless project (eglot--error
+ "(new-process) Cannot work without a current project!"))
 (let ((current-process (eglot--current-process))
   (command (let ((probe (cdr (assoc major-mode eglot-executables
  (unless probe
(eglot--error "Don't know how to start EGLOT for %s 
buffers"
  major-mode))
  probe)))
-  (cond ((and current-process
-  (process-live-p current-process))
- (eglot--message "(new-process) Reconnecting instead")
- (eglot-reconnect current-process interactive))
-(t
- (eglot--connect
-  (file-name-base
-   (directory-file-name
-(car (project-roots (project-current)
-  (lambda (name)
-(eglot-make-local-process
- name
- command))
-  (lambda ()
-(eglot--message "Connected")
-(dolist (buffer (buffer-list))
-  (with-current-buffer buffer
-(if (and buffer-file-name
- (cl-some
-  (lambda (root)
-(string-prefix-p
- (expand-file-name root)
- (expand-file-name buffer-file-name)))
-  (project-roots project)))
-(eglot--signalDidOpen)))
+  (cond
+   ((and current-process
+ (process-live-p current-process))
+(when (and
+   interactive
+   (y-or-n-p "[eglot] Live process found, reconnect instead? "))
+  (eglot-reconnect current-process interactive)))
+   (t
+(eglot--connect
+ project
+ (file-name-base
+  (directory-file-name
+   (car (project-roots (project-current)
+ (lambda (name)
+   (

[elpa] externals/eglot b1554fc 055/139: * eglot.el (eglot--process-receive): Skip null method notifs.

2018-05-14 Thread Jo�o T�vora
branch: externals/eglot
commit b1554fc921f8d91870373cf9d3a089afc3f0f63d
Author: João Távora 
Commit: João Távora 

* eglot.el (eglot--process-receive): Skip null method notifs.
---
 eglot.el | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index ebc07d2..693535a 100644
--- a/eglot.el
+++ b/eglot.el
@@ -477,8 +477,11 @@ identifier.  ERROR is non-nil if this is an error."
   (plist-get message :params)
   (let ((id (plist-get message :id)))
 (if id `(:id ,id)
-   (eglot--warn "No implemetation for notification %s yet"
-method)))
+   ;; pyls keeps on sending nil notifs for each notif we
+   ;; send it, just ignore these.
+   (unless (null method)
+ (eglot--warn "No implemetation for notification %s yet"
+  method
 
 (defvar eglot--expect-carriage-return nil)
 



[elpa] externals/elpa 7d0bf64 062/139: Workaround RLS's regusal to treat nil as empty json object

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit 7d0bf64235fb3a572396a1fb0db8c2f26141f4aa
Author: João Távora 
Commit: João Távora 

Workaround RLS's regusal to treat nil as empty json object

* eglot.el (eglot--connect): Use dummy params.
---
 eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eglot.el b/eglot.el
index 0300ad3..8f371d2 100644
--- a/eglot.el
+++ b/eglot.el
@@ -229,7 +229,7 @@ SUCCESS-FN with no args if all goes well."
 (setf (eglot--capabilities proc) capabilities)
 (setf (eglot--status proc) nil)
 (when success-fn (funcall success-fn proc))
-(eglot--notify proc :initialized nil
+(eglot--notify proc :initialized (eglot--obj :__dummy__ t)
 
 (defvar eglot--command-history nil
   "History of COMMAND arguments to `eglot'.")



[elpa] externals/elpa e8f859e 031/139: Rework commands for connecting and reconnecting

2018-05-14 Thread Jo�o T�vora
branch: externals/elpa
commit e8f859e77e5e6109efdc62ee257b261c54137aca
Author: João Távora 
Commit: João Távora 

Rework commands for connecting and reconnecting

* eglot.el (eglot--current-process-or-lose): Add doc.
(eglot--command): Remove.
(eglot--bootstrap-fn): New process-local variable.
(eglot--connect): Redesign.
(eglot-make-local-process): New function.
(eglot-reconnect): New interactive command.
(eglot-new-process): Redesign.
(eglot--process-sentinel): Add doc.
(eglot--protocol-initialize): Rework.
(eglot--mode-line-format): Use eglot-reconnect.
---
 eglot.el | 139 +--
 1 file changed, 81 insertions(+), 58 deletions(-)

diff --git a/eglot.el b/eglot.el
index fe63a29..c7bb5d4 100644
--- a/eglot.el
+++ b/eglot.el
@@ -54,6 +54,7 @@
  (gethash cur eglot--processes-by-project)
 
 (defun eglot--current-process-or-lose ()
+  "Return the current EGLOT process or error."
   (or (eglot--current-process)
   (eglot--error "No current EGLOT process%s"
 (if (project-current) ""
@@ -109,29 +110,62 @@ A list (ID WHAT DONE-P)." t)
   "Status as declared by the server.
 A list (WHAT SERIOUS-P)." t)
 
-(defun eglot--command (&optional errorp)
-  (let ((probe (cdr (assoc major-mode eglot-executables
-(unless (or (not errorp)
-probe)
-  (eglot--error "Don't know how to start EGLOT for %s buffers"
-major-mode))
-probe))
+(eglot--define-process-var eglot--bootstrap-fn nil
+  "Function for returning processes/connetions to LSP servers.
+Must be a function of one arg, a name, returning a process
+object.")
 
-(defun eglot--connect (name filter sentinel)
-  "Helper for `eglot-new-process'.
+(defun eglot-make-local-process (name command)
+  "Make a local LSP process from COMMAND.
 NAME is a name to give the inferior process or connection.
-FILTER and SENTINEL are filter and sentinel.
-Should return a list of (PROCESS BUFFER)."
-  (let ((proc (make-process :name name
-:buffer (get-buffer-create
- (format "*%s inferior*" name))
-:command (eglot--command 'error)
-:connection-type 'pipe
-:filter filter
-:sentinel sentinel
-:stderr (get-buffer-create (format "*%s stderr*"
-   name)
-(list proc (process-buffer proc
+Returns a process object."
+  (let* ((readable-name (format "EGLOT server (%s)" name))
+ (proc
+  (make-process
+   :name readable-name
+   :buffer (get-buffer-create
+(format "*%s inferior*" readable-name))
+   :command command
+   :connection-type 'pipe
+   :filter 'eglot--process-filter
+   :sentinel 'eglot--process-sentinel
+   :stderr (get-buffer-create (format "*%s stderr*"
+  name)
+proc))
+
+(defun eglot--connect (short-name bootstrap-fn &optional success-fn)
+  "Make a connection with SHORT-NAME and BOOTSTRAP-FN.
+Call SUCCESS-FN with no args if all goes well."
+  (let* ((proc (funcall bootstrap-fn short-name))
+ (buffer (process-buffer proc)))
+(setf (eglot--bootstrap-fn proc) bootstrap-fn)
+(with-current-buffer buffer
+  (let ((inhibit-read-only t))
+(setf (eglot--short-name proc) short-name)
+(puthash (project-current) proc eglot--processes-by-project)
+(erase-buffer)
+(read-only-mode t)
+(with-current-buffer (eglot-events-buffer proc)
+  (let ((inhibit-read-only t))
+(insert
+ (format "\n---\n"
+(eglot--protocol-initialize
+ proc
+ (cl-function
+  (lambda (&key capabilities)
+(setf (eglot--capabilities proc) capabilities)
+(setf (eglot--status proc) nil)
+(when success-fn (funcall success-fn)
+
+(defun eglot-reconnect (process &optional interactive)
+  "Reconnect to PROCESS.
+INTERACTIVE is t if called interactively."
+  (interactive (list (eglot--current-process-or-lose) t))
+  (eglot-quit-server process 'sync interactive)
+  (eglot--connect (eglot--short-name process)
+  (eglot--bootstrap-fn process)
+  (lambda ()
+(eglot--message "Reconnected"
 
 (defun eglot-new-process (&optional interactive)
   "Start a new EGLOT process and initialize it.
@@ -140,32 +174,28 @@ INTERACTIVE is t if called interactively."
   (let ((project (project-current)))
 (unless project (eglot--error "(new-process) Cannot work without a current 
project!"))
 (let ((current-process (eglot--current-process)))
-  (when (and current-process
-

  1   2   3   >