Commit graph

1990 commits

Author SHA1 Message Date
Michael Davis
0e083497a5 Persist register selection in pending keymaps
Previously the register selection (via `"`) would be lost in the middle
of any key sequence longer than one key. For example, `<space>f` would
clear the register selection after the `<space>` making it inaccessible
for the `file_picker` command.

This behavior does not currently have any effect in the default keymap
but might affect custom keymaps. This change aligns the behavior of the
register with count. Making this change allows propagating the register
to the `command_palette` (see the child commit) or other pickers should
we decide to use registers in those in the future. (Interactive global
search for example.)
2023-06-08 00:48:25 +09:00
Alex Vinyals
204bac1706
commands(toggle): use pattern matching on the Value enum (#7240) 2023-06-07 17:50:16 +09:00
gibbz00
9926c2d292 Remove Keymap(KeyTrie) and simply use KeyTrie. 2023-06-07 10:11:13 +09:00
gibbz00
b8563685ec Move keymap.reverse_keymap() to Keytrie:
The plan is let `Keymaps` simply store `KeyTrie`s, as the `Keymap(Keytrie)` wrapping serves little to no purpose.
2023-06-07 10:11:13 +09:00
gibbz00
eda4c79f2f Remove pub keymap.name();
`keymap.name` is only used internally.
2023-06-07 10:11:13 +09:00
gibbz00
3d0bc72099 Place Info::from_keymap() contents in keymap.infobox():
This makes it easier later control the order in which the key events
are presented.
2023-06-07 10:11:13 +09:00
gibbz00
19326d23d1 Keymap infobox: Idiomatic body tuple.
Does not change any behavior other than making the tuple slightly
more idiomatic.  Keymap infobox shows key events, then the respective
description. This commit makes sure that order is used from the get go,
rather than flipping it midway.
2023-06-07 10:11:13 +09:00
gibbz00
3a0892f793 Exclude config no_op bindings in command palette. 2023-06-07 10:11:13 +09:00
gibbz00
39773e48d3 Remove superfluous command description pruning for keymap infobox:
Exist under the wrong (possibly just outdated) assumption that command
descriptions are written with their `KeyTrie` name prefixed
2023-06-07 10:11:13 +09:00
gibbz00
d20c1632a7 helix_term::keymap: Remove one-liner solely used for a test. 2023-06-07 10:11:13 +09:00
gibbz00
f7df53c948 Make Keymap a tuple struct. 2023-06-07 10:11:13 +09:00
gibbz00
daea97a89f keymap: Rename KeyTrie::Leaf -> KeyTrie::MapppableCommand
The variant Sequence is technically also a leaf.
2023-06-07 10:11:13 +09:00
gibbz00
a56af221d7 keymap: Derive Default for KeyTrieNode 2023-06-07 10:11:13 +09:00
Alex Vinyals
a2b8cfdb8c
feat(core): add plaintext matching fallback to tree-sitter matching (#4288) 2023-06-05 23:13:00 +09:00
Michael Davis
428d33ab50
Exit gracefully on termination signals (#7236) 2023-06-05 22:27:57 +09:00
Alex Vinyals
d5707a4696
feat(commands): allows cycling option values at runtime (#4411) 2023-06-05 22:22:05 +09:00
Ethan Wilkes
3334e7e4b2
fixed repeat_last_motion extends selection (#7159) 2023-05-29 00:51:22 +09:00
Matthew Toohey
207829eefe
Fix off-by-one in select symbol references (#7132) 2023-05-25 14:01:56 +02:00
Poliorcetics
8e2660b5cc
Update diagnostics correctly on LSP exit (#7111)
* chore: avoid format! call with argument when useless

* feat: also clear diagnostics for unopened documents when exiting an LSP

* feat: we already worked on `self.editor.diagnostics` no need to redo the checks
2023-05-23 12:33:01 +02:00
Szabin
70e4cdbd8e
Add command to merge non-consecutive ranges (#7053)
* Add command for merging non-consecutive ranges

* Add `merge_selections` command to book

* Simplify `merge_ranges`

Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.

* Clarify doc comment of `merge_ranges`
2023-05-20 01:31:39 +02:00
Philipp Mildenberger
2a512f7c48 Rebase cleanup/fixes and use lsp::CompletionItem in item_to_transaction directly 2023-05-18 22:25:32 +02:00
Philipp Mildenberger
f45bbf165e Apply all review suggestions (doc_id -> id, error message, unnecessary if)
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-05-18 22:04:49 +02:00
Philipp Mildenberger
2b746ea6fa Some minor clarity/cosmetic improvements
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-05-18 22:04:49 +02:00
Philipp Mildenberger
39b9a4bba2 Add function Editor::language_server_by_id and refactor/simplify related code, also don't 'crash' in completion menu if language_server somehow disappeared 2023-05-18 22:04:47 +02:00
Philipp Mildenberger
3e4bac1d96 Fix lsp_restart across multiple different document scopes (language servers weren't restarted, if not of the same scope id), and fix some smaller rebase issues 2023-05-18 21:58:17 +02:00
Philipp Mildenberger
93fd79a949 Remove offset_encoding in CodeActionOrCommandItem, as it can be retrieved on demand 2023-05-18 21:58:17 +02:00
Philipp Mildenberger
ff26208427 Filter language servers also by capabilities in doc.language_servers_with_feature
* Add `helix_lsp::client::Client::supports_feature(&self, LanguageServerFeature)`
* Extend `doc.language_servers_with_feature` to use this method as filter as well
* Add macro `language_server_with_feature!` to reduce boilerplate for non-mergeable language server requests (like goto-definition)
* Refactored most of the `find_map` code to use the either the macro or filter directly via `doc.language_servers_with_feature`
2023-05-18 21:58:17 +02:00
Philipp Mildenberger
451fe528bb Filter out already seen language servers in requests that can be sent to multiple language servers (code-action, completion, symbol pickers) 2023-05-18 21:58:17 +02:00
Philipp Mildenberger
8ab6d7be5e Use let else instead of variable and fix some error messages
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-05-18 21:58:17 +02:00
Philipp Mildenberger
1d5d5dab47 Remove offset_encoding in CompletionItem 2023-05-18 21:58:15 +02:00
Philipp Mildenberger
2eeac10755 Refactor doc language servers to a HashMap, and the config to use a Vec to retain order 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
b1199c552b Remove symbol picker is_empty check 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
58c913ce45 Simplify 'lsp_stop' command 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
7d20740b5b Fix docgen and lsp-stop documentation 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
60a6af1fea Remove boilerplate in the goto methods by generically composing functions 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
1122928c2a Add method doc.supports_language_server for better readability 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
76b5cab524 Refactored doc.language_servers and doc.language_servers_with_feature to return an iterator and refactor LanguageServerFeature handling to a HashMap (language server name maps to features)
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-05-18 21:48:32 +02:00
Philipp Mildenberger
0637691eb1 Use DoubleEndedIterator instead of collect to Vec for reversing
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-05-18 21:48:32 +02:00
Philipp Mildenberger
dd2f74794a Fix error messages when no language server is available
Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>
2023-05-18 21:48:32 +02:00
Philipp Mildenberger
f9b08656f4 Fix sorting issues of the editor wide diagnostics and apply diagnostics related review suggestions
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-05-18 21:48:32 +02:00
Philipp Mildenberger
b6c60beb2d Remove unnecessary completion support check (likely an artifact) 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
44b2b40190 Fix issue with ltex-ls, filtering params is not what we want here 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
05583f8cc9 Fix hardcoded offset_encoding 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
74e21e1b25 Fix some lints/docgen hints 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
7d4f7eb4bd Fix 'WorkspaceConfiguration' request with empty configuration section strings 2023-05-18 21:48:32 +02:00
Philipp Mildenberger
71551d395b Adds support for multiple language servers per language.
Language Servers are now configured in a separate table in `languages.toml`:

```toml
[langauge-server.mylang-lsp]
command = "mylang-lsp"
args = ["--stdio"]
config = { provideFormatter = true }

[language-server.efm-lsp-prettier]
command = "efm-langserver"

[language-server.efm-lsp-prettier.config]
documentFormatting = true
languages = { typescript = [ { formatCommand ="prettier --stdin-filepath ${INPUT}", formatStdin = true } ] }
```

The language server for a language is configured like this (`typescript-language-server` is configured by default):

```toml
[[language]]
name = "typescript"
language-servers = [ { name = "efm-lsp-prettier", only-features = [ "format" ] }, "typescript-language-server" ]
```

or equivalent:

```toml
[[language]]
name = "typescript"
language-servers = [ { name = "typescript-language-server", except-features = [ "format" ] }, "efm-lsp-prettier" ]
```

Each requested LSP feature is priorized in the order of the `language-servers` array.
For example the first `goto-definition` supported language server (in this case `typescript-language-server`) will be taken for the relevant LSP request (command `goto_definition`).

If no `except-features` or `only-features` is given all features for the language server are enabled, as long as the language server supports these. If it doesn't the next language server which supports the feature is tried.

The list of supported features are:

- `format`
- `goto-definition`
- `goto-declaration`
- `goto-type-definition`
- `goto-reference`
- `goto-implementation`
- `signature-help`
- `hover`
- `document-highlight`
- `completion`
- `code-action`
- `workspace-command`
- `document-symbols`
- `workspace-symbols`
- `diagnostics`
- `rename-symbol`
- `inlay-hints`

Another side-effect/difference that comes with this PR, is that only one language server instance is started if different languages use the same language server.
2023-05-18 21:48:30 +02:00
Ivan Gulakov
2cccb3f09c
Fix completion on paths containing spaces (#6779)
There was an issue with autocompletion of a path with a space in it.

Before:

:o test\ dir -> <TAB> -> test\ dirfile1

After:

:o test\ dir -> <TAB> -> test\ dir\file1
2023-05-18 15:27:29 +09:00
Pascal Kuthe
b0705337be automatically disable TS when parsing takes longer than 500ms 2023-05-18 15:23:37 +09:00
Pascal Kuthe
2f2306475c async picker syntax highlighting 2023-05-18 15:23:37 +09:00
Pascal Kuthe
25d4ebe30d don't move cursor while forward deleting in append mode
Currently, when forward deleting (`delete_char_forward` bound to `del`,
`delete_word_forward`, `kill_to_line_end`) the cursor is moved to the
left in append mode (or generally when the cursor is at the end of the
selection). For example in a document `|abc|def`  (|indicates selection)
if enter append mode the cursor is moved to `c` and the selection
becomes: `|abcd|ef`. When deleting forward (`del`) `d` is deleted. The
expectation would be that the selection doesn't shrink so that `del`
again deletes `e` and then `f`. This would look as follows:

`|abcd|ef`
`|abce|f`
`|abcf|`
`|abc |`

This is inline with how other editors like kakoune work.
However, helix currently moves the selection backwards leading to the
following behavior:

`|abcd|ef`
`|abc|ef`
`|ab|ef`
`ef`

This means that `delete_char_forward` essentially acts like
`delete_char_backward` after deleting the first character in append
mode.

To fix the problem the cursor must be moved to the right while deleting
forward (first fix in this commit). Furthermore, when the EOF char is
reached a newline char must be inserted (just like when entering
appendmode) to prevent the cursor from moving to the right
2023-05-18 15:20:55 +09:00