From 18ed39789ac832ba6e1db619930c3e958d8e1bb5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 16 Aug 2017 12:50:53 +0100 Subject: [PATCH] Organize a bit --- lisp/progmodes/eglot.el | 50 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index c7f8774d838..e3b288b0381 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/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)) -- 2.39.2