* feat: add 'file-abs-path' to statusline (#4434)
* cleanup implementation
* rename to be non-abbreviated names
---------
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* implement another selection modifying command
* Selection feels more ergonomic in case of swapping the direction. This also fixes a problem when starting at an empty line.
* rename select_line_up/down to select_line_above/below
* apply clippy suggestion of using cmp instead of if-chain
* revert `Extent` implementing `Clone/Copy`
* move select_line functions below extend_line implementations
* implement help add function, which saturates at the number of text lines
---------
Co-authored-by: Emi <emanuel.boehm@gmail.com>
Test Document
-------------
```
{{
}
}
```
Steps To Reproduce
------------------
1. 2j # move_visual_line_down
1. C # copy_selection_on_next_line
1. mdm # surround_delete
Debug
-----
`assertion failed: last <= from', transaction.rs:597:13`
Release
-------
`called `Result::unwrap()` on an `Err` value: Char range out of bounds:
char range 18446744073709551614..18446744073709551615,
Rope/RopeSlice char length 7', ropey-1.6.1/src/rope.rs:546:37`
Description
-----------
Processing the surrounding pairs in order violates the assertion the
ranges are ordered. To handle nested surrounds all positions have to
be sorted. Also surround_replace has to track the proper replacement
character for each position.
1. Create a document containing `{A}`
1. C-w v # vsplit
1. gl # goto_line_end
1. b # move_prev_word_start
1. ` # switch_to_lowercase
1. mrm( # surround replace
1. C-w v # vsplit
In the debug build surround_replace/delete will immedately assert with
`assertion failed: last <= from', transaction.rs:597:13`. The splits and
lowercase conversion are not needed to trigger the bug.
In the release build the surround becomes `)a(` and the last vsplit
causes the transaction to panic.
`internal error: entered unreachable code:
(Some(Retain(18446744073709551573)))', transaction.rs:185:46`
Since the selection direction is backwards get_surround_pos returns the
pairs reversed but the downstream code assumes they are in the forward
direction.
Joining lines with Alt-J does not properly select the inserted spaces
when the selection contains blank lines. In the worst case it panics
with an out of bounds index.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
Char index out of bounds: char index 11, Rope/RopeSlice char length 10'
Steps to reproduce:
* Create a new document
```
a
b
c
d
e
```
* % (Select all)
* Alt-J (join and select the spaces)
URIs need to be normalized to be comparable. For example a language
server could send a URI for a path containing '+' as '%2B' but we might
encode this in something like 'Document::url' as just '+'. We can
normalize the URI straight into a PathBuf though since this is the only
value we compare these diagnostics URIs against. This also covers
edge-cases like windows drive letter capitalization.
* Use next and avoid a redundant prefix strip
* Avoid allocations
Especially when `expand_tilde` is claled on a path
that doesn't contain a tilde.
* Add a test
* Use Into<Cow<…>>
* Put the expand_tilde test at the end of the file
* Remove unused importsw
Previously we used the IdleTimeout event to trigger LSP
`completion/resolveItem` requests. We can now refactor this to use an
event system hook instead and lower the timeout.
* neovim like scroll function
* clear line annotations outside of move_vertically/_visual
* add nvim scroll function to commands
* assign nvim-scroll to C-d and C-u (half page scrolls)
* dont remove backspace and space mapping
* move non-softwrap logic to seperate function, call this in nvim-scroll fn
* Revert "move non-softwrap logic to seperate function, call this in nvim-scroll fn"
This reverts commit e4905729c3.
* Revert "clear line annotations outside of move_vertically/_visual"
This reverts commit 1df3fefe55.
* add TODO for when inline diagnostics gets merged
* move nvim-scroll logic into scroll(), dont respect scrolloff
* run cargo fmt
* run cargo clippy
* update documenation for Ctrl-d and Ctrl-u remap
* 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>
`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>
* 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>
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)
* injecting the icon through a resource file, no extra deps
* formatted
* scripted rc compilation
* formatted and restructured
* simplified conditional func call
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`.
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).
* 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>
* 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
`: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.
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.
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.
* 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
* 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
* 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
* 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()
* 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>