Commit Graph

3773 Commits (9059c65a5385f6d3cc0bc7f6e3f835ae542635a5)
 

Author SHA1 Message Date
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
Bob 1db01caec7
remove duplicated shell calls (#3465) 2 years ago
Michael Davis 8102c3224f
Limit the number of items in the jumplist (#4750)
Previously, jumplists could grow unchecked. Every transaction is
applied to jumplist selections to ensure that they are up to date
and within document bounds, so this would cause every edit to become
more expensive as jumplist lengths increased throughout a session.
Setting a maximum number of entries limits the cost.

Vim and Neovim limit their jumplists:

* b298fe6cba/src/structs.h (L141)
* e8cc489acc/src/nvim/mark_defs.h (L57)

Notably, Kakoune does not. In Kakoune, changes are applied to jumplist
entries lazily as you hit `<C-o>`/`<C-i>` though, so Kakoune doesn't
have the same growing cost concerns. Kakoune also does not have a
concept of a View which limits the cost further.

Vim and Neovim limit to 100. This seems unreasonably high to me so I've
set this to 30 to start. We can increase if this is problematically
low.
2 years ago
dependabot[bot] 4443885b38
build(deps): bump cc from 1.0.76 to 1.0.77 (#4844)
Bumps [cc](https://github.com/rust-lang/cc-rs) from 1.0.76 to 1.0.77.
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.76...1.0.77)

---
updated-dependencies:
- dependency-name: cc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
dependabot[bot] 4ef6621c24
build(deps): bump serde_json from 1.0.87 to 1.0.88 (#4845)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.87...v1.0.88)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
Yusuf Bera Ertan 48e44720e4
build(nix): don't run tests in builds since CI runs them already, update inputs (#4834) 2 years ago
Michael Davis 0b2bb061b9
Bump TREE_SITTER_MATCH_LIMIT to 256 (#4830)
The limit of 64 breaks some highlighting in Erlang files with
complicated record definitions. Bumping to 256  seems to work on all
files I have seen.
2 years ago
Michael Davis bbde897ac3
Select new pasted text in normal mode only (#4824)
d6323b7cbc changed the behavior of paste
to select the newly inserted text. This is preferrable in normal mode
because it's useful to be able to act on the new text. This behavior
is worse for insert or select mode though:

* In insert mode, the cursor ends up on the last character of the newly
  selected text, so further typing inserts text before the last
  character.
* In select mode, the current selection is replaced with the new text
  selection which doesn't extend the current selection. With this
  change, the selection is extended to include the new text.

This aligns the behavior more closely with Kakoune, but it's
coincidental instead of intentional: Kakoune doesn't implement
bracketed paste (AFAIK) which causes this behavior in insert mode,
and Kakoune doesn't have a select mode.
2 years ago
A-Walrus 2f9ca3840a
Add preview for scratch buffers in buffer picker (#3454) 2 years ago
Sora 420e33a600
Implement simple indents.scm for Elixir (#4821) 2 years ago
Chickenkeeper 117239ea45
Fix broken html doctype highlighting (#4829) 2 years ago
Filipe Azevedo 8dac863a5b
Add `:reload-all` command (#4663) 2 years ago
Matthew Toohey 46eb185d45
build(nix): update nci (#4823) 2 years ago
Lennard Hofmann 0e23e4f882
Make `r<tab>` and `f<tab>` work (#4817)
Previously, commands such as `r<tab>` (replace with tab) or `t<tab>`
(select till tab) had no effect. This is because `KeyCode::Tab` needs
special treatment (like `KeyCode::Enter`).
2 years ago
Blaž Hrastnik 7e99087fa3
minor: render_diagnostics doesn't require &self either 2 years ago
Blaž Hrastnik a640ab6b1f
Avoid repeatedly loading config 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
ath3 598bd8bf11
Update tree-sitter-cmake (#4809) 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
Ollie Charles eada6d534e
Match `.hs-boot` files to Haskell (#4800)
Haskell source files are now either `.hs` (as before) or `.hs-boot`, which is a type of Haskell file that only contains type declarations (https://downloads.haskell.org/ghc/latest/docs/users_guide/separate_compilation.html#how-to-compile-mutually-recursive-modules)
2 years ago
Rohit K Viswanath 58e7e1c5e3
Theme: Mellow (#4770) 2 years ago
wes adams 19694877aa
When buffer closes, focus on parent buffer (#4766) 2 years ago
Austen Adler 1569d2000b
Select surrounding characters when using match/surround (m) mode (#4752)
Co-authored-by: Austen Adler <agadler@austenadler.com>
2 years ago
Felipe S. S. Schneider 9a4e6fdf25
Add support for color modes with Monokai Pro (#4789) 2 years ago
Blaž Hrastnik 767b179839
Update lang-support doc 2 years ago
Blaž Hrastnik 433ccef3fc
Make nil the preferred language server over rnix-lsp 2 years ago
ChrHorn 322e957ea1
Remove prefix filtering from autocomplete menu (#4578)
PR #4134 switched the autocomplete menu from alphabetical to fuzzy
sorting. This commit removes the still existing filtering by prefix and
should enable full fuzzy sorting of the autocomplete menu.

closes #3084, #1807

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
kristopherbullinger 7483c76222
update `x_offset` calculation in Buffer::set_string_truncated (#3839)
when `truncate_start` is `true`, the `x_offset` is now properly updated
according to the width of the content or the truncated length.
2 years ago
Michael Davis 94346356e7
Use TreeCursor to pretty-print :tree-sitter-subtree (#4606)
The current `:tree-sitter-subtree` has a bug for field-names when the
field name belongs to an unnamed child node. Take this ruby example:

    def self.method_name
      true
    end

The subtree given by tree-sitter-cli is:

    (singleton_method [2, 0] - [4, 3]
      object: (self [2, 4] - [2, 8])
      name: (identifier [2, 9] - [2, 20])
      body: (body_statement [3, 2] - [3, 6]
        (true [3, 2] - [3, 6])))

But the `:tree-sitter-subtree` output was

    (singleton_method
      object: (self)
      body: (identifier)
      (body_statement (true)))

The `singleton_method` rule defines the `name` and `body` fields in an
unnamed helper rule `_method_rest` and the old implementation of
`pretty_print_tree_impl` would pass the `field_name` down from the
named `singleton_method` node.

To fix it we switch to the [TreeCursor] API which is recommended by
the tree-sitter docs for traversing the tree. `TreeCursor::field_name`
accurately determines the field name for the current cursor position
even when the node is unnamed.

[TreeCursor]: https://docs.rs/tree-sitter/0.20.9/tree_sitter/struct.TreeCursor.html
2 years ago
Michael Davis c6b83368b3
Capture word parts while calculating shellwords (#4632)
This fixes an edge case for completing shellwords. With a file
"a b.txt" in the current directory, the sequence `:open a\<tab>`
will result in the prompt containing `:open aa\ b.txt`. This is
because the length of the input which is trimmed when replacing with
completion is calculated on the part of the input which is parsed by
shellwords and then escaped (in a separate operation), which is lossy.
In this case it loses the trailing backslash.

The fix provided here refactors shellwords to track both the _words_
(shellwords with quotes and escapes resolved) and the _parts_ (chunks
of the input which turned into each word, with separating whitespace
removed). When calculating how much of the input to delete when
replacing with the completion item, we now use the length of the last
part.

This also allows us to eliminate the duplicate work done in the
`ends_with_whitespace` check.
2 years ago
Michael Davis b474ee1843
Factor out common code for focusing the next view (#4607)
There is some common code between Editor::focus_next and Editor::focus
that can be eliminated by refactoring Tree::focus_next into a function
that only returns the next ViewId.
2 years ago
Michael Davis 6eec14ee37
Use key-sequence format for command palette keybinds (#4712)
The text within the command palette used a custom format to display
the keybinding for a command. This change switches to the key sequence
format that we use for pending keys and macros.
2 years ago
Pascal Kuthe 4b89177e53
sort fuzzy matches with equal score by length in picker (#4698) 2 years ago
Blaž Hrastnik fe11ae2218
minor: Simplify some command code 2 years ago
Blaž Hrastnik a3173c2280
minor: cloning filter and using count() is wasteful here 2 years ago
Garrett D'Amore f843967059
Improvements to Meson syntax. (#4572)
Co-authored-by: Garrett D'Amore <garrett.damore@weka.io>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
dependabot[bot] 70ebbd018a
build(deps): bump chrono from 0.4.22 to 0.4.23 (#4747)
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.22 to 0.4.23.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.22...v0.4.23)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
dxtr85 888368dae9
Fix deprecation warnings for chrono 0.4.23 (#4738)
Co-authored-by: dxtr <dxtr@W540.mito>
2 years ago
Blaž Hrastnik df6d04425d
fix build 2 years ago
Armin Ronacher 392a018aeb
Add command to add word boundaries to search (#4322)
* Add command to add word boundaries to search

* Calculate string capacity before building
2 years ago
Manos Mertzianis 77be98c783
Popup scrollbar (#4449)
* init

* cargo fmt

* optimisation of the scrollbar render both for Menu and Popup. Toggling off scrollbar for Popup<Menu>, since Menu has its own

* rendering scroll track

* removed unnecessary cast

* improve memory allocation

* small correction
2 years ago
ath3 3b7760dfb0
Refactor blackhole register (#4504) 2 years ago
Michael Davis 652497bdd6
Use tree-sitter-bicep fork with sources checked in (#4751) 2 years ago
Sora 506e8caba7
Remove Statement in Zig indentation query (#4745) 2 years ago
Gaurav Tyagi 91ff903bf3
Add global error/warning count statusline element (#4569) 2 years ago
Jonathan 1233c9a989
Add support for Bicep files (#4403) 2 years ago
dependabot[bot] 4791bd66b7
build(deps): bump cc from 1.0.74 to 1.0.76 (#4748)
Bumps [cc](https://github.com/rust-lang/cc-rs) from 1.0.74 to 1.0.76.
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.74...1.0.76)

---
updated-dependencies:
- dependency-name: cc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
dependabot[bot] 4f924f4771
build(deps): bump similar from 2.2.0 to 2.2.1 (#4746)
Bumps [similar](https://github.com/mitsuhiko/similar) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/mitsuhiko/similar/releases)
- [Changelog](https://github.com/mitsuhiko/similar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/similar/compare/2.2.0...2.2.1)

---
updated-dependencies:
- dependency-name: similar
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years ago
Michael Davis c74b97447f
Fix range offsets for multiple shell insertions (#4619)
d6323b7cbc introduced a regression for
shell commands like `|`, `!`, and `<A-!>` which caused the new
selections to be incorrect. This caused a panic when piping (`|`)
would cause the new range to extend past the document end.

The paste version of this bug was fixed in
48a3965ab4.

This change also inherits the direction of the new range from the old
range and adds integration tests to ensure that the behavior isn't
broken in the future.
2 years ago
wes adams fd585c1ee4
Statusline indicator to show number of selected chars (#4682)
Co-authored-by: wes adams <wadams@grayshift.com>
2 years ago