When a new View of a Document is created, a default cursor of 0, 0 is
created, and it does not get normalized to a single width cursor until
at least one movement of the cursor happens. This appears to have no
practical negative effect that I could find, but it makes tests difficult
to work with, since the initial selection is not what you expect it to be.
This changes the initial selection of a new View to be the width of the
first grapheme in the text.
* Use new macro syntax for encoding sequences of keys
* Make convenience helpers for common test pattern
* Use indoc for inline indented raw strings
* Add feature flag for integration testing to disable rendering
- Add file-picker.follow-symlinks configuration option (default is true), this
also controls if filename and directory completers follow symlinks.
- Update FilePicker to set editor error if opening a file fails, instead of
panicing.
Fix#1548Fix#2246
In certain circumstances it was possible to get into an infinite loop
when replaying macros such as when different macros attempt to replay
each other.
This commit adds changes to track which macros are currently being
replayed and prevent getting into infinite loops.
When a goto command is cancelled, the jumplist should remain unchanged.
This commit delays saving the current selection to the jumplist until
jumping to a reference.
* Add shrink equivalent of extend_to_line_bounds
* Add a check for being past rope end in end position calc
* Include the EOL character in calculations
* Bind to `A-x` for now
* Document new keybind
* add Tree::swap_split_in_direction()
* add swap_view_{left,down,up,right} commands, bound to H,J,K,L
respectively in the Window menu(s)
* add test for view swapping
* feat(theme): add separate diagnostic colors
This commit adds separate diagnostic highlight colors for the different
types of LSP severities. If the severity type doesn't exist or is
unknown, we use some fallback coloring which was in use before this
commit.
Some initial color options were also added in the theme.toml
Resolves issue #2157
* feat(theme): add docs for new diagnostic options
* feat(theme): adjust defaults & reduce redundancy
- the different colors for different diagnostic severities are now
disabled in the default theme, instead diagnostics are just generally
underlined (as prior to the changes of this feature)
- the theme querying is now done once instead of every iteration in the
loop of processing every diagnostic message
* support insert register in prompt
* use next_char_handler instead of a flag
* Fix clippy issue
* show autoinfo when inserting register
* Revert "show autoinfo when inserting register"
This reverts commit 5488344de1c607d44bdf8693287a85b92cb32518.
* use completion instead of autoinfo
autoinfo is overlapped when using prompt
* recalculate_completion after inserting register
* Update helix-term/src/ui/prompt.rs
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Change the layout of existing split view from horizontal to vertical and
vica-versa. It only effects the focused view and its siblings, i.e. not
recursive.
Command is mapped to 't' or 'C-t' under the Window menus.
This made sense initially when the implementation was still new (so we
got user reports more frequently), but a parsing error now generally
signifies a language server isn't properly implementing the spec.
Currently ctrl-w in insert mode deletes the cursor which results in
unexpected behavior. The patch also reduces the selection to cursor before
performing prev word to remove the behavior of removing unnecessary text
when nothing should be removed.
1. `::#(|)#::` after `ctrl-w` should be `#(|)#::`, previously `#(|)#:`
2. `#(|::)#` after `ctrl-w` should be `#(|::)#`, previously `#(|)#`
Fix#2390
Inserting a newline currently collapses any connected selections when inserting
or appending. It's happening because we're reducing the selections down to
their cursors (`let selection = ..` line) and then computing the new selection
based on the cursor. We're discarding the original head and anchor information
which are necessary to emulate Kakoune's behavior.
In Kakoune, inserting a newline retains the existing selection and _slides_
it (moves head and anchor by the same amount) forward by the newline and
indentation amount. Appending a newline extends the selection to include the
newline and any new indentation.
With the implementation of insert_newline here, we slide by adding the global
and local offsets to both head and anchor. We extend by adding the global
offset to both head and anchor but the local offset only to the head.
* Making the 'set-option' command help more descriptive.
* Adding the generated docs
* Making the message multi-line
* Replace newline with break in generated docs
* add reflow command
Users need to be able to hard-wrap text for many applications, including
comments in code, git commit messages, plaintext documentation, etc. It
often falls to the user to manually insert line breaks where appropriate
in order to hard-wrap text.
This commit introduces the "reflow" command (both in the TUI and core
library) to automatically hard-wrap selected text to a given number of
characters (defined by Unicode "extended grapheme clusters"). It handles
lines with a repeated prefix, such as comments ("//") and indentation.
* reflow: consider newlines to be word separators
* replace custom reflow impl with textwrap crate
* Sync reflow command docs with book
* reflow: add default max_line_len language setting
Co-authored-by: Vince Mutolo <vince@mutolo.org>
Allow tab-completion to continue when there is only a single, unambigous
completion target which is a directory. This allows e.g. nested directories
to be quickly drilled down just by hitting <tab> instead of first selecting
the completion then hitting <enter>.
* add run_shell_command
* docgen
* fix command name
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* refactored Info::new
* show 'Command failed' if execution fails
* TypedCommand takes care of error handling and printing the error to the statusline.
* docgen
* use Popup instead of autoinfo
* remove to_string in format!
* Revert chage in info.rs
* Show "Command succeed" when success
* Fix info.rs
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
When fiddling with paths in a :o prompt, one usually would want Ctrl-W to erase a path segment
rather than the whole path. This is how Ctrl-W works in e.g. (neo)vim out of the box.
Currently A-left move one word left and the behavior will be more
consistent for people coming GUI world if the key was changed to control
given that both browsers and editors like vscode uses C-left right by
default to move word rather than alt.
A-hl currently is not very consistent with hl when next object is
selected, since it may go up/down or left/right and this behavior is
confusing such that some people think it should swap the keys with A-jk,
so it is better to use A-pn since that only specifies two direction.
A-jk have the same issue as in it usually moves right and is not
consistent with the behavior of jk so people may think A-hl is better,
maybe A-oi is better here since A-hl will be swapped to A-pn, A-oi can
convey the meaning of in and out, similar to some window manager keys?
* feat(commands): better handling of buffer-close
Previously, when closing buffer, you would loose cursor position in other docs.
Also, all splits where the buffer was open would be closed.
This PR changes the behavior, if the view has also other buffer
previously viewed it switches back to the last one instead of the view
being closed. As a side effect, since the views are persisted,
the cursor history is persisted as well.
Fixes: https://github.com/helix-editor/helix/issues/1186
* Adjust buffer close behavior
* Remove closed documents from jump history
* Fix after rebase
* Fix ctrl-u on insert behavior
Now should follow vim behavior more
- no longer remove text on cursor
- no longer remove selected text while inserting
- first kill to start non-whitespace, start, previous new line
* Add comment for c-u parts
Select multiple line and open should be based on the whole selection
and not just the line of the cursor, which causes weird behavior like
opening in the middle of the selection which user might not expect.
* added command to extend selection to line above
* fixed view not scrolling up when reaching top of the screen
* refactored shared code into separate impl
* Send active diagnostics to LSP when requesting code actions.
This allows for e.g. clangd to properly send the quickfix code actions
corresponding to those diagnostics as options.
The LSP spec v3.16.0 introduced an opaque `data` member that would allow
the server to persist arbitrary data between the diagnostic and the code
actions request, but this is not supported yet by this commit.
* Reuse existing range_to_lsp_range functionality
hx --health output table's second and third columns were not showing
symbols like ✔ or ✘ to indicate whether LSP or DAP binaries were found.
This change adds these symbols to improve accessibility.
Fixes#1894
Signed-off-by: Nirmal Patel <npate012@gmail.com>
* Make `:write` create nonexistent subdirectories
Prompting as to whether this should take place remains a TODO.
* Move subdirectory creation to new `w!` command
The `file_picker_at_current_directory` command opens the file picker at
the current working directory (CWD). This can be useful when paired with
the built-in `:cd` command which changes the CWD.
It has been mapped to `space F` by default.
During a single HighlightEvent::Source, the highlight spans do not
change and we can merge them into a single style at the beginning
of the event and use it instead of re-computing it for every grapheme
* Add runtime language configuration (#1794)
* Add set-language typable command to change the language of current buffer.
* Add completer for available language options.
* Update set-language to refresh language server as well
* Add language id based config lookup on `syntax::Loader`.
* Add `Document::set_language3` to set programming language based on language
id.
* Update `Editor::refresh_language_server` to try language detection only if
language is not already set.
* Remove language detection from Editor::refresh_language_server
* Move document language detection to where the scratch buffer is saved.
* Rename Document::set_language3 to Document::set_language_by_language_id.
* Remove unnecessary clone in completers::language
when using helix over mosh, the screen doesn't get cleared and
characters get left all over the place until they are overwritten. with
this change, the screen gets properly cleared as soon as helix starts
The search implementation would start searching at the next grapheme
boundary after the previous selection. In case the next occurence of the
needle is immediately after the current selection, this occurence would
not be found (without wraparound) because the first grapheme is skipped.
The correct approach is to use the ensure_grapheme_boundary functions instead
of using the functions that skip unconditionally to the next grapheme.
Currently, the picker's re-using a few bindings which are also present
in the prompt. This causes some editing behaviours to not function on
the picker.
**Ctrl + k** and **Ctrl + j**
This should kill till the end of the line on prompt, but is overridden
by the picker for scrolling. Since there are redundancies (`Ctrl + p`,
`Ctrl + n`), we can remove it from picker.
**Ctrl + f** and **Ctrl + b**
This are used by the prompt for back/forward movement. We could modify
it to be Ctrl + d and Ctrl + u, to match the `vim` behaviour.
* WIP: Rework indentation system
* Add ComplexNode for context-aware indentation (including a proof of concept for assignment statements in rust)
* Add switch statements to Go indents.toml (fixes the second half of issue #1523)
Remove commented-out code
* Migrate all existing indentation queries.
Add more options to ComplexNode and use them to improve C/C++ indentation.
* Add comments & replace Option<Vec<_>> with Vec<_>
* Add more detailed documentation for tree-sitter indentation
* Improve code style in indent.rs
* Use tree-sitter queries for indentation instead of TOML config.
Migrate existing indent queries.
* Add documentation for the new indent queries.
Change xtask docgen to look for indents.scm instead of indents.toml
* Improve code style in indent.rs.
Fix an issue with the rust indent query.
* Move indentation test sources to separate files.
Add `#not-kind-eq?`, `#same-line?` and `#not-same-line` custom predicates.
Improve the rust and c indent queries.
* Fix indent test.
Improve rust indent queries.
* Move indentation tests to integration test folder.
* Improve code style in indent.rs.
Reuse tree-sitter cursors for indentation queries.
* Migrate HCL indent query
* Replace custom loading in indent tests with a designated languages.toml
* Update indent query file name for --health command.
* Fix single-space formatting in indent queries.
* Add explanation for unwrapping.
Co-authored-by: Triton171 <triton0171@gmail.com>
* publish a source tarball with version and grammars
* include_str! the release version from a VERSION file
* remove setting of .version file from tag
don't need this anymore since the file is checked into source
* Move top level lsp config to editor.lsp
This is mainly done to accomodate the new lsp.signature-help config
option that will be introduced in https://github.com/helix-editor/helix/pull/1755
which will have to be accessed by commands. The top level config
struct is split and moved to different places, making the relocation
necessary
* Revert rebase slipup
This avoids costly conversions via byte_to_char (which are then
reversed back into bytes internally in Ropey).
Reduces time spent in slice/byte_to_char from ~24% to ~5%.
When the picker results output is empty, movement actions result in a panic:
```
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero', helix-term/src/ui/picker.rs:420:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
This could be a no-op instead when the matches length is zero.
Currently match is finding the match based on the anchor rather than the
head (cursor) so this behavior is rather unexpected when user is doing
a match but a different item was matched instead when the selection is
more than one character.
This restores much of the behavior that existed before this PR:
helix will build the grammars when compiling. The difference is that
now fetching is also done during the build phase and is done much
more quickly - both shallow and in parallel.
This is a rather large refactor that moves most of the code for
loading, fetching, and building grammars into a new helix-loader
module. This works well with the [[grammars]] syntax for
languages.toml defined earlier: we only have to depend on the types
for GrammarConfiguration in helix-loader and can leave all the
[[language]] entries for helix-core.
The vision with 'use-grammars' is to allow the long-requested feature
of being able to declare your own set of grammars that you would like.
A simple schema with only/except grammar names controls the list
of grammars that is fetched and built. It does not (yet) control which
grammars may be loaded at runtime if they already exist.
build_grammars adapts the functionality that previously came from
helix-syntax to be used at runtime from the command line flags.
fetch_grammars wraps command-line git to perform the same actions
previously done in the scripts in #1560.
helix-syntax mostly existed for the sake of the build task which
checks and compiles the submodules. Since we won't be relying on
that process anymore, it doesn't end up making much sense to have
a very thin crate just for some functions that we could port to
helix-core.
The remaining build-related code is moved to helix-term which will
be able to provide grammar builds through the --build-grammars CLI
flag.
* Move runtime file location definitions to core
* Add basic --health command
* Add language specific --health
* Show summary for all langs with bare --health
* Use TsFeature from xtask for --health
* cargo fmt
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Add arrow key mappings for tree-sitter parent/child/sibling nav
This helps my use case, where I use a non-qwerty layout with a
programmable mechanical keyboard, and use a layer switching key (think
fn) to send left down up right from the traditional hjkl positions.
* Add new bindings to docs
* Fix bug with auto replacing components in compositor
This was last known to be working with 5995568c at the
time of commit, but now doesn't work with latest rust
stable.
The issue probably stems from using
std::any::type_name() for finding a component in the
compositor, for which the docs explicitly warn against
considering it as a unique identifier for types.
`replace_or_push()` takes a boxed `Component` and
passes it to `find_id()` which compares this with a
bare Component. `type_name()` returns `Box<T>` for
the former and `T` for latter and we have a false
negative. This has been solved by using a generics
instead of trait objects to pass in a `T: Component`
and then use it for comparison.
I'm not exactly sure how this worked fine at the
time of commit of 5995568c; maybe the internal
implementation of `type_name()` changed to properly
indicate indirection with Box.
* Do not compare by type name in compositor find_id
* add basic completion replay
* use transaction as the last completion
* completion replay only on trigger position
* cache changes in CompletionAction
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Implement buffer-close-all
* Implement buffer-close-others
* Refactor all buffer close variants to use shared logic
* Fix clippy lint
* Docgen for new commands
* Shorten error message for attempting to close buffers that don't exist
* Refactor shared buffer methods to pass only editor, not whole compositor
* Switch signature of bulk buffer closing to use slice of DocumentIds
Addresses feedback that accepting an IntoIterator implementor is too
much for an internal. Also possibly saves some moving?
* Show infobox to hint textobjects with `mi` and `ma`
* Add note to infobox than any pair of characters will work too
The wording could probably be a little more clear, but I wanted to
keep it short but still accurate.
* Don't allocate a vec for the static help text
* Fix bug where `mi<esc>` would swallow next input and persist infobox
* Better help text for arbitrary pair matching in textobject selection
* Add way to add fake pending key data below status, use with `mi`/`ma`
This is a bit hacky as it makes use of global state which will end
up managed in multiple places, but has precedent in the way autoinfo
works. There should probably be a bigger refactor to handle this
kind of state better.
* Return early on anything other than `mi` and `ma` for autoinfo
* Remove "ascii" from help text with `mi` and `ma`
* Update helix-term/src/ui/editor.rs
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Refactor file picker filetype filter logic to remove panic, make clearer
An unwrap was unneccesarily present due to a prior contribution of mine
which was before I had any understanding of error handling in Rust. I've
also swapped a match for an if let, as was originally suggested in the
original pull request adding filetype filtering, but was merged before I
could address.
* Add some comments to the file picker code for clarity
* Switch to expect instead of ignoring type def error
* ignore Enter keypress when menu has no selection
supersedes #1622
Builds on the work in #1285. I want to allow Enter to create a newline
when there is no selection in the autocomplete menu.
This occurs somewhat often when using LSP autocomplete in Elixir which
uses `do/end` blocks (and I set the autocomplete menu delay to 0 which
exacerbates the problem):
```elixir
defmodule MyModule do
def do_foo(x) do
x
end
def other_function(y) do|
end
```
Here the cursor is `|` in insert mode. The LSP suggests `do_foo` but I
want to create a newline. Hitting Enter currently closes the menu,
so I end up having to hit Enter twice when the module contains any
local with a `do` prefix, which can be inconsistent. With this change,
we ignore the Enter keypress to end up creating the newline in this case.
* pop compositor layer when ignoring Enter keypress
* move closing function out of consumed event result closure
* explicitly label close_fn as an 'Option<Callback>'
* impl auto pairs config
Implements configuration for which pairs of tokens get auto completed.
In order to help with this, the logic for when *not* to auto complete
has been generalized from a specific hardcoded list of characters to
simply testing if the next/prev char is alphanumeric.
It is possible to configure a global list of pairs as well as at the
language level. The language config will take precedence over the
global config.
* rename AutoPair -> Pair
* clean up insert_char command
* remove Rc
* remove some explicit cloning with another impl
* fix lint
* review comments
* global auto-pairs = false takes precedence over language settings
* make clippy happy
* print out editor config on startup
* move auto pairs accessor into Document
* rearrange auto pair doc comment
* use pattern in Froms
* Add Event::Used to use event callback without consuming
* Close popup if contents ignored event
* collect event results before executing callbacks
* don't add new result variant, use Ignored(..) instead
* break in match cases
* Make auto_close configurable
* fix merge
* auto close hover popups
* fix formatting
Some users (including myself) want to turn off filtering of files
prefixed with `.`, as they are often useful to edit. For example, `.env`
files, configuration for linters `.eslint.json` and the like.
The unwrap (or '.ok()' rather) triggers for some errors but not
negative status codes. In the case where helix is being packaged
in an empty git repository, the existing mechanism will fail because
git init
git rev-parse HEAD
gives a negative exit code and prints to stderr
stderr: "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree....
with a stdout of "HEAD\n" (too short to slice with [..8]).
* feat(commands): command palette
Add new command to display command pallete that can be used
to discover and execute available commands.
Fixes: https://github.com/helix-editor/helix/issues/559
* Make picker take the whole context, not just editor
* Bind command pallete
* Typable commands also in the palette
* Show key bindings for commands
* Fix tests, small refactor
* Refactor keymap mapping, fix typo
* Ignore sequence key bindings for now
* Apply suggestions
* Fix lint issues in tests
* Fix after rebase
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
In order to implement this completer, the completion function needs to
be able to access the compositor's context (to allow it to get the
list of buffers currently open in the context's editor).
If building from source and the source is contained in a larger
repository, we'd contain the wrong version. It's also easy to
accidentally have a newer tag that would change the version.
This code:
let start = ensure_grapheme_boundary_next(text, text.byte_to_char(start));
let end = ensure_grapheme_boundary_next(text, text.byte_to_char(end));
Would convert byte to char index, but then internally immediately convert back
to byte index, operate on it, then convert it to char index.
This change reduces the amount of time spent in ensure_grapheme_boundary from
29% to 2%.
* add select_next_sibling and select_prev_sibling commands
* refactor objects to use higher order functions
* address clippy feedback
* move selection cloning into commands
* add default keybindings under left/right brackets
* use [+t,]+t for selecting sibling syntax nodes
* setup Alt-{j,k,h,l} default keymaps for syntax selection commands
* reduce boilerplate of select_next/prev_sibling in commands
* import tree-sitter Node type in commands
* add show_subtree command for viewing tree-sitter subtree in Popup
* remove '.slice(..)' from show_subtree command
* name docs and subtree Popups 'hover'
* feat(commands): shrink_selection
Add `shrink_selection` command that can be used to shrink
previously expanded selection.
To make `shrink_selection` work it was necessary to add
selection history to the Document since we want to shrink
the selection towards the syntax tree node that was initially
selected.
Selection history is cleared any time the user changes
selection other way than by `expand_selection`. This ensures
that we don't get some funky edge cases when user calls
`shrink_selection`.
Related: https://github.com/helix-editor/helix/discussions/1328
* Refactor shrink_selection, move history to view
* Remove useless comment
* Add default key mapping for extend&shrink selection
* Rework contains_selection method
* Shrink selection without expand selects first child
* feat(commands): ensure_selections_forward
Add command that ensures that selections are in forward direction.
Fixes: https://github.com/helix-editor/helix/issues/1332
* Add keybinding for ensure_selections_forward
Add `A-:` keybinding for the ensure_selections_forward command.
* Re-use range.flip for flip_selections command
* feat: Update settings at runtime
fix the clippy warning
* update the documentation
* use to_value instead of to_vec+from_value
* drop the equal
* remove an useless comment
* apply suggestion
* feat(ui): file encoding in statusline
Display file encoding in statusline if the encoding
isn't UTF-8.
* Re-export encoding_rs from core
From there it can be imported by other mods
that rely on it.
* feat(lsp): configurable diagnostic severity
Allow severity of diagnostic messages to be configured.
E.g. allow turning of Hint level diagnostics.
Fixes: https://github.com/helix-editor/helix/issues/1007
* Use language_config() method
* Add documentation for diagnostic_severity
* Use unreachable for unknown severity level
* fix: documentation for diagnostic_severity config
* tmp add code for dedent
* finish normal_mode with dedent behavior
* use function pointer
* rebase from origin
* check dedent condition inside normal_mode implementation
* using if let...
* fix check
* using char_is_whitespace instead of ch.is_whitespace
* fix clippy
* abstract restore_indent function
* Add auto pairs for same-char pairs
* Add unit tests for all existing functionality
* Add auto pairs for same-char pairs (quotes, etc). Account for
apostrophe in prose by requiring both sides of the cursor to be
non-pair chars or whitespace. This also incidentally will work for
avoiding a double single quote in lifetime annotations, at least until
<> is added
* Slight factor of moving the cursor transform of the selection to
inside the hooks. This will enable doing auto pairing with selections,
and fixing the bug where auto pairs destroy the selection.
Fixes#1014
* Move `runtime/themes/base16_default_terminal.toml` to
`base16_theme.toml` alongside `theme.toml`
* Use `terminfo` crate to detect whether the terminal supports true
color and, if the user has no theme configured and their terminal does
not support true color, load the alt default theme instead of the
normal default.
Remove `terminfo` dependency, use `COLORTERM` env instead
Prevent user from switching to an unsupported theme
Add `true-color-override` option
If the terminal is wrongly detected to not support true color,
`true-color-override = true` will override the detection.
Rename `true-color-override` to `true-color`
* Macros WIP
`helix_term::compositor::Callback` changed to take a `&mut Context` as
a parameter for use by `play_macro`
* Default to `@` register for macros
* Import `KeyEvent`
* Special-case shift-tab -> backtab in `KeyEvent` conversion
* Move key recording to the compositor
* Add comment
* Add persistent display of macro recording status
When macro recording is active, the pending keys display will be shifted
3 characters left, and the register being recorded to will be displayed
between brackets — e.g., `[@]` — right of the pending keys display.
* Fix/add documentation
Following the addition of `xtask`, `cargo run` has multiple possible
targets, necessitating the usage of `cargo run --bin hx` to run Helix
during development. This allows `cargo run` to be used to run `hx`.
1. pressing o on a line with no indentation will open a new line as
expected, but esc will then delete the line altogether
2. the kill_line behavior happens after insert mode changes are already
commited to history, and the change isn't commited. pressing u after
this will break highlighting & undo history
This reverts commit c08d2fae58.
Tree sitter returns an index referring to the position of the scope in
the scopes array. We can use that same index to avoid a hashmap lookup
and instead store the styles in an array.
This currently stores the styles in both a map and an array because the
UI still uses hashmap lookups, but it's a reasonable tradeoff.
* restore indent when press esc right after open a new line
* add comment for restore_indent
* fix, and make kill to line end behaves like emacs
* update comment
* fix comment
* adjust cancel restore_indent situation
* check esc logic in mode transaction
* improve comment
* add more check for dedent
* update comment
* use matches to check for last_cmd
* no need to introduct CommandFun type
* accept count for goto_window
also fix view is not fullfilled issue
* fix fulfilled mispell
* Update helix-term/src/commands.rs
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Update helix-term/src/commands.rs
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* fix merge issue
* revert line computation logic
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* goto_file
* support goto_file under current cursor
* add C-w f/F
* sync space w with window mode
* Update helix-term/src/commands.rs
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
fixes#1136
* removed a log::info
* removed temp.rs
* cargo clippy no longer complains
* new get_lang_server function
* get_lang_server is now launch_language_server
* launch_lang_server will now close the previous one
* better code readability
* remove resfresh_ls(and a wrong comment)
* Do not crash when run goto command without line number
Report an error when running goto command without entering a
line number.
Fixes#1159
* Use is_empty() instead check len zero
* Add typable `goto` command
* Support `:<line-number>` on prompt
* Rename function according to convention
* Directly call into goto_line_number function
* align lines
* remove log statement
* use selections to align
* fix a clippy issue
* only accept 1,2,3 as user count
* Update helix-term/src/commands.rs
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* return if user count is not correct
* add doc
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* squashed WIP commits
* hide_gitignore working with config
* pass reference to new config parameter of file_picker()
* update config option name to match name on walk builder
* add comments to config and documentation of option to book
* add git_ignore option to WalkBuilder within prompt in commands.rs
* WIP: add FilePickerConfig struct
* WIP: cleanup
* WIP: add more options including max_depth
* WIP: changed defaults to match ignore crate defaults
* WIP: change WalkBuilder in global_search() to use config options
* WIP: removed follow_links, changed max_depth to follow config setting
* WIP: update book with file-picker inline table notation
* update documentation for file-picker config in book
* adjusted to [editor.file-picker] in book configuration.md
* adjust comments in editor.rs to be doc comments, cleanup
* adjust comments
* adjust book
* Jump to end char of surrounding pair from any cursor pos
* Separate bracket matching into exact and fuzzy search
* Add constants for bracket chars
* Abort early if char under cursor is not a bracket
* Simplify bracket char validation
* Refactor node search and unify find methods
* Remove bracket constants
* Add command to inc/dec number under cursor
With the cursor over a number in normal mode, Ctrl + A will increment the
number and Ctrl + X will decrement the number. It works with binary, octal,
decimal, and hexidecimal numbers. Here are some examples.
0b01110100
0o1734
-24234
0x1F245
If the number isn't over a number it will try to find a number after the
cursor on the same line.
* Move several functions to helix-core
* Change to work based on word under selection
* It no longer finds the next number if the cursor isn't already over
a number.
* It only matches numbers that are part of words with other characters
like "foo123bar".
* It now works with multiple selections.
* Add some unit tests
* Fix for clippy
* Simplify some things
* Keep previous selection after incrementing
* Use short word instead of long word
This change requires us to manually handle minus sign.
* Don't pad decimal numbers if no leading zeros
* Handle numbers with `_` separators
* Refactor and add tests
* Move most of the code into core
* Add tests for the incremented output
* Use correct range
* Formatting
* Rename increment functions
* Make docs more specific
* This is easier to read
* This is clearer
* Type can be inferred
* readline style insert mode
* update keymap.md
* don't save change history in insert mode
* Revert "don't save change history in insert mode"
This reverts commit cb47f946d7fb62ceda68e7d1692a3914d0be7762.
* don't affect register and history in insert mode
* add insert_register
* don't call exit_select_mode in insert mode
* avoid set_selection
* avoid duplicated current!
* helix-view/view: impl method to remove document from jumps
* helix-view/editor: impl close_document
* helix-view/editor: remove close_buffer argument from `close`
According to archseer, this was never implemented or used properly. Now
that we have a proper "buffer close" function, we can get rid of this.
* helix-term/commands: implement buffer-close (bc, bclose)
This behaves the same as Kakoune's `delete-buffer` / `db` command:
* With 3 files opened by the user with `:o ab`, `:o cd`, and `:o ef`:
* `buffer-close` once closes `ef` and switches to `cd`
* `buffer-close` again closes `cd` and switches to `ab`
* `buffer-close` again closes `ab` and switches to a scratch buffer
* With 3 files opened from the command line with `hx -- ab cd ef`:
* `buffer-close` once closes `ab` and switches to `cd`
* `buffer-close` again closes `cd` and switches to `ef`
* `buffer-close` again closes `ef` and switches to a scratch buffer
* With 1 file opened (`ab`):
* `buffer-close` once closes `ab` and switches to a scratch buffer
* `buffer-close` again closes the scratch buffer and switches to a new
scratch buffer
* helix-term/commands: implement buffer-close! (bclose!, bc!)
Namely, if you have a document open in multiple splits, all the splits
will be closed at the same time, leaving only splits without that
document focused (or a scratch buffer if they were all focused on that
buffer).
* helix-view/tree: reset focus if Tree is empty
* Add commit hash to version info, if present
* Rename GIT_HASH to indicate that it includes version, fix linter error
* Add whitespace after use statement
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Add arrow keys to view mode
* Drop C-up and C-down
* Update docs for #987
* Format correctly
* Drop other keymaps
* Correct keymap.md
* Add arrow keys to view mode
Drop C-up and C-down
Update docs for #987
Format correctly
Drop other keymaps
Correct keymap.md
Rebase
Co-authored-by: Rust & Python <nexinov@localhost.gud-o15>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Allow keys to be mapped to sequences of commands
* Handle `Sequence` at the start of `Keymap::get`
* Use `"[Multiple commands]"` as command sequence doc
* Add command sequence example to `remapping.md`
* add wonly
* Update book/src/keymap.md
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* add `wonly` to space w mode too
* remove the TODO
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Adds ctrl! and alt! macros (which existed before the big keymap
refactor) and uses them in event handling of Components. Note
that this converts crossterm's KeyEvent to our own KeyEvent on
each invocation of handle_event in Components.
Space mode and view mode are duplicated on two different
keybinds, and they tend to get out of sync by contributers
forgetting to update both of them. This commit adds a test
that explicitly checks that they are identical. Prevents
issues like #1050.
b which was assigned to page_up conflicts with
align to bottom, so this commit replaces page up,
down, etc keybinds to use normal mode keybinds
(C-f, C-b, etc) in view mode too.
* Launch with defaults upon invalid config/theme
* Startup message if there is a problematic config
* Statusline error if trying to switch to an invalid theme
* Use serde `deny_unknown_fields` for config
* Add reverse search functionality
* Change keybindings for extend to be in select mode, incorporate Movement and Direction enums
* Fix accidental revert of #948 in rebase
* Add reverse search to docs, clean up mismatched whitespace
* Reverse search optimization
* More optimization via github feedback
* Add prompt shourtcut to book
Add completions to search
Add c-s to pick word under doc cursor to prompt line
* limit 20 last items of search completion, update book
* Update book/src/keymap.md
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* limit search completions 200
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Prevent preview binary or large file (#847)
* fix wrong method name
* fix add use trait
* update lock file
* rename MAX_PREVIEW_SIZE from MAX_BYTE_PREVIEW
* read small bytes to determine cotent type
* [WIP] add preview struct to represent calcurated preveiw
* Refactor content type detection
- Remove unwraps
- Reuse a single read buffer to avoid 1kb reallocations between previews
* Refactor preview rendering so we don't construct docs when not necessary
* Replace unwarap whit Preview::NotFound
* Use index access to hide unwrap
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* fix Get and unwarp equivalent to referce of Index acess
* better preview implementation
* Rename Preview enum and vairant
Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
* fixup! Rename Preview enum and vairant
* simplify long match
* Center text, add docs, fix formatting, refactor
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
* Truncate the starts of file paths in picker
* Simplify the truncate implementation
* Break loop at appropriate point
* Fix alignment and ellipsis presence
* Remove extraneous usage of `x_offset`
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Implement `hx --tutor` and `:tutor` to load `tutor.txt`
* Document `hx --tutor` and `:tutor`
* Change `Document::set_path` to take an `Option`
* `Document::set_path` accepts an `Option<&Path>` instead of `&Path`.
* Remove `Editor::open_tutor` and make tutor-open functionality use
`Editor::open` and `Document::set_path`.
* Use `PathBuf::join`
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Add comments explaining unsetting tutor path
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Improve statusline
* Change diagnostic count display to show counts of individual
diagnostic types next to their corresponding gutter dots.
* Add selection count to the statusline.
* Do not display info or hint count in statusline
* Reduce padding
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Reduce padding
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Use `Span::styled`
* Reduce padding
* Use `Style::patch`
* Remove unnecessary `Cow` creation
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* filter items by starts_with pre nth char of cursor
* add config for filter completion items by starts_with
* filter items by starts_with pre nth char of cursor
* add config for filter completion items by starts_with
* remove completion items pre filter configuratio
* Add treesitter textobject queries
Only for Go, Python and Rust for now.
* Add tree-sitter textobjects
Only has functions and class objects as of now.
* Fix tests
* Add docs for tree-sitter textobjects
* Add guide for creating new textobject queries
* Add parameter textobject
Only parameter.inside is implemented now, parameter.around
will probably require custom predicates akin to nvim' `make-range`
since we want to select a trailing comma too (a comma will be
an anonymous node and matching against them doesn't work similar
to named nodes)
* Simplify TextObject cell init
* improve idle completion trigger
* add completion-trigger-len to book
* rename semantics_completion to language_server_completion and optimize idle completion trigger
* initial implementation of global search
* use tokio::sync::mpsc::unbounded_channel instead of Arc, Mutex, Waker poll_fn
* use tokio_stream::wrappers::UnboundedReceiverStream to collect all search matches
* regex_prompt: unified callback; refactor
* global search doc
Regression due to #635 where escape key in insert mode
would not exit normal mode. This happened due to hard
coding the escape key to cancel a sticky keymap node.
* Implement shell interaction commands
* Use slice instead of iterator for shell invocation
* Default to `sh` instead of `$SHELL` for shell commands
* Enforce trailing comma in `commands` macro
* Use `|` register for shell commands
* Move shell config to `editor` and use in command
* Update shell command prompts
* Remove clone of shell config
* Change shell function names to match prompts
* Log stderr contents upon external command error
* Remove `unwrap` calls on potential common errors
`shell` will no longer panic if:
* The user-configured shell cannot be found
* The shell command does not output UTF-8
* Remove redundant `pipe` parameter
* Rename `ShellBehavior::None` to `Ignore`
* Display error when shell command is used and `shell = []`
* Document shell commands in `keymap.md`
* feat: merge default languages.toml with user provided languages.toml
* refactor: use catch-all to override all other values for merge toml
* tests: add a test case for merging languages configs
* refactor: change test module name