Commit graph

2380 commits

Author SHA1 Message Date
Mehdi Abedi
4df08ddbe0
Allow numbers as second input event (#8471)
* Make sure pending key list is empty when count handling

This will allow using numbers as second key event.

* count handling; add an exception for 'g'

* Lookup the key event before considering a number as count

* Avoid the allocation of another vec for the pending keys

---------

Co-authored-by: x <x@torrent>
2024-02-14 11:53:15 +01:00
Mihir Gadgil
c59f29921d
Add changes to history when paste-replacing (#9625) 2024-02-13 10:16:23 -06:00
kyfanc
fe869e5dc7
fix lsp config reload (#9415)
`syn_loader` was replaced rather than interior value being replace,
old value was still being referenced and not updated after `:config-refresh`.
By using `ArcSwap` like for `config`, each `.load()` call will return the most
updated value.

Co-authored-by: kyfan <kyfan@email>
2024-02-13 11:58:53 +01:00
dependabot[bot]
c111e28a6f
build(deps): bump toml from 0.7.6 to 0.8.10 (#9539)
Bumps [toml](https://github.com/toml-rs/toml) from 0.7.6 to 0.8.10.
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.7.6...toml-v0.8.10)

---
updated-dependencies:
- dependency-name: toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-13 01:48:45 +09:00
dependabot[bot]
7d8ce1a400
build(deps): bump tempfile from 3.9.0 to 3.10.0 (#9538)
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.9.0 to 3.10.0.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.9.0...v3.10.0)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 02:23:24 +01:00
Kirawi
786b5c533e
follow neovim's truecolor detection (#9577) 2024-02-11 18:38:09 +01:00
Galen Abell
581a1ebf5d
Add glob file type support (#8006)
* Replace FileType::Suffix with FileType::Glob

Suffix is rather limited and cannot be used to match files which have
semantic meaning based on location + file type (for example, Github
Action workflow files). This patch adds support for a Glob FileType to
replace Suffix, which encompasses the existing behavior & adds
additional file matching functionality.

Globs are standard Unix-style path globs, which are matched against the
absolute path of the file. If the configured glob for a language is a
relative glob (that is, it isn't an absolute path or already starts with
a glob pattern), a glob pattern will be prepended to allow matching
relative paths from any directory.

The order of file type matching is also updated to first match on globs
and then on extension. This is necessary as most cases where
glob-matching is useful will have already been matched by an extension
if glob matching is done last.

* Convert file-types suffixes to globs

* Use globs for filename matching

Trying to match the file-type raw strings against both filename and
extension leads to files with the same name as the extension having the
incorrect syntax.

* Match dockerfiles with suffixes

It's common practice to add a suffix to dockerfiles based on their
context, e.g. `Dockerfile.dev`, `Dockerfile.prod`, etc.

* Make env filetype matching more generic

Match on `.env` or any `.env.*` files.

* Update docs

* Use GlobSet to match all file type globs at once

* Update todo.txt glob patterns

* Consolidate language Configuration and Loader creation

This is a refactor that improves the error handling for creating
the `helix_core::syntax::Loader` from the default and user language
configuration.

* Fix integration tests

* Add additional starlark file-type glob

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2024-02-11 18:24:20 +01:00
ath3
f8e2d822ba
Fix scroll track (#9508) 2024-02-09 03:24:45 +01:00
Michael Davis
bbcc89241f Fix pulldown_cmark breaking changes to tag types
* Tags and TagEnd are now separate enums since
  <https://redirect.github.com/raphlinus/pulldown-cmark/pull/517>.
* The `Tag::Heading` member has been changed from a tuple variant to a
  struct variant.
2024-02-07 23:53:51 +09:00
dependabot[bot]
630d91168a build(deps): bump pulldown-cmark from 0.9.6 to 0.10.0
Bumps [pulldown-cmark](https://github.com/raphlinus/pulldown-cmark) from 0.9.6 to 0.10.0.
- [Release notes](https://github.com/raphlinus/pulldown-cmark/releases)
- [Commits](https://github.com/raphlinus/pulldown-cmark/compare/v0.9.6...v0.10.0)

---
updated-dependencies:
- dependency-name: pulldown-cmark
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-07 23:53:51 +09:00
dependabot[bot]
72c508de24
build(deps): bump libc from 0.2.152 to 0.2.153 (#9541)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-07 17:34:49 +09:00
Diego
a37af2dcbf
fix division by zero when prompt completion area is too small (#9524) 2024-02-06 22:45:57 +09:00
Waleed Dahshan
cf4492174d
Use range positions to determine insert_newline motion (#9448)
* use anchor and head positions to determine motion

* use range cursor to decide extending or shifting

* add condition to cursor moving back on normal
2024-01-30 06:58:33 +09:00
Pascal Kuthe
87a720c3a1
make path changes LSP spec conform (#8949)
Currently, helix implements operations which change the paths of files
incorrectly and inconsistently. This PR ensures that we do the following
whenever a buffer is renamed (`:move` and workspace edits)

* always send did_open/did_close notifications
* send will_rename/did_rename requests correctly
  * send them to all LSP servers not just those that are active for a
    buffer
  * also send these requests for paths that are not yet open in a buffer (if
    triggered from workspace edit).
  * only send these if the server registered interests in the path
* autodetect language, indent, line ending, ..

This PR also centralizes the infrastructure for path setting and
therefore `:w <path>` benefits from similar fixed (but without didRename)
2024-01-29 01:34:45 +09:00
NitinKM
4ab7029535
Add icon to Windows executable (#9104)
* injecting the icon through a resource file, no extra deps

* formatted

* scripted rc compilation

* formatted and restructured

* simplified conditional func call
2024-01-28 18:31:10 +09:00
Michael Davis
8b6565c839 Respect injections in :tree-sitter-highlight-name 2024-01-28 18:13:33 +09:00
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
dependabot[bot]
cbd8602018
build(deps): bump smallvec from 1.12.0 to 1.13.1 (#9405)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-23 23:19:36 +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
dependabot[bot]
8a00620a71
build(deps): bump smallvec from 1.11.2 to 1.12.0 (#9341)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 14:12:15 +09: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
dependabot[bot]
bad10a5ddd
build(deps): bump libc from 0.2.151 to 0.2.152 (#9282)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 09:51:58 +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
dependabot[bot]
2e3f330b12
build(deps): bump tempfile from 3.8.1 to 3.9.0 (#9199)
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.8.1 to 3.9.0.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.8.1...v3.9.0)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-04 15:38:05 +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
dependabot[bot]
7f44a6ad50
build(deps): bump once_cell from 1.18.0 to 1.19.0 (#9053)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-12 22:46:11 +09:00
dependabot[bot]
3e249829ee
build(deps): bump libc from 0.2.150 to 0.2.151 (#9056)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-12 11:05:20 +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
dependabot[bot]
4c2bd4905e
build(deps): bump open from 5.0.0 to 5.0.1 (#8992)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-05 12:28:32 +09:00
Skyler Hawthorne
bf7c4e1659
use workspace inheritance for common version (#8925) 2023-12-05 10:54:18 +09:00
dependabot[bot]
8532cec01c
build(deps): bump grep-searcher from 0.1.12 to 0.1.13 (#8998)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-05 10:45:18 +09:00
dependabot[bot]
79965a238d
build(deps): bump url from 2.4.1 to 2.5.0 (#8991)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-05 10:41:30 +09:00
dependabot[bot]
0d9145a1bf
build(deps): bump grep-regex from 0.1.11 to 0.1.12 (#8930)
Bumps [grep-regex](https://github.com/BurntSushi/ripgrep) from 0.1.11 to 0.1.12.
- [Release notes](https://github.com/BurntSushi/ripgrep/releases)
- [Changelog](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/ripgrep/compare/grep-regex-0.1.11...0.1.12)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 02:41:10 +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
dependabot[bot]
008208fcfb
build(deps): bump grep-searcher from 0.1.11 to 0.1.12 (#8929)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-28 09:54:16 +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
Fomalhaut Weisszwerg
b7f98d1d99
set Cargo feature resolver to v2 (#8917)
* fix: version of Cargo feature resolver.

This commit solve the ambiguity to determin the version of resolver.
To get more detail, see the following two documents:

- https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
- https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html

* unified: Rust edition in all workspaces.

Now, the Rust 2021 is available in all workspaces.

* fined up: Cargo.toml by using workspace inheritance.

To get more detail of the `workspace.package` table, see a following document:

- https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table
2023-11-27 13:24:57 +01:00
Davide Ferrero
3f9788daaa
update which crate to 5.0.0 (#8902)
* update which crate to 5.0.0

* update which crate to 5.0.0
2023-11-26 01:37:00 +09: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
dependabot[bot]
aac7bd9b08
build(deps): bump libc from 0.2.149 to 0.2.150 (#8741)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-09 11:13:03 +09: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
dependabot[bot]
53bb62b318
build(deps): bump tempfile from 3.8.0 to 3.8.1 (#8672)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-31 16:57:03 +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
dependabot[bot]
1852292451
build(deps): bump libc from 0.2.148 to 0.2.149 (#8503)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-10 18:47:25 +09: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
dependabot[bot]
312c175aec
build(deps): bump indoc from 2.0.3 to 2.0.4 (#8329)
Bumps [indoc](https://github.com/dtolnay/indoc) from 2.0.3 to 2.0.4.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/2.0.3...2.0.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-19 11:29:46 +09:00
dependabot[bot]
53500f6ebd
build(deps): bump libc from 0.2.147 to 0.2.148 (#8327)
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.147 to 0.2.148.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.147...0.2.148)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-19 11:29:30 +09:00
Pascal Kuthe
13d4463e41 correctly center items in picker preview 2023-09-14 11:00:28 +09:00
Pascal Kuthe
e9d0bd7aef fix crash in picker preview for invalid ranges 2023-09-14 11:00:28 +09:00
Em Zhan
7090555dab
Add insert-final-newline config option (#8157)
Co-authored-by: Xalfer <64538944+Xalfer@users.noreply.github.com>
2023-09-11 19:06:25 -05:00
Luke Halasy
b959162ceb
Add tree-sitter-highlight-name command (#8170)
* adds treesitter-highlight-name command

* commit documentation changes

* moves the get_highlight_name function into core/syntax

* rename get_highlight_name function to get_highlight_for_node_at_position

* addresses pr comments: moves fn into helper fn, simplifies a lot

* commit updated documentation changes

* changes scope method to return &str so that callers can decide whether or not to own
2023-09-10 14:57:44 +02:00
Pascal Kuthe
eb9c37844c
fix syntax highlights in dynamic picker (#8206) 2023-09-09 13:41:49 +09:00
Weiyuan Wu
8017bb2999
add redraw command (#6949)
Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2023-09-08 10:46:36 +09:00
Michael Davis
c0fd8bc61b
Fix Clone definition for Injector (#8194) 2023-09-07 11:10:00 +09:00
Pascal Kuthe
e6cdc5f9d3
Don't use word splitting during fuzzy matching (#8192) 2023-09-06 23:03:48 +09:00
Pascal Kuthe
0cfd46c14f
Do not show (running) when opening picker (#8148)
* only stream from background thread if necessary

If the file transversal is longer shorter 30ms it will now be performed
on the main thread. Spawning a thread can take a while (or rather it
takes a while until that thread is scheduled) so the files can actually
take a while to show up. This prevents the `(running)` indicator from
briefly showing up when opening the file picker in a small directory.

* run partial cargo update
2023-09-06 14:01:56 +09:00
Lorenzo Bellina
e8fc77fe98
Maintain the current cursor's position and view in the vsplit/hsplit commands too (#8109)
Co-authored-by: Benjamin Bouvier <public@benj.me>
2023-09-04 12:39:48 +09:00
woojiq
bb3e6998e6
Fix find commands for buffers with non-LF line-endings (#8111) 2023-09-03 23:12:38 +02:00
Pascal Kuthe
a38ec6d6ca
avoid excessive memory consumption in picker (#8127)
* avoid excessive memory consumption from file picker

* fix typos

Co-authored-by: Chris <75008413+cd-a@users.noreply.github.com>

---------

Co-authored-by: Chris <75008413+cd-a@users.noreply.github.com>
2023-09-01 09:13:36 +09:00
Michael Davis
48373d4a2b
Clear completion when switching windows via click (#8118)
The completion component assumes that it operates on the same View but
it's possible to break this assumption by switching windows through
left-clicking. I believe we should clear the completion menu when
switching windows to fix this.

This change fixes a panic for this scenario:

* Open a buffer with LSP completion available
* Split the window (for example '<C-w>v')
* Enter insert mode and trigger the completion menu
* Select a completion candidate (for example with '<C-n>')
* Switch to the original window by left-clicking in its area
* Enter insert mode and make edits (for example 'o<backspace>')

This will trip the 'assert_eq' in Document::restore.
2023-08-31 15:12:32 +09:00
Pascal Kuthe
0cb595e226
transition to nucleo for fuzzy matching (#7814)
* transition to nucleo for fuzzy matching

* drop flakey test case

since the picker streams in results now any test that relies
on the picker containing results is potentially flakely

* use crates.io version of nucleo

* Fix typo in commands.rs

Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>

---------

Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>
2023-08-30 13:26:21 +09:00
woojiq
b67d2c3a68
fix: line numbers remain relative when helix loses focus (#7955)
* fix: line numbers remain relative when helix loses focus

If `line number = relative` and a new window is opened in helix, lines inside unfocused windows will be `absolute`. This commit adds the same thing when helix becomes unfocused in a terminal emulator.

* partial rebase
2023-08-29 16:00:55 +09:00
Michael Davis
546c8ca344 Handle switch from crossterm::Result to io::Result 2023-08-23 05:17:17 +09:00
Michael Davis
e8fef6b6fc Bump crossterm to 0.27 in helix-term on macos 2023-08-23 05:17:17 +09:00
dependabot[bot]
c3442f3a18 build(deps): bump crossterm from 0.26.1 to 0.27.0
Bumps [crossterm](https://github.com/crossterm-rs/crossterm) from 0.26.1 to 0.27.0.
- [Release notes](https://github.com/crossterm-rs/crossterm/releases)
- [Changelog](https://github.com/crossterm-rs/crossterm/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossterm-rs/crossterm/compare/0.26.1...0.27.0)

---
updated-dependencies:
- dependency-name: crossterm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-23 05:17:17 +09:00
dependabot[bot]
10f75ac67a
build(deps): bump tempfile from 3.7.1 to 3.8.0 (#8038)
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.7.1 to 3.8.0.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.7.1...v3.8.0)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-22 12:49:15 +09:00
Pascal Kuthe
e5f8d8ef04
create separate timer for redraw requests (#8023)
* create separate timer for redraw requests

* Update helix-view/src/editor.rs

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-08-22 06:24:30 +09:00
Mike
0cc94cd87a
goto_file_impl: use relative path to open file (#7965)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-08-21 11:15:45 -05:00
nkitsaini
22f4f313f1
Remove unnecessary Err from get_canonicalized_path (#8009)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-08-20 21:11:32 +02:00
nkitsaini
2767459f89
Remove path completions for :new command (#8010) 2023-08-20 12:51:08 -05:00
Andrés Cabero
090a225f28
goto_file: open picker if a directory is selected (#7909)
* feat: open file picker on directories using goto_file (gf)

* remove helper and call to canonicalize
2023-08-15 09:37:44 +02:00
Jonathan LEI
3a162e2bef
Make editor remember the latest search register (#5244) 2023-08-14 18:59:49 -05:00
quantonganh
085706e0cd
Include completions for git-ignored files in debugger prompt (#7936) 2023-08-14 08:46:06 -05:00
Daniel Ebert
155cedc5c8 Fix broken indentation that causes the indentation tests to fail.
For some reason, `cargo fmt` does not change the indentation in
these places (maybe it isn't sure about what the correct formatting
should be).
2023-08-11 23:44:02 +09:00
Skyler Hawthorne
7078e84007 Fix YAML auto indent
YAML indents queries are tweaked to fix auto indent behavior.

A new capture type `indent.always` is introduced to address use cases
where combining indent captures on a single line is desired.

Fixes #6661
2023-08-11 06:22:22 +09:00
Alex Vinyals
48eb0d4792
Enhance :toggle to support cycling numbers (#7877) 2023-08-08 20:56:55 -05:00
dependabot[bot]
f7c0ca7e0c
build(deps): bump tempfile from 3.7.0 to 3.7.1 (#7862)
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.7.0 to 3.7.1.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.7.0...v3.7.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-08 15:20:49 +02:00
woojiq
aa4d84a0b3
Align view for background buffer opened with alt-ret (#7691)
* fix(picker): `alt-ret' changes cursor pos of current file, not new one

Closes #7673

* fix other pickers

* symbol pickers
* diagnostick pickers

This is done using the already patched `jump_to_location` method.

* fix global and jumplist pickers

* use `view` as old_id; make `align_view` method of `Action`

* test(picker): basic <alt-ret> functionality

* fix: picker integrational test

* fix nit

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-08-08 15:17:29 +02:00
Connortsui20
fcbac485f8
Show whether file readonly in statusline (#7740) 2023-08-08 14:51:34 +02:00
Jesse Luehrs
a7a145ad3d
Center the picker preview selection using visual lines (#7837)
this way the preview always shows the selection even if lines were
wrapped
2023-08-07 20:06:51 -05:00
Anshul Dalal
c7e9e94f00
Skip rendering gutters when gutter width exceeds view width (#7821) 2023-08-07 19:13:10 -05:00
Austin L Wolfgram
5535ba8b7d
fix range formatting error message typo (#7823) 2023-08-04 04:33:30 -04:00
Skyler Hawthorne
15e07d4db8 feat: smart_tab
Implement `smart_tab`, which optionally makes the tab key run the
`move_parent_node_start` command when the cursor has non- whitespace to
its left.
2023-08-01 09:41:42 -05:00
Skyler Hawthorne
93acb53812 add node boundary movement 2023-08-01 09:41:42 -05:00
Michael Davis
d4f9716fbc Add yank_to_clipboard commands, bind to <space>y by default
The clipboard special registers are able to retain multiple selections
and also join the value when copying it to the clipboard. So by default
we should yank regularly to the '*' and '+' registers. That will have
the same behavior for the clipboards but will allow pasting multiple
selections if the clipboard doesn't change between yanks.
2023-07-31 15:05:38 +09:00
Michael Davis
4555a6b433 Reimplement clipboard commands in terms of special regs
Since the clipboard provider now lives on the Registers type, we want
to eliminate it from the Editor. We can do that and clean up the
commands that interact with the clipboard by calling regular yank,
paste and replace impls on the clipboard special registers.

Eventually the clipboard commands could be removed once macro keybinding
is supported.
2023-07-31 15:05:38 +09:00
Michael Davis
2d838d729c Preview the latest value for regular registers
This fixes a discrepancy between regular registers which are used for
yanking multiple values (for example via `"ay`) and regular registers
that store a history of values (for example `"a*`).

Previously, the preview shown in `select_register`'s infobox would show
the oldest value in history. It's intuitive and useful to see the most
recent value pushed to the history though.

We cannot simply switch the preview line from `values.first()`
to `values.last()`: that would fix the preview for registers
used for history but break the preview for registers used to yank
multiple values. We could push to the beginning of the values with
`Registers::push` but this is wasteful from a performance perspective.
Instead we can have `Registers::read` return an iterator that
returns elements in the reverse order and reverse the values in
`Register::write`. This effectively means that `push` adds elements to
the beginning of the register's values. For the sake of the preview, we
can switch to `values.last()` and that is then correct for both usage-
styles. This also needs a change to call-sites that read the latest
history value to switch from `last` to `first`.
2023-07-31 15:05:38 +09:00
Michael Davis
a23b70182c commands: Allow using selected register where hardcoded
These snippets use hardcoded registers but it can be useful to be able
to specify a register for these commands.
2023-07-31 15:05:38 +09:00
Michael Davis
baceb02a09 Use refactored Registers type
This is an unfortunately noisy change: we need to update virtually all
callsites that access the registers. For reads this means passing in the
Editor and for writes this means handling potential failure when we
can't write to a clipboard register.
2023-07-31 15:05:38 +09:00
Philipp Mildenberger
8a28f30593
Reformat with nightly rustfmt for better let-else formatting (#7721) 2023-07-27 11:57:19 +09:00
Michael Davis
953073a679 highlighted_code_block: Take input text as &str
This removes a handful of allocations for functions calling into the
function, which is nice because the prompt may call this function on
every keypress.
2023-07-27 11:50:19 +09:00
Michael Davis
98ef05d768 Prefer RopeSlice to &Rope in helix_core::syntax
Pascal and I discussed this and we think it's generally better to
take a 'RopeSlice' rather than a '&Rope'. The code block rendering
function in the markdown component module is a good example for how
this can be useful: we can remove an allocation of a rope and instead
directly turn a '&str' into a 'RopeSlice' which is very cheap.

A change to prefer 'RopeSlice' to '&Rope' whenever the rope isn't
modified would be nice, but it would be a very large diff (around 500+
500-). Starting off with just the syntax functions seems like a nice
middle-ground, and we can remove a Rope allocation because of it.

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
2023-07-27 11:50:19 +09:00
Michael Davis
f0b877e258 Tune regex highlights for usage in prompts
Since regex is almost always injected into other languages,
`pattern_character`s will inherit the highlight for the structure that
injects them (for example `/foo/` in JavaScript or `~r/foo/` in Elixir).
This removes the string highlight when used in the prompt.

We also add `ERROR` node highlighting so that errors in regex syntax
appear in the prompt. This resolves a TODO in the `regex_prompt`
function about highlighting errors in the regex.
2023-07-27 11:50:19 +09:00
Michael Davis
0dc3753eb2 Syntax-highlight regex prompts
We can use tree-sitter-regex highlighting in prompts for entering
regexes, like `search` or `global_search`. The `highlighted_code_block`
function from the markdown component makes this a very small change.

This could be improved in the future by leaving the parsed syntax tree
on the prompt, allowing incremental updates. Prompt lines are usually so
short though and tree-sitter-regex is rather small and uncomplicated,
so that improvement probably wouldn't make a big difference.
2023-07-27 11:50:19 +09:00
Michael Davis
6a431afc4e
Save an undo checkpoint before accepting completion (#7747) 2023-07-27 11:48:16 +09:00
dependabot[bot]
46251a1411
build(deps): bump tempfile from 3.6.0 to 3.7.0 (#7726)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-25 03:03:03 +02:00
Ryan Fowler
5c41f22c2a
Add support for LSP DidChangeWatchedFiles (#7665)
* Add initial support for LSP DidChangeWatchedFiles

* Move file event Handler to helix-lsp

* Simplify file event handling

* Refactor file event handling

* Block on future within LSP file event handler

* Fully qualify uses of the file_event::Handler type

* Rename ops field to options

* Revert newline removal from helix-view/Cargo.toml

* Ensure file event Handler is cleaned up when lsp client is shutdown
2023-07-22 00:21:21 +02:00
sigmaSd
8977123f25
feat: resolve code action (#7677) 2023-07-21 14:50:08 -05:00
dependabot[bot]
b87858b7b4
build(deps): bump indoc from 2.0.2 to 2.0.3 (#7663)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-18 10:49:11 +09:00
Pascal Kuthe
8f1c6456f3
Clear statusline while prompt is visible (#7646) 2023-07-17 14:09:07 +09:00
Alex Vinyals
843ae97120
enhanced surround_replace to provide visual feedback (#7588) 2023-07-13 22:01:44 +09:00
Jonathan
0e0501c510
Fix piping to Helix on macOS (#5468) 2023-07-13 12:01:17 +09:00
Tudyx
9893a1fbcc
Auto indent change if selection is linewise (#7316) 2023-07-11 14:01:48 -05:00
Yomain
8afc0282f2
Fix crash when cwd is deleted (#7185) 2023-07-11 19:51:04 +02:00
Pascal Kuthe
1adb19464f
search buffer contents during global search (#5652) 2023-07-11 21:26:11 +09:00
dependabot[bot]
ac57e93583
build(deps): bump smallvec from 1.10.0 to 1.11.0 (#7597)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 10:26:00 +09:00
Gabriel Hansson
c1488267e5
(Updated) Apply motion API refinements (#6078)
* _apply_motion generalization where possible

API encourages users to not forget setting `editor.last_motion` when
applying a motion. But also not setting `last_motion` without applying a
motion first.

* (rename) will_find_char -> find_char

method name makes it sound like it would be returning a boolean.

* use _apply_motion in find_char

Feature that falls out from this is that repetitions of t,T,f,F are
saved with the context extention/move and count. (Not defaulting to extend
by 1 count).

* Finalize apply_motion API

last_motion is now a private field and can only be set by calling
Editor.apply_motion(). Removing need (and possibility) of writing:

`motion(editor); editor.last_motion = motion`

Now it's just: `editor.apply_motion(motion)`

* editor.last_message: rm Box wrap around Arc

* Use pre-existing `Direction` rather than custom `SearchDirection`.

* `LastMotion` type alias for `Option<Arc<dyn Fn(&mut Editor)>>`

* Take motion rather than cloning it.

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

* last_motion as Option<Motion>.

* Use `Box` over `Arc` for `last_motion`.

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-07-09 16:50:24 -04:00
Alex Vinyals
28452e1f2a
Initialize log and config files right after parsing arguments (#7585) 2023-07-09 11:30:43 -05:00
Ryan Fowler
828c7432e3
Implement the wa! command (#7577) 2023-07-09 09:38:50 -05:00
Alex Vinyals
1698992de6
Fix :log-open when --log is specified (#7573) 2023-07-09 16:35:07 +02:00
Alberto Romero
507dd50860
Add filename completer for shell prompt (#7569) 2023-07-08 18:12:28 +02:00
Pascal Kuthe
618620b369
use redraw handle for debouncing LSP messages (#7538) 2023-07-08 06:46:34 +09:00