Commit graph

2125 commits

Author SHA1 Message Date
Nick
d8b8d2fda6
Fix error message shown for goto references (#9382) 2024-01-25 14:11:12 +09:00
Michael Davis
6d724a8f33 Re-export which from helix-stdx::env
We use `which::which` in many crates, so `which` was a separate
dependency across all of them. We can centralize `which` into the
stdx crate so it's easy for all crates to depend on it.

I also moved the rest of `helix-view/src/env.rs` into helix-stdx's
`env` module since it only contained a thin wrapper around `which`
and `std::env`.
2024-01-24 15:47:49 +09:00
Pascal Kuthe
8e592a151f refactor completion and signature help using hooks 2024-01-23 11:20:19 +09:00
Pascal Kuthe
13ed4f6c47 Add hook/event system 2024-01-23 11:20:19 +09:00
Michael Davis
1f916e65cf Create helix-stdx crate for stdlib extensions
helix-stdx is meant to carry extensions to the stdlib or low-level
dependencies that are useful in all other crates. This commit starts
with all of the path functions from helix-core and the CWD tracking that
lived in helix-loader.

The CWD tracking in helix-loader was previously unable to call the
canonicalization functions in helix-core. Switching to our custom
canonicalization code should make no noticeable difference though
since `std::env::current_dir` returns a canonicalized path with
symlinks resolved (at least on unix).
2024-01-18 10:57:53 +09:00
Daniel Sedlak
af8e524a7d
Address clippy lints (#9371) 2024-01-17 12:40:45 -06:00
Matouš Dzivjak
c60ba4ba04
feat(lsp): implement show document request (#8865)
* feat(lsp): implement show document request

Implement [window.showDocument](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#window_showDocument)
LSP server-sent request.

This PR builds on top of helix-editor#5820,
moves the external-URL opening functionality into shared crate-level
function that returns a callback that is now used by both the
`open_file` command as well as the window.showDocument handler if
the URL is marked as external.

* add return

* use vertical split

* refactor

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-01-17 18:24:38 +01:00
Ben Dennis
dcdecaab22
Exit a language server if it sends a message with invalid json (#9332)
* Keep lsp event listener thread alive when malformed json is encountered from the lsp server

* Update unexpected error flow in recv() to close outstanding requests and close the language server

* Log malformed notifications as info instead of error

* Make close_language_server a nested function inside recv, similar to what's done in send

* Update malformed notification log text

* Clean up new log text a bit

* Initialize recv_buffer closer to where it's used

* Use "exit" instead of "close"

* Remove whitespace

* Remove the need for a helper method to exit the language server

* Match on Unhandled error explicitly and keep catch-all error case around
2024-01-17 15:49:25 +01:00
Michael Davis
eca3ccff76
Select subtree within injections in :tree-sitter-subtree (#9309)
`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
2024-01-15 15:34:38 +09:00
jw013
054ce3961a
Fallback to filename for +arg (#9333) 2024-01-14 15:11:18 +01:00
Gabriel Dinner-David
84e24b33dc
make sure to sync views when applying edits to unfocused views (#9173) 2024-01-09 10:21:16 +09:00
Sammo98
65d0412880
health - add formatter to display (#7986) 2024-01-09 10:15:50 +09:00
Philipp Mildenberger
41ca46cf8c
Initialize diagnostics when opening a document (#8873) 2024-01-09 10:01:04 +09:00
Pascal Kuthe
48c49f0227
update history of a newly focused view (#9271) 2024-01-09 09:56:09 +09:00
Michael Davis
0cbd8d3df1
Check for rename support before showing LSP rename prompt (#9277) 2024-01-09 09:55:11 +09:00
jw013
00d681cc69
Update goto_file docs (#8563) (#9001)
Make the pluralization of files and selections consistent to emphasize
the 1-to-1 relation between files and selections. The prior wording
with plural "files" and singular "selection" can mislead users into
thinking the command can open multiple files from a single selection.
2024-01-08 03:11:18 +01:00
Tshepang Mbambo
da4afaf3da
remove build warnings (#9180) 2024-01-04 15:51:00 +09:00
Pascal Kuthe
783ff27b1b consistent diagnostic sorting 2023-12-27 15:28:14 +09:00
Pascal Kuthe
515ef17207 make diagnostics stick to word boundaries
Diagnostics are currently extended if text is inserted at their end. This is
desirable when inserting text after an identifier. For example consider:

let foo = 2;
    --- unused variable

Renaming the identifier should extend the diagnostic:

let foobar = 2;
    ------ unused variable

This is currently implemented in helix but as a consequence adding whitespaces
or a type hint also extends the diagnostic:

let foo      = 2;
    -------- unused variable
let foo: Bar = 2;
    -------- unused variable

In these cases the diagnostic should remain unchanged:

let foo      = 2;
    --- unused variable
let foo: Bar = 2;
    --- unused variable

As a heuristic helix will now only extend diagnostics that end on a word char
if new chars are appended to the word (so not for punctuation/ whitespace).
The idea for this mapping was inspired for the word level tracking vscode uses
for many positions. While VSCode doesn't currently update diagnostics after
receiving publishDiagnostic it does use this system for inlay hints for example.
Similarly, the new association mechanism implemented here can be used for word
level tracking of inlay hints.

A similar mapping function is implemented for word starts. Together
these can be used to make a diagnostic stick to a word. If that word
is removed that diagnostic is automatically removed too. This is the exact
same behavior VSCode inlay hints eixibit.
2023-12-27 15:28:14 +09:00
Pascal Kuthe
8653e1b02f Add config to mark diagnostic sources as persistent 2023-12-27 15:28:14 +09:00
ath3
9ba691cd3a
Support drawing popup frame (#4313)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2023-12-19 10:17:12 +09:00
TornaxO7
914c83420b
fix :indent-style crash (#9087)
* removing unreachable statement in `:indent-style`

* update checks when setting indent line and update docs

* `cargo xtask docgen`
2023-12-15 19:05:04 +01:00
Daniel Ebert
938a710904 Make the indent heuristic configurable 2023-12-15 15:59:54 +09:00
TornaxO7
b81aacc5e1
Join empty lines with only one space in join_selections (#8989)
* fix: #8977

fixes the issue that lines with only spaces are getting
joined as well

* reverting some renamings

* improve empty line check

* adding integration test

* reverting code block

* fix conditon check for line end

* applying suggested style
2023-12-06 16:19:54 +01:00
Hendrik Norkowski
b023faacf8
fix(ui): use crossterm cursor when at the end of the rope (#8934) 2023-11-29 00:11:23 +09:00
Hendrik Norkowski
71fd85894b
use crossterm cursor in editor when out of focus (#6858)
Use crossterm cursor in the editor when the terminal is out of focus to achieve consistent out-of-focus cursor behaviour
2023-11-27 20:11:16 +01:00
chtenb
8c68074fa6
Fix precedence of ui.virtual.whitespace (#8879)
* Revert "Revert "Fix precedence of ui.virtual.whitespace (#8750)""

This reverts commit 811d62d3b3.

* Fix ui.text overwriting the syntax highlighting

Adjust ui.text description
2023-11-25 14:27:31 +01:00
Cole Helbling
8b0ae3d279
bump MSRV to 1.70.0 (#8877)
* rust-toolchain.toml: bump MSRV to 1.70.0

With Firefox 120 released on 21 November 2023, the MSRV is now 1.70.0.

* Fix cargo fmt with Rust 1.70.0

* Fix cargo clippy with Rust 1.70.0

* Fix cargo doc with Rust 1.70.0

* rust-toolchain.toml: add clippy component

* .github: bump dtolnay/rust-toolchain to 1.70

* helix-term: bump rust-version to 1.70

* helix-view/gutter: use checked_ilog10 to count digits

* helix-core/syntax: use MAIN_SEPARATOR_STR constant

* helix-view/handlers/dap: use Display impl for displaying process spawn error

* WIP: helix-term/commands: use checked math to assert ranges cannot overlap
2023-11-25 13:55:49 +01:00
Blaž Hrastnik
811d62d3b3
Revert "Fix precedence of ui.virtual.whitespace (#8750)"
This reverts commit 41b307b673.
2023-11-22 16:00:28 +09:00
chtenb
41b307b673
Fix precedence of ui.virtual.whitespace (#8750) 2023-11-22 11:42:40 +09:00
Bjorn Ove Hay Andersen
47b6c4bc78
Resolve args.files before changing directory (#8676)
* Resolve args.files before changing directory

* Removed the open_cwd work-around now that the path is full

* If -w is specified, use that as the working directory

* Open the remaining files in the argument list, also when the first is a directory

* Use an iterator access the files argument
2023-11-21 12:07:00 +01:00
Matouš Dzivjak
3052050ee0
open urls with goto_file command (#5820)
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: https://github.com/helix-editor/helix/issues/1472
Superseds: https://github.com/helix-editor/helix/pull/4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
2023-11-21 12:04:20 +01:00
Ryan Mehri
6bf5548dbd make increment/decrement exit select mode 2023-11-18 01:07:57 -06:00
Ryan Mehri
09c78e8b4e make switch case commands exit select mode 2023-11-18 01:07:57 -06:00
Ryan Mehri
d4a0eba1a7 make align exit select mode 2023-11-18 01:07:57 -06:00
Ryan Mehri
5913073733 make replace with clipboard commands exit select mode 2023-11-18 01:07:57 -06:00
Ryan Mehri
1271a50a82 make paste commands exit select mode 2023-11-18 01:07:57 -06:00
Ryan Mehri
34de1cab62 make indent/unindent exit select mode 2023-11-18 01:07:57 -06:00
Yomain
e868678139
Add command to move files with LSP support (#8584)
* Added rename command

* Added an error if the new path already exists

* Fixed wrong command name being used

* fixed clippy suggestions

* removed didRenameFiles call, fixed early return due to path Err

* added ':rnm' alias to ':rename'

* code cleanup

* formatting

* removed debug line

* cargo fmt

* Improved new buffer error message

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Removed unnecessary path normalizing

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Update helix-term/src/commands/typed.rs

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Update helix-term/src/commands/typed.rs

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Update helix-term/src/commands/typed.rs

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* Update helix-term/src/commands/typed.rs

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>

* feat: change `rename` command to `move`

* feat: add multi lsp support when moving files

* feat: allow lsp calls with a custom timeout

* feat: sending lsp file_changed event once file has moved

---------

Co-authored-by: ontley <theontley@gmail.com>
Co-authored-by: ontley <67148677+ontley@users.noreply.github.com>
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-11-08 12:38:17 -06:00
Skyler Hawthorne
10b178e94b
swap yank command registers (#8708)
#8703 swapped the `+` and `*` registers, but did not swap them in the
corresponding yank commands.
2023-11-04 09:35:38 +09:00
Ryan Mehri
d0430f1c81
Only render preview if picker has a preview function (#8667) 2023-10-30 15:03:38 -05:00
Paul Olteanu
8d44459c6a
Add helix-specific ignore files (#8099) 2023-10-21 04:20:29 -05:00
Bjorn Ove Hay Andersen
e6d2835b09
Fixed issue when the first file specified as an argument was a relative directory (#8520) 2023-10-18 10:45:05 +02:00
Yomain
cd591647ec
fix(lsp): ensure we only highlight diagnostics for lsp with the feature enabled (#8551) 2023-10-17 05:07:00 -05:00
Lorenzo Bellina
d9d7f67898
Add support for showing all LSPs in --health (#7315)
* Add support for showing all LSPs in --health <lang>

* Add support for showing all LSPs in --health languages

* Use available/configured in --health languages

* Apply @AlexanderBrevig suggestion in --health

* Update `--health <language>`

Better output (inspired by #8156).

Handle the case where no LSPs are configured.

* Display all LSPs in `--health languages` instead of x/x

Displays all LSPs as a list in the table generated wih `--health languages`

* Make check_binary accept Optional references to str

Avoids some calls to .clone()

* Apply @the-mikedavis suggestions

* Avoid useless collecting and cloning

* Use for loop instead of .try_for_each()
2023-10-16 11:42:25 +02:00
Bjorn Ove Hay Andersen
07a006d1d5
Add +N CLI argument to jump to first file's line number (#8521)
* Accept +num flag for opening at line number

* Update +N argument feature according to feedback in original PR #5603

* Only override the line number of the first file if +N is specified

---------

Co-authored-by: Nachum Barcohen <38861757+nabaco@users.noreply.github.com>
2023-10-12 10:35:43 +02:00
Bjorn Ove Hay Andersen
a857480561
Set the working directory before loading the config (#8498) 2023-10-09 11:38:09 -05:00
Lloyd Bond
75c0a5ceb3
enable starting hx with a working directory (#8223)
* added working path arg to cli and help menu

* improve working path cli arg handling

* enable hx to set the working path

* applied cargo formatting

* improved code from cargo clippy suggestion

* improved code from follow up review

* fix for -w <path> is set but args.files is empty

* improved formatting of --help output
2023-10-03 10:18:27 +09:00
Michael Davis
01e281ce10
markdown: Recognize <code> tags with attributes as code (#8397) 2023-09-26 11:05:19 +09:00
A-Walrus
f520b16fca
Style Bold/Italic/Strikethrough markdown in docs (#8385)
* Style Bold/Italic/Strikthrough markdown in docs

* Flatten to single match
2023-09-25 17:42:42 +02:00