João Távora [Thu, 10 May 2018 11:21:29 +0000 (12:21 +0100)]
Adjust flymake integration
When opening a new file (signalling textDocument/didOpen) it makes
sense to call the flymake callback (if it exists) with no diagnostics,
just to get rid of that "Wait", since we don't know if later in this
callback cycle the server will ever report new diagnostics.
* eglot.el (eglot--managed-mode): Don't call flymake-mode or eldoc-mode
(eglot--managed-mode-hook): Add them here.
(eglot--maybe-activate-editing-mode): Call flymake callback.
(eglot--server-textDocument/publishDiagnostics): Set unreported
diagnostics to nil if invoking callback.
João Távora [Thu, 10 May 2018 11:07:11 +0000 (12:07 +0100)]
More correctly setup rust-mode-related autoloads
By autoloading the add-hook form and the eglot--setup-rls-idiosyncrasies
definition, a user can start rust-mode without loading eglot.el along
with it.
* eglot.el (rust-mode-hook)
(eglot--setup-rls-idiosyncrasies): Wrap in autoloaded progn.
João Távora [Wed, 9 May 2018 21:41:37 +0000 (22:41 +0100)]
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.
João Távora [Wed, 9 May 2018 11:24:10 +0000 (12:24 +0100)]
Get rid of eglot-mode
* eglot.el (eglot--managed-mode): Don't call eglot-mode. When
shutting down, offer to kill server.
(mode-line-misc-info): Update to use eglot--managed-mode
João Távora [Tue, 8 May 2018 15:07:07 +0000 (16:07 +0100)]
Support workspace/applyedit
* eglot.el (eglot--reply): Don't send result or error if not
provided.
(eglot--server-workspace/applyEdit): New server method.
(eglot--apply-text-edits): Rework.
(eglot--apply-workspace-edit): New helper.
(eglot-rename): Simplify.
João Távora [Tue, 8 May 2018 12:37:35 +0000 (13:37 +0100)]
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.
João Távora [Tue, 8 May 2018 10:38:02 +0000 (11:38 +0100)]
Reasonable textdocument/documenthighlight support
* README.md: Update.
* eglot.el (eglot--current-buffer-TextDocumentPositionParams): New
helper.
(xref-backend-identifier-completion-table): Refactor a bit.
(xref-backend-identifier-at-point): Use when-let and
eglot--current-buffer-TextDocumentPositionParams
(xref-backend-definitions, xref-backend-references): Refactor a
bit.
(eglot-completion-at-point): Use
eglot--current-buffer-TextDocumentPositionParams
(eglot-eldoc-function): Rewrite to handle
textDocument/documentHighlight.
(eglot--highlights): New variable.
(eglot--client-capabilities): Update with support for documentHighlight.
João Távora [Tue, 8 May 2018 01:05:03 +0000 (02:05 +0100)]
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.
João Távora [Mon, 7 May 2018 22:43:03 +0000 (23:43 +0100)]
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.
João Távora [Mon, 7 May 2018 21:56:20 +0000 (22:56 +0100)]
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.
João Távora [Mon, 7 May 2018 15:32:23 +0000 (16:32 +0100)]
Solve another textdocument/didchange bug
* eglot.el (eglot--signal-textDocument/didChange): Rework a bit.
(eglot--after-change): Store the actual after-text in the
eglot--recent-after-changes.
João Távora [Mon, 7 May 2018 14:04:02 +0000 (15:04 +0100)]
Support javascript's javascript-typescript-langserver
* README.md: Improve a bit
* eglot.el (eglot--make-process): Take MANAGED-MAJOR-MODE arg
(eglot-executables): Add basic javascript support.
(eglot--connect): Pass mode to eglot--make-process
(eglot--interactive): Check that guessed command is a listp.
(eglot): Minor improvement to message.
(eglot--current-buffer-TextDocumentItem): Guess language from mode
symbol.
João Távora [Mon, 7 May 2018 12:42:56 +0000 (13:42 +0100)]
Workaround two suspected emacs bugs
* eglot.el (eglot--process-filter): Use a proper unique tag. Use
unwind-protect.
(eglot--sync-request): Rework.
(eglot--server-client/registerCapability): Use a proper done tag.
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.