Commit Graph

691 Commits (e8cc7ace759c2aaf3a14257a5c48e0f8a960d4cd)

Author SHA1 Message Date
nibon7 43997f1936
Use `^` and `$` to match the beginning and end of a line when searching (#1790)
Fixes #1737

Signed-off-by: nibon7 <nibon7@163.com>
2 years ago
Gokul Soumya b0aaf08995
Change parameter object keybind from `p` to `a` (#1708)
This is largely to avoid a collision with the soon
to be merged paragraph object which takes up the p key.
2 years ago
Blaž Hrastnik 19247ff0ec
Split out typable commands into a separate file 2 years ago
Daniel S Poulin 9bfb0caf1b
Add comment textobject for surround selection and navigation (#1605) 2 years ago
Blaž Hrastnik 5d14f56fa9
Reuse visual_coords_at_pos function in view 2 years ago
Blaž Hrastnik 0062af6a19
minor: Remove some outdated comments 2 years ago
Blaž Hrastnik 737282d0e9
Extract a common function for paste_before/_after 2 years ago
Blaž Hrastnik c0b86afdc8 Refactor align_selection by simplifying the calculation 2 years ago
Bob Qi 1c1aee74b4 refactor align_selection using kakoune logic 2 years ago
Gokul Soumya 5c810e5e52
Fix bug with auto replacing components in compositor (#1711)
* 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
2 years ago
Daniel S Poulin 78d37fd332
Implement bulk buffer closing commands (#1677)
* 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?
2 years ago
Daniel S Poulin b13d44156c
Show infobox to hint textobjects with `mi` and `ma` (#1686)
* 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>
2 years ago
Gokul Soumya c15996aff5
Show surround delete and replace errors in editor (#1709)
* Refactor surround commands to use early returns

* Show surround delete and replace errors in editor
2 years ago
Matouš Dzivjak 951fd1c80e
fix(commands): don't indent empty lines (#1653)
* fix(commands): don't indent empty lines

Fixes: https://github.com/helix-editor/helix/issues/1642

* Apply suggestions

* Update helix-term/src/commands.rs

* Update helix-term/src/commands.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Skyler Hawthorne a494f47a5d
Configurable auto pairs (#1624)
* 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
2 years ago
Bram 40eb1268c7
Close some popups automatically (#1285)
* 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
2 years ago
Blaž Hrastnik 1ca6ba03ca
Simplify some code 2 years ago
Blaž Hrastnik c7b326be04
ui: prompt: Render aliases + border on the doc 2 years ago
Blaž Hrastnik 504d5ce8bd Move most LSP specific commmands to commands::lsp 2 years ago
Blaž Hrastnik 4e1b3b12f3 Refactor symbol picker to share code 2 years ago
Matouš Dzivjak afec54485a
feat(commands): command palette (#1400)
* 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>
2 years ago
Blaž Hrastnik 24f90ba8d8 Manually recalculate initial completion where it matters 2 years ago
Blaž Hrastnik af21e2a5b4 Pass through Editor instead of Context 2 years ago
Cole Helbling e023a78919 WIP: show all buffers that couldn't be closed 2 years ago
Cole Helbling 6118486eb2 helix-term: implement buffer completer
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).
2 years ago
Cole Helbling a1207fd768 helix-term/commands: display buffer id in picker 2 years ago
Blaž Hrastnik d11b652139 Allow static strings in set_status/set_error so API is nicer 2 years ago
Gokul Soumya 966fbc5984 Add tree-sitter based function, class navigation 2 years ago
Ludwig Stecher 4429993842
Add `PageUp`, `PageDown`, `Ctrl-u`, `Ctrl-d`, `Home`, `End` keyboard shortcuts to file picker (#1612)
* Add `PageUp`, `PageDown`, `Ctrl-u`, `Ctrl-d`, `Home`, `End` keyboard shortcuts to file picker

* Refactor file picker paging logic

* change key mapping

* Add overlay component

* Use closure instead of margin to calculate size

* Don't wrap file picker in `Overlay` automatically
2 years ago
Kirawi 23907a063c
use PathBuf::to_string_lossy() instead of to_str() (#1655) 2 years ago
Blaž Hrastnik bd549d8a20 Merge remote-tracking branch 'origin/master' into debug 2 years ago
Cydiater 7083b98a38
postpone clone after found (#1656) 2 years ago
Blaž Hrastnik f88c077f99 Replace tendril with smartstring
Slightly smaller API surface, less dependencies.
2 years ago
Matouš Dzivjak fdb9a1677b
feat(editor): add config for search wrap_around (#1516)
* feat(editor): add config for search wrap_around

Fixes: https://github.com/helix-editor/helix/issues/1489

* Move search settings into separate config

* Disable linter
2 years ago
Gokul Soumya bf773db451 Show infobox with register contents 2 years ago
Gokul Soumya 5995568c1d Prevent multiple code action popups 2 years ago
Gokul Soumya 547c3ecd0c Preselect first item in code action popup menu 2 years ago
Gokul Soumya e90276df0b Replace if let with early return 2 years ago
Blaž Hrastnik 094a0aa3f9 Render code actions as a menu, allow adding padding to popup 2 years ago
Blaž Hrastnik f7f55143a1 Improve code action picker by displaying it inline 2 years ago
Blaž Hrastnik 2a7ae963e1 Automatically commit changes to history if not in insert mode
Fixes #1500
2 years ago
CossonLeo d49e5323f9
Use markup scopes for the Markdown component (#1363) 2 years ago
Ivan Tham 759b850859
Allow specifying file start position (#445)
Like helix-term/src/commands.rs:3426:15
2 years ago
Michael Davis f453f8724d
change show_subtree command into ':tree-sitter-subtree' typable command (#1524)
* add default keymap for show_subtree command

* remove space+t keymap

* add a typable command ':show-subtree'

* generate documentation for ':show-subtree'

* remove non-typable show_subtree command

* ':show-subtree'->':tree-sitter-subtree'
2 years ago
Michael Davis 392dfa0841
add select_next_sibling and select_prev_sibling commands (#1495)
* 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
2 years ago
Blaž Hrastnik e7eab95b94 Update to rust 1.58, fix a bunch of optional lints 2 years ago
Matouš Dzivjak 38ca8daa09
fix(commands): run fmt for all documents being closed (#1444)
When writing all documents, fmt wouldn't be run.
Run fmt in close all implementation so that all documents
are formatted if necessary.

Fixes: https://github.com/helix-editor/helix/issues/1442
2 years ago
Michael Davis 64d3e7b705
add show_subtree command for viewing tree-sitter subtree in Popup (#1453)
* add show_subtree command for viewing tree-sitter subtree in Popup

* remove '.slice(..)' from show_subtree command

* name docs and subtree Popups 'hover'
2 years ago
Mathis Brossier 85cf2648a2
buffer picker allow hsplit / vsplit (#1502) 2 years ago
Matouš Dzivjak 2e02a1d6bc
feat(commands): shrink_selection (#1340)
* 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
2 years ago