Commit graph

1642 commits

Author SHA1 Message Date
A-Walrus
75e6a64327 Switch to Result for invalid language 2022-09-10 22:23:38 +09:00
A-Walrus
e8add6f46d Add error handling to set language command
If you type a nonexistant language an appropriate message will show,
and the language won't be changed.
2022-09-10 22:23:38 +09:00
A-Walrus
cc47d3fb9d Add text to language completer 2022-09-10 22:23:38 +09:00
Skyler Hawthorne
e12690e2f5 Remove default insert mode movement bindings
Helix is first and foremost a modal editor. Willingness to support non-modal
editing is there, but it is not one that should be encouraged with the default
settings. There are an increasing number of users who are stumbling because
they are trying to use Helix as a non-modal editor, so this is an effort to
encourage new users to stop and take notice that Helix has a different paradigm
than VSCode, Sublime, etc. Users can still add these bindings back to their own
configs if they wish.
2022-09-08 17:36:04 -05:00
A-Walrus
e14b48af2e
Fix :reflow panic by enusring cursor in view (#3733) 2022-09-07 12:50:54 -05:00
Blaž Hrastnik
a123fb6057
Remove LspNotDefined, instead return an Option<> 2022-09-07 16:42:33 +09:00
dependabot[bot]
5e1296b888
build(deps): bump once_cell from 1.13.1 to 1.14.0 (#3715)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-05 18:33:01 -05:00
Blaž Hrastnik
1acdfaa073
fix: View needs to retain the original scroll offset on split 2022-09-05 11:58:00 +09:00
Michael Davis
9c3c6a1c22
Fix off-by-one in extend_line_above (#3689)
`extend_line_above` (and `extend_line` when facing backwards) skip
a line when the current range does not fully cover a line.

Before this change:

    foo
    b#[|a]#r
    baz

With `extend_line_above` or `extend_line` selected the line above.

    #[|foo
    bar]#
    baz

Which is inconsistent with `extend_line_below`. This commit changes
the behavior to select the current line when it is not already
selected.

    foo
    #[|bar]#
    baz

Then further calls of `extend_line_above` extend the selection up
line-wise.
2022-09-05 11:34:49 +09:00
Blaž Hrastnik
44b447947c
fix: lsp: Don't send didOpen events for documents with no URL
Fixes #3683
2022-09-04 17:28:17 +09:00
Blaž Hrastnik
cc4b71274a
minor: Simplify another document_mut statement 2022-09-04 17:27:15 +09:00
A-Walrus
c93d52cc8a
Fix cargo doc warnings, and add GitHub action to ensure it (#3650) 2022-09-03 09:58:16 -05:00
Blaž Hrastnik
6ec4017a8d
Expand doc/view macros to allow fetching specific id
This simplifies the code and hides away unwraps
2022-09-03 12:36:06 +09:00
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>
2022-09-02 11:39:38 +09:00
A-Walrus
45dbcb6783
Fix closing buffer with custom keymap (#3633)
* Fix closing buffer with custom keymap

* Add comment explaining if
2022-09-02 01:59:39 +09:00
Blaž Hrastnik
5c2b77b41f
Make mode editor-wide rather than per-document 2022-09-01 16:14:38 +09:00
Saber Haj Rabiee
1cbf552554
fix: prevents storing last prompt if is top of stack (#3609) 2022-09-01 10:29:15 +09:00
Michael Davis
7c34f20dca
Fix Prompt::handle_event compilation 2022-08-31 11:37:17 -05:00
Frojdholm
4c9f144dac
fix: Recalculate completion when going through prompt history (#3193)
* fix: Recalculate completion when going through prompt history

* Update completion when the prompt line is changed

It should not be possible to update the line without also updating the
completion since the completion holds an index into the line.

* Fix Prompt::with_line recalculate completion

with_line was the last function where recalculate completion had to be
done manually. This function now also recalculates the completion so
that it's impossible to forget.

* Exit selection when recalculating completion

Keeping the selection index when the completion has been recalculated
doesn't make sense. This clears the selection automatically, removing
most needs to manually clear it.

* Remove &mut on save_filter

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-09-01 01:26:21 +09:00
Gokul Soumya
e3e71fa36b
Show clipboard info in --health output (#2947)
* Show clipboard info in --health output

* health: Separate 'languages' category from 'all'

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2022-09-01 01:23:45 +09:00
Charlie Groves
5c3f43a7f0
Share the restore_term code between panic and normal exits (#3612)
It was starting to diverge as the normal exit code was restoring the prompt but the panic code
wasn't, and the panic code was disabling bracketed paste but the normal code wasn't.

This changes the panic path slightly in that we won't disable raw mode if exiting alternate screen
and disabling bracketed paste fails. If that happens, things are so busted I don't think it matters
anyway.
2022-09-01 01:23:21 +09:00
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.
2022-09-01 01:20:55 +09:00
Michael Davis
83f177d270
Refactor goto_ts_object_impl as a motion (#3264)
This refactor changes the overall structure of the goto_ts_object_impl
command without removing any functionality from its behavior. The
refactored motion:

* acts on all selections instead of reducing to one selection
* may be repeated with the `repeat_last_motion` (A-.) command
* informs the user when the syntax-tree is not accessible in the current buffer
2022-08-31 17:48:33 +09:00
Michael Davis
7547a961bb
Discard LSP publishDiagnostic when LS is not initialized (#3403)
This is invalid according to the [LSP spec]:

> In addition the server is not allowed to send any requests
> or notifications to the client until it has responded with an
> InitializeResult, with the exception that during the initialize
> request the server is allowed to send the notifications
> window/showMessage, window/logMessage and telemetry/event as well
> as the window/showMessageRequest request to the client.

So we should discard the message when the language server is not
yet initialized. This can happen if the server sends
textDocument/publishDiagnostics before responding to the initialize
request. clojure-lsp appears to exhibit this behavior in the wild.

[LSP Spec]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initialize
2022-08-31 17:47:18 +09:00
Michael Davis
701cea54d2
jumplist: Add documents to view history (#3593)
This change adds documents to the view's document history Vec.
(This is used by `ga` for example to access the last buffer.)

Previously, a sequence like so would have confusing behavior:

1. Open file A: any document with an active language server
2. Find some definition that lives in another file - file B - with `gd`
3. Jump back in the jumplist with `C-o` to file A
4. Use `ga` intending to switch back to file B

The behavior prior to this change was that `ga` would switch to file
A: you could not use `ga` to switch to file B.
2022-08-31 10:45:47 +09:00
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>
2022-08-31 10:44:06 +09:00
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.
2022-08-31 10:34:04 +09:00
Blaž Hrastnik
e77b7d147c
fix: Recalculate completion after pasting into prompt 2022-08-30 12:27:04 +09:00
Blaž Hrastnik
8a4fbf6daf
completion: remove_follow links on filename_impl
We don't need to follow links since we're only scanning the current
directory level (non-recursive).
2022-08-30 12:23:49 +09:00
PiergiorgioZagaria
d2cec25395
Fix process spawning error handling (#3349)
* Fix process spawning error handling

* Log stderr in any case
2022-08-30 11:02:34 +09:00
Michael Davis
5f043dde56
Derive Document language name from languages.toml name key (#3338)
* Derive Document language name from `languages.toml` `name` key

This changes switches from deriving the language name from the
`languages.toml` `scope` key to `name` (`language_id` in the
`LanguageConfiguration` type). For the most part it works to derive the
language name from scope by chopping off `source.` or `rsplit_once` on
`.` but for some languages we have now like html (`text.html.basic`),
it doesn't. This also should be a more accurate fallback for the
`language_id` method which is used in LSP and currently uses the
`rsplit_once` strategy.

Here we expose the language's name as `language_name` on `Document` and
replace ad-hoc calculations of the language name with the new method.

This is most impactful for the `file-type` statusline element which is
using `language_id`.

* Use `Document::language_name` for the `file-type` statusline element

The `file-type` indicator element in the statusline was using
`Document::language_id` which is meant to be used to for telling
Language Servers what language we're using. That works for languages
with `language-server` configurations in `languages.toml` but shows
text otherwise. The new `Document::language_name` method from the
parent commit is a more accurate way to determine the language.
2022-08-30 10:59:45 +09:00
Bob
411c5e4871
let extend-line respect range direction (#3046)
* let extend-line respect range direction

* fix extend above logic

* keep `x` existing binding

* Update book/src/keymap.md

Co-authored-by: Ivan Tham <pickfire@riseup.net>

Co-authored-by: Ivan Tham <pickfire@riseup.net>
2022-08-29 10:00:40 +09:00
Charlie Groves
f38ede8631
Add bracketed paste (#3233) 2022-08-29 09:48:49 +09:00
Clay
99b1e8ad89
Fix markdown indented code block rendering (#3503) 2022-08-24 09:12:04 +09:00
Blaž Hrastnik
e4c9d4082a
fix: Reset document mode when losing focus
Fixes #3090
2022-08-23 14:07:50 +09:00
Blaž Hrastnik
7b8e4ac95a
Editor: remove duplication for view focus/swap commands 2022-08-23 11:44:10 +09:00
Ivan Tham
dd2b9e55a2 Reduce health tick width
Use the same tick as book to reduce margin of whitespace errors.
2022-08-22 19:27:26 -05:00
Charlie Groves
18909aafe2
Update to crossterm-0.25 (#3390) 2022-08-22 10:29:30 +09:00
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.
2022-08-21 13:54:02 +09:00
Saber Haj Rabiee
1577a9d0ab
style: fixes unused_parens warnings on nightly builds (#3471) 2022-08-18 18:07:18 -05:00
Daniel S Poulin
7711db3a3a
Adjust m textobject description and minor code clarification (#3343)
* Update description of `m` textobject to its actual functionality

Sometime recently the functionality of `m` was changed to match the
nearest pair to the cursor, rather than the former functionality of
matching the pair only if the cursor was on one of the brace characters
directly.

* Rename surround methods to reflect that they work on pairs

The current naming suggests that they may work generally on any
textobject, whereas their implementation really focuses on pairs.

* Change description of m textobject to match actual functionality

The current implementation of `m` no longer merely looks at the pair
character the cursor is on, but actually will search for the pair
(defined in helix-core/src/surround.rs) that encloses the cursor, and
not the entire selection.

* Accept suggested wording change

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

* Prefix pair surround for consistency

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2022-08-17 10:41:59 +09:00
ChrHorn
a7ff39fe3e
remove duplicate entries from theme picker (#3439) 2022-08-16 00:18:04 +09:00
Kyle L. Davis
21f2affa16
Fix conditional setting of stdin handle on Windows (#3379)
* Revert 3121353c6a

* Switch to conditional compilation

* Run formatter

* Switch from conditional compilation to compile-time bool
2022-08-12 11:27:18 +09:00
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>
2022-08-09 10:31:26 +09:00
A-Walrus
6b84344e20
Add completion for nested settings (#3183)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2022-08-06 12:16:18 -05:00
Michael Davis
973c51c3e9
Remove C-n and C-p from the insert mode keymap (#3340)
These are read-line-like bindings which we'd like to minimize in
insert mode in general.

In particular these two are troublesome if you have a low
`editor.idle-timeout` config and are using LSP completions: the
behavior of C-n/C-p switches from moving down/up lines to moving
down/up the completion menu, so if you hit C-n too quickly
expecting to be in the completion menu, you'll end up moving down
a line instead. Using C-p moves you back up the line but doesn't
re-trigger the completion menu. This kind of timing related change
to behavior isn't realistically that big of a deal but it can be
annoying.
2022-08-07 01:25:09 +09:00
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
2022-08-07 00:46:50 +09:00
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
2022-08-07 00:46:23 +09:00
Dario Oddenino
3121353c6a
Avoid setting stdin handle when not necessary (#3248)
* Avoid setting stdin handle when not necessary

Avoid setting the stdin handle in `shell_impl` when the input argument
is None.

This permits to run commands with no stdin with :sh

* refactoring to avoid code duplication

* making clippy happy

* Process variable name fix
2022-08-05 11:15:50 +09:00
Michael Davis
f32c05db85
Detect indent-style in :set-language (#3330)
Indent style may change when choosing a language with `:set-language`.
Line-endings most likely will not change, but `:set-language` should
have a similar effect as reloading a file (`:reload`), plus the two
are currently grouped in the implementation and line-ending detection
is not particularly expensive.
2022-08-05 09:11:31 +09:00