Commit graph

2603 commits

Author SHA1 Message Date
RoloEdits
01fce51c45
fix(keymap): point to proper MappableCommand instead of Command (#13214) 2025-03-28 08:51:36 -05:00
Keir Lawson
7929c0719d
Track progress title an display in place of internal token (#13180)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-03-27 12:00:23 -05:00
Michael Davis
d43de14807
LSP: Avoid requesting document colors for ghost transactions
The point of ghost transactions is to avoid notifying language servers
about changes since the change is meant to be temporary. This is used
for completion while selecting items in the menu: updating the language
server would mess up incomplete completions.

When a document is changed by a ghost transaction the language server
will not be notified so its understanding of the document will not be
synchronized and any positions it sends may be out-of-date. So we should
avoid triggering a request for new document color information when a
document is changed by a ghost transaction.
2025-03-25 08:52:47 -04:00
Nick
5adb4b7413
Allow :theme to show current theme (#13192)
Updates the signature for the command to take 0 arguments. This probably
regressed during 0efa8207d8.
2025-03-25 18:43:26 +09:00
Nik Revenco
0ee5850016
Color swatches ( 🟩 green 🟥 #ffaaaa ) (#12308) 2025-03-23 16:07:02 -05:00
Michael Davis
7e7a98560e
LSP: Eagerly decode request results in the client
Previously the `call` helper (and its related functions) returned a
`serde_json::Value` which was then decoded either later in the client
(see signature help and hover) or by the client's caller. This led to
some unnecessary boilerplate in the client:

    let resp = self.call::<MyRequest>(params);
    Some(async move { Ok(serde_json::from_value(resp.await?)?) })

and in the caller. It also allowed for mistakes with the types. The
workspace symbol request's calling code for example mistakenly decoded a
`lsp::WorkspaceSymbolResponse` as `Vec<lsp::SymbolInformation>` - one of
the untagged enum members (so it parsed successfully) but not the
correct type.

With this change, the `call` helper eagerly decodes the response to a
request as the `lsp::request::Request::Result` trait item. This is
similar to the old helper `request` (which has become redundant and has
been eliminated) but all work is done within the same async block which
avoids some awkward lifetimes. The return types of functions like
`Client::text_document_range_inlay_hints` are now more verbose but it is
no longer possible to accidentally decode as an incorrect type.

Additionally `Client::resolve_code_action` now uses the `call_with_ref`
helper to avoid an unnecessary clone.
2025-03-22 14:40:29 -04:00
Michael Davis
6da1a79d80
Add document and LSP lifecycle events, move some callbacks into hooks
This adds events for:

* a document being opened
* a document being closed
* a language server sending the initialized notification
* a language server exiting

and also moves some handling done for these scenarios into hooks,
generally moving more into helix-view. A hook is also added on
`DocumentDidChange` which sends the `text_document_did_change`
notification - this resolves a TODO in `document`.
2025-03-22 11:41:50 -04:00
Michael Davis
2cc33b5c47
Add pull diagnostics identifier to LSP diagnostic provider
This includes a change to lsp-types to store the identifier as an Arc
since it will be cloned for each diagnostic.
2025-03-22 09:25:29 -04:00
Michael Davis
683fac65e7
Refactor DiagnosticProvider as an enum
This resolves a TODO in the core diagnostic module to refactor this
type. It was originally an alias of `LanguageServerId` for simplicity.
Refactoring as an enum is a necessary step towards introducing
"internal" diagnostics - diagnostics emitted by core features such as
a spell checker. Fully supporting this use-case will require further
larger changes to the diagnostic type, but the change to the provider
can be made first.

Note that `Copy` is not derived for `DiagnosticProvider` (as it was
previously because `LanguageServerId` is `Copy`). In the child commits
we will add the `identifier` used in LSP pull diagnostics which is a
string - not `Copy`.
2025-03-22 09:25:29 -04:00
Michael Davis
2d4c2a170c
commands: Allow any number of arguments in :bc, :bc!
Limiting to zero arguments was incorrect - a set of buffers can be
specified.
2025-03-22 09:17:30 -04:00
Michael Davis
14cab4ba62
LSP: Gracefully handle partial failures in multi-server LSP requests
This is the same change as 1c9a5bd366 but for:

* document symbols
* workspace symbols
* goto definition/declaration/.../references
* hover

Instead of bailing when one server fails, we log an error and continue
gathering items from the other responses.
2025-03-22 08:54:22 -04:00
Michael Davis
3a63e85b6a
Support EditorConfig (#13056) 2025-03-22 16:06:41 +09:00
Ian Hobson
1c9a5bd366
Show successfully requested code actions after a failed request (#13156)
When requesting code actions from multiple LSP servers,
rather than bailing as soon as an error is encountered,
instead log the error and then keep going so that successful
requests can be presented to the user.
2025-03-21 09:10:24 -05:00
Michael Davis
33c17d48ff
minor: Move 'execute_lsp_command' helper into helix-view
This is a minor move that will make future refactors of code actions
simpler. We should be able to move nearly all code action functionality
into `helix-view`, save UI stuff like the `menu::Item` implementation
and dealings with the compositor.
2025-03-19 09:41:18 -04:00
dependabot[bot]
70a60efcbe
build(deps): bump the rust-dependencies group with 5 updates (#13131) 2025-03-18 12:52:22 +09:00
Michael Davis
9574e551cf
commands: Allow zero or one arguments in :reflow
`:reflow` can optionally be passed a width.
2025-03-14 10:36:02 -04:00
iximeow
d1e0891260
warn when configured theme is unusable for color reasons (#13058)
if `config.toml` either does not have `editor.true-color` or sets
it to false, many (most?) themes stop being usable. when loading such a
theme, Helix falls back to the default theme, but didn't mention this
anywhere - even in `~/.cache/helix/helix.log` when run with `-v`.

if this occurs when reloading a theme at runtime with `:theme`, there's
a fairly helpful error about

> `theme requires true color support`

seems worth logging about this if it happens during startup too.
2025-03-12 15:52:07 -05:00
Michael Davis
e74956fa4d
minor: Add a helper function for setting the configured theme
This block was duplicated in `Application::new` and in another helper
`Application::refresh_theme`. This change adds a helper to cover both
cases.
2025-03-12 16:32:52 -04:00
dependabot[bot]
ff558f9105
build(deps): bump the rust-dependencies group with 5 updates (#13070)
Bumps the rust-dependencies group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [tempfile](https://github.com/Stebalien/tempfile) | `3.17.1` | `3.18.0` |
| [once_cell](https://github.com/matklad/once_cell) | `1.20.3` | `1.21.0` |
| [serde](https://github.com/serde-rs/serde) | `1.0.218` | `1.0.219` |
| [tokio](https://github.com/tokio-rs/tokio) | `1.43.0` | `1.44.0` |
| [indexmap](https://github.com/indexmap-rs/indexmap) | `2.7.1` | `2.8.0` |


Updates `tempfile` from 3.17.1 to 3.18.0
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.17.1...v3.18.0)

Updates `once_cell` from 1.20.3 to 1.21.0
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.20.3...v1.21.0)

Updates `serde` from 1.0.218 to 1.0.219
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.218...v1.0.219)

Updates `tokio` from 1.43.0 to 1.44.0
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.43.0...tokio-1.44.0)

Updates `indexmap` from 2.7.1 to 2.8.0
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/main/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.7.1...2.8.0)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-11 08:29:38 -05:00
Michael Davis
b38eae1f98
minor: Fix native line-ending handling in trimming integration tests 2025-03-10 11:09:46 -04:00
Michael Davis
67879a1e5b
Avoid inserting final newlines in empty files
This matches the behavior described by the EditorConfig spec for its
`insert_final_newline` option:

> Editors must not insert newlines in empty files when saving those
> files, even if `insert_final_newline = true`.

Co-authored-by: Axlefublr <101342105+Axlefublr@users.noreply.github.com>
2025-03-10 10:38:11 -04:00
Michael Davis
aa20eb8e7f
Add config for trimming trailing whitespace and newlines on write
These match the equivalent options in VSCode. `trim_trailing_whitespace`
is also the name used by EditorConfig.

* `trim-final-newlines` trims any extra line endings after the final one
* `trim-trailing-whitespace` trims any trailing whitespace (but not
  empty lines)
2025-03-10 10:18:55 -04:00
Noel Cower
2d3b75a8c5
fix: render rulers before the cursor
Render rulers before the cursor to ensure that the cursor, when over
a ruler, is not hidden from view. Without this, you typically end up
with 1) foreground text that is the same as the background if the
ruler doesn't already have a foreground and 2) no visible cursor,
because the ruler's background color took precedence. By moving the
rulers before the cursor, this ensures that the theme is still rendered
more or less the way one would visually expect things to turn out.
2025-03-07 12:44:28 -05:00
Michael Davis
fbc0f956b3
minor: Move json deserialization into text_document_hover future
This follows a pattern used in the signature help request for example.
Moving the json deserialization into the return future of
`text_document_hover` makes the types easier for callers to work with.
2025-03-04 12:01:07 -05:00
Michael Davis
ab56f9e26b
minor: Tweak some verbose LSP logs
The info log within `process_request_response` duplicated the body of
the JSON message printed earlier by the transport which was confusing.

The error log in the completion handler was easy to hit during normal
use and is not actually an error - dropping is the graceful way to
handle changes occurring while completion requests are in flight.
2025-03-04 11:25:11 -05:00
Alexander Brassel
82f8ac208f
Improve %% escaping error message (#13018) 2025-03-04 10:03:11 -06:00
dependabot[bot]
9440feae7c
build(deps): bump the rust-dependencies group with 11 updates (#13017)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-03 18:09:43 -06:00
Michael Davis
0efa8207d8
Rewrite command line parsing, add flags and expansions (#12527)
Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
2025-02-26 19:50:15 -06:00
may
e1c7a1ed77
remove unnecessary allocations in switch_case (#12786) 2025-02-26 19:03:29 -06:00
Michael Davis
7bebe0a70e
Highlight file picker directories with 'ui.text.directory'
This applies the same styling as the parent commit to the file pickers.
2025-02-26 19:19:37 -05:00
Nik Revenco
682967d328
feat: Improve look of Global Search Picker (#12855)
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-02-26 18:09:57 -06:00
David Vogt
c98302a543
feat(lsp): add container name as a column in the symbol pickers (#12930) 2025-02-26 17:28:34 -06:00
Roberto Vidal
0ba2e05a6f
fix: escape percent character when yanking to search register (#12886)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-02-26 17:22:41 -06:00
Michael Davis
fcddd50325
Set theme before opening documents
This is not consequential now but when we switch to the new highlighter
we will want the theme to be set (and the loader's `scopes` to be set
based on the theme) before parsing a document. Previously `set_theme`
came after the loading of documents, so documents would be missing
locals highlights after being loaded and before the first edit.
2025-02-26 10:49:36 -05:00
dependabot[bot]
35575b0b0f
build(deps): bump the rust-dependencies group with 6 updates (#12956)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-24 18:05:24 -06:00
Michael Davis
3d7e2730e7
Read language servers from config in :lsp-restart
`:lsp-stop` should consider only the set of active language servers for
a document. `:lsp-restart` though may be used to start up a language
server that crashed or was manually stopped, so it needs to consider the
language servers in config instead.

This change inlines the `valid_lang_servers` function into `:lsp-stop`
and `:lsp-restart` and changes `:lsp-restart` to check the doc's config
rather than active language servers. `:lsp-restart` now also does not
need to clone the language server names as strings since it borrows from
the config and arguments rather than `Document`. The completer has also
been split into two - one matching active language servers, used by
`:lsp-stop`, and the other matching configured language servers, used by
`:lsp-restart`.

This also removes the part of `:lsp-restart` which bailed if a language
server failed to be restarted (for example because it is not installed).
There might be multiple language servers configured for a language and
only one installed. In that case the `:lsp-restart` should be considered
successful even if not all servers could be started. Bailing prevented
any language servers which could start from being attached to the
document. Instead errors are collected and emitted at the end.
2025-02-20 12:50:09 -05:00
Michael Davis
e0da129727
Use custom titles for register select info boxes
Previously all register selection info boxes had "Registers" as the
title. That was particularly confusing for `copy_between_registers`
which presents two info boxes back-to-back.
2025-02-19 10:29:15 -05:00
Michael Davis
b8912adbbf
Use a Cow<'static, str> for the Info component title
Some uses of the component (like for register) provide a static title.
We can trivially avoid the title allocation in those cases.
2025-02-19 10:10:55 -05:00
Michael Davis
e35d420199
application: Eliminate duplicate theme and syntax loader clones
The application held onto these since their introduction in ce97a2f0 but
the Arcs are duplicated between Application and Editor - we can store it
only on Editor without issue.
2025-02-17 19:01:54 -05:00
dependabot[bot]
48194825b9
build(deps): bump the rust-dependencies group with 3 updates (#12903)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-17 17:36:50 -06:00
Axlefublr
0445062d27
fix :yank-joined disrespecting default-yank-register option (#12890) 2025-02-17 10:06:29 -06:00
dependabot[bot]
7275b7f850
build(deps): bump pulldown-cmark from 0.12.2 to 0.13.0 in the rust-dependencies group (#12865)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-13 08:31:38 -06:00
Harishankar G
df752bbd45
Prevent auto-format in auto-save (#12817)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2025-02-12 12:11:01 -06:00
T. Li
d8c4c7c26f
fix: check and print remaining language servers (#12841) 2025-02-12 09:57:25 -06:00
Nikita Revenco
199dc05a04
fix: Align Markdown styles with tree sitter highlights (#12696)
Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
2025-02-10 14:58:39 -06:00
Michael Davis
62625eda46
LSP: Move diagnostic handling from Application to Editor
There is no functional change to the move - it's just moving the code
into helix-view under a new method `Editor::handle_lsp_diagnostics` -
thought there is a typo fix, the removal of an unnecessary clone (for
the document's language config) and the removal of some nesting.

Co-authored-by: Sofus Addington <sofus@addington.dk>
2025-02-04 10:39:42 -05:00
Michael Davis
066e938ba0
Add copy_between_registers for interactive register copying 2025-02-02 20:49:25 -05:00
Michael Davis
e882a750ea
commands: Eagerly clear autoinfo in select_register, insert_register
This causes the infobox to disappear even when you type a non-character
key like escape. For example `"<esc>` now clears the infobox where
before it was left hanging.
2025-02-02 20:45:25 -05:00
Michael Davis
70d452db3e
core: Make completion item documentation optional
Path completion items always have documentation but future core (i.e.
non-LSP) completions may not always have documentation - for example
word completion from the current buffer.
2025-02-01 21:24:25 -05:00
Michael Davis
369f2bb93d
ui: Expose the 'prompt' module
The prompt Completion type alias is otherwise private. This will be
used in <https://redirect.github.com/helix-editor/helix/pull/12527>
to refactor some functions to return prompt completions.
2025-02-01 21:12:20 -05:00