[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa a4f99e0 005/139: Introduce and use `eglot--current
From: |
João Távora |
Subject: |
[elpa] externals/elpa a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose' |
Date: |
Mon, 14 May 2018 09:53:24 -0400 (EDT) |
branch: externals/elpa
commit a4f99e09d3a4eaafb1d59875f0d314549a104137
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
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)
+ (cl-destructuring-bind
+ (&rest all
+ &key
+ ;; capabilities reported by server
+ _textDocumentSync
+ _hoverProvider
+ _completionProvider
+ _definitionProvider
+ _referencesProvider
+ _documentHighlightProvider
+ _documentSymbolProvider
+ _workspaceSymbolProvider
+ _codeActionProvider
+ _documentFormattingProvider
+ _documentRangeFormattingProvider
+ _renameProvider
+ _executeCommandProvider
+ )
+ capabilities
+ (when interactive
+ (eglot--message
+ "So yeah I got lots (%d) of capabilities"
+ (length all)))))))
(defun eglot--debug (format &rest args)
(display-warning 'eglot
- [elpa] externals/elpa 0ec7801 012/139: Simplify `eglot--protocol-initialize`, (continued)
- [elpa] externals/elpa 0ec7801 012/139: Simplify `eglot--protocol-initialize`, João Távora, 2018/05/14
- [elpa] externals/elpa 88e3655 040/139: Appease checkdoc.el, João Távora, 2018/05/14
- [elpa] externals/elpa f7f77e1 044/139: Make M-x eglot the main entry point, João Távora, 2018/05/14
- [elpa] externals/elpa 51ff863 046/139: Must re-announce didOpen after reconnect, João Távora, 2018/05/14
- [elpa] externals/elpa d2eca65 045/139: Fix another Flymake sync bug, João Távora, 2018/05/14
- [elpa] externals/elpa c95a0a4 041/139: Multiple servers per project are possible, João Távora, 2018/05/14
- [elpa] externals/elpa e60c7fc 013/139: Overhaul async mechanism safety, João Távora, 2018/05/14
- [elpa] externals/elpa a3545fb 050/139: Rename RPC methods for clarity, João Távora, 2018/05/14
- [elpa] externals/elpa 4d4b85d 061/139: eglot-editing-mode becomes eglot--managed-mode, João Távora, 2018/05/14
- [elpa] externals/elpa 4f246b5 017/139: * eglot.el (eglot-mode-map): Move up before minor mode., João Távora, 2018/05/14
- [elpa] externals/elpa a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose',
João Távora <=
- [elpa] externals/elpa 8e6488f 023/139: Don't switch to possibly dead buffer in sentinel, João Távora, 2018/05/14
- [elpa] externals/elpa be52e1e 037/139: Rework connection restarting again, João Távora, 2018/05/14
- [elpa] externals/elpa cc183a6 043/139: Fix assorted bugs, João Távora, 2018/05/14
- [elpa] externals/elpa e8f859e 031/139: Rework commands for connecting and reconnecting, João Távora, 2018/05/14
- [elpa] externals/elpa b511b7d 036/139: Redesign and simplify parser, João Távora, 2018/05/14
- [elpa] externals/elpa b4dd4f8 022/139: Report server status in the mode-line, João Távora, 2018/05/14
- [elpa] externals/elpa 46bb1c0 049/139: Reorganize file, João Távora, 2018/05/14
- [elpa] externals/elpa b69302c 060/139: Make M-x eglot's interactive spec a separate function, João Távora, 2018/05/14
- [elpa] externals/elpa b657b32 068/139: Use rootUri instead of rootPath, João Távora, 2018/05/14
- [elpa] externals/elpa eebd32b 059/139: When user declines to reconnect, first quit existing server, João Távora, 2018/05/14