]> git.eshelyaron.com Git - emacs.git/log
emacs.git
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

6 years agoPrefer ccls over cquery for c/c++
João Távora [Fri, 7 Sep 2018 11:46:46 +0000 (12:46 +0100)]
Prefer ccls over cquery for c/c++

* README.md (Installation and usage): Prefer ccls to cquery. Mention clangd.

* eglot.el (eglot-server-programs): Suggest ccls for c/c++ by default.

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

6 years agoFix serious breakage introduced by
João Távora [Fri, 7 Sep 2018 11:22:14 +0000 (12:22 +0100)]
Fix serious breakage introduced by

string-prefix-p doesn't work on symbols

* eglot.el (eglot-handle-notification): Coerce method name to string.

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

6 years agoDon't warn on implementation-specific notifications ()
Fangrui Song [Fri, 7 Sep 2018 09:00:18 +0000 (02:00 -0700)]
Don't warn on implementation-specific notifications ()

Only warn when method name doesn't start with '$'. Per the spec:

  "if a server or client receives notifications or requests
  starting with ‘$/’ it is free to ignore them if they are unknown."

* eglot.el (eglot-handle-notification t t): Check method name for $.

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

6 years agoWhen exiting emacs, don't ask the user to confirm killing processes ()
Evgeni Kolev [Mon, 27 Aug 2018 13:17:09 +0000 (16:17 +0300)]
When exiting emacs, don't ask the user to confirm killing processes ()

Copyright-paperwork-exempt: yes

* eglot.el (eglot--connect, eglot--inferior-bootstrap): pass noquery t to
make-process.

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

6 years agoHandle case when :textdocumentsync isn't a number
João Távora [Sat, 25 Aug 2018 21:57:22 +0000 (22:57 +0100)]
Handle case when :textdocumentsync isn't a number

Also closes https://github.com/joaotavora/eglot/issues/87.

* eglot.el (eglot--signal-textDocument/didChange): Grab :change
from :textDocumentSync server capability.

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

6 years agoCorrectly delete text before expanding snippet completions
João Távora [Mon, 20 Aug 2018 22:51:27 +0000 (23:51 +0100)]
Correctly delete text before expanding snippet completions

Suggested by Amol Mandhane.

* eglot.el (eglot-completion-at-point): Use length of obj in
:exit-function

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

6 years agoIgnore extra keys in textdocument/publishdiagnostics ()
Phillip Dixon [Mon, 20 Aug 2018 09:21:51 +0000 (21:21 +1200)]
Ignore extra keys in textdocument/publishdiagnostics ()

Accoding to the "discussion" in https://reviews.llvm.org/D50571, it
was deemed sufficient that VSCode is fine with the non-standard
extension -- jt

Copyright-paperwork-exempt: yes

* eglot.el (eglot-handle-notification): Add &allow-other-keys

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

6 years agoConsider :triggercharacters in company completion
João Távora [Mon, 20 Aug 2018 00:10:11 +0000 (01:10 +0100)]
Consider :triggercharacters in company completion

* eglot.el (eglot-completion-at-point): Take advantage of
:company-prefix-length.

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

6 years agoImprove snippet support
João Távora [Sun, 19 Aug 2018 01:11:09 +0000 (02:11 +0100)]
Improve snippet support

* eglot.el (eglot-client-capabilities): Don't always declare
snippet support.
(eglot--snippet-expansion-fn): New helper.
(eglot-completion-at-point): Better annotations when snippets
are supported.

6 years agoAdd go-langserver ()
Evgeni Kolev [Sat, 18 Aug 2018 11:33:13 +0000 (14:33 +0300)]
Add go-langserver ()

Copyright-paperwork-exempt: yes

* README.md (Installation and usage): Add go-langserver.
* eglot.el (eglot-server-programs): Add go-langserver.

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

6 years agoDon't error if server replies with empty hover message
João Távora [Sat, 18 Aug 2018 11:26:55 +0000 (12:26 +0100)]
Don't error if server replies with empty hover message

* eglot.el (eglot-eldoc-function): Check non-nil contents.

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

6 years agoFix textdocument/hover responses where markedstring is a plist ()
Michal Krzywkowski [Fri, 17 Aug 2018 23:56:01 +0000 (01:56 +0200)]
Fix textdocument/hover responses where markedstring is a plist ()

* eglot.el (eglot--hover-info): Forward all non-vector content to
eglot--format-markup.

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

6 years agoSupport snippet completions
João Távora [Fri, 10 Aug 2018 01:29:26 +0000 (02:29 +0100)]
Support snippet completions

* eglot.el (eglot-client-capabilities): Declare support for
snippet-based completions.
(eglot-completion-at-point): Expand snippet completions with
YASnippet if that is found.
(eglot-note, eglot-warning, eglot-error): Diagnostic
overlay priorities have to be slightly lower than yasnippet's,
which must be reasonably high.

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

6 years agoFix eglot-capabilities when querying for multiple features
João Távora [Fri, 17 Aug 2018 22:23:31 +0000 (23:23 +0100)]
Fix eglot-capabilities when querying for multiple features

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

* eglot.el (eglot--server-capable): Fix problems with queries for
multiple capabilities.

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

6 years agoPrompt for server in interactive eglot-shutdown
João Távora [Mon, 13 Aug 2018 19:02:48 +0000 (20:02 +0100)]
Prompt for server in interactive eglot-shutdown

* eglot.el (eglot--read-server): New helper.
(eglot-shutdown): Use it.

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

6 years agoAdd kotlin-language-server ()
James Nguyen [Mon, 13 Aug 2018 00:50:17 +0000 (17:50 -0700)]
Add kotlin-language-server ()

https://github.com/fwcd/KotlinLanguageServer

copyright-paperwork-exempt: yes

* README.md (Installation and Usage): declare Kotlin support.

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

6 years agoHandle edits to same position in the correct order
João Távora [Mon, 13 Aug 2018 00:45:40 +0000 (01:45 +0100)]
Handle edits to same position in the correct order

In eglot--apply-text-edits, the markers returned by
eglot--lsp-position-to-point are of the "stay" type, i.e. have an
insertion-type of nil.  This causes multiple insertion edits to the
same location to happen in the reverse order in which they appear in
the LSP message, which is a violation of the spec and a bug.

There are more ways to solve this (see related discuttion in
https://github.com/joaotavora/eglot/pull/64), but the easiest way is
to revert the order in which the edits are processed.  This is because
the spec tells us that the order is only relevant in precisely this
"same position" case.  So if we reverse the order we fix this bug and
don't break anything else.

* eglot.el (eglot--apply-text-edits): Apply edits in reverse..

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

6 years agoControl the size of the events buffer
João Távora [Mon, 13 Aug 2018 00:29:41 +0000 (01:29 +0100)]
Control the size of the events buffer

* eglot.el (eglot-events-buffer-size): New defcustom.
(eglot--connect): Use it.

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

6 years agoImplement asynchronous server connection
João Távora [Sat, 11 Aug 2018 13:52:33 +0000 (14:52 +0100)]
Implement asynchronous server connection

A new defcustom eglot-sync-connect controls this feature.  If it is t,
eglot should behave like previously, waiting synchronously for a
connection to be established, with the exception that there is now a
non-nil timeout set to eglot-connect-timeout, which defaults to 30
seconds.

eglot-connect is now considerably more complicated as it replicates
most of the work that jsonrpc-request does vis-a-vis handling errors,
timeouts and user quits..

* eglot-tests.el
(eglot--call-with-dirs-and-files): Simplify cleanup logic.
(slow-sync-connection-wait)
(slow-sync-connection-intime, slow-async-connection)
(slow-sync-error): New tests.

* eglot.el (eglot-sync-connect): New defcustom.
(eglot-ensure, eglot): Simplify.
(eglot--connect): Honour eglot-sync-connect.  Complicate
considerably.
(eglot-connect-timeout): New defcustom.
(Package-requires): Require jsonrpc 1.0.6

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

6 years agoKill server's output and events buffers from eglot-shutdown ()
Michal Krzywkowski [Sat, 11 Aug 2018 23:22:26 +0000 (01:22 +0200)]
Kill server's output and events buffers from eglot-shutdown ()

* eglot.el
(Package-Requires): Require jsonrpc 1.0.5
(eglot-shutdown): Kill events and stderr buffers of the
server, unless new PRESERVE-BUFFERS argument is non-nil.
eglot-reconnect): Preserve buffers on shutdown.

* eglot-tests.el (eglot--call-with-dirs-and-files): Call
eglot-shutdown with non-nil PRESERVE-BUFFERS arg.

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

6 years agoImprove eglot-execute-command api to ease overriding by servers
João Távora [Sat, 11 Aug 2018 16:28:59 +0000 (17:28 +0100)]
Improve eglot-execute-command api to ease overriding by servers

* eglot.el (eglot-execute-command): COMMAND can be a symbol.
(eglot-code-actions): Pass symbols to eglot-command.

6 years agoAdd a generic eglot-execute-command api
Michal Krzywkowski [Thu, 9 Aug 2018 13:24:29 +0000 (15:24 +0200)]
Add a generic eglot-execute-command api

* eglot.el (eglot-execute-command): New defgeneric and method.  Use it
  to request :workspace/executeCommand.
(eglot-code-actions): Use it.

6 years ago* eglot.el (eglot-cquery): capitalize docstring.
Michal Krzywkowski [Fri, 10 Aug 2018 17:13:59 +0000 (19:13 +0200)]
* eglot.el (eglot-cquery): capitalize docstring.

6 years ago* eglot.el (advice-add jsonrpc-request): add &allow-other-keys
João Távora [Fri, 10 Aug 2018 00:42:01 +0000 (01:42 +0100)]
* eglot.el (advice-add jsonrpc-request): add &allow-other-keys

6 years agoRequire jsonrpc.el 1.0.2 (gnu elpa didn't build 1.0.1)
João Távora [Fri, 10 Aug 2018 00:28:41 +0000 (01:28 +0100)]
Require jsonrpc.el 1.0.2 (gnu elpa didn't build 1.0.1)

* eglot.el (Package-Requires): Require jsonrpc 1.0.2

6 years agoSnappier completions that don't hinder typing
João Távora [Fri, 10 Aug 2018 00:03:59 +0000 (01:03 +0100)]
Snappier completions that don't hinder typing

This should improve company-capf's performance.

* eglot.el (Package-Requires): Require jsonrpc 1.0,1
(eglot-completion-at-point): Use completion-table-dynamic.  Pass
CANCEL-ON-INPUT to jsonrpc-request.

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

6 years agoNotify server of recent changes before save notification
Michal Krzywkowski [Thu, 9 Aug 2018 19:21:32 +0000 (21:21 +0200)]
Notify server of recent changes before save notification

* eglot.el (eglot--signal-textDocument/didSave): Call
  eglot--signal-textDocument/didChange.

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

6 years ago* eglot.el (eglot-initialization-options): fix spurious typo.
João Távora [Tue, 7 Aug 2018 21:13:28 +0000 (22:13 +0100)]
* eglot.el (eglot-initialization-options): fix spurious typo.

6 years agoAccept functions as entries in eglot-server-programs
João Távora [Mon, 6 Aug 2018 16:53:09 +0000 (17:53 +0100)]
Accept functions as entries in eglot-server-programs

CONTACT in the (MAJOR-MODE . CONTACT) association in
eglot-server-programs can now be a function of no arguments producing
any value previously valid for contact.  The function is called at
time of `M-x eglot` or `eglot-ensure`.  This is useful for servers
requiring command-line invocations that depend on the specific
momentary environment.

* eglot.el (eglot-server-programs): CONTACT can be a fucntion of no
arguments.
(eglot--guess-contact, eglot--connect): Accept function
CONTACTs.

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

6 years agoEglot-workspace-configuration's keys needn't be keywords
João Távora [Mon, 6 Aug 2018 00:10:12 +0000 (01:10 +0100)]
Eglot-workspace-configuration's keys needn't be keywords

* eglot.el (eglot-signal-didChangeConfiguration): Convert
alist keys into a json-compatible plist.

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

6 years agoDefault eglot-handle-notifictiona|request must &allow-other-keys
João Távora [Fri, 3 Aug 2018 08:14:42 +0000 (09:14 +0100)]
Default eglot-handle-notifictiona|request must &allow-other-keys

* eglot.el (eglot-handle-notification, eglot-handle-request): Add
&allow-other-keys

6 years agoFix placement of diagnostics with same start and end positions
Michal Krzywkowski [Fri, 3 Aug 2018 08:22:18 +0000 (10:22 +0200)]
Fix placement of diagnostics with same start and end positions

Some servers such as cquery and clangd publish diagnostic with
identical start and end positions.

* eglot.el (eglot-handle-notification
  :textDocument/publishDiagnostics): Add 1 to :line since LSP lines
  are 0-based.  Don't subtract 1 from :character, since both emacs and
  LSP have 0-based columns.

6 years agoErase company-doc buffer in between doc requests
João Távora [Thu, 2 Aug 2018 10:02:20 +0000 (11:02 +0100)]
Erase company-doc buffer in between doc requests

* eglot.el (eglot-completion-at-point): Erase temporary
"*eglot-doc*" buffer for company's doc.

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

6 years ago* eglot.el (eglot-client-capabilities): fix a typo.
Michal Krzywkowski [Mon, 30 Jul 2018 20:17:32 +0000 (22:17 +0200)]
* eglot.el (eglot-client-capabilities): fix a typo.