João Távora [Wed, 11 Jul 2018 23:30:32 +0000 (00:30 +0100)]
Implement workspace/didchangeconfiguration ()
* README.md (Supported Protocol Features, Commands and
keybindings): mention workspace/didChangeConfiguration.
* eglot.el (eglot-server-initialized-hook): New hook.
(eglot--connect): Run it.
(eglot-workspace-configuration): New variable.
(eglot-signal-didChangeConfiguration): New command.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/29
GitHub-reference: close https://github.com/joaotavora/eglot/issues/40
Fixes an issue with the latest RLS, where the server returns a plist
instead of a plain string as documentation for completion candidates,
which broke the `annotation-function`. This change was introduced by
https://github.com/rust-lang-nursery/rls/commit/206a9fb41e837333d0e67187a6a9fe24868b77a4
Copyright-paperwork-exempt: yes
* eglot.el (eglot-completion-at-point): Use eglot--format-markup
João Távora [Mon, 25 Jun 2018 16:37:43 +0000 (17:37 +0100)]
Cache buffer's managing server
* eglot.el (eglot--cached-current-server): New variable.
(eglot--managed-mode-onoff): Set it.
(eglot--current-server): Read it.
(eglot--maybe-activate-editing-mode): Add assertion.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/32
João Távora [Thu, 21 Jun 2018 22:32:14 +0000 (23:32 +0100)]
Empty ranges are valid in lsp
The previous hack in eglot--range-region, designed to appease cquery's
occasional practice of publishing diagnostics with empty regions, was
moved to the proper notification handler.
Reported by mkcms <k.michal@zoho.com>.
* eglot.el (eglot--range-region): Allow empty ranges, which are
allowed in LSP.
(eglot-handle-notification :textDocument/publishDiagnostics): Maybe
fallback to flymake-diag-region here.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/27
João Távora [Wed, 20 Jun 2018 18:05:25 +0000 (19:05 +0100)]
Guess server for js2-mode and rjsx-mode
* eglot.el (eglot-server-programs): Add entries for js2-mode and
rjsx-mode. Coalesce entries for c++ and c-mode. Improve
docstring.
(eglot--guess-contact): Allow lists are keys in
eglot-server-programs.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/26
João Távora [Wed, 20 Jun 2018 17:47:45 +0000 (18:47 +0100)]
Improve eglot-ensure and mention it in readme.md
* README.md (Installation and Usage): Mention eglot-ensure.
* eglot.el (eglot-ensure): No-op for non-file buffers.
(eglot--connect): Don't fallback to 'eglot-lsp-server here.
(eglot--guess-contact): Error if something can't be guessed.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/25
João Távora [Sun, 10 Jun 2018 12:41:10 +0000 (13:41 +0100)]
New eglot-ensure to put in a major-mode's hook
* eglot.el (Commentary): Mention eglo-ensure.
(eglot--connect): Rearrange args.
(eglot--guess-contact): Rename from eglot--interactive.
(eglot): Use eglot--guess-contact.
(eglot, eglot-reconnect): Rearrange call to eglot--connect.
(eglot-ensure): New command to put in mode hook.
* eglot-tests.el (eglot--tests-connect): New helper.
(auto-detect-running-server, auto-reconnect, rls-watches-files)
(rls-basic-diagnostics, rls-hover-after-edit, rls-rename)
(basic-completions, hover-after-completions): Use it.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/17
João Távora [Sun, 10 Jun 2018 06:16:41 +0000 (07:16 +0100)]
Simplify jsonrpc status setting
* eglot.el (eglot--connect): Don't set jsonrpc-status.
(eglot-clear-status): New interactive command.
(eglot--mode-line-format): Simplify.
* jsonrpc.el (jsonrpc--async-request-1): Simplify.
(jsonrpc-connection): Replace status with last-error.
(jsonrpc-clear-status): Delete.
(jsonrpc--connection-receive): Set last-error.
João Távora [Fri, 8 Jun 2018 15:05:02 +0000 (16:05 +0100)]
Support json.c. api purely based on classes
No more jsonrpc-connect.
This is a big commit because of a data loss problem. It should be at
least two separate commits (json.c-support and new API)
* eglot.el (eglot-server-programs): Rework docstring.
(eglot-handle-request): Don't take ID param
(eglot-lsp-server): No more initargs.
(eglot--interactive): Return 5 args.
(eglot): Take 5 args.
(eglot-reconnect): Pass 6 args to eglot--connect.
(eglot--dispatch): Remove.
(eglot--connect): Take 6 args. Rework.
(eglot-handle-notification): Change all specializations
to use a non-keyword symbol spec.
(eglot-handle-request): Remove ID param from all
specializations. Don't pass ID to jsonrpc-reply.
(eglot--register-unregister): Don't take JSONRPC-ID arg.
Don't pass ID to jsonrpc-reply.
* jsonrpc-tests.el (returns-3, signals-an--32603-JSONRPC-error)
(times-out, stretching-it-but-works)
(json-el-cant-serialize-this, jsonrpc-connection-ready-p)
(deferred-action-intime, deferred-action-toolate)
(deferred-action-timeout): Pass JSON objects compatible with
json.c
(jsonrpc--test-client, jsonrpc--test-endpoint): New classes
(jsonrpc--with-emacsrpc-fixture): Don't use jsonrpc-connect.
(jsonrpc-connection-ready-p): Update signature.
* jsonrpc.el: Rewrite commentary.
(jsonrpc-connection): Rework class.
(jsonrpc-process-connection): Rework class.
(initialize-instance): New methods..
(jsonrpc--json-read, jsonrpc--json-encode): Reindent.
(jsonrpc-connect): Delete.
(jsonrpc--json-read, jsonrpc--json-encode):
New functions for working with json.c
(jsonrpc--process-filter): Call them.
(jsonrpc--unanswered-request-id): New variable.
(jsonrpc--connection-receive): Use jsonrpc--unanswered-request-id
(jsonrpc-connection-send): Take keyword params to build message
instead of message.
(jsonrpc-notify, jsonrpc--async-request-1): Use new
jsonrpc-connection-send.
(jsonrpc-reply): Simplify.
* eglot-tests.el (rls-watches-files, rls-basic-diagnostics)
(rls-hover-after-edit): Correctly compare using string= and
non-keyword symbols.
João Távora [Wed, 6 Jun 2018 11:04:39 +0000 (12:04 +0100)]
Slightly polish the flymake integration
For backends, like RLS, that don't textDocument/publishDiagnostics
right away, assume that the file is clean. Since Flymake allows
multiple reportings, it should be OK.
* eglot.el (eglot--unreported-diagnostics): Move variable up here.
(eglot--maybe-activate-editing-mode): Assume no diagnostics on
open.
João Távora [Tue, 5 Jun 2018 16:26:38 +0000 (17:26 +0100)]
Cleanup the flymake 26.1 hack slightly
* eglot.el (eglot-handle-notification): Use proper flymake
diagnostic types.
(eglot-code-actions): Use eglot--diag-data.
(eglot--make-diag, eglot--diag-data): New aliases to
`flymake-diagnostic-data' and `flymake-make-diagnostic'.
(eglot-error eglot-warning eglot-note)
(dolist eglot-error eglot-warning eglot-note): put
flymake-overlay-control in these.
(eglot-error eglot-warning eglot-note): put corresponding
flymake-category.
(horrible hack at the end): Move the Flymake 26.1 hack here.
João Távora [Fri, 1 Jun 2018 15:59:00 +0000 (16:59 +0100)]
New command m-x eglot-code-actions
Also available when left-clicking diagnostics.
* README.md: Mention eglot-code-actions. Slightly rewrite
differences to lsp-mode.
* eglot.el (eglot-code-actions): New command.
(eglot-handle-notification :textDocument/publishDiagnostics): Use
eglot--make-diag and eglot--overlay-diag-props.
(eglot--mode-line-props): Use eglot--mouse-call.
(eglot--mouse-call): Renamed from eglot--mode-line-call.
(eglot-client-capabilities): List :executeCommand and :codeAction
as capabilities.
(eglot--diag, advice-add flymake--highlight-line): Horrible hack.
(eglot--overlay-diag-props): Horrible hack.
João Távora [Mon, 28 May 2018 22:07:56 +0000 (23:07 +0100)]
More yak shaving
* eglot.el (eglot--with-live-buffer, eglot--widening): New macros.
(eglot--lambda): Move up here.
(eglot--process-filter): Simplify with eglot--with-live-buffer.
(eglot--async-request): Simplify with eglot--with-live-buffer.
(eglot--TextDocumentItem): Simplify with eglot--widening.
(eglot--signal-textDocument/didChange, eglot--apply-text-edits):
Simplify with eglot--widening.
João Távora [Mon, 28 May 2018 21:30:01 +0000 (22:30 +0100)]
New m-x eglot-stderr-buffer useful for debugging
* eglot.el (eglot--make-process): Save stderr buffer in process.
(eglot-stderr-buffer): New interactive command.
(eglot--mode-line-format): Bind C-mouse-1 to new
eglot-stderr-buffer.
João Távora [Sun, 27 May 2018 14:34:50 +0000 (15:34 +0100)]
Make eglot--recent-changes a simpler list
* eglot.el (eglot-server-ready-p): Don't add default method here.
(eglot-server-ready-p): Do it here.
(eglot--outstanding-edits-p): Remove.
(eglot--before-change, eglot--after-change)
(eglot--signal-textDocument/didChange): Use eglot--recent-changes
as a list. Simplify.
(eglot--signal-textDocument/didOpen): Use eglot--recent-changes as
a list.
João Távora [Sun, 27 May 2018 11:58:49 +0000 (12:58 +0100)]
Hopefully fix the flymake bootstrap problem
Immediately after M-x eglot, eglot's use of flymake was having trouble
detecting the first diagnostics sent from the server, resulting in an
annoying "Wait" in the mode-line.
* eglot.el (eglot--current-flymake-report-fn): Move up here.
(eglot--managed-mode): Set eglot--current-flymake-report-fn to nil
on teardown.
(eglot--maybe-activate-editing-mode): Simplify.
(eglot-handle-notification textDocument/publishDiagnostics): Set unreported-diagnostics to a cons.
(eglot-handle-notification eglot-rls window/progress): Simplify.
João Távora [Sun, 27 May 2018 10:58:41 +0000 (11:58 +0100)]
Set spinner in textdocument/didchange as it matters to rls
Otherwise, the asynch eldoc action will immediately send the
textDocument/documentHighlight requests, without understanding that
they need to be deferred a bit more.
* eglot.el (eglot--signal-textDocument/didChange): Set the spinner
here.
João Távora [Sun, 27 May 2018 10:41:24 +0000 (11:41 +0100)]
Fix assorted cquery-related bugs
Some versions of cquery send a :role key as part of the response to
textDocument/documentHighlight. Ignore it for now.
Also cquery sometimes send 0-length ranges upon which we now fallback
to flymake-diag-region.
Finally, in eglot-eldoc-funciton, the previous hack of calling the
eglot--hover-info outside of the when-buffer-window macrolet contained
a bug. It must be called in the correct buffer. Revert the hack and do
it by querying from eglot.el if ert is running tests.
* eglot.el (eglot--range-region): Return a cons and fallback to
flymake-diag-region if server returned a useless range.
(eglot-handle-notification, eglot--hover-info): Update call to
eglot--range-region.
(eglot-help-at-point): Ensure `eglot--hover-info` runs in right
buffer.
(eglot-eldoc-function): Don't abuse eldoc-last-message like this.
Also update call to eglot--range-region. Consider ert-running-test
(eglot--apply-text-edits): Use pcase-lambda.
(ert): require it.
João Távora [Sat, 26 May 2018 18:10:45 +0000 (19:10 +0100)]
Merge branch 'cquery-support' into master
The conflicts in eglot.el where fixed by calling the new eglot--debug
helper coming from 'cquery-support'. This helper was converted to
allow a non-string format passed directly to eglot--log-event.
Also fixed some compilation warnings.
* eglot.el (eglot--debug): Allow non-string FORMAT to be a JSON
object. (eglot-handle-notification :$cquery/progress)
(eglot-handle-notification :$cquery/setInactiveRegions)
(eglot-handle-notification :$cquery/publishSemanticHighlighting):
Solve compilation warnings.
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.
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.
João Távora [Sat, 26 May 2018 00:07:10 +0000 (01:07 +0100)]
Document current api breaches a bit
* eglot-tests.el (eglot--call-with-dirs-and-files)
(auto-reconnect): use eglot--process
* eglot.el (eglot-shutdown, eglot, eglot-reconnect)
(eglot--connect): Use eglot--process
(eglot--process): Alias to concentrate the hack here.
(eglot--signal-textDocument/didChange): Tweak comment.
Josh Elsasser [Fri, 25 May 2018 03:10:15 +0000 (20:10 -0700)]
Log debug messages through eglot--debug
* eglot.el (eglot--async-request, eglot--process-sentinel):
(eglot--call-deferred): Use eglot--debug to log messages to
the server events buffer.
(eglot--server-receive): Demote "Notification unimplemented"
message on missing handlers to a pure debug message.
Josh Elsasser [Tue, 22 May 2018 00:15:12 +0000 (17:15 -0700)]
Demote unvisited diagnostics logging to debug level
The PublishDiagnostic spec (LSP Specification, 3.0) does not
strictly forbid the server from publishing diagnostics before
a file has been visited.
* eglot.el (eglot--server-textDocument/publishDiagnostics): Log
the "received diagnostics for unvisited file" warning as debug
to avoid spamming users of compliant language servers.
Josh Elsasser [Mon, 21 May 2018 19:27:05 +0000 (12:27 -0700)]
Add cquery support for c/c++ projects
Implements minimal support for the core cquery language
server. None of its extensions are implemented yet.
* eglot.el (eglot-server-programs): Add cquery to list
of guessed programs for c-mode and c++-mode.
(eglot-initialization-options eglot-cquery): Specialize init
options to pass cquery a cache directory and disable a flood
of $cquery/progress messages.
(eglot-handle-notification $cquery/publishSemanticHighlighting):
(eglot-handle-notification $cquery/setInactiveRegions):
(eglot-handle-notification $cquery/progress): New no-op functions
to avoid filling logs with "unknown message" warnings.
(eglot-cquery): New eglot-lsp-server subclass.
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.
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.
* jsonrpc.el (defgroup jsonrpc, jsonrpc-request-timeout): Remove.
(jrpc-default-request-timeout): New constant.
(jsonrpc-async-request): Use it.
(jsonrpc-request): Accept timeout kwarg and pass it on.