Commit graph

1326 commits

Author SHA1 Message Date
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
2022-02-10 11:04:40 +09:00
Gokul Soumya
bf773db451 Show infobox with register contents 2022-02-10 10:52:06 +09:00
Gokul Soumya
5995568c1d Prevent multiple code action popups 2022-02-08 16:44:39 +09:00
Gokul Soumya
547c3ecd0c Preselect first item in code action popup menu 2022-02-08 16:44:39 +09:00
Gokul Soumya
e90276df0b Replace if let with early return 2022-02-08 16:44:39 +09:00
Blaž Hrastnik
23553bd37c Update dependencies (crossterm 0.23, tree-sitter 0.20.4)
Fixes #677
2022-02-07 10:47:57 +09:00
Blaž Hrastnik
e7f5ec5561 fix: There is no such thing as markup.normal, use ui.text 2022-02-07 10:30:03 +09:00
Blaž Hrastnik
6ea477ab60 Don't use block_on in jobs.finish(), we can .await 2022-02-05 15:05:19 +09:00
Blaž Hrastnik
d3221b03a2 fix: Only parse git revision, don't use the tag for version
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.
2022-02-03 01:19:44 +09:00
Blaž Hrastnik
36b975c4ce ui: menu: Don't allocate scrollbar space if options fit 2022-02-01 01:25:59 +09:00
Blaž Hrastnik
f10a06f4de ui: Only render menu scrollbar if it doesn't fit 2022-01-31 16:04:58 +09:00
Blaž Hrastnik
094a0aa3f9 Render code actions as a menu, allow adding padding to popup 2022-01-31 16:04:58 +09:00
Blaž Hrastnik
f7f55143a1 Improve code action picker by displaying it inline 2022-01-31 16:04:58 +09:00
Blaž Hrastnik
62561e9d23 Stop collecting highlight_iter events then turning back into iter 2022-01-30 22:38:44 +09:00
Blaž Hrastnik
5aead46f4b Remove some unnecessary clippy tags 2022-01-30 22:38:44 +09:00
Blaž Hrastnik
2a7ae963e1 Automatically commit changes to history if not in insert mode
Fixes #1500
2022-01-30 22:38:44 +09:00
CossonLeo
d49e5323f9
Use markup scopes for the Markdown component (#1363) 2022-01-24 10:41:25 +09:00
Benjamin
4044c70eb2
Fix picker won't scroll down when it hits the bottom #1544 (#1567) 2022-01-23 23:06:28 +09:00
Ivan Tham
759b850859
Allow specifying file start position (#445)
Like helix-term/src/commands.rs:3426:15
2022-01-23 16:54:03 +09:00
Blaž Hrastnik
e2d2f19fd0
Merge pull request #1154 from sudormrfbin/cursor-shape-new
Change cursor shape on mode change
2022-01-23 16:35:22 +09:00
Blaž Hrastnik
add3be8528 Slicing micro-optimization 2022-01-23 16:04:26 +09:00
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%.
2022-01-23 16:04:12 +09:00
Blaž Hrastnik
53d881f172 Store theme scopes on the loader, this way theme isn't passed around 2022-01-23 16:00:24 +09:00
Blaž Hrastnik
6728e44490 syntax: Split parsing and highlighting 2022-01-23 16:00:24 +09:00
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'
2022-01-21 23:15:35 +09:00
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
2022-01-21 00:52:33 +09:00
Skyler Hawthorne
96d4ca5f73
Dependabot/cargo/pulldown cmark 0.9.1 (#1533)
* build(deps): bump pulldown-cmark from 0.8.0 to 0.9.1

Bumps [pulldown-cmark](https://github.com/raphlinus/pulldown-cmark) from 0.8.0 to 0.9.1.
- [Release notes](https://github.com/raphlinus/pulldown-cmark/releases)
- [Commits](https://github.com/raphlinus/pulldown-cmark/compare/v0.8.0...v0.9.1)

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

Signed-off-by: dependabot[bot] <support@github.com>

* cmark 0.9 fixes

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-18 09:41:44 +08:00
Blaž Hrastnik
e7eab95b94 Update to rust 1.58, fix a bunch of optional lints 2022-01-16 14:19:48 +09:00
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>
2022-01-16 10:55:28 +09:00
WindSoilder
22297d0b40
Add alt-backspace, alt-<, alt->, ctrl-j to insert mode (#1441)
* add alt-backspace keymap to delete word backward

* add more useful keymap

* map to correct command

* add C-j to insert_newline
2022-01-16 10:41:21 +09:00
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
2022-01-16 10:39:49 +09:00
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'
2022-01-16 10:26:09 +09:00
Kevin Sjöberg
3a34036310
Use the correct language ID for JavaScript & TypeScript (#1466)
* Use correct language ID for JavaScript/TypeScript

* Add missing slash

* Only calculate fallback when needed
2022-01-15 15:23:06 +09:00
Mathis Brossier
85cf2648a2
buffer picker allow hsplit / vsplit (#1502) 2022-01-14 15:32:24 +09:00
Gokul Soumya
b3b4e78585 Merge branch 'master' into cursor-shape-new 2022-01-09 10:38:58 +05:30
Benoît Cortier
05e5520ec0
Put some tests behind #[cfg(test)] (#1459)
It was missing in a few places.
2022-01-09 00:32:50 +09:00
Gokul Soumya
449624965b Merge branch 'master' into cursor-shape-new 2022-01-06 11:32:03 +05:30
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
2022-01-06 11:12:02 +09:00
Blaž Hrastnik
3e4f81547c fix: Use std::path::MAIN_SEPARATOR to determine completion
Refs #1439
2022-01-06 11:03:54 +09:00
Stuart Hinson
b18bda928f
fix slash in search selector status message (#1449) 2022-01-06 10:39:19 +09:00
Blaž Hrastnik
7767703979 fix: Only use shellwords parsing on unix platforms 2022-01-05 11:01:30 +09:00
Blaž Hrastnik
bed9aced5f Revert "Convert Windows style path separator in completers to Unix style (#1389)"
This reverts commit 49444f9c05.
2022-01-05 10:58:12 +09:00
Blaž Hrastnik
efaac6c5d3 Release 0.6 2022-01-04 18:54:37 +09:00
Mathis Brossier
dbaed0ba83
scroll: change only main selection, only when needed (#1420)
Co-authored-by: mathis <mathis.brossier@universite-paris-saclay.fr>
2022-01-03 11:50:53 +09:00
Omnikar
ed97ecceb8
Add :cquit! command and prevent :cquit from ignoring unsaved changes (#1414)
* Add `:cquit!` command and prevent `:cquit` from ignoring unsaved changes

* `cargo xtask docgen`
2022-01-03 11:31:24 +09:00
Triton171
4da050b4bb
Add basic indentation for languages without treesitter-based indentation rules (always use the indent of the current line for a new line). (#1341)
Fix several bugs in the treesitter indentation calculation.

Co-authored-by: Triton171 <triton0171@gmail.com>
2022-01-03 11:03:57 +09:00
Kirawi
93a948d889
switch redundant current! usage to doc! (#1416) 2022-01-03 10:46:57 +09:00
Alexis Mousset
8a019b423f
Detect workspace root using language markers (#1370)
* Detect workspace root using language markers

* Avoid allocating root_markers

* Update helix-core/src/lib.rs

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

* Update helix-core/src/lib.rs

Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com>

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com>
2021-12-31 17:06:54 +09:00
Blaž Hrastnik
a066f59dc8 Don't just filter commands by fuzzy match, also order the matches 2021-12-30 15:20:22 +09:00
ath3
49444f9c05
Convert Windows style path separator in completers to Unix style (#1389) 2021-12-30 00:30:20 +09:00
WindSoilder
f1ed042c84
Fix: when goto normal mode, only want to remove indentation if the line is blank with no text following (#1349)
* when opened new line contains other characters after current position, don't dedent

* abstract checking logic
2021-12-29 18:21:20 +09:00
Stuart Hinson
34db33e1dc
Use a fuzzy matcher for commands (#1386)
* Use a fuzzy matcher for commands

* Take Clippy up on its suggestion

* Rescope FUZZY_MATCHER
2021-12-29 18:18:17 +09:00
Matouš Dzivjak
bd2ab5be43
feat(commands): ensure_selections_forward (#1393)
* 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
2021-12-29 18:17:46 +09:00
Omnikar
5b69e9b466
Fix indentation (#1387) 2021-12-28 08:03:14 +09:00
Matouš Dzivjak
a4641a8613
feat(commands): sort command (#1288)
* feat(commands): sort/rsort  command

Add basic implementation of sort command.

* Sort by selections instead, implement reverse sort

* Generate docs

* Rename sort! to rsort
2021-12-27 13:11:06 +09:00
Omnikar
8340d73545 Extract macro parsing to helix-view and add unit tests 2021-12-27 10:13:18 +09:00
Omnikar
2d4bc0aec7 Change how macros separate keypresses
* Keypresses are no longer separated by spaces
* Single-character keypresses are serialized as-is
* Multi-character keypresses are delimited by `<>`
2021-12-27 10:13:18 +09:00
Ivan Tham
ee3eb4057a Update macro display as [q] in message 2021-12-27 10:13:18 +09:00
Ivan Tham
b9cb3930e2 Mark macros as experimental in docs
Given that currently macro does not integrate well with registers and
the internal representation of macros is expected to be changed.
2021-12-27 10:13:18 +09:00
Ivan Tham
9a32617b30 Rename play macro to replay macro
Macro needs to be defined first before playing so replay is more accurate.
Also, replay have the same length as record which makes it looks nice.
2021-12-27 10:13:18 +09:00
Ivan Tham
5326a05117 Improve macro error handling 2021-12-27 10:13:18 +09:00
Ivan Tham
c7a59e24e6 Switch macro Q and q 2021-12-27 10:13:18 +09:00
Tamo
a306a1052a
Update settings at runtime (#798)
* 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
2021-12-26 10:04:33 +09:00
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.
2021-12-26 00:10:46 +09:00
Gabriel Berto
5d7b5db8ab
Resolve completion item (#1315)
Co-authored-by: Gabriel Berto <gabriel.berto@pottencial.com.br>
2021-12-25 19:00:57 +09:00
Matouš Dzivjak
0e7d757869
feat(lsp): configurable diagnostic severity (#1325)
* 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
2021-12-25 14:32:43 +09:00
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>
2021-12-25 14:24:29 +09:00
Gokul Soumya
c0bbadcaaf Manually draw all block cursors 2021-12-23 11:56:52 +05:30
Matouš Dzivjak
75a8b789d2
LSP code action commands (#1304)
* feat(lsp): codeAction commands

* Don't block on command call

* Fix lifetime of command execution

* Fix lint issues
2021-12-21 18:21:45 +09:00
WindSoilder
600ce70cf6
Improve dedent behavior (#1232)
* 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
2021-12-21 18:17:55 +09:00
dependabot[bot]
5dfdc95f6f
build(deps): bump once_cell from 1.8.0 to 1.9.0 (#1322)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.8.0...v1.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-21 08:48:53 +09:00
Ivan Tham
f174d27d0d
Change text for gg to explain <n>gg (#1287) 2021-12-18 20:28:17 +05:30
Kirawi
02fc52f6d5
Apply recent nightly suggestions (#1286)
array iterators are now implicit
2021-12-18 14:57:49 +09:00
Gokul Soumya
d4fb1d0633 Merge branch 'master' into cursor-shape-new 2021-12-18 08:33:15 +05:30
Gokul Soumya
016640f4fb Remove ui.cursor.primary and hashmap lookups 2021-12-18 08:26:11 +05:30
Omnikar
6da2174e14
Allow paste commands to take a count (#1261)
* Allow paste commands to take a count

* Call `.repeat` within iterator methods

* Implement counts for paste-replace
2021-12-14 17:49:29 +09:00
Midnight Exigent
e188926138
Fix panic when scrolling through completion popup (#1260)
* fix(completion_popup): Fixes #1256

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

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2021-12-14 10:14:23 +09:00
Skyler Hawthorne
94535fa013
Add auto pairs for same-char pairs (#1219)
* 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
2021-12-14 00:58:58 +09:00
Blaž Hrastnik
730d3be201 Add ui.gutter to theme all gutters (i.e. set bg) 2021-12-14 00:52:15 +09:00
Omnikar
cce34feb4e Assume true color support on Windows 2021-12-14 00:48:45 +09:00
Omnikar
98ce2a301d Load alt default theme if true color is not supported
* 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`
2021-12-14 00:47:18 +09:00
Blaž Hrastnik
7ad8eaaef0 wip 2021-12-14 00:41:51 +09:00
Blaž Hrastnik
b25d453f64 minor: Shorten goto file(s) descriptions 2021-12-13 14:36:53 +09:00
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
2021-12-12 21:16:48 +09:00
ath3
3156577fbf
Open files with spaces in filename, allow opening multiple files (#1231) 2021-12-12 21:13:33 +09:00
Blaž Hrastnik
3307f44ce2 ui: popup: Don't allow scrolling past the end of content 2021-12-10 19:23:58 +09:00
Omnikar
b66d3d3d9d
Add save_selection command (#1247) 2021-12-10 11:46:24 +09:00
Omnikar
44681c5057
Add default-run = "hx" to helix-term/Cargo.toml (#1244)
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`.
2021-12-10 11:04:31 +09:00
Blaž Hrastnik
df3b88387b dap: Improve variables UI 2021-12-09 11:28:53 +09:00
Blaž Hrastnik
dac317e620 TODO 2021-12-09 10:55:32 +09:00
Blaž Hrastnik
60c86eff89 dap: Simplify a few more statements that could use the debugger macro 2021-12-09 10:55:32 +09:00
Kirawi
29c053e84e
Only use a single documentation popup (#1241) 2021-12-08 16:11:18 +09:00
Gokul Soumya
71292f9f11 docs: Auto generate command list 2021-12-08 10:23:50 +09:00
Blaž Hrastnik
d8351d35ab dap: Extract a macro that fetches a debugger or returns 2021-12-08 00:59:11 +09:00
Blaž Hrastnik
e98993d609 dap: Fix an off-by-one error when jumping 2021-12-08 00:22:48 +09:00
WindSoilder
93e276cd9d
Make kill_to_line_end behave like emacs (#1235) 2021-12-07 01:44:04 +09:00
Blaž Hrastnik
cab09093dd fix: Normalize backtab into shift-tab
Fixes #1150
2021-12-06 12:25:19 +09:00
Blaž Hrastnik
bf8437d098 clippy lint 2021-12-06 09:36:02 +09:00
Blaž Hrastnik
dc8df7ba21 Make thread_picker non-blocking 2021-12-06 09:35:59 +09:00
Blaž Hrastnik
2b4de41bf0 dap: Reply to RunInTerminal 2021-12-06 09:32:21 +09:00