Commit Graph

178 Commits (3256b013889eee5f9bc66f58b59386214bc49cf2)

Author SHA1 Message Date
trivernis 3256b01388
Merge remote-tracking branch 'origin/master' 1 year ago
TotalKrill 16e13b9789
allow specifying environment for language servers in language.toml (#4004)
Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com>
Co-authored-by: Stephen Wakely <fungus.humungus@gmail.com>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Matouš Dzivjak 8abed3bd78
feat(lsp): pass client_info on initialization (#4904)
Pass client name ('helix') and client version (version / git hash)
to LSP server on initialization.
2 years ago
Michael Davis 2077f5e26a
Apply completion edits to all cursors (#4496)
Completion edits - either basic `insert_text` strings or structured
`text_edit`s - are assumed by the LSP spec to apply to the current
cursor (or at least the trigger point). We can use the range (if any)
and text given by the Language Server to create a transaction that
changes all ranges in the current selection though, allowing auto-
complete to affect multiple cursors.
2 years ago
sigmaSd 4960c41f18
feat(lsp): add support for lsp Diagnostic{}.data (#4935) 2 years ago
trivernis e20886dd60
Merge branch 'master' 2 years ago
Michael Davis e6dad960cf
Drain pending requests on language server termination (#4852)
This prevents a freeze while shutting down when using `efm-langserver`.
`efm-langserver` exits immediately after seeing a shutdown request,
without responding to the request. We block awaiting the reply to the
shutdown request which will never come, so we time out.

This change responds to any pending requests with `Err` saying that the
stream has been closed.
2 years ago
Michael Davis 9059c65a53
lsp: Check server provider capabilities (#3554)
Language Servers may signal that they do not support a method in
the initialization result (server capabilities). We can check these
when making LSP requests and hint in the status line when a method
is not supported by the server. This can also prevent crashes in
servers which assume that clients do not send requests for methods
which are disabled in the server capabilities.

There is an existing pattern the LSP client module where a method
returns `Option<impl Future<Output = Result<_>>>` with `None` signaling
no support in the server. This change extends this pattern to the rest
of the client functions. And we log an error to the statusline for
manually triggered LSP calls which return `None`.
2 years ago
Michael Davis 8be2d1dcbf
Handle language server termination (#4797)
This change handles a language server exiting. This was a UX sore-spot:
if a language server crashed, Helix did not recognize the exit and
continued to send requests to it. All requests would timeout since they
would not receive responses. This would also hold-up Helix closing
itself down since it would try to gracefully shutdown the server which
is implemented in the LSP spec as a request.

We could attempt to automatically restart the language server on crash.
I left this for future work since that change will need to be slightly
complicated: it will need to cover the case of a language server
repeatedly crashing.
2 years ago
Michael Davis 89efb4f711
lsp: Resolve completion item asynchronously on idle-timeout (#4781)
d7d0d5ffb7 resolves completion items on
the idle-timeout event. The `Completion::resolve_completion_item`
function blocks on the LSP request though, which blocks the compositor
and in turn blocks the event loop. So until the language server returns
the resolved completion item, Helix is unable to respond to keypresses
or other LSP messages.

This is typically ok since the resolution request is fast but for some
language servers this can be problematic, and ideally we shouldn't be
blocking like this anyways.

When receiving a `completionItem/resolve` request, the Volar server
sends a `workspace/configuration` request to Helix and blocks itself
on the response, leading to a deadlock. Eventually the resolve request
times out within Helix but Helix is locked up and unresponsive in that
window.

This change resolves the completion item without blocking the
compositor.
2 years ago
Matthias Deiml dee5b2a983
Add LSP workspace command picker (#3140)
* Add workspace command picker

* Make command typable

* Add optional argument to lsp-workspace-command
2 years ago
Blaž Hrastnik 13126823f8
lsp: Support insertReplace
Fixes #4473
2 years ago
trivernis 3893898ffc
Merge branch 'master' 2 years ago
Blaž Hrastnik c2c1280f02
Resolve a bunch of upcoming clippy lints 2 years ago
trivernis 8b789b6b86
Merge branch 'seperate_code_action' 2 years ago
ath3 7c9809eeb2
Find workspace from document path (#3553) 2 years ago
Alexis Kalabura b9ff5d0e0a
[lsp-restart]: call the force_shutdown method for the old_client (#3972)
* [lsp-restart]: call the shutdown_and_exit method for the old_client

* change shutdown_and_exit to force_shutdown

* remove extra log
2 years ago
Kirawi 8c2cc43017
diff full-doc LSP edits (#4041)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
trivernis 1e1967308d
Merge branch 'master' 2 years ago
Riccardo Binetti 888f4fef6f
Split helix_core::find_root and helix_loader::find_local_config_dirs (#3929)
* Split helix_core::find_root and helix_loader::find_local_config_dirs

The documentation of find_root described the following priority for
detecting a project root:
- Top-most folder containing a root marker in current git repository
- Git repository root if no marker detected
- Top-most folder containing a root marker if not git repository detected
- Current working directory as fallback

The commit contained in https://github.com/helix-editor/helix/pull/1249
extracted and changed the implementation of find_root in find_root_impl,
actually reversing its result order (since that is the order that made
sense for the local configuration merge, from innermost to outermost
ancestors).

Since the two uses of find_root_impl have different requirements (and
it's not a matter of reversing the order of results since, e.g., the top
repository dir should be used by find_root only if there's not marker in
other dirs), this PR splits the two implementations in two different
specialized functions.

In doing so, find_root_impl is removed and the implementation is moved
back in find_root, moving it closer to the documented behaviour thus
making it easier to verify it's actually correct

* helix-core: remove Option from find_root return type

It always returns some result, so Option is not needed
2 years ago
trivernis 4487f144bd
Swap screenshot in README
Signed-off-by: trivernis <trivernis@protonmail.com>
2 years ago
trivernis 9d1d6a74ec
Merge remote-tracking branch 'tree-explorer-icons/tree_explorer_icons' 2 years ago
trivernis beeca2d823
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
Filipe Azevedo 385ccdfc9c
add :lsp-restart command (#3435) 2 years ago
Blaž Hrastnik 1df32c917c diagnostics: Use Vec<Tag> instead of Option<Vec<Tag>> 2 years ago
Luke Cycon 64b0745413
Track source and tags in diagnostics (#3898) 2 years ago
trivernis 59c0c41a74
Merge branch 'lsp-execute-command' 2 years ago
trivernis 3cec10e1b1
Fix missing error variant 2 years ago
trivernis 2da81760f5
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
trivernis 388181bab7
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
Blaž Hrastnik a123fb6057
Remove LspNotDefined, instead return an Option<> 2 years ago
Blaž Hrastnik 1caba2d3e8
lsp: Don't log "LSP not defined" errors in the logfile 2 years ago
trivernis 151ac52741
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
Michael Davis 672ea98b05
Advertise WorkspaceSymbolClientCapabilities support (#3361) 2 years ago
PiergiorgioZagaria 219d2c2515
Change default formatter for any language (#2942)
* Change default formatter for any language

* Fix clippy error

* Close stdin for Stdio formatters

* Better indentation and pattern matching

* Return Result<Option<...>> for fn format instead of Option

* Remove unwrap for stdin

* Handle FormatterErrors instead of Result<Option<...>>

* Use Transaction instead of LspFormatting

* Use Transaction directly in Document::format

* Perform stdin type formatting asynchronously

* Rename formatter.type values to kebab-case

* Debug format for displaying io::ErrorKind (msrv fix)

* Solve conflict?

* Use only stdio type formatters

* Remove FormatterType enum

* Remove old comment

* Check if the formatter exited correctly

* Add formatter configuration to the book

* Avoid allocations when writing to stdin and formatting errors

* Remove unused import

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
2 years ago
MDeiml 90d40b70e8 Add workspace command picker 2 years ago
Erasin 42115d02bc
Suport diagnostic code (#3096)
* add code for diagnostic.

This PR provides a solution to resolve #2994. missing Code Actions for lsp

* remote unused import
2 years ago
trivernis c3c50517ee
Merge branch 'lsp-restart'
Signed-off-by: trivernis <trivernis@protonmail.com>
2 years ago
Gokul Soumya 791bf7e50a
Add lsp signature help (#1755)
* Add lsp signature help

* Do not move signature help popup on multiple triggers

* Highlight current parameter in signature help

* Auto close signature help

* Position signature help above to not block completion

* Update signature help on backspace/insert mode delete

* Add lsp.auto-signature-help config option

* Add serde default annotation for LspConfig

* Show LSP inactive message only if signature help is invoked manually

* Do not assume valid signature help response from LSP

Malformed LSP responses are common, and these should not crash the
editor.

* Check signature help capability before sending request

* Reuse Open enum for PositionBias in popup

* Close signature popup and exit insert mode on escape

* Add config to control signature help docs display

* Use new Margin api in signature help

* Invoke signature help on changing to insert mode
2 years ago
Gokul Soumya 21b66ba068
lsp: Add workspace/applyEdit to client capabilites (#3012)
The functionality already existed, but the capability wasn't being
reported correctly to the server:

230ba264bf/helix-term/src/application.rs (L716-L728)
2 years ago
lazytanuki 096abdd19b
feat: highlight / select symbol under cursor using LSP textDocument/documentHighlight (#2738)
* feat: highlight symbol under cursor using LSP textDocument/documentHighlight

* fix: please clippy

* fix: shorter description and code style
2 years ago
Blaž Hrastnik 425de09d21 Fix tests again 2 years ago
Blaž Hrastnik 24f03097e3 Remove some more unwraps 2 years ago
Michael Davis 45ce1ebdb6
embed jsonrpc types from jsonrpc-core crate (#2801)
We should not depend on jsonrpc-core anymore:

* The project just announced it's no longer actively maintained[^1],
  preferring their new implementation in `jsonrpsee`.
* The types are too strict: we would benefit from removing some
  `#[serde(deny_unknown_fields)]` annotations to allow language
  servers that disrespect the spec[^2].
* We don't use much of the project. Just the types out of core.
  These are easy to embed directly into the `helix-lsp` crate.

[^1]: https://github.com/paritytech/jsonrpc/pull/674
[^2]: https://github.com/helix-editor/helix/issues/2786
2 years ago
farwyler f92a25a856
Passing extra formatting options to LSPs (#2635)
* allows passing extra formatting options to LSPs

- adds optional field 'format' to [[language]] sections in 'languages.toml'

- passes specified options the LSPs via FormattingOptions

* cleaner conversion of formatting properties

* move formatting options inside lsp::Client

* cleans up formatting properties merge
2 years ago
Blaž Hrastnik 3d91c99c3e
fix: lsp: Sort edits by start range, Omnisharp sends them in reverse 2 years ago
Michael Davis 50dd11985c
prevent panic when handling an LSP response with no request (#2475)
A language server may push a response which doesn't belong to any
request. With this change, we discard the response rather than
crashing.

In the case of #2474, the language server sends an error message
with a null request ID which should not ever exist in the
`pending_requests` HashMap.

closes #2474
2 years ago
Blaž Hrastnik 7ae6cad52e
Don't panic on LSP parsing errors
This made sense initially when the implementation was still new (so we
got user reports more frequently), but a parsing error now generally
signifies a language server isn't properly implementing the spec.
2 years ago
EmmChriss 807cdc60bf
configurable lsp request timeout (#2405) 2 years ago
chunghha 3a398eec56
fix typos (#2304) 2 years ago