]> git.eshelyaron.com Git - emacs.git/log
emacs.git
5 years ago* eglot.el (xref-backend-references): don't use return-from.
João Távora [Mon, 11 Feb 2019 21:34:50 +0000 (21:34 +0000)]
* eglot.el (xref-backend-references): don't use return-from.

5 years agoDon't sort xref's by default
João Távora [Mon, 11 Feb 2019 21:33:49 +0000 (21:33 +0000)]
Don't sort xref's by default

But use a eglot-xref-lessp-function in case someone wants to tweak
this.

* eglot.el (eglot-xref-lessp-function): New variable.
(eglot--handling-xrefs): Use it.

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

5 years agoUse a less buggy flymake
João Távora [Mon, 11 Feb 2019 21:21:49 +0000 (21:21 +0000)]
Use a less buggy flymake

* eglot.el (Package-Requires) Require flymake 1.0.5

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

5 years agoDon't teardown company if started via trigger chars
João Távora [Tue, 5 Feb 2019 21:49:38 +0000 (21:49 +0000)]
Don't teardown company if started via trigger chars

Reported by zhanghj in https://github.com/company-mode/company-mode/issues/866

* eglot.el (eglot-completion-at-point): More carefully calculate
:company-prefix-length

5 years agoConsider mode derivation when guessing servers
João Távora [Mon, 14 Jan 2019 15:31:26 +0000 (15:31 +0000)]
Consider mode derivation when guessing servers

* eglot.el (eglot-server-programs): Remove js2-mode and rjsx-mode.
(eglot--guess-contact): Use provided-mode-derived-p

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

5 years agoProtect against null messages from eldoc
João Távora [Mon, 14 Jan 2019 14:15:20 +0000 (14:15 +0000)]
Protect against null messages from eldoc

* eglot.el (eglot--eldoc-message): Protect against nil FORMAT.

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

5 years agoFix bug introduced by commit fixing this issue
Sergey Kostyaev [Thu, 10 Jan 2019 19:45:30 +0000 (02:45 +0700)]
Fix bug introduced by commit fixing this issue

* eglot.el (eglot--sig-info): Protect against invalid label.

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

5 years agoAdd built-in support for dart's dart_language_server
Brady Trainor [Wed, 26 Dec 2018 00:21:53 +0000 (16:21 -0800)]
Add built-in support for dart's dart_language_server

Closes https://github.com/joaotavora/eglot/issues/194.

Copyright-paperwork-exempt: yes

* README.md (Connecting to a server): Add dart_language_server.

* eglot.el (eglot-server-programs): Add dart_language_server.

5 years agoHandle label offsets in parameterinformation
João Távora [Wed, 9 Jan 2019 21:09:35 +0000 (21:09 +0000)]
Handle label offsets in parameterinformation

At least ccls uses this.

* eglot.el (eglot-client-capabilities): Declare support for
:labelOffsetSupport.
(eglot--sig-info): Handle label offsets in ParameterInformation

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

5 years agoDisplay truncated docstring if too large for echo area
João Távora [Mon, 7 Jan 2019 08:44:37 +0000 (08:44 +0000)]
Display truncated docstring if too large for echo area

* eglot.el (eglot--eldoc-message): Display first line doc.

6 years agoRename new defcustoms with friendlier names
João Távora [Sun, 6 Jan 2019 22:14:27 +0000 (22:14 +0000)]
Rename new defcustoms with friendlier names

* eglot.el (eglot-doc-too-large-for-echo-area): Rename from
eglot-eldoc-extra-buffer-if-too-large.
(eglot-put-doc-in-help-buffer): Rename from
eglot-eldoc-extra-buffer.
(eglot-auto-display-help-buffer): Rename from
eglot-auto-display-eldoc-extra-buffer.
(eglot--eldoc-message): Use new variable names.

6 years agoFix test failure introduced by previous commit
João Távora [Sun, 6 Jan 2019 12:55:21 +0000 (12:55 +0000)]
Fix test failure introduced by previous commit

Remove the hack of unsetting eldoc-last-message in
eglot--eldoc-message.  This allows any subsequent eglot-eldoc-function
calls (prompted by simple cursor movement) to return it immediately,
thus refreshing the help buffer with the same contents.  For this to
work, we also have to set eglot--eldoc-hint globally in
eglot-eldoc-function.

An alternative to making the test pass would be to keep the hack of
unsetting eldoc-last-message only in the case that we actually get to
display the help buffer.  This would actually be more efficient, but
potentially more hacky.

The bottom line here is that eldoc doesn't have a good API to deal
with asynchronous docstring fetching.  See this thread:

https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00151.html

* eglot.el (eglot--eldoc-message): Don't unset eldoc-last-message.
(eglot-eldoc-function): Set eglot--eldoc-hint for synchronous
operation too.

6 years agoShow large docs in help buffer instead of echo are by default
João Távora [Sat, 5 Jan 2019 22:47:43 +0000 (22:47 +0000)]
Show large docs in help buffer instead of echo are by default

* eglot.el (eglot--managed-mode): Add and remove from eglot--eldoc-message
(eglot--eldoc-hint, eglot--help-buffer): New helpers.
(eglot-eldoc-extra-buffer)
(eglot-auto-display-eldoc-extra-buffer): New defcustoms.
(eglot--eldoc-message): New helper.
(eglot-eldoc-function): Set eglot--eldoc-hint.
(eglot-help-at-point): Use new helpers.
(eglot-eldoc-extra-buffer-if-too-large): New predicate.

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

6 years agoPrevent eldoc flicker when moving around
João Távora [Sat, 5 Jan 2019 14:35:01 +0000 (14:35 +0000)]
Prevent eldoc flicker when moving around

* eglot.el (eglot-eldoc-function): Return eldoc-last-message
immediately.

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

6 years agoHandle (un)registercapability requests via generic functions
João Távora [Sat, 5 Jan 2019 13:32:13 +0000 (13:32 +0000)]
Handle (un)registercapability requests via generic functions

* eglot.el (Version): Bump to 1.4
(eglot-register-capability, eglot-unregister-capability): New
generic functions.
(eglot--register-unregister): Call eglot-register-capability,
eglot-unregister-capability.
(eglot-register-capability s (eql
workspace/didChangeWatchedFiles)): Rename from
eglot--register-workspace/didChangeWatchedFiles.
(eglot-unregister-capability s (eql
workspace/didChangeWatchedFiles)): Rename from
eglot--unregister-workspace/didChangeWatchedFiles.

6 years agoAppease checkdoc
João Távora [Sat, 5 Jan 2019 13:03:01 +0000 (13:03 +0000)]
Appease checkdoc

* eglot.el (eglot--post-self-insert-hook)
(eglot--pre-command-hook, eglot--before-change)
(eglot--eclipse-jdt-contact): Fix docstrings.

6 years ago* eglot.el (eglot-workspace-configuration): safe when listp.
João Távora [Wed, 2 Jan 2019 20:34:09 +0000 (20:34 +0000)]
* eglot.el (eglot-workspace-configuration): safe when listp.

6 years agoRun connection hooks with proper dir-locals
João Távora [Wed, 2 Jan 2019 17:12:36 +0000 (17:12 +0000)]
Run connection hooks with proper dir-locals

eglot-connect-hook and eglot-server-initialized-hook must run in a
buffer with properly setup directory-local variables for the project.

This is crucial for things like eglot-signal-didChangeConfiguration,
which needs a properly setup value of eglot-workspace-configuration to
succeed.

I could have chosen any of the buffers where Eglot is activating
itself, but the approach using
hack-dir-local-variables-non-file-buffer seems more correct, despite
the name.

* eglot.el (eglot--connect): Run connection hooks with proper
dir-locals.

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

6 years agoAllow read-only modes for markup rendering
João Távora [Tue, 1 Jan 2019 14:56:46 +0000 (14:56 +0000)]
Allow read-only modes for markup rendering

gfm-mode is read-only, so it must be set after the string has been
inserted in the temporary buffer.

* eglot.el (eglot--format-markup): Insert string before setting
mode.

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

6 years agoRemove a hard dependency on flymake-mode
João Távora [Thu, 27 Dec 2018 18:31:42 +0000 (18:31 +0000)]
Remove a hard dependency on flymake-mode

* eglot.el (eglot-handle-notification): Don't specifically check for
flymake-mode before reporting diagnostics.

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

6 years agoSlightly simplify eglot-completion-at-point
João Távora [Sun, 23 Dec 2018 14:01:38 +0000 (14:01 +0000)]
Slightly simplify eglot-completion-at-point

* eglot.el (eglot-completion-at-point): Don't propertize
completion string with all LSP properties.

6 years agoActually make completion sorting work
João Távora [Sat, 22 Dec 2018 15:23:41 +0000 (15:23 +0000)]
Actually make completion sorting work

* eglot.el (eglot-completion-at-point): Complicate severely.

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

6 years agoFix previous commit where workaround had been removed
João Távora [Sat, 22 Dec 2018 15:27:27 +0000 (15:27 +0000)]
Fix previous commit where workaround had been removed

Do remove the workaround, but not more than that.

* eglot.el (eglot-completion-at-point): set local var strings.

6 years agoUse gfm-view-mode
João Távora [Sat, 22 Dec 2018 15:18:55 +0000 (15:18 +0000)]
Use gfm-view-mode

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

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

6 years agoRemove workaround for company bug that has been fixed
João Távora [Sat, 22 Dec 2018 15:17:41 +0000 (15:17 +0000)]
Remove workaround for company bug that has been fixed

See https://github.com/company-mode/company-mode/pull/845.

* eglot.el (eglot-completion-at-point): Remove workaround for
company-mode bug.

6 years ago* eglot.el (package-requires): require jsonrpc 1.0.7.
João Távora [Wed, 19 Dec 2018 21:57:00 +0000 (21:57 +0000)]
* eglot.el (package-requires): require jsonrpc 1.0.7.

6 years agoTake over flymake and eldoc completely while managing buffers
João Távora [Sun, 16 Dec 2018 19:03:06 +0000 (19:03 +0000)]
Take over flymake and eldoc completely while managing buffers

Take a pragmatic approach and override all other Flymake and Eglot
backends while Eglot is enabled.  Restore previous values after
eglot-shutdown.

Certainly cases might arise where using more than one datasource
besides LSP while Eglot is managing the buffer is useful.  But
currently contrary, it confuses users enabling Eglot in buffers that
already have flymake/eldoc backends configured.

The reasons are slightly different for Eldoc and Flymake:

- For Eldoc the :before-until strategy only makes sense for
  synchronous backends, which Eglot isn't.  This conflicts with
  python.el default python-eldoc-function, which is also asynchronous.

- For Flymake, the default backends in Emacs (python-mode, c-mode, and
  a few others) are mainly repetitions of what LSP does.  The global
  value is still run though (in case you want to put, say, a
  spell-checking backend there).

* eglot.el (eglot--saved-bindings, eglot--setq-saving): New
helpers.
(eglot--managed-mode): Use them.

6 years agoBe more careful when making xref summaries
João Távora [Sun, 16 Dec 2018 14:33:14 +0000 (14:33 +0000)]
Be more careful when making xref summaries

* eglot.el (eglot--xref-make): Only highlight to end-of-line at
most.

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

6 years agoDon't make bogus responses to client/(un)registercapability
João Távora [Sun, 16 Dec 2018 14:22:57 +0000 (14:22 +0000)]
Don't make bogus responses to client/(un)registercapability

* eglot.el (eglot--register-unregister): Response is void.

6 years agoAdd edebug specs to destructuring macros
João Távora [Sun, 16 Dec 2018 13:51:14 +0000 (13:51 +0000)]
Add edebug specs to destructuring macros

* eglot.el (eglot--dbind, eglot--lambda, eglot--dcase): Add edebug
specs.

6 years agoRewrite eglot--sig-info a bit for readability
João Távora [Sun, 16 Dec 2018 13:48:57 +0000 (13:48 +0000)]
Rewrite eglot--sig-info a bit for readability

* eglot.el (eglot--sig-info): Rewrite a bit.

6 years agoAdjust active param highlighting in first line of signature (3/3)
Fredrik Bergroth [Thu, 13 Dec 2018 12:03:42 +0000 (13:03 +0100)]
Adjust active param highlighting in first line of signature (3/3)

Highlight only first active parameter match (even if there are many)

Copyright-paperwork-exempt: yes

* eglot.el (eglot--sig-info): Simplify.

6 years agoAdjust active param highlighting in first line of signature (2/3)
Fredrik Bergroth [Thu, 13 Dec 2018 12:02:15 +0000 (13:02 +0100)]
Adjust active param highlighting in first line of signature (2/3)

Use regex with word boundaries when scanning for active param, to
avoid matching substrings.

Copyright-paperwork-exempt: yes

* eglot.el (eglot--sig-info): Use `re-search-forward`.

6 years agoAdjust active param highlighting in first line of signature (1/3)
Fredrik Bergroth [Thu, 13 Dec 2018 11:59:57 +0000 (12:59 +0100)]
Adjust active param highlighting in first line of signature (1/3)

JT@2018/12/16: Previously, the whole first line of the rendered
documentation was searched for, potentially highlighting params
in the wrong place.

Copyright-paperwork-exempt: yes

* eglot.el (eglot--sig-info): Search for active parameter within
`params-start` and `params-end`.

6 years agoApply eglot--format-markup to signature documentation
Fredrik Bergroth [Thu, 13 Dec 2018 11:55:28 +0000 (12:55 +0100)]
Apply eglot--format-markup to signature documentation

Copyright-paperwork-exempt: yes

* eglot.el (eglot--sig-info): Call eglot--format-markup on signature
  documentation.

6 years ago* eglot.el (version): bump to 1.3
João Távora [Mon, 10 Dec 2018 00:10:57 +0000 (00:10 +0000)]
* eglot.el (version): bump to 1.3

6 years agoBe lenient by default to unknown methods or notifications
João Távora [Fri, 7 Dec 2018 22:51:40 +0000 (22:51 +0000)]
Be lenient by default to unknown methods or notifications

* eglot.el (eglot-strict-mode): Describe meaning of
disallow-non-standard-keys.
(eglot-handle-notification, eglot-handle-request): Check
eglot-strict-mode.

6 years agoHandle array params to server notification or requests
João Távora [Fri, 7 Dec 2018 22:43:13 +0000 (22:43 +0000)]
Handle array params to server notification or requests

* eglot.el (eglot-handle-notification): Remove extraneous id
(eglot--connect): If params is an array, make it a list.

6 years agoScratch/use elpa flymake ()
João Távora [Fri, 7 Dec 2018 14:46:23 +0000 (14:46 +0000)]
Scratch/use elpa flymake ()

Use GNU ELPA's Flymake

* eglot.el (Package-Requires): require Flymake 1.0.2.
(version< emacs-version "27.0"): Remove horrible hack

* Makefile (ELPADEPS): Renamed from JSONRPC.
(%.elc): Use it.
(eglot-check): Use it.

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

6 years agoWarn about suspicious interface usage at compile-time
João Távora [Thu, 6 Dec 2018 18:26:17 +0000 (18:26 +0000)]
Warn about suspicious interface usage at compile-time

For fun, set eglot-strict-mode to '(disallow-non-standard-keys
enforce-required-keys enforce-optional-keys) when compiling, or just
use flymake-mode in eglot.el.

* eglot.el (eglot--lsp-interface-alist): Use in compile-time.
Order alphabetically.  Fix a few bugs.
(eglot-strict-mode): Disallow non-standard-keys when compiling.
Update docstring.
(eglot--keywordize-vars, eglot--check-interface): New
compile-time-helpers.
(eglot--dbind, eglot--dcase): Use new helpers.

6 years agoUse eglot--dbind and eglot--lambda throughout
João Távora [Wed, 5 Dec 2018 19:54:55 +0000 (19:54 +0000)]
Use eglot--dbind and eglot--lambda throughout

The default behaviour of these macros is to be lenient towards servers
sending unknown keys, which should fix the issue.

* eglot.el (eglot--lsp-interface-alist): Add a bunch of new interfaces.
(eglot--connect, eglot-handle-notification)
(xref-backend-identifier-completion-table)
(xref-backend-definitions, xref-backend-apropos)
(xref-backend-references, eglot-completion-at-point)
(eglot--sig-info, eglot-help-at-point, eglot-eldoc-function)
(eglot-imenu, eglot--apply-text-edits)
(eglot--apply-workspace-edit)
(eglot--register-workspace/didChangeWatchedFiles): Use
eglot--dbind and eglot--lambda to destructure LSP objects.

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

6 years agoAdjust previous fix
João Távora [Tue, 4 Dec 2018 23:10:35 +0000 (23:10 +0000)]
Adjust previous fix

* eglot.el (eglot--before-change): Don't reset
eglot--last-inserted-char here.
(eglot--pre-command-hook): Do it here.
(eglot--managed-mode): Add/remove eglot--pre-command-hook to/from
pre-command-hook.

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

6 years agoFix bug introduced by previous fix
João Távora [Tue, 4 Dec 2018 09:47:36 +0000 (09:47 +0000)]
Fix bug introduced by previous fix

* eglot.el (eglot--CompletionParams): Don't use last-input-event.

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

6 years agoHandle codeaction/command polymorphism with eglot--dcase
João Távora [Mon, 3 Dec 2018 14:07:21 +0000 (14:07 +0000)]
Handle codeaction/command polymorphism with eglot--dcase

* eglot-tests.el (eglot-dcase): Augment test.

* eglot.el (eglot--lsp-interface-alist): Add Command interface.
(eglot--dcase): Fix indentation.  When given interface, always
assume strict mode.
(eglot-code-actions): Use eglot--dcase.

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

6 years agoRobustify previous fix against non-standard insertion bindings
João Távora [Mon, 3 Dec 2018 12:24:26 +0000 (12:24 +0000)]
Robustify previous fix against non-standard insertion bindings

* eglot.el (eglot--managed-mode): Manage post-self-insert-hook.
(eglot--last-inserted-char): New variable.
(eglot--post-self-insert-hook): Set it.
(eglot--before-change): Reset it.
(eglot--CompletionParams): Use it.

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

6 years agoProperly clear old diagnostics when making new ones
Michal Krzywkowski [Mon, 3 Dec 2018 11:49:34 +0000 (12:49 +0100)]
Properly clear old diagnostics when making new ones

* eglot.el (eglot-handle-notification
  textDocument/publishDiagnostics): Call flymake report function with
  :region.

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

6 years agoUse javascript-typescript-langserver for typescript-mode ()
Mario Rodas [Sun, 2 Dec 2018 19:16:58 +0000 (14:16 -0500)]
Use javascript-typescript-langserver for typescript-mode ()

Copyright-paperwork-exempt: Yes

* eglot.el (eglot-server-programs): add typescript-mode to
  javascript-typescript-langserver's contact

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

6 years agoSupport completioncontext to help servers like ccls
João Távora [Sun, 2 Dec 2018 10:54:09 +0000 (10:54 +0000)]
Support completioncontext to help servers like ccls

* eglot.el (eglot-client-capabilities): Annouce
textDocument/completion/contextSupport.
(eglot--CompletionParams): New helper.
(eglot-completion-at-point): Use it.

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

6 years agoDon't break in indirect buffers
João Távora [Sat, 1 Dec 2018 22:47:56 +0000 (22:47 +0000)]
Don't break in indirect buffers

Indirect buffers, such as the ones created by ediff-regions-wordwise,
have eglot enabled but not buffer-file-name.  Resort to the finding
the file-name of the original buffer for these.

* eglot.el (eglot--TextDocumentIdentifier): Work in indirect
buffers.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/116
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/150

6 years agoUse eglot--dbind for destructuring
Michal Krzywkowski [Tue, 27 Nov 2018 22:42:45 +0000 (23:42 +0100)]
Use eglot--dbind for destructuring

* eglot.el (eglot--lsp-interface-alist): Add CodeAction,
  FileSystemWatcher, Registration, TextDocumentEdit, WorkspaceEdit.
(eglot-handle-notification): Use eglot--dbind.
(eglot--apply-workspace-edit): Use eglot--dbind and eglot--lambda.
(eglot-code-actions): Use eglot--lambda.
(eglot--register-workspace/didChangeWatchedFiles): Use eglot--lambda.

6 years agoIntroduce eglot--dcase
João Távora [Thu, 29 Nov 2018 22:36:03 +0000 (22:36 +0000)]
Introduce eglot--dcase

* eglot.el (eglot--dcase): New macro.

* eglot-tests.el (eglot-dcase-with-interface)
(eglot-dcase-no-interface): New tests.

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

6 years agoSimplify interface of eglot--dbind macro
João Távora [Wed, 28 Nov 2018 20:26:37 +0000 (20:26 +0000)]
Simplify interface of eglot--dbind macro

* eglot.el (eglot--dbind): Use new interface.
(eglot--lambda): Use new eglot--dbind interface.
(eglot--lsp-interface-alist): Fix docstring.
(eglot--call-with-interface): Simplify.
(eglot--plist-keys): New helper.

* eglot-tests.el (eglot-strict-interfaces):
Add a new test clause.

6 years agoTouch up last commit
Michal Krzywkowski [Wed, 28 Nov 2018 18:53:35 +0000 (19:53 +0100)]
Touch up last commit

* eglot.el (eglot-current-column): Rename from eglot--current-column.
(eglot-current-column-function): Use it as value and mention in docstring.
(eglot--xref-make): Use eglot-current-column.

6 years ago* eglot.el (eglot--current-column): new helper.
Michal Krzywkowski [Tue, 27 Nov 2018 22:28:11 +0000 (23:28 +0100)]
* eglot.el (eglot--current-column): new helper.

(eglot-current-column-function): Set to eglot--current-column.
(eglot--pos-to-lsp-position): Don't bind tab-width anymore.
(eglot--xref-make): Use eglot--current-column.

6 years agoImprove performance of xref summary line collection
João Távora [Tue, 27 Nov 2018 13:49:30 +0000 (13:49 +0000)]
Improve performance of xref summary line collection

* eglot.el (eglot--temp-location-buffers): New variable.
(eglot--handling-xrefs): New macro.
(eglot--xref-make): Use eglot--temp-location-buffers.
(xref-backend-definitions, xref-backend-references)
(xref-backend-apropos): Use eglot--handling-xrefs.

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

6 years agoUse entire line as xref summary when available
João Távora [Tue, 27 Nov 2018 12:42:56 +0000 (12:42 +0000)]
Use entire line as xref summary when available

After an original implementation by Michael Livshin.  Also close https://github.com/joaotavora/eglot/issues/127.

* eglot.el (eglot--xref-make): Rework.
(xref-backend-definitions, xref-backend-references)
(xref-backend-apropos): Simplify call to `eglot--xref-make'.

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

6 years agoRevert "codeaction command can be a command object ()"
João Távora [Fri, 23 Nov 2018 18:12:14 +0000 (18:12 +0000)]
Revert "codeaction command can be a command object ()"

This reverts commit 1e7f94d75a30628be56ad00de8c6245f5f3e9fdf.

The spec doesn't define Command as implemented in the commit.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/164
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/165

6 years agoCodeaction command can be a command object ()
Michal Krzywkowski [Fri, 23 Nov 2018 18:00:00 +0000 (19:00 +0100)]
Codeaction command can be a command object ()

* eglot.el (eglot-code-actions): Handle case when the :command field
  is not a string.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/164
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/165

6 years agoControl strictness towards incoming lsp messages
João Távora [Fri, 23 Nov 2018 12:31:15 +0000 (12:31 +0000)]
Control strictness towards incoming lsp messages

A new variable, eglot-strict-mode controls whether Eglot is strict or
lax with regard to incoming LSP messages.

1. Bug reports should be tested with eglot-strict-mode set to
   '(disallow-non-standard-keys enforce-required-keys)

2. Users struggling to get non-standard servers working set this
   variable to '(), nil.  For now, by popular demand, this is the
   default value.

Note that this commit in particular introduces a new infrastructure,
but does not yet alter any code in Eglot to use it.  Neither is the
variable eglot--lsp-interface-alist populated.

* eglot-tests.el (eglot-strict-interfaces): New test.

* eglot.el (eglot--lsp-interface-alist): New variable.
(eglot-strict-mode): New variable.
(eglot--call-with-interface): New helper.
(eglot--dbind): New macro.
(eglot--lambda): New macro.

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

6 years ago* eglot.el (version): bump to 1.2
João Távora [Fri, 23 Nov 2018 00:12:45 +0000 (00:12 +0000)]
* eglot.el (version): bump to 1.2

6 years ago* eglot.el (eglot-completion-at-point): less chatter.
João Távora [Fri, 23 Nov 2018 00:11:44 +0000 (00:11 +0000)]
* eglot.el (eglot-completion-at-point): less chatter.

6 years agoCorrectly insert textedit-less snippets
João Távora [Thu, 22 Nov 2018 23:07:18 +0000 (23:07 +0000)]
Correctly insert textedit-less snippets

Fixes a slight regression from https://github.com/joaotavora/eglot/issues/160.

* eglot.el (eglot-completion-at-point): When there is plain
`insertText' snippet, delete the full completion text.

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

6 years agoFix potential security issue fontifying lsp doc
João Távora [Mon, 19 Nov 2018 23:16:33 +0000 (23:16 +0000)]
Fix potential security issue fontifying lsp doc

Previously, a server could mistankely or maliciously call *-mode
functions by in the response to a completion or hover request,
specifically in the :documentation field of the response.

Although there are plenty of similar avenues of attack in Emacs, it's
probably a good idea not to let LSP servers decide which functions to
call in an Emacs session running Eglot.

* eglot.el (eglot--format-markup): Call major-mode to fontify
buffer, not some dynamically constructed function name.
(eglot-completion-at-point): Ensure eglot--format-markup runs in
source buffer.

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

6 years agoAdd support for r's languageserver ()
Alex Branham [Tue, 20 Nov 2018 21:27:38 +0000 (15:27 -0600)]
Add support for r's languageserver ()

Copyright-paperwork-exempt: yes

* eglot.el (eglot-server-programs): Add R language server.
* README.md (Installation and usage): Mention it.

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

6 years agoProperly delete inserted text after completion
Michal Krzywkowski [Wed, 21 Nov 2018 14:54:22 +0000 (15:54 +0100)]
Properly delete inserted text after completion

* eglot.el (eglot-completion-at-point): In :exit-function, delete only
  the region of buffer that was inserted by completion.

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

6 years agoTreat tab characters as 1 column wide in position conversion functions
Michal Krzywkowski [Mon, 19 Nov 2018 20:22:14 +0000 (21:22 +0100)]
Treat tab characters as 1 column wide in position conversion functions

Fixes https://github.com/joaotavora/eglot/issues/158.

* eglot.el (eglot--pos-to-lsp-position): Call
  eglot-current-column-function with tab-width bound to 1.
(eglot--lsp-position-to-point): Call eglot-move-to-column-function
with tab-width bound to 1.

6 years agoFormat documentation of signature parameters
Michal Krzywkowski [Sat, 17 Nov 2018 11:12:31 +0000 (12:12 +0100)]
Format documentation of signature parameters

* eglot.el (eglot--sig-info): Call `eglot--format-markup` on parameter
  :documentation.

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

6 years agoAdd ability to report lsp-compliant columns
João Távora [Tue, 13 Nov 2018 22:08:16 +0000 (22:08 +0000)]
Add ability to report lsp-compliant columns

* eglot.el (eglot-current-column-function): New variable.
(eglot-lsp-abiding-column): New helper.
(eglot--pos-to-lsp-position): Use eglot-current-column-function.
(eglot-move-to-column-function): Tweak docstring.

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

6 years agoAdd support for textedits in completion
Michal Krzywkowski [Wed, 31 Oct 2018 19:59:30 +0000 (20:59 +0100)]
Add support for textedits in completion

* eglot.el (eglot-completion-at-point): Apply the CompletionItem's
  :textEdit and :additionalTextEdits when they're present.

6 years agoTweak solution to with a hint from fangrui song
João Távora [Tue, 13 Nov 2018 09:46:47 +0000 (09:46 +0000)]
Tweak solution to with a hint from fangrui song

* eglot.el (eglot-move-to-lsp-abiding-column): Simplify slightly.

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

6 years agoComplex completions work when chosen from *completions*
João Távora [Mon, 12 Nov 2018 23:17:22 +0000 (23:17 +0000)]
Complex completions work when chosen from *completions*

* eglot.el (eglot-completion-at-point): Make exit-function work
even if its arguments was stripped of its properties.

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

6 years agoAdd ability to move to lsp-precise columns
João Távora [Mon, 12 Nov 2018 22:29:38 +0000 (22:29 +0000)]
Add ability to move to lsp-precise columns

Also close https://github.com/joaotavora/eglot/issues/125.

Idea and much of design contributed by Michał Krzywkowski
<k.michal@zoho.com>

This introduces the variable eglot-move-to-column-function.

According to the standard, LSP column/character offsets are based
on a count of UTF-16 code units, not actual visual columns.  So
when LSP says position 3 of a line containing just \"aXbc\",
where X is a multi-byte character, it actually means `b', not
`c'.  This is what the function
`eglot-move-to-lsp-abiding-column' does.

However, many servers don't follow the spec this closely, and
thus this variable should be set to `move-to-column' in buffers
managed by those servers.

* eglot.el (eglot-move-to-column-function): New variable.
(eglot-move-to-lsp-abiding-column): New function.
(eglot--lsp-position-to-point): Use eglot-move-to-column-function.

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

6 years agoFix a bug introduced by previous bugfix
João Távora [Fri, 9 Nov 2018 01:46:55 +0000 (01:46 +0000)]
Fix a bug introduced by previous bugfix

This commit fixes a bug but introduced another when completing a
symbol in xref-find-definitions.

commit ee58d92a7de1c8b1914c77177a7d5e755f1de827
Author: Michał Krzywkowski <k.michal@zoho.com>
Date:   Sun Nov 4 16:59:05 2018 +0100

* eglot.el (xref-backend-identifier-completion-table): Use vector.

6 years agoMove constants to top instead of forward-declaring
João Távora [Wed, 7 Nov 2018 13:10:29 +0000 (13:10 +0000)]
Move constants to top instead of forward-declaring

* eglot.el (eglot--symbol-kind-names, eglot--kind-names): Move to
top of file.

6 years agoSupport ocaml-language-server out of the box ()
Mario Rodas [Wed, 7 Nov 2018 12:09:58 +0000 (07:09 -0500)]
Support ocaml-language-server out of the box ()

Copyright-paperwork-exempt: yes

* eglot.el (eglot-server-programs): Add ocaml-language-server.

* README.md (Installation and usage): Mention ocaml-language-server

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

6 years ago* eglot.el (eglot-client-capabilities): mention supported symbolkinds.
Michal Krzywkowski [Mon, 5 Nov 2018 18:42:32 +0000 (19:42 +0100)]
* eglot.el (eglot-client-capabilities): mention supported symbolkinds.

6 years agoMake imenu hierarchical
Michal Krzywkowski [Sun, 4 Nov 2018 15:34:58 +0000 (16:34 +0100)]
Make imenu hierarchical

* eglot.el (eglot-imenu): Use :containerName to build a nested imenu
  index alist.

6 years agoFix a bug when response to definitions request is a single location
Michal Krzywkowski [Sun, 4 Nov 2018 15:59:05 +0000 (16:59 +0100)]
Fix a bug when response to definitions request is a single location

It's valid to return just a single Location for a definitions request.

* eglot.el (xref-backend-definitions): Coerce response to a vector.

6 years agoSimplify eglot-code-action. fix compilation warning
João Távora [Sun, 4 Nov 2018 12:56:37 +0000 (12:56 +0000)]
Simplify eglot-code-action. fix compilation warning

* eglot.el (eglot-code-actions): Simplify.
(eglot-client-capabilities): Mention supported codeActionKind's
directly.
(eglot--code-action-kinds): Remove.

6 years agoAdd support for code action literals
Michal Krzywkowski [Wed, 31 Oct 2018 21:14:16 +0000 (22:14 +0100)]
Add support for code action literals

Code action literals allow the server to simply return a WorkspaceEdit
for a code action, so the client does not have to execute a command.

* eglot.el (eglot-client-capabilities): Add :codeActionLiteralSupport.
(eglot--code-action-kinds): New variable.
(eglot-code-actions): Apply provided WorkspaceEdit.

6 years agoUse the container name of a symbol in imenu
Michal Krzywkowski [Wed, 31 Oct 2018 13:16:56 +0000 (14:16 +0100)]
Use the container name of a symbol in imenu

* eglot.el (eglot-imenu): Prepend :containerName to each symbol, when
  provided.

6 years agoDon't ignore unknown symbolkinds in imenu
Michal Krzywkowski [Wed, 31 Oct 2018 12:06:59 +0000 (13:06 +0100)]
Don't ignore unknown symbolkinds in imenu

Some servers provide custom SymbolKinds.  For example, ccls says that
symbols defined with #define are of kind 255.

* eglot.el (eglot-imenu): Don't delete elements with unknown symbol
  kind from the return list, instead put them in `(Unknown)` group.

6 years agoRemove duplicates from imenu
Michal Krzywkowski [Wed, 31 Oct 2018 11:54:26 +0000 (12:54 +0100)]
Remove duplicates from imenu

* eglot.el (eglot-imenu): Don't append the result list to itself,
  which causes duplicates.

6 years agoRequire subr-x at compile time ()
Alex Branham [Tue, 30 Oct 2018 21:59:05 +0000 (16:59 -0500)]
Require subr-x at compile time ()

if-let and when-let are macros that the byte compiler can expand
at compile time. No need to require subr-x at run time.

* eglot.el (subr-x): Require only when compiling.

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

6 years agoAccept deprecated field in symbolinformation
João Távora [Tue, 30 Oct 2018 12:22:32 +0000 (12:22 +0000)]
Accept deprecated field in symbolinformation

* eglot.el (xref-backend-identifier-completion-table)
(eglot-imenu): Accept and ignore "deprecated"

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

6 years agoFix misspelling of "outstanding" ()
Dale Sedivec [Sun, 21 Oct 2018 20:02:47 +0000 (15:02 -0500)]
Fix misspelling of "outstanding" ()

Copyright-paperwork-exempt: yes

* eglot.el (eglot--mode-line-format): Fix a typo.

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

6 years agoHandle case when project was not found in eclipse.jdt.ls contact
Michal Krzywkowski [Tue, 11 Sep 2018 21:13:56 +0000 (23:13 +0200)]
Handle case when project was not found in eclipse.jdt.ls contact

6 years agoOverride eglot-execute-command for eclipse.jdt.ls server
Michal Krzywkowski [Thu, 9 Aug 2018 13:25:58 +0000 (15:25 +0200)]
Override eglot-execute-command for eclipse.jdt.ls server

* eglot.el (eglot-execute-command eglot-eclipse-jdt): New defmethod.

6 years agoAdd support for eclipse.jdt.ls server
Michal Krzywkowski [Thu, 9 Aug 2018 10:21:11 +0000 (12:21 +0200)]
Add support for eclipse.jdt.ls server

* eglot.el (eglot-server-programs): Add java-mode entry.
(eglot-eclipse-jdt): New class.
(eglot-initialization-options): Override for eglot-eclipse-jdt.
(eglot--eclipse-jdt-contact): New function.

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

6 years agoAllow function contacts to be interactive
Michal Krzywkowski [Thu, 9 Aug 2018 10:20:36 +0000 (12:20 +0200)]
Allow function contacts to be interactive

* eglot.el (eglot-server-programs): Mention that the function must
  accept one argument.
(eglot--guess-contact): Pass to functional contacts the interactive
value.

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

6 years agoImprove signature help
Michal Krzywkowski [Sat, 6 Oct 2018 15:08:04 +0000 (17:08 +0200)]
Improve signature help

* eglot.el (eglot--sig-info): Don't lose existing information.
  Attempt to highlight the active parameter by searching for it's
  :label in signature's :label.  Append to the result first sentence
  of signature's :documentation, if present.

6 years agoSort references and definitions by line number
Michal Krzywkowski [Sat, 8 Sep 2018 19:36:00 +0000 (21:36 +0200)]
Sort references and definitions by line number

* eglot.el (eglot--sort-xrefs): New function.
(xref-backend-definitions):
(xref-backend-references):
(xref-backend-apropos): Use it.

6 years agoMerge pull request from mkcms/fix-diagnostics-wrong-type-argument
Michal Krzywkowski [Mon, 15 Oct 2018 21:12:28 +0000 (23:12 +0200)]
Merge pull request from mkcms/fix-diagnostics-wrong-type-argument

Handle case when diagnostic :character is out of range

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

6 years agoHandle case when diagnostic :character is out of range
Michal Krzywkowski [Sat, 8 Sep 2018 22:24:49 +0000 (00:24 +0200)]
Handle case when diagnostic :character is out of range

* eglot.el (eglot-handle-notification): Don't error out when
  flymake-diag-region returns nil.

6 years agoEglot-ignored-server-capabilites: prefer all choices over "other"
Michal Krzywkowski [Mon, 15 Oct 2018 20:58:14 +0000 (22:58 +0200)]
Eglot-ignored-server-capabilites: prefer all choices over "other"

Previously the "Other" choice matched every value, so it was always
shown in the customize buffer.

* eglot.el (eglot-ignored-server-capabilites): Make the "Other" choice
  the last possible option.

6 years agoMake eglot-ignored-server-capabilites more user-friendly ()
Michal Krzywkowski [Wed, 3 Oct 2018 19:08:38 +0000 (21:08 +0200)]
Make eglot-ignored-server-capabilites more user-friendly ()

* eglot.el (eglot-ignored-server-capabilites): Add list of possible
  choices to :type, along with a user-friendly description.

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

6 years agoCorrectly map documentsymbol's :kind to its name ()
Michal Krzywkowski [Mon, 24 Sep 2018 12:24:19 +0000 (14:24 +0200)]
Correctly map documentsymbol's :kind to its name ()

Previously we were mapping :kind in DocumentSymbol with
names from the CompletionItemKind enum, whereas we should
have used the SymbolKind enum.

* eglot.el (eglot--symbol-kind-names): New variable.
(eglot-imenu): Use it instead of eglot--kind-names.

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

6 years agoAutoload eglot-ensure ()
whatacold [Mon, 24 Sep 2018 12:21:47 +0000 (20:21 +0800)]
Autoload eglot-ensure ()

Copyright-paperwork-exempt: yes

* eglot.el (eglot-ensure): Add autoload cookie

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

6 years agoDon't block kill-buffer-hook if server somehow hangs
João Távora [Mon, 17 Sep 2018 09:00:16 +0000 (10:00 +0100)]
Don't block kill-buffer-hook if server somehow hangs

* eglot.el (eglot--signal-textDocument/didClose): Use
with-demoted-errors.

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

6 years agoDon't send other notifications before initialized
Aleksey Kladov [Sat, 8 Sep 2018 22:19:29 +0000 (23:19 +0100)]
Don't send other notifications before initialized

Copyright-paperwork-exempt: yes

* eglot.el (eglot--connect): send initialized before
activating minor mode.

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