]> git.eshelyaron.com Git - emacs.git/log
emacs.git
6 years agoApply text edits atomically
João Távora [Thu, 21 Jun 2018 13:53:50 +0000 (14:53 +0100)]
Apply text edits atomically

As suggested by mkcms <k.michal@zoho.com>, but do it in
eglot--apply-text-edits, where it benefits all its users.

* eglot.el (eglot--apply-text-edits): Use atomic-change-group.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/22

6 years agoDefer textdocument/formatting requests
João Távora [Thu, 21 Jun 2018 12:58:48 +0000 (13:58 +0100)]
Defer textdocument/formatting requests

* eglot.el (eglot-format-buffer): Pass DEFERRED to eglot--request.

6 years agoSimplify eglot-format-buffer
João Távora [Wed, 20 Jun 2018 18:29:30 +0000 (19:29 +0100)]
Simplify eglot-format-buffer

Use replace-buffer-contents, as suggested by mkcms
<k.michal@zoho.com>, but do it in eglot--apply-text-edits, where it
benefits all its users.

* README.md (Commands and keybindings): Mention
eglot-format-buffer.

* eglot.el (eglot-format-buffer): Don't try to heuristically
preserve point here.
(eglot--apply-text-edits): Use replace-buffer-contents.

* eglot-tests.el (formatting): adjust test to strictly check for point
position.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/22

6 years agoGuess server for js2-mode and rjsx-mode
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

6 years agoImprove eglot-ensure and mention it in readme.md
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

6 years agoUse gfm-mode for formatted strings ()
Rami Chowdhury [Sat, 16 Jun 2018 22:59:57 +0000 (18:59 -0400)]
Use gfm-mode for formatted strings ()

* eglot.el (eglot--format-markup): Use gfm-mode instead of
markdown-mode.

Copyright-paperwork-exempt: yes
GitHub-reference: https://github.com/joaotavora/eglot/issues/20

6 years agoMinor cleanup to new textdocument/formatting feature
João Távora [Fri, 15 Jun 2018 22:56:29 +0000 (23:56 +0100)]
Minor cleanup to new textdocument/formatting feature

* README.md (Language feature): Tick textDocument/formatting

* eglot.el (eglot-client-capabilities): Add formatting capability.
Also move codeAction capability to the correct section.

(eglot-format-buffer): Remove unused lexical variable before-point.

6 years agoImplement formatting ()
Michal Krzywkowski [Fri, 15 Jun 2018 22:47:52 +0000 (00:47 +0200)]
Implement formatting ()

Implement textDocument/formatting

* eglot.el (eglot-format-buffer): New command to format
current buffer.

* eglot-tests.el (formatting): New test.

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

6 years ago* eglot.el (version): bump to 0.10
João Távora [Wed, 13 Jun 2018 17:48:41 +0000 (18:48 +0100)]
* eglot.el (version): bump to 0.10

6 years agoFix a bug when eglot--request times out
João Távora [Wed, 13 Jun 2018 17:46:19 +0000 (18:46 +0100)]
Fix a bug when eglot--request times out

* eglot.el (eglot--request): Better timeout
message.
(eglot--async-request): Must return the timer.

6 years ago* eglot.el (eglot-shutdown): accept timeout param.
João Távora [Wed, 13 Jun 2018 11:46:36 +0000 (12:46 +0100)]
* eglot.el (eglot-shutdown): accept timeout param.

6 years agoFix bug in querying server capabilities
João Távora [Wed, 13 Jun 2018 11:30:20 +0000 (12:30 +0100)]
Fix bug in querying server capabilities

This lead to javascript-typescript-stdio being sent an incremental
didChange notif, which it doesn't support.

* eglot.el (eglot--server-capable): Fix bug.

6 years ago* eglot.el (version): bump to 0.9
João Távora [Sun, 10 Jun 2018 13:57:02 +0000 (14:57 +0100)]
* eglot.el (version): bump to 0.9

6 years agoNew eglot-ensure to put in a major-mode's hook
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

6 years agoFix indentation f@#$%^ by previous commit
João Távora [Sat, 9 Jun 2018 20:12:48 +0000 (21:12 +0100)]
Fix indentation f@#$%^ by previous commit

Courtesy of aggressive-indent-mode... Agressive it is...

6 years agoAttempt to handle rls sophisticated globs for didchangewwatchedfiles
João Távora [Sat, 9 Jun 2018 20:09:03 +0000 (21:09 +0100)]
Attempt to handle rls sophisticated globs for didchangewwatchedfiles

* eglot.el (eglot--wildcard-to-regexp): New helper.
(eglot--register-workspace/didChangeWatchedFiles): Use it.

6 years agoCheck flymake-mode before calling report-fn
João Távora [Fri, 8 Jun 2018 17:58:34 +0000 (18:58 +0100)]
Check flymake-mode before calling report-fn

* eglot.el (eglot-handle-notification): Check flymake-mode.

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

6 years agoSlightly polish the flymake integration
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.

6 years ago* eglot.el (eglot--make-process): use 'utf-8-emacs-unix
João Távora [Wed, 6 Jun 2018 10:09:43 +0000 (11:09 +0100)]
* eglot.el (eglot--make-process): use 'utf-8-emacs-unix

Attempt to improve the situation reported in https://github.com/joaotavora/eglot/issues/14.

6 years agoShoosh compiler
João Távora [Tue, 5 Jun 2018 16:28:03 +0000 (17:28 +0100)]
Shoosh compiler

* eglot.el (eglot-server-ready-p): Use cl-defmethod

6 years agoCleanup the flymake 26.1 hack slightly
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.

6 years agoSupport purposedly ignoring a server capability
João Távora [Mon, 4 Jun 2018 11:49:28 +0000 (12:49 +0100)]
Support purposedly ignoring a server capability

* eglot.el (eglot-ignored-server-capabilites): New defcustom.
(eglot--server-capable): Use it.

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

6 years agoFix typos
brotzeit [Mon, 4 Jun 2018 10:50:01 +0000 (12:50 +0200)]
Fix typos

Close https://github.com/joaotavora/eglot/issues/13.

* eglot.el (eglot--all-major-modes)
(eglot--notify, eglot--xref-reset-known-symbols): Fix typos.

6 years ago* eglot.el (version): bump to 0.8
João Távora [Fri, 1 Jun 2018 16:58:00 +0000 (17:58 +0100)]
* eglot.el (version): bump to 0.8

6 years agoFix completionitem/resolve
João Távora [Fri, 1 Jun 2018 16:52:00 +0000 (17:52 +0100)]
Fix completionitem/resolve

Should fix interoperation with company-quickhelp.

* eglot.el (eglot-completion-at-point): Correctly pass properties
to completionItem/resolve.

6 years agoExplicitly trigger eldoc after workspace edits
João Távora [Fri, 1 Jun 2018 16:04:17 +0000 (17:04 +0100)]
Explicitly trigger eldoc after workspace edits

It's usually a nice thing to do.

* eglot.el (eglot--apply-workspace-edit): Call
eglot-eldoc-function.

6 years agoNew command m-x eglot-code-actions
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.

6 years agoRevert an unfinished feature that made it to the last commit
João Távora [Fri, 1 Jun 2018 15:09:19 +0000 (16:09 +0100)]
Revert an unfinished feature that made it to the last commit

commit ee6ab89666704232f744d6262040979b0142c44b
   Author: João Távora <joaotavora@gmail.com>
   Date:   Fri Jun 1 14:43:30 2018 +0100

   Add MELPA badge

6 years agoAdd melpa badge
João Távora [Fri, 1 Jun 2018 13:43:30 +0000 (14:43 +0100)]
Add melpa badge

* README.mdown: Now in MELPA too

6 years agoPrevent possible cquery choke on :initializationoptions
João Távora [Fri, 1 Jun 2018 13:12:54 +0000 (14:12 +0100)]
Prevent possible cquery choke on :initializationoptions

Hopefully help debug https://github.com/joaotavora/eglot/issues/10.

* eglot.el (eglot-initialization-options): Use `list'

6 years ago* eglot.el (version): bump to 0.7
João Távora [Wed, 30 May 2018 02:20:54 +0000 (03:20 +0100)]
* eglot.el (version): bump to 0.7

6 years agoMore yak shaving
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.

6 years agoNew m-x eglot-stderr-buffer useful for debugging
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.

6 years agoOn reconnection, ignore errors of shutting down hung server
João Távora [Sun, 27 May 2018 18:45:52 +0000 (19:45 +0100)]
On reconnection, ignore errors of shutting down hung server

* eglot.el
(eglot, eglot-reconnect): Ignore any errors on shutdown.

6 years agoBe more criterious before running the idle timer
João Távora [Sun, 27 May 2018 15:51:15 +0000 (16:51 +0100)]
Be more criterious before running the idle timer

* eglot.el (eglot--change-idle-timer): make a defvar-local
(eglot--after-change): Only run timer if the buffer is live.

6 years agoMake eglot--recent-changes a simpler list
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.

6 years agoSet eglot--versioned-identifier to 0 on didopen
João Távora [Sun, 27 May 2018 13:53:53 +0000 (14:53 +0100)]
Set eglot--versioned-identifier to 0 on didopen

Else cquery will rightfully complain about this.

* eglot.el (eglot--signal-textDocument/didOpen): Also set
eglot--versioned-identifier to 0.

6 years agoCorrectly apply workspace edits in documentchanges form
João Távora [Sun, 27 May 2018 13:17:36 +0000 (14:17 +0100)]
Correctly apply workspace edits in documentchanges form

This was breaking M-x eglot-rename for cquery

* eglot.el (eglot--apply-workspace-edit): Fix and simplify.

6 years ago* eglot.el (version): bump to 0.6
João Távora [Sun, 27 May 2018 12:17:07 +0000 (13:17 +0100)]
* eglot.el (version): bump to 0.6

6 years agoHopefully fix the flymake bootstrap problem
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.

* eglot-tests.el (rls-basic-diagnostics): Simplify test.

6 years agoSet spinner in textdocument/didchange as it matters to rls
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.

6 years agoFix assorted cquery-related bugs
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.

6 years ago* eglot.el (version): bump to 0.5
João Távora [Sat, 26 May 2018 18:29:51 +0000 (19:29 +0100)]
* eglot.el (version): bump to 0.5

6 years agoMerge branch 'cquery-support' into master
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.

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 agoLog debug messages through eglot--debug
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.

6 years agoDemote unvisited diagnostics logging to debug level
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.

6 years agoIntroduce eglot--debug for unimportant messages
Josh Elsasser [Tue, 22 May 2018 00:03:55 +0000 (17:03 -0700)]
Introduce eglot--debug for unimportant messages

* eglot.el (eglot--debug): New function to log noisy or trivial
messages to the eglot events buffer.

6 years agoAdd cquery support for c/c++ projects
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.

* README.md: Mention cquery in the README.

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