Commit Graph

389 Commits (3256b013889eee5f9bc66f58b59386214bc49cf2)

Author SHA1 Message Date
trivernis 388181bab7
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
cossonleo aec001ad84 completion fix 2 years ago
Blaž Hrastnik a123fb6057
Remove LspNotDefined, instead return an Option<> 2 years ago
trivernis c24c30584b
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
Blaž Hrastnik 6ec4017a8d
Expand doc/view macros to allow fetching specific id
This simplifies the code and hides away unwraps
2 years ago
aaron404 e8730ca5fd
initial implementation of bufferline (#2759)
* initial implementation of bufferline

* fixed lint

* changed to 'bufferline', added enum for config modes, some cleanup

* fixed lint

* added file modification indicator

* removed redundant code, added proper themeing with fallback, changed 'file modified' indicator

* remove commented code

* Update helix-term/src/ui/editor.rs

simplify text and offset computation

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>

* add ui.bufferline.background key for themes

Co-authored-by: lazytanuki <43273245+lazytanuki@users.noreply.github.com>

* address PR comments

* Update helix-term/src/ui/editor.rs

* simplify computation of editor area:

* change to set_stringn to avoid overflow

* Update configuration.md

Updates documentation to reflect decision re: defaulting to never showing bufferline.

* addressed pr comments

* fix build error

* address pr comments

* revert accidental change

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
Co-authored-by: lazytanuki <43273245+lazytanuki@users.noreply.github.com>
Co-authored-by: Seth Bromberger <sbromberger@users.noreply.github.com>
2 years ago
A-Walrus 45dbcb6783
Fix closing buffer with custom keymap (#3633)
* Fix closing buffer with custom keymap

* Add comment explaining if
2 years ago
Blaž Hrastnik 5c2b77b41f
Make mode editor-wide rather than per-document 2 years ago
Michael Davis 93c6a337c4
Avoid command execution hooks on closed docs (#3613)
Fixes a panic with a config like:

    [keys.normal.space]
    x = [":buffer-close"]

by bailing out of the command-execution handling if the document
doesn't exist after handling a command.
2 years ago
Lucy 404db2ebee
Move mode transition logic to handle_keymap_event() (#2634)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Michael Davis 9e24f2aa81
Use the original document and view for mode transition hooks (#3508)
When changing focus, the lookup with `current!` may change the
view and end up executing mode transition hooks on the newly
focused view. We should use the same view and document to execute
mode transition hooks so that switching away from a view triggers
history save points.
2 years ago
Charlie Groves f38ede8631
Add bracketed paste (#3233) 2 years ago
trivernis 151ac52741
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
Blaž Hrastnik e4c9d4082a
fix: Reset document mode when losing focus
Fixes #3090
2 years ago
Charlie Groves 18909aafe2
Update to crossterm-0.25 (#3390) 2 years ago
A-Walrus ed74e6d5d4
Switch to `tabpad` configuration option (#3458)
Virtual whitespace tabs are created from the `tab` character padded
with `tabpad` up to  the tab width.
2 years ago
Gokul Soumya 634b6d455f
Add custom event type replacing crossterm's Event (#3169)
Ported over from 61365dfbf3 in the `gui` branch. This will allow
adding our own events, most notably an idle timer event (useful
for adding debounced input in [dynamic pickers][1] used by interactive
global search and workspace symbols).

[1]: https://github.com/helix-editor/helix/pull/3110

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
A-Walrus c00b8f7ad7
Fix tab highlight when tab is partially visible (#3313)
* Fix tab highlight when tab is partially visible

* Make it style based, and not truncation based

Dealing with truncating is a mess, especially when it comes to wide
unicode graphemes. This way it should work no matter what.

* Inline style calculation into branches
2 years ago
A-Walrus fdd8bbf16b
Fix indent guide styling (#3324)
* Fix incorrect indent guide styling

Before the indent guides on top of whitespace inherited the theme
from them. Now they do not.

* Fix dark_plus theme indent_guides

* Use whitespace style as fallback for indent-guide

* Fix dark_plus theme indent_guides

* Move indent_guide style patching out of loop
2 years ago
Matthias Deiml 0ee2061102
Avoid copying fragments (#3136)
* Avoid copying fragments

* Add slice / slices method

* Better documentation for fragment and slice methods
2 years ago
Omnikar afd292e3b9
Resolve clippy lints (#3307) 2 years ago
trivernis a6e16df9a3
Merge branch 'master' of github.com:helix-editor/helix 2 years ago
trivernis 7cb8330751
Merge remote-tracking branch 'pr-tree/tree_explore'
Signed-off-by: trivernis <trivernis@protonmail.com>
2 years ago
Blaž Hrastnik 906259cc41
fix: Indent levels could bleed over on the left edge
Fixes #3087
Refs #3105
    #	modified:   theme.toml
2 years ago
Gokul Soumya 791bf7e50a
Add lsp signature help (#1755)
* Add lsp signature help

* Do not move signature help popup on multiple triggers

* Highlight current parameter in signature help

* Auto close signature help

* Position signature help above to not block completion

* Update signature help on backspace/insert mode delete

* Add lsp.auto-signature-help config option

* Add serde default annotation for LspConfig

* Show LSP inactive message only if signature help is invoked manually

* Do not assume valid signature help response from LSP

Malformed LSP responses are common, and these should not crash the
editor.

* Check signature help capability before sending request

* Reuse Open enum for PositionBias in popup

* Close signature popup and exit insert mode on escape

* Add config to control signature help docs display

* Use new Margin api in signature help

* Invoke signature help on changing to insert mode
2 years ago
Ivan Tham e8214fb1e6
Make gutters padding optional (#2996)
If all gutters are removed, there are still an extra one padding, would be nice
to remove that to save some space.
2 years ago
Mr. E dbf68e0370
Customizable/configurable status line (#2434)
* feat(statusline): add the file type (language id) to the status line

* refactor(statusline): move the statusline implementation into an own struct

* refactor(statusline): split the statusline implementation into different functions

* refactor(statusline): Append elements using a consistent API

This is a preparation for the configurability which is about to be
implemented.

* refactor(statusline): implement render_diagnostics()

This avoid cluttering the render() function and will simplify
configurability.

* feat(statusline): make the status line configurable

* refactor(statusline): make clippy happy

* refactor(statusline): avoid intermediate StatusLineObject

Use a more functional approach to obtain render functions and write to
the buffers, and avoid an intermediate StatusLineElement object.

* fix(statusline): avoid rendering the left elements twice

* refactor(statusline): make clippy happy again

* refactor(statusline): rename `buffer` into `parts`

* refactor(statusline): ensure the match is exhaustive

* fix(statusline): avoid an overflow when calculating the maximal center width

* chore(statusline): Describe the statusline configurability in the book

* chore(statusline): Correct and add documentation

* refactor(statusline): refactor some code following the code review

Avoid very small helper functions for the diagnositcs and inline them
instead.
Rename the config field `status_line` to `statusline` to remain
consistent with `bufferline`.

* chore(statusline): adjust documentation following the config field refactoring

* revert(statusline): revert regression introduced by c0a1870

* chore(statusline): slight adjustment in the configuration documentation

* feat(statusline): integrate changes from #2676 after rebasing

* refactor(statusline): remove the StatusLine struct

Because none of the functions need `Self` and all of them are in an own
file, there is no explicit need for the struct.

* fix(statusline): restore the configurability of color modes

The configuration was ignored after reintegrating the changes of #2676
in 8d28f95.

* fix(statusline): remove the spinner padding

* refactor(statusline): remove unnecessary format!()
2 years ago
Mathspy d06800f1dd
Add mode specific styles (#2676)
* Add mode specific styles

In similar vein to neovim's lualine and similar statusline packages this
allows helix users to style their mode based on which mode it is thus
making each mode more visually distinct at a glance

* Add an example based on rosepine

* Add editor.colors-mode config

* Document statusline mode styles
2 years ago
Seth Bromberger 07e7a13a9e
fixes background reset (#2900)
* fixes background reset

* moves creation of default style out of loop

* patches with background_style

* removes commented code
2 years ago
Gokul Soumya 3108a11d35
Refactor handling of mouse events (#2893)
- Simplified match statements by destructuring MouseEvent struct
  at the top and then matching on event.kind.
- Extracted out closures for calculating (1) position and view
  of mouse click and (2) gutter coordinates and view of mouse click.
2 years ago
Blaž Hrastnik fde9e034d4 Only draw cursorline in the currently focused buffer 2 years ago
Tobias Menzi 8dc86beabd
Implement cursorline (#2170)
* Implement cursorline

* Binary search possible lines
2 years ago
Michael Davis d948ace67b
check selection's visible width when copying on mouse click (#2711)
* check selection's visible width when copying on mouse click

Mouse-click-up copies the selection produced by dragging. The event
is ignored if the selection has a width of 1 though so you don't
copy when clicking rather than dragging. The current check copies
text when it has a visible width of 1 but is actually multiple
characters in the rope like a CRLF line-ending. With this change
we check the unicode width of the character(s) in the selection
rather than the range length, so clicking on a CRLF line-ending
does not copy.

* use range.fragment to simplify getting the primary selection width
2 years ago
Seth Bromberger c107f4ea49
fixes #2856 by resetting style on diagnostic (#2861) 2 years ago
Gokul Soumya 8b67acf130
Format keys identically in statusline and command palette (#2790)
The command palette previously used + as a delimiter for denoting
a single key in a key sequence, (like C+w). This was at odds with
how the statusline displayed them with pending keys (like <C-w>).
This patch changes the palette formatting to the statusline formatting
2 years ago
Gokul Soumya 8ad0b83e30 Make indent guides configurable 2 years ago
Gokul Soumya 8c4c923e80 Add indent guides support 2 years ago
Mathspy fa4934cff9
Default rulers color to red (#2669)
* Default rulers color to red

Currently if the theme a user is using doesn't have `ui.virtual.rulers`
set and they set up a ruler it just fails silently making it really hard
to figure out what went wrong. Did they set incorrectly set the ruler?
Are they using an outdated version of Helix that doesn't support rulers?

This happened to me today, I even switched to the default theme with
the assumption that maybe my theme just doesn't have the rulers setup
properly and it still didn't work.

Not sure if this is a good idea or not, feel free to suggest better
alternatives!

* Use builtin Style methods instead of Bevy style defaults

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

* Only default the style if there's no ui or ui.virtual

* Update themes style from ui.virtual to ui.virtual.whitespace

* Revert ui.virtual change in onelight theme

* Prefer unwrap_or_else

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
cossonleo 06a5bca79b optimize tree explore render 2 years ago
cossonleo 21d4bf859b tree helper and file explorer 2 years ago
Mathis Brossier 8c64c3dfa3
mouse selection now uses character indexing (#2839) 2 years ago
Blaž Hrastnik 370a16d0f0
Update to ropey 1.5 2 years ago
Robert Walter 776686ab24
Separate colors for different diagnostics types (#2437)
* 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
2 years ago
unrelentingtech 2c60798b00
feat(ui): add nbsp (non-breaking space) to rendered whitespace (#2322) 2 years ago
Michael Davis e4c2618099
prevent rendering visible whitespace on trailing cursor (#2331) 2 years ago
chunghha 3a398eec56
fix typos (#2304) 2 years ago
Omnikar e6b865ed0b allow whitespace to be rendered
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
adaliaramon 94eba0e66a
Added ability to remap 0 if it is not part of a count (#2174)
* Added ability to remap 0

* Removed duplicated match body
2 years ago
Thomas 5d5b6bab9b
Add rulers option (#2060)
* Add color_column option

* Rename to ruler

Co-authored-by: DeviousStoat <devious@stoat.com>
2 years ago
Dr. David A. Kunz b04c425c63
Make gutters configurable (#1967)
* config option line numbers none

* view tests

* added tests

* doc

* comment

* Make gutters configurable

* docu

* docu

* rm none docu

* order

* order

* precedence

* simpler

* rm todo

* fixed clippy

* order

* double quotes

* only allow diagnostics and line-numbers

* tests

* docu

* format

* rm short variant and more docu

* performance improvements

* typo

* rename
2 years ago
unrelentingtech d5c0866978
Apply ui.gutter style to empty gutters (#2032)
The unstyled column on the left from the diagnostics_or_breakpoints gutter
looks sad if you want to add a background to all gutters. Let's fix this.
2 years ago
Gokul Soumya 420b5b8301
Compute style only once per source highlight event (#1966)
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
2 years ago
Joe bee05dd32a
Add refresh-config and open-config command (#1803)
* Add refresh-config and open-config command

* clippy

* Use dynamic dispatch for editor config

* Refactor Result::Ok to Ok

* Remove unused import

* cargo fmt

* Modify config error handling

* cargo xtask docgen

* impl display for ConfigLoadError

* cargo fmt

* Put keymaps behind dyn access, refactor config.load()

* Update command names

* Update helix-term/src/application.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

* Switch to unbounded_channel

* Remove --edit-config command

* Update configuration docs

* Revert "Put keymaps behind dyn access", too hard

This reverts commit 06bad8cf492b9331d0a2d1e9242f3ad4e2c1cf79.

* Add refresh for keys

* Refactor default_keymaps, fix config default, add test

* swap -> store, remove unneeded clone

* cargo fmt

* Rename default_keymaps to default

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Blaž Hrastnik a7ee9f74f7
No need for KeymapResult anymore since we can query .sticky() 2 years ago
Blaž Hrastnik 7909d6f05e
keymap: Store pending/sticky on the root level 2 years ago
Blaž Hrastnik 59f05088b9
Optimize rendering by using Ropey::byte_slice
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%.
2 years ago
Blaž Hrastnik fd02d1bf89
Fix tab rendering to use dynamic tab width
Each tab is just wide enough to round to the nearest tab stop.

Refs #1243
2 years ago
Blaž Hrastnik 0062af6a19
minor: Remove some outdated comments 2 years ago
Blaž Hrastnik 68bad148a5
Extract idle timeout code into ui/editor.rs 2 years ago
Mateusz S. Szczygieł 14e2ced440
Make repeat operator work with completion edits (#1640)
* 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>
2 years ago
Ludwig Stecher 59c691d2db
Highlight matching text in file picker suggestions (#1635)
* Highlight matching text in file picker suggestions

* Remove cache, specialize highlighting code

* Fix outdated comments
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
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
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 bd549d8a20 Merge remote-tracking branch 'origin/master' into debug 2 years ago
Gokul Soumya bf773db451 Show infobox with register contents 2 years ago
Blaž Hrastnik 62561e9d23 Stop collecting highlight_iter events then turning back into iter 2 years ago
Blaž Hrastnik 5aead46f4b Remove some unnecessary clippy tags 2 years ago
Blaž Hrastnik 2a7ae963e1 Automatically commit changes to history if not in insert mode
Fixes #1500
2 years ago
Blaž Hrastnik e2d2f19fd0
Merge pull request #1154 from sudormrfbin/cursor-shape-new
Change cursor shape on mode change
2 years ago
Blaž Hrastnik add3be8528 Slicing micro-optimization 2 years ago
Blaž Hrastnik 11c3ba9350 Speed up ensure_next_boundary during render
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%.
2 years ago
Blaž Hrastnik 6728e44490 syntax: Split parsing and highlighting 2 years ago
Mathis Brossier f5b0821860
Fix panics when resizing (#1408)
* Change buffer.get & buffer.get_mut to return Option, Implement Trait Index & IndexMut to panic

* Prevent FilePicker from drawing outside buffer (rust panics)

* apply suggestion

* add function in_bounds to avoid useless calculations

Co-authored-by: mathis <mathis.brossier@universite-paris-saclay.fr>
2 years ago
Gokul Soumya 449624965b Merge branch 'master' into cursor-shape-new 2 years ago
Kirawi 93a948d889
switch redundant current! usage to doc! (#1416) 2 years ago
Matouš Dzivjak 4b0b1a5657
feat(ui): file encoding in statusline (#1355)
* 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.
2 years ago
BB 60f3225c7f
Truncate the start of file paths in the StatusLine (#1351)
* Truncate the start of file paths in the StatusLine

* cargo fmt

Co-authored-by: Bódi Balázs <97936@4ig.hu>
2 years ago
Gokul Soumya c0bbadcaaf Manually draw all block cursors 2 years ago
Gokul Soumya d4fb1d0633 Merge branch 'master' into cursor-shape-new 2 years ago
Gokul Soumya 016640f4fb Remove ui.cursor.primary and hashmap lookups 2 years ago
Blaž Hrastnik 730d3be201 Add ui.gutter to theme all gutters (i.e. set bg) 3 years ago
Omnikar e91d357fae
Macros (#1234)
* 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
3 years ago
Oskar Nehlin a06871a689
feat: Make it possible to keybind `TypableCommands` (#1169)
* Make TypableCommands mappable

* Fix pr comments

* Update PartialEq implementation
3 years ago
Blaž Hrastnik 34f46e7502 Bump rust to 1.57, fix new lint failures 3 years ago
Blaž Hrastnik dfd499f5a9 dap: Highlight line of current stack frame 3 years ago
Blaž Hrastnik c955eaa6cd Revert "Improve dedent behavior, make kill_to_line_end behave like emacs (#1173)"
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.
3 years ago
Blaž Hrastnik 259678585c ui: Optimize tree-sitter style lookups
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.
3 years ago
Blaž Hrastnik 7bbf4c5b06 ui: Only calculate span styling when it's actually in bounds 3 years ago
Blaž Hrastnik 96ae5897a1 Remove another parameter from render_view 3 years ago
Blaž Hrastnik 30ac5869df dap: Extract diagnostics gutter into gutters.rs 3 years ago
Blaž Hrastnik 8ffafb826f dap: Rewrite breakpoints so that there's a single set maintained 3 years ago
Blaž Hrastnik 3633f85b38 Pass editor into render_view & gutter, reducing the number of params 3 years ago
WindSoilder c08d2fae58
Improve dedent behavior, make kill_to_line_end behave like emacs (#1173)
* 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
3 years ago
Blaž Hrastnik 9ed930b233 Merge remote-tracking branch 'origin/master' into debug 3 years ago
Blaž Hrastnik 225e8ccf31 Extract gutters into helix-view 3 years ago
Blaž Hrastnik 27c1a84f05 Reuse a text buffer for each gutter line 3 years ago
Blaž Hrastnik ba45db84d4 Tie the GutterFn lifetime to the doc so we can avoid cloning data 3 years ago
Blaž Hrastnik 30171416cb Gutter functions 3 years ago
Gokul Soumya 7961355ba1 Change cursor shape on mode change
Fixes #323. Due to terminal limitations we can only
change the shape of the primary cursor.
3 years ago