]> git.eshelyaron.com Git - emacs.git/log
emacs.git
6 years agoReally ensure eglot--shutdown deletes a process completely
João Távora [Sat, 26 May 2018 17:52:17 +0000 (18:52 +0100)]
Really ensure eglot--shutdown deletes a process completely

* eglot.el (eglot-lsp-server): rename slot "moribund" to
"shutdown-requested"
(eglot--connect): Don't check if shutdown was requested here.
(eglot--process-sentinel): Set shutdown-requested to
:sentinel-done here.
(eglot-shutdown): use eglot--shutdown-requested.  Improve check
for process liveness.

6 years agoGet rid of eglot--obj, an uninteresting abstraction
João Távora [Sat, 26 May 2018 15:37:10 +0000 (16:37 +0100)]
Get rid of eglot--obj, an uninteresting abstraction

* eglot.el (eglot--obj): Get rid of this. It wasn't widely used
anyway.
(eglot-client-capabilities)
(eglot--connect, eglot--async-request, eglot--notify)
(eglot--reply, eglot--pos-to-lsp-position, eglot-handle-request)
(eglot--register-unregister, eglot-handle-request)
(eglot--TextDocumentIdentifier)
(eglot--VersionedTextDocumentIdentifier)
(eglot--TextDocumentItem, eglot--TextDocumentPositionParams)
(eglot--signal-textDocument/didChange)
(eglot--signal-textDocument/didSave)
(xref-backend-identifier-completion-table)
(xref-backend-references, xref-backend-apropos, eglot-imenu)
(eglot-rename): Use list instead of eglot--obj.

6 years agoCleanup deferred request mechanism with a readable log
João Távora [Sat, 26 May 2018 15:22:46 +0000 (16:22 +0100)]
Cleanup deferred request mechanism with a readable log

* eglot.el (eglot-lsp-server): Rework doc of deferred-actions
slot.
(defvar eglot--next-request-id): Move down, now buffer local.
(defun eglot--next-request-id): Remove.
(eglot--call-deferred): Be more informative.
(eglot--async-request): Simplify.

6 years agoSimpify eglot--server-receive
João Távora [Sat, 26 May 2018 15:13:53 +0000 (16:13 +0100)]
Simpify eglot--server-receive

* eglot.el (eglot--obj): Cleanup whitespace.
(eglot--server-receive): Simplify.

6 years agoDon't rely on flymake's idle timer for textdocument/didchange
João Távora [Sat, 26 May 2018 15:11:11 +0000 (16:11 +0100)]
Don't rely on flymake's idle timer for textdocument/didchange

* eglot.el (eglot--after-change): Set idle timer here.
(eglot--change-idle-timer): New var.
(eglot--signal-textDocument/didChange): No seed to set spinner here.
(eglot-flymake-backend) Don't send didChange here.

6 years agoFix indentation broken by the defclass monster commit
João Távora [Tue, 22 May 2018 10:42:12 +0000 (11:42 +0100)]
Fix indentation broken by the defclass monster commit

* eglot.el (for, eglot-handle-notification publishDiagnostics)
(eglot-handle-request registerCapability, eglot-handle-request
unregisterCapability, eglot-handle-request applyEdit): fix
indentation.

6 years agoIntroduce new api methods for experimental clients to use
João Távora [Tue, 22 May 2018 10:41:02 +0000 (11:41 +0100)]
Introduce new api methods for experimental clients to use

Should help Josh Elsasser implement pull request https://github.com/joaotavora/eglot/issues/6.

* eglot.el (eglot--obj): Move upwards in file.
(eglot-server-ready-p): Tweak comment.
(eglot-initialization-options): New API defgeneric..
(eglot-client-capabilities): New API defgeneric.
(eglot--client-capabilities): Remove.
(eglot--connect): Call new API methods here.

6 years agoDo rust's rls hack properly with new class-based api
João Távora [Tue, 22 May 2018 10:14:08 +0000 (11:14 +0100)]
Do rust's rls hack properly with new class-based api

* eglot.el (eglot-server-ready-p): New API method.
(eglot-handle-request, eglot-handle-notification): New
defgeneric's.
(eglot--ready-predicates, eglot--server-ready-p): Remove.
(eglot--async-request): Call eglot-server-ready-p.
(eglot--request): Tweak comment.
(eglot--rls-probably-ready-for-p): Remove.
(eglot-server-ready-p eglot-rls): Adapts earlier
eglot--rls-probably-ready-for-p.
(eglot-handle-notification eglot-rls): Specialize to eglot-rls.
(eglot-rls): New eglot-lsp-server subclass.

* eglot-tests.el (auto-detect-running-server)
(auto-reconnect, basic-completions)
(hover-after-completions): Use eglot--interactive

6 years agoUse an eieio class to represent a server.
João Távora [Tue, 22 May 2018 01:00:49 +0000 (02:00 +0100)]
Use an eieio class to represent a server.

Allow clients of eglot.el to use specific server classes to represent
experimental servers.

Wherever you used to read "proc" you now probably read "server",
unless it's really the process properties that are sought after.

Should help Josh Elsasser implement pull request https://github.com/joaotavora/eglot/issues/6.

* eglot-tests.el (eglot--call-with-dirs-and-files)
(auto-detect-running-server, auto-reconnect, basic-completions)
(hover-after-completions): Adapt to server defclass instead of
proc.

* eglot.el
(eglot-server-programs): Add docstring.
(eglot--processes-by-project): Removed.
(eglot--servers-by-project): New variable.
(eglot--current-process): Removed.
(eglot--current-server): New function.
(eglot-server): New class.
(cl-print-object eglot-server): New method.
(eglot--current-process-or-lose): Removed.
(eglot--current-server-or-lose): New function.
(eglot--define-process-var): Remove.
(eglot--make-process): Rework.
(eglot--project-short-name): Remove.
(eglot--connect): Rework.
(eglot--interactive): Rework to allow custom classes.
(eglot, eglot-reconnect, eglot--process-sentinel)
(eglot--process-filter, eglot-events-buffer, eglot--log-event):
Rework.
(eglot--process-receive): Removed.
(eglot--server-receive): New function.
(eglot--send): Renamed from eglot--process-send.
(eglot--process-send): Removed.
(eglot-forget-pending-continuations)
(eglot-clear-status, eglot--call-deferred)
(eglot--server-ready-p, eglot--async-request, eglot--request)
(eglot--notify, eglot--reply, eglot--managed-mode-onoff)
(eglot--maybe-activate-editing-mode, eglot--mode-line-format):
Rework.
(eglot-shutdown): Rework.
(eglot-handle-notification *, eglot-handle-request *)
(eglot--register-unregister)
(eglot--signal-textDocument/didOpen)
(eglot--signal-textDocument/didClose)
(eglot--signal-textDocument/willSave)
(eglot--signal-textDocument/didSave)
(xref-backend-identifier-completion-table)
(xref-backend-definitions, xref-backend-references)
(xref-backend-apropos, eglot-completion-at-point)
(eglot-help-at-point, eglot-eldoc-function, eglot-imenu)
(eglot-rename)
(eglot--register-workspace/didChangeWatchedFiles)
(eglot--unregister-workspace/didChangeWatchedFiles)
(eglot--rls-probably-ready-for-p, eglot-handle-notification):
Rework (proc->server)

fixup

* eglot-tests.el (eglot--call-with-dirs-and-files)
(auto-detect-running-server, auto-reconnect, basic-completions)
(hover-after-completions):

* eglot.el (eglot--processes-by-project): Removed.
(eglot--servers-by-project): New variable.
(eglot--current-process): Removed.
(eglot--current-server): New function.

6 years agoIntroduce eglot-handle-request and eglot-handle-notification as api
João Távora [Mon, 21 May 2018 08:00:49 +0000 (09:00 +0100)]
Introduce eglot-handle-request and eglot-handle-notification as api

* eglot.el (eglot--process-receive): Call eglot-handle-request and
eglot-handle-notification.
(eglot-handle-notification, eglot-handle-request): New generic
functions.
(eglot--server-window/showMessage)
(eglot--server-window/progress)
(eglot--server-telemetry/event, eglot--server-window/logMessage):
Convert to eglot-handle-notification.
(eglot-handle-request, eglot--server-client/registerCapability)
(eglot--server-client/unregisterCapability)
(eglot-handle-request): Convert to eglot-handle-request.

6 years agoFix a bug introduced in the previous commit
João Távora [Sat, 19 May 2018 23:44:21 +0000 (00:44 +0100)]
Fix a bug introduced in the previous commit

* eglot.el (eglot--format-markup): Ignore errors when calling
possibly unknown functions.
(eglot-completion-at-point): Use eglot--format-markup
(eglot--hover-info): Yak shaving

6 years agoRewrite a couple of defs and shave a yak
João Távora [Sat, 19 May 2018 23:35:11 +0000 (00:35 +0100)]
Rewrite a couple of defs and shave a yak

* eglot.el (eglot--define-process-var): Simplify.
(eglot--format-markup): Rewrite.
(eglot--warn, eglot--pos-to-lsp-position)
(eglot--lsp-position-to-point, eglot--server-capable)
(eglot--maybe-activate-editing-mode)
(eglot--server-textDocument/publishDiagnostics)
(eglot--server-workspace/applyEdit, eglot--hover-info): Yak
shaving.

6 years ago* eglot.el (version): bump to 0.4
João Távora [Sat, 19 May 2018 22:41:14 +0000 (23:41 +0100)]
* eglot.el (version): bump to 0.4

6 years agoAdd some completion tests for pyls
João Távora [Sat, 19 May 2018 16:04:46 +0000 (17:04 +0100)]
Add some completion tests for pyls

* eglot-tests.el (edebug): Require it.
(eglot--call-with-dirs-and-files): Simplify.
(eglot--call-with-test-timeout): Don't timeout if edebug.
(auto-detect-running-server, auto-reconnect): Skip unless rls is
found.
(basic-completions): New test.
(hover-after-completions): New failing test.

* eglot.el (eglot-eldoc-function): Force write
eldoc-last-message, for tests sake.

6 years agoHandle managed buffers in own process var
João Távora [Sat, 19 May 2018 15:50:09 +0000 (16:50 +0100)]
Handle managed buffers in own process var

This should save some trouble when testing noninteractively.  Because
eglot--shutdown didn't turn off the minor mode, test code running
immediately after it could still make didClose requests, for example.
The sentinel was the previous responsible for turning off the minor
mode and didn't get a chance to run in that case. Now eglot--shutdown
is also responsible for turning off the minor mode.

All this should be hidden behind eglot--managed-mode-onoff.

* eglot.el (eglot--managed-buffers): New process-local variable.
(eglot--process-sentinel): Turn off managed mode.
(eglot--managed-mode-onoff): New function.
(eglot--managed-mode): Don't offer to kill server here.
(eglot--buffer-managed-p): Remove.
(eglot--maybe-activate-editing-mode): Activate mode here.
(eglot-shutdown): Turn off minor mode here.
(eglot--server-window/progress): Simplify slightly.

6 years agoRobustness fixes for the request mechanism
João Távora [Sat, 19 May 2018 13:26:46 +0000 (14:26 +0100)]
Robustness fixes for the request mechanism

* eglot.el (eglot--async-request): Pass actual id to eglot--log-event
(eglot--request): Also cancel any continuations.

6 years agoCheck capabilities before sending :completionitem/resolve
João Távora [Sat, 19 May 2018 12:45:10 +0000 (13:45 +0100)]
Check capabilities before sending :completionitem/resolve

* eglot.el (eglot--server-capable): Rewrite.
(eglot-completion-at-point): Check caps before sending
:completionItem/resolve

6 years agoBetter decide what text exactly to present as completions
João Távora [Sat, 19 May 2018 12:16:36 +0000 (13:16 +0100)]
Better decide what text exactly to present as completions

For inserting, :insertText takes precedence over :label.
For annotating, first sentence of :documentation, then :detail,
then :kind name.

Also remember to send didChange in the :exit-function

* eglot.el (eglot-completion-function): Rework main function and
:annotation-function, and :exit-function

6 years ago* eglot.el (eglot-clear-status): remember to update modeline
João Távora [Sat, 19 May 2018 12:12:08 +0000 (13:12 +0100)]
* eglot.el (eglot-clear-status): remember to update modeline

6 years agoCollect regions to change as markers, then edit
João Távora [Sat, 19 May 2018 10:12:41 +0000 (11:12 +0100)]
Collect regions to change as markers, then edit

* eglot.el (eglot--lsp-position-to-point): Accept MARKER optional
arg.
(eglot--range-region): Accept MARKERS optional arg. Return a list.
(eglot--server-textDocument/publishDiagnostics)
(eglot--hover-info, eglot-eldoc-function): eglot--range-region
returns a list, not a cons.
(eglot--apply-text-edits): First collect regions as markers, then
edit.

GitHub-reference: close https://github.com/joaotavora/eglot/issues/4

6 years agoIf we're going to send rootpath, better send an absolute one
João Távora [Sat, 19 May 2018 09:24:18 +0000 (10:24 +0100)]
If we're going to send rootpath, better send an absolute one

javascript-typescript-langserver complained.

* eglot.el (eglot--connect): Use expand-file-name.

6 years agoRobustify timer handling for eglot--async-request
João Távora [Sat, 19 May 2018 09:06:12 +0000 (10:06 +0100)]
Robustify timer handling for eglot--async-request

This basically cherry-picks an ealier commit for the jsonrpc-refactor
branch:
  a2aa1ed..: João Távora 2018-05-18 Robustify timer handling for jrpc-async-request

* jrpc.el (jrpc--async-request): Improve timeout handling. Return a list (ID TIMER)
(jrpc--request): Protect against user-quits, cancelling timer

6 years agoSimplify some infrastructure fucntions
João Távora [Sat, 19 May 2018 08:29:52 +0000 (09:29 +0100)]
Simplify some infrastructure fucntions

* eglot.el (eglot--contact): Simplify docstring.
(eglot--make-process): Simplify.
(eglot--connect): Simplify.
(eglot--interactive): Simplify and correct odd bug.
(eglot--process-sentinel): Correct messages. Delete before
attempting reconnection.
(eglot-shutdown): Simplify.

6 years ago* eglot.el (version): bump to 0.3
João Távora [Thu, 17 May 2018 13:09:50 +0000 (14:09 +0100)]
* eglot.el (version): bump to 0.3

6 years agoMake it work on windows
João Távora [Thu, 17 May 2018 13:03:20 +0000 (14:03 +0100)]
Make it work on windows

Apparently passing :coding 'no-conversion to make-process on windows
is essential to receive any text at all in the process filter.

Also needed to tweak uri-to-path and path-to-uri.

Thanks to lsp-mode.el for these hints

* eglot.el (eglot--make-process): Pass :coding 'no-conversion to
make-process.
(eglot--path-to-uri): Add a forward slash if windows-nt.
(eglot--uri-to-path): Remove a forward slash if windows-nt.
(eglot--server-textDocument/publishDiagnostics): Simplify and use
eglot--uri-to-path.

6 years agoFix eglot--error and eglot--message helpers
João Távora [Thu, 17 May 2018 13:04:15 +0000 (14:04 +0100)]
Fix eglot--error and eglot--message helpers

* eglot.el (eglot--error, eglot--message):
Safely interpret %s.

6 years ago* eglot.el (eglot--lambda): add missing indent spec.
João Távora [Thu, 17 May 2018 13:04:33 +0000 (14:04 +0100)]
* eglot.el (eglot--lambda): add missing indent spec.

6 years agoSimplify some function calling infrastructure
João Távora [Wed, 16 May 2018 23:30:53 +0000 (00:30 +0100)]
Simplify some function calling infrastructure

eglot--mapply is a confusing abstraction. Hide some of that confusion
behind eglot--lambda. More stably dispatch server notifications and
requests without introspecting their contents.

* eglot.el (eglot--process-receive): Simplify.
(eglot--async-request): Improve doc.
(eglot--request): Simplify.
(eglot--mapply): Remove.
(xref-backend-identifier-completion-table)
(xref-backend-definitions, xref-backend-references)
(xref-backend-apropos, eglot-completion-at-point)
(eglot-eldoc-function, eglot-imenu, eglot--apply-text-edits):
Don't use eglot--mapply, use normal mapcar/mapc.

6 years agoReplace eglot--with-lsp-range with a function and pcase-let
João Távora [Wed, 16 May 2018 22:45:35 +0000 (23:45 +0100)]
Replace eglot--with-lsp-range with a function and pcase-let

* eglot.el (eglot--with-lsp-range): Remove.
(eglot--range-region): New function.
(eglot--server-textDocument/publishDiagnostics)
(eglot--hover-info, eglot-eldoc-function)
(eglot--apply-text-edits): Use it.

6 years agoAdd php's php-language-server to built-in guessed servers
João Távora [Tue, 15 May 2018 12:24:08 +0000 (13:24 +0100)]
Add php's php-language-server to built-in guessed servers

Closes https://github.com/joaotavora/eglot/issues/1. The problem in that issue is that php-language-server has a
bug when it's not passed it the deprecated ":rootPath" field. The bug
doesn't happen if the ":processId" field is also absent. Eglot was
triggering the bug, because it didn't pass ":rootPath", but there's
nothing wrong in doing so.

* README.md: Add php-language-server to the built-in list.

* eglot.el (eglot-server-programs): Add php-language-server.
(eglot--connect): Also pass (deprecated) rootPath.

6 years agoBump version and slightly improve doc
João Távora [Tue, 15 May 2018 09:59:46 +0000 (10:59 +0100)]
Bump version and slightly improve doc

* eglot.el: Bump version. Add nicer Commentary header.
(eglot): Improve docstring.

* README.md: Update

6 years agoMore quietly report request timeouts as events
João Távora [Mon, 14 May 2018 22:58:29 +0000 (23:58 +0100)]
More quietly report request timeouts as events

* eglot.el (eglot--sync-request): Use eglot--log-event

6 years agoShutdown server if connection initialization fails
João Távora [Mon, 14 May 2018 22:09:27 +0000 (23:09 +0100)]
Shutdown server if connection initialization fails

Also tweak autoreconnection logic

* eglot.el (eglot--connect): Immediately `eglot-shutdown` if
connection initialization failed. Don't treat interactive calls
specially.
(eglot--process-sentinel): Tweak messages.

6 years agoFix a ridiculous bug when generating transient projects
João Távora [Mon, 14 May 2018 21:19:23 +0000 (22:19 +0100)]
Fix a ridiculous bug when generating transient projects

* eglot.el (eglot--find-current-process, eglot--interactive): Fix
horrible bug.

6 years agoSupport didchangewatchedfiles with dynamic registration
João Távora [Mon, 14 May 2018 13:18:18 +0000 (14:18 +0100)]
Support didchangewatchedfiles with dynamic registration

RLS uses this, presumaly for knowing about Cargo.toml changes and stuff.

* README.md: Update protocol compliance.

* eglot.el (filenotify): Require it.
(eglot--file-watches): New process-local var.
(eglot--process-sentinel): Kill all watches
(eglot--register-unregister): New helper.
(eglot--server-client/registerCapability): Simplify.
(eglot--server-client/unregisterCapability): New method.
(eglot--register-workspace/didChangeWatchedFiles)
(eglot--unregister-workspace/didChangeWatchedFiles): New
capability.
(eglot--client-capabilities): Update.

6 years agoRemove an unused variable
João Távora [Mon, 14 May 2018 10:41:46 +0000 (11:41 +0100)]
Remove an unused variable

* eglot.el (eglot--expect-carriage-return): Get rid of this.

6 years agoNow send willsavewaituntil
João Távora [Mon, 14 May 2018 10:20:37 +0000 (11:20 +0100)]
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.

6 years agoDon't define a menu if nothing to show there for now
João Távora [Mon, 14 May 2018 09:50:49 +0000 (10:50 +0100)]
Don't define a menu if nothing to show there for now

* eglot.el (eglot-menu): Remove it.
(eglot--mode-line-format): Don't define a menu.

6 years agoUse rls in travis ci and add actual tests
João Távora [Sun, 13 May 2018 22:25:15 +0000 (23:25 +0100)]
Use rls in travis ci and add actual tests

Also run a hook when connected

* eglot-tests.el (eglot--with-dirs-and-files)
(eglot--make-file-or-dirs, eglot--call-with-dirs-and-files)
(eglot--find-file-noselect): New helpers.
(auto-detect-running-server, auto-reconnect): New actual tests.

* eglot.el (eglot-connect): Run hook when connected
(eglot-connect-hook): New variable

* .travis.yml: Use rust stable and install rls

* README.md: Update mention of automated tests

6 years agoFix automatic project creation
João Távora [Sun, 13 May 2018 22:22:31 +0000 (23:22 +0100)]
Fix automatic project creation

* eglot.el (eglot): Take PROJECT arg. Return process.
(eglot--interactive): Returns a project.

6 years agoWork with any old directory, no formal project needed
João Távora [Sun, 13 May 2018 21:03:32 +0000 (22:03 +0100)]
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.

6 years agoAsk server for textdocument/signaturehelp if it supports it
João Távora [Sun, 13 May 2018 19:35:45 +0000 (20:35 +0100)]
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

6 years agoFix copyright header. obviously not since 2003
João Távora [Sat, 12 May 2018 21:05:20 +0000 (22:05 +0100)]
Fix copyright header. obviously not since 2003

6 years agoReinstate the catch/loop/throw idiom in eglot-request
João Távora [Sun, 13 May 2018 01:39:32 +0000 (02:39 +0100)]
Reinstate the catch/loop/throw idiom in eglot-request

This reverts parts of commit fabee14ed5b32c30c6ac5cb1ce88f387522a6a1e.

Unfortunately, this may cause problems when calling the error
callbacks directly as in the process sentinel. In that particular
scenario the accept-process-output won't have return, because no
output has is being handled. Consequently, if we're unlucky, we have
another 30 seconds to way before the flag is tested and the loop
exits.

* eglot.el (eglot-request): Use catch/loop/throw again

6 years agoNew command eglot-help-at-point and a readme update
João Távora [Sat, 12 May 2018 14:59:53 +0000 (15:59 +0100)]
New command eglot-help-at-point and a readme update

* README.md (Commands and keybindings): New section.

* eglot.el (eglot-eldoc-function): Use eglot--hover-info.
Don't care about kind in highlightSymbol
(eglot--hover-info): New helper.
(eglot-help-at-point): New command.

6 years agoGet rid of catch/loop/throw idiom (suggested by thien-thi nguyen)
João Távora [Fri, 11 May 2018 10:46:53 +0000 (11:46 +0100)]
Get rid of catch/loop/throw idiom (suggested by thien-thi nguyen)

* eglot.el (eglot--process-filter)
(eglot--request): Replace catch/loop/throw idiom with let/test/loop/set

6 years agoRework autoreconnection logic
João Távora [Fri, 11 May 2018 09:59:59 +0000 (10:59 +0100)]
Rework autoreconnection logic

Can't be a global var, has to be a per process thing.

* eglot.el (eglot-autoreconnect): New defcustom
(eglot--inhibit-autoreconnect): Renamed from eglot--inhibit-autoreconnect
(eglot--connect): Run autoreconnect timer here.
(eglot--inhibit-auto-reconnect): Removed.
(eglot--process-sentinel): Don't run timer here. Rework.
(eglot, eglot-reconnect): Pass INTERACTIVE to eglot--connect.

6 years agoDuh, json.el is in emacs, and json-mode.el is useless here
João Távora [Fri, 11 May 2018 01:03:10 +0000 (02:03 +0100)]
Duh, json.el is in emacs, and json-mode.el is useless here

* eglot.el (Package-Requires): Don't require json-mode

6 years agoPrepare to sumbit to gnu elpa
João Távora [Thu, 10 May 2018 21:40:32 +0000 (22:40 +0100)]
Prepare to sumbit to gnu elpa

* eglot.el: Update headers.

6 years ago(eglot--xref-make): fix use of cl-destructuring-bind.
João Távora [Thu, 10 May 2018 21:56:11 +0000 (22:56 +0100)]
(eglot--xref-make): fix use of cl-destructuring-bind.

6 years agoMisc little adjustments for readability
João Távora [Thu, 10 May 2018 21:04:59 +0000 (22:04 +0100)]
Misc little adjustments for readability

* eglot.el (eglot--log-event, eglot--process-receive)
(eglot--xref-make, xref-backend-apropos): Use cl-destructuring-bind.
(eglot--server-window/showMessageRequest): Compact.

6 years agoSupport :completionitem/resolve
João Távora [Thu, 10 May 2018 20:56:54 +0000 (21:56 +0100)]
Support :completionitem/resolve

This is quite handy with company and company-quickhelp

* eglot.el (eglot-completion-at-point): Send
:completionItem/resolve

* README.md: Mention completionItem/resolve

6 years agoRename functions. eglot--request is now the synchronous one
João Távora [Thu, 10 May 2018 20:31:37 +0000 (21:31 +0100)]
Rename functions. eglot--request is now the synchronous one

* eglot.el (eglot--connect, eglot-shutdown)
(xref-backend-identifier-completion-table)
(xref-backend-definitions, xref-backend-references)
(xref-backend-apropos, eglot-completion-at-point, eglot-rename):
Call eglot--request.
(eglot--async-request): Renamed from eglot--request.
(eglot--request): Renamed from eglot--sync-request.
(eglot--TextDocumentIdentifier)
(eglot--VersionedTextDocumentIdentifier)
(eglot--TextDocumentPositionParams, eglot--TextDocumentItem):
Renamed from the more verbose eglot--current-buffer-* variante.
(eglot-rename, eglot-imenu, eglot-eldoc-function)
(eglot-completion-at-point, xref-backend-definitions)
(xref-backend-identifier-at-point)
(eglot--signal-textDocument/didSave)
(xref-backend-identifier-completion-table)
(eglot--signal-textDocument/didClose)
(eglot--signal-textDocument/didOpen)
(eglot--signal-textDocument/didChange): Use new function names.

6 years agoFriendlier m-x eglot
João Távora [Thu, 10 May 2018 19:00:15 +0000 (20:00 +0100)]
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

6 years agoImprove eglot-eldoc-function
João Távora [Thu, 10 May 2018 18:23:56 +0000 (19:23 +0100)]
Improve eglot-eldoc-function

Use the :range key if the server provided it. Also simplify code with
a new eglot--with-lsp-range macro.

* eglot.el (eglot--format-markup): Tweak comment.
(eglot--with-lsp-range): New helper macro.
(eglot--server-textDocument/publishDiagnostics)
(eglot--apply-text-edits): Use it.
(eglot-eldoc-function): Use range if server provides it.

6 years agoReduce log chatter
João Távora [Thu, 10 May 2018 17:44:47 +0000 (18:44 +0100)]
Reduce log chatter

* eglot.el (eglot--process-sentinel, eglot--request): Use
eglot--log-event.
(eglot--log-event): Print "message" if type unknown.
(eglot--debug, eglot--log): Remove.
(eglot--server-window/logMessage, eglot--server-telemetry/event):
Make noops.
(eglot--call-deferred): Also reduce chatter here.

6 years agoOnly call deferred actions after a full message has been received
João Távora [Thu, 10 May 2018 12:52:21 +0000 (13:52 +0100)]
Only call deferred actions after a full message has been received

Otherwise it can be quite wasteful.

* eglot.el (eglot--process-filter): Don't eglot--call-deferred here.
(eglot--process-receive): Do it here.

6 years agoResist server failure during synchronous requests
João Távora [Thu, 10 May 2018 12:14:19 +0000 (13:14 +0100)]
Resist server failure during synchronous requests

Calling the error handler unprotected could lead to the rest of the
sentinel not running at all. This defeated the auto-reconnection in
Rust, for example.

* eglot.el (eglot--process-sentinel): Rework.

6 years agoSimplify mode-line updating logic
João Távora [Thu, 10 May 2018 11:54:35 +0000 (12:54 +0100)]
Simplify mode-line updating logic

* eglot.el (eglot--define-process-var): Simplify.
(eglot--short-name, eglot--spinner, eglot--status): Don't
auto-update mode-line.
(eglot--process-receive): Update it here.

6 years agoMore rls-specifics: update flymake diags when indexing done
João Távora [Thu, 10 May 2018 11:51:21 +0000 (12:51 +0100)]
More rls-specifics: update flymake diags when indexing done

RLS could/should report diagnostics for every opened file, even if
there aren't any problems. Because it doesn't, loop for every buffer
managed by the process and call eglot--current-flymake-report-fn

* eglot.el
(eglot--server-window/progress): Call eglot--current-flymake-report-fn

6 years agoAdjust flymake integration
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.

6 years agoShorten summary line to appease package-lint.el
João Távora [Thu, 10 May 2018 11:07:31 +0000 (12:07 +0100)]
Shorten summary line to appease package-lint.el

6 years agoMore correctly setup rust-mode-related autoloads
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.

6 years agoAdd minimal headers, commentary and autoloads
João Távora [Wed, 9 May 2018 22:24:15 +0000 (23:24 +0100)]
Add minimal headers, commentary and autoloads

6 years agoFancier rls spinner
João Távora [Wed, 9 May 2018 22:12:19 +0000 (23:12 +0100)]
Fancier rls spinner

* eglot.el (eglot--mode-line-format): Use (nth 3) of
eglot--spinner.
(eglot--server-window/progress): Save detail message in spinner.

6 years agoNew "deferred requests" that wait until server is ready
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.

6 years agoCall eglot-eldoc-function after completion finishes
João Távora [Wed, 9 May 2018 21:28:29 +0000 (22:28 +0100)]
Call eglot-eldoc-function after completion finishes

* eglot.el (eglot-completion-at-point): Call
eglot-eldoc-function after completion finishes.

6 years agoSimplify `eglot-shutdown`
João Távora [Wed, 9 May 2018 21:26:02 +0000 (22:26 +0100)]
Simplify `eglot-shutdown`

* eglot.el (eglot, eglot-reconnect)
(eglot--managed-mode): Call new eglot-shutdown.
(eglot-shutdown): Simplify.
(eglot--process-sentinel): Also call error functions.
(eglot--process-filter): Reindent.

6 years agoGet rid of eglot-mode
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

6 years agoSimplify eglot--signal-textdocument/didchange
João Távora [Wed, 9 May 2018 09:58:28 +0000 (10:58 +0100)]
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.

6 years agoFix odd bugs and tweak stuff
João Távora [Wed, 9 May 2018 01:43:47 +0000 (02:43 +0100)]
Fix odd bugs and tweak stuff

* eglot.el (eglot--log-event): Insert before markers.
(eglot--process-receive): Shave lines.
(xref-backend-references): Use cl-return-from.
(eglot--log-event): Simplify
(eglot-completion-at-point): Saner annotation

6 years agoSupport workspace/applyedit
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.

6 years agoSupport textdocument/rename
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.

6 years agoReasonable textdocument/documenthighlight support
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.

6 years agoFix odd bugs
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.

6 years agoWhen killing server, always wait 3 seconds
João Távora [Tue, 8 May 2018 00:52:27 +0000 (01:52 +0100)]
When killing server, always wait 3 seconds

* eglot.el (eglot--request): Accept TIMEOUT param.

6 years agoTry to fix some textdocument/completion bugs
João Távora [Tue, 8 May 2018 00:46:30 +0000 (01:46 +0100)]
Try to fix some textdocument/completion bugs

* eglot.el (eglot-completion-at-point): Rework slightly.

6 years agoHalf-decent imenu support via textdocument/documentsymbol
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.

6 years agoOnly request stuff that server says it's capable of
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.

6 years agoSimplify mode-line code with a helper.
João Távora [Mon, 7 May 2018 21:40:53 +0000 (22:40 +0100)]
Simplify mode-line code with a helper.

* eglot.el (eglot--mdoe-line-props): New helper.
(eglot--mode-line-format): Use it.

6 years agoGet rid of eglot--buffer-open-count
João Távora [Mon, 7 May 2018 21:16:28 +0000 (22:16 +0100)]
Get rid of eglot--buffer-open-count

Hasn't really proved useful yet.

* eglot.el (eglot--buffer-open-count): Remove.
(eglot--signal-textDocument/didOpen)
(eglot--signal-textDocument/didClose): Simplify.

6 years agoGet rid of eglot--special-buffer-process
João Távora [Mon, 7 May 2018 21:15:21 +0000 (22:15 +0100)]
Get rid of eglot--special-buffer-process

Hasn't really proved useful yet.

* eglot.el (eglot--special-buffer-process): Delete.
(eglot--current-process): Simplify.
(eglot--events-buffer): Simplify.

6 years ago* eglot.el: reformat to shave off some lines.
João Távora [Mon, 7 May 2018 21:14:06 +0000 (22:14 +0100)]
* eglot.el: reformat to shave off some lines.

6 years agoFix bug in hover support
João Távora [Mon, 7 May 2018 21:06:49 +0000 (22:06 +0100)]
Fix bug in hover support

* eldoc.el (eglot-eldoc-function): Use eglot--format-markup.
(subr-x): Require it.
(eglot--format-markup): Pacify byte-compiler.

6 years agoClean up client capabilities
João Távora [Mon, 7 May 2018 17:46:28 +0000 (18:46 +0100)]
Clean up client capabilities

* eglot.el (eglot--client-capabilities): Clean up client
capabilities.

6 years agoHalf-baked textdocument/hover support
João Távora [Mon, 7 May 2018 17:45:57 +0000 (18:45 +0100)]
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

6 years agoTweak the async request engine.
João Távora [Mon, 7 May 2018 17:43:30 +0000 (18:43 +0100)]
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.

6 years agoExplain why didopen on after-revert-hook is a bad idea
João Távora [Mon, 7 May 2018 16:27:01 +0000 (17:27 +0100)]
Explain why didopen on after-revert-hook is a bad idea

The reason is that the global find-file-hook is called again, and that
already does the didOpen. Too many didOpen's would be bad.

* eglot.el (eglot--managed-mode): Remove commented lines.

6 years agoHalf-decent completion support
João Távora [Mon, 7 May 2018 16:23:27 +0000 (17:23 +0100)]
Half-decent completion support

* README.md: Update.

* eglot.el (eglot--kind-names): New variable.
(eglot--managed-mode): Handle completion-at-point-functions.
(eglot-completion-at-point): New function.

6 years agoSolve another textdocument/didchange bug
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.

6 years agoSupport javascript's javascript-typescript-langserver
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.

6 years agoIncrease request timeout length to 10 seconds
João Távora [Mon, 7 May 2018 12:45:10 +0000 (13:45 +0100)]
Increase request timeout length to 10 seconds

* eglot.el (eglot-request-timeout): New var.
(eglot--request): Use it.

6 years agoWorkaround two suspected emacs bugs
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.

6 years agoEtoomanylambdas
João Távora [Mon, 7 May 2018 11:18:08 +0000 (12:18 +0100)]
Etoomanylambdas

* eglot.el (eglot--sync-request): Remove a lambda.

6 years agoFix the odd bug here and there
João Távora [Mon, 7 May 2018 10:53:44 +0000 (11:53 +0100)]
Fix the odd bug here and there

* eglot.el (eglot--connect): Activate editing mode where
applicable here.
(eglot, eglot-reconnect): Not here or here.
(eglot--process-sentinel): Catch auto-reconnect errors.
(eglot--notify): Dont send 'id=null', it messes up js's lsp
(eglot--reply): Do send id here.
(eglot--log-event): Simplify protocol. Complexify implementation.
(eglot--process-receive, eglot--process-send): Simplify
eglot--log-event call.
(eglot--request, eglot--notify, eglot--reply): Simplify
eglot--process-send call
(eglot--server-client/registerCapability): Fix bug when replying
with wrong id.
(eglot--xref-reset-known-symbols): Take DUMMY arg.

6 years agoHalf-decent xref support
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.

6 years agoVery basic xref support
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.

6 years agoNew helper eglot--sync-request
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.

6 years agoCleanup mistake with textdocumentitem and textdocumentidentifier
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.

6 years agoHandle dynamic registration in general (but nothing specific yet)
João Távora [Fri, 4 May 2018 14:19:19 +0000 (15:19 +0100)]
Handle dynamic registration in general (but nothing specific yet)

* eglot.el (eglot--server-client/registerCapability): Implement.
(eglot--register-workspace/didChangeWatchedFiles): Dummy registrator.