João Távora [Sat, 5 May 2018 10:26:12 +0000 (11:26 +0100)]
Half-decent xref support
* eglot.el
(eglot--xref-known-symbols): New hacky var.
(eglot--xref-reset-known-symbols): New helper.
(xref-find-definitions, xref-find-references): Advise after to
call the new helper.
(xref-backend-identifier-completion-table): Rework.
(eglot--xref-make): New helper.
(xref-backend-definitions): Use it.
(xref-backend-references, xref-backend-apropos): Implement.
(eglot--obj): Add a debug spec.
(eglot--lambda): Add debug spec.
João Távora [Sat, 5 May 2018 01:29:06 +0000 (02:29 +0100)]
Very basic xref support
* eglot.el (eglot--pos-to-lisp-position): Move up.
(eglot--mapply, eglot--lambda): New helpers.
(eglot--uri-to-path): New helper.
(eglot--managed-mode): Manage xref-backend-functions.
(eglot-xref-backend): New function.
(xref-backend-identifier-completion-table)
(xref-backend-identifier-at-point)
(xref-backend-definitions): New methods.
(xref-backend-references)
(xref-backend-apropos): New methods, still unimplemented.
João Távora [Sat, 5 May 2018 01:16:10 +0000 (02:16 +0100)]
New helper eglot--sync-request
This should help with xref definitions
* eglot.el (eglot--request): Rework a bit. Continuation is always
cleared on timeout, regardless of user-supplied fn.
(eglot--sync-request): New function.
(eglot--process-receive): watch out for vector results.
João Távora [Sat, 5 May 2018 01:24:37 +0000 (02:24 +0100)]
Cleanup mistake with textdocumentitem and textdocumentidentifier
Also introduce eglot--path-to-uri
* eglot.el (eglot--path-to-uri): Rename from eglot--uri and rework.
(eglot--connect): Use it.
(eglot--current-buffer-TextDocumentIdentifier): New function.
(eglot--current-buffer-VersionedTextDocumentIdentifier)
(eglot--signal-textDocument/didChange)
(eglot--signal-textDocument/didClose)
(eglot--signal-textDocument/willSave)
(eglot--signal-textDocument/didSave): Use it.
João Távora [Fri, 4 May 2018 11:17:26 +0000 (12:17 +0100)]
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
João Távora [Fri, 4 May 2018 09:49:34 +0000 (10:49 +0100)]
Eglot-editing-mode becomes eglot--managed-mode
* eglot.el (eglot--sentinel): Use eglot--managed-mode.
(eglot--managed-mode-map): Renamed from eglot-editing-mode-map.
(eglot--managed-mode): Renamed from eglot-editing-mode.
(eglot-mode): Simplify.
(eglot--buffer-managed-p): New function.
(eglot--maybe-activate-editing-mode): Simplify.
João Távora [Fri, 4 May 2018 10:21:11 +0000 (11:21 +0100)]
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.
João Távora [Thu, 3 May 2018 22:59:56 +0000 (23:59 +0100)]
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.
João Távora [Thu, 3 May 2018 15:14:35 +0000 (16:14 +0100)]
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.
João Távora [Thu, 3 May 2018 14:10:32 +0000 (15:10 +0100)]
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.
João Távora [Thu, 3 May 2018 13:08:37 +0000 (14:08 +0100)]
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.
João Távora [Thu, 3 May 2018 10:48:35 +0000 (11:48 +0100)]
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.
João Távora [Wed, 2 May 2018 16:00:46 +0000 (17:00 +0100)]
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*
João Távora [Wed, 2 May 2018 14:49:41 +0000 (15:49 +0100)]
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.
João Távora [Wed, 2 May 2018 12:37:35 +0000 (13:37 +0100)]
Events buffer uses eglot-mode, source buffers use eglot-editing-mode
* eglot.el (eglot--special-buffer-process): New var.
(eglot--current-process): Consider eglot--special-buffer-process.
(eglot-events-buffer): Use eglot-mode
(eglot-editing-mode): New minor mode.
(eglot-mode): Turns on eglot-editing-mode maybe.
João Távora [Tue, 1 May 2018 22:13:49 +0000 (23:13 +0100)]
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.
João Távora [Mon, 30 Apr 2018 17:54:54 +0000 (18:54 +0100)]
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.