Commit Graph

160 Commits (9124c231f426318e970c62647c1ddabed3c9a389)

Author SHA1 Message Date
A-Walrus 1d8bb2249b
Change focus to modified docs on quit (#3872)
* Change focus to modified docs on quit

When quitting with modified documents, automatically switch focus to
one of them.

* Update helix-term/src/commands/typed.rs

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>

* Make it work with buffer-close-all and the like

* Cleanup

Use Cow instead of String, and rename DoesntExist -> DoesNotExist

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2 years ago
ath3 7c9809eeb2
Find workspace from document path (#3553) 2 years ago
Joe bcba5d67f9
Add goto preview (#2982) 2 years ago
Filipe Azevedo 385ccdfc9c
add :lsp-restart command (#3435) 2 years ago
Joe aa00a470f3
Fix preview bug (#3644)
* Fix preview bug

* Add comment to empty case
2 years ago
A-Walrus d38950bdf9
Remove border from code actions popup (#3444) 2 years ago
Blaž Hrastnik c2e41082e4
Remove the .txt suffix from tutor
The tutor file is loaded as .txt which can potentially spawn a
language server. Then the path is unset, but the LS remains active.
This can cause panics since updates are now submitted for a doc
with no path.

As a quick workaround we remove the extension which should avoid
detection.

Fixes #3730
2 years ago
A-Walrus 75e6a64327 Switch to Result for invalid language 2 years ago
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.
2 years ago
A-Walrus e14b48af2e
Fix :reflow panic by enusring cursor in view (#3733) 2 years ago
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>
2 years ago
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.
2 years ago
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.
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
Danilo Spinella 110eb73045
Add cwd parameter which is not optional anymore (#3240) 2 years ago
Gokul Soumya a8b123fe17
Fix byte index error in signature help highlighting
The language server sends a char offset range within the
signature help label text to highlight as the current parameter,
but helix uses byte offset ranges for rendering highlights. This
was brought up in the [review of the original signature help PR][1],
but the ranges were being highlighted correctly, and there were no
out of bound or indexing panics. Turns out rust-analyzer was
[incorrectly sending byte offsets] instead of char offsets and this
made it seem like all was well and good with offsets in helix during
initial testing.

[1]: https://github.com/helix-editor/helix/pull/1755#discussion_r906715371
[2]: https://github.com/rust-lang/rust-analyzer/pull/12272
2 years ago
Gokul Soumya de8ade8967
Shorten embedded command descriptions (#3070)
* Shorten embedded command descriptions

- Compact descriptions in command palette and infobox

* Shorten typed command descriptions

* Fix typo in decrement command description
2 years ago
Alexis Kalabura 8b2a14153b
add statusline element to display file line endings (#3113)
* add statusline element to display file line endings

* run cargo fmt --all

* change the word *ending* from plural to singular

* support for the unicode-lines feature flag
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
Bob e5c7aaed91
support prefilling prompt (#2459)
* support prefilling prompt

* introduce with_line builder method in Prompt

* extract show_prompt

* use textobject_word as fallback input
2 years ago
Gokul Soumya af35c62407 Show file path only in workspace diagnostic picker 2 years ago
Gokul Soumya a43bcc8765 Display error code only if not none 2 years ago
Gokul Soumya 2c37e25cb5 Display diagnostic text before code in picker 2 years ago
Gokul Soumya c4e022971d Remove source from diagnostic picker display
It is usually the name of the LSP and doesn't add much
useful information.
2 years ago
Joe b26e7e2e8f
Add live preview to theme picker (#1798)
* Add theme picker with live preview

* Add live theme preview to :theme command

* cargo fmt

* Fix clippy warnings

* Remove picker variant

* Remove unused import

* Cleanup

* Change current_theme to last_theme

* Fix accidental comment flash deletion

* Typo

* Remove theme cache

* Add some comments

* Refactor some theme handling

TIL flatmap on Option is called  and_then

* Remove unnecessary renames

* Constrain last_theme theme preview lifecycle

* Switch to bitflag implementation

* Better handling of last_theme

* Sort theme names

* Better memory juggling

* Missed a branch

* Remove name from theme, switch bitand to &

* cargo fmt

* Update helix-view/src/editor.rs

* Switch boolean to enum

* Remove bitflag impl

* cargo fmt

* Remove un-needed type arg

* cargo fmt
2 years ago
Gokul Soumya 6e2aaed5c2
Reuse menu::Item trait in picker (#2814)
* Refactor menu::Item to accomodate external state

Will be useful for storing editor state when reused by pickers.

* Add some type aliases for readability

* Reuse menu::Item trait in picker

This opens the way for merging the menu and picker code in the
future, since a picker is essentially a menu + prompt. More
excitingly, this change will also allow aligning items in the
picker, which would be useful (for example) in the command palette
for aligning the descriptions to the left and the keybinds to
the right in two separate columns.

The item formatting of each picker has been kept as is, even though
there is room for improvement now that we can format the data into
columns, since that is better tackled in a separate PR.

* Rename menu::Item::EditorData to Data

* Call and inline filter_text() in sort_text() completion

* Rename diagnostic picker's Item::Data
2 years ago
Falco Hirschenberger ed89f8897e
Add workspace and document diagnostics picker (#2013)
* Add workspace and document diagnostics picker

fixes #1891

* Fix some of @archseer's annotations

* Add From<&Spans> impl for String

* More descriptive parameter names.

* Adding From<Cow<str>> impls for Span and Spans

* Add new keymap entries to docs

* Avoid some clones

* Fix api change

* Update helix-term/src/application.rs

Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>

* Fix a clippy hint

* Sort diagnostics first by URL and then by severity.

* Sort diagnostics first by URL and then by severity.

* Ignore missing lsp severity entries

* Add truncated filepath

* Typo

* Strip cwd from paths and use url-path without schema

* Make tests a doctest

* Better variable names

Co-authored-by: Falco Hirschenberger <falco.hirschenberger@itwm.fraunhofer.de>
Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>
2 years ago
lazytanuki 096abdd19b
feat: highlight / select symbol under cursor using LSP textDocument/documentHighlight (#2738)
* feat: highlight symbol under cursor using LSP textDocument/documentHighlight

* fix: please clippy

* fix: shorter description and code style
2 years ago
Blaž Hrastnik 23b5b1e25a Remove a couple more unwraps 2 years ago
Blaž Hrastnik 19dccade7c
Merge pull request #2359 from dead10ck/test-harness
Integration testing harness
2 years ago
Gokul Soumya 8e8367eea6
Refactor Margin for fine grained control (#2727) 2 years ago
ath3 ce85b9716d
Enable shellwords for Windows (with escaping disabled) (#2767) 2 years ago
Skyler Hawthorne 41bf1d5811 fix(command): write-quit: do not quit if write fails
During write-quit, if the file fails to be written for any reason, helix
will still quit without saving the changes. This fixes this behavior by
introducing fallibility to the asynchronous job queues. This will also
benefit all contexts which may depend on these job queues.

Fixes #1575
2 years ago
Skyler Hawthorne ed950fcc56 Add more context; Editor::open doesn't need to own path 2 years ago
Gygaxis Vainhardt debd2405d9
views -> buffers in write-all (#2788) 2 years ago
Gokul Soumya e9283b20b4
Add docstring for language_server!() macro (#2750) 2 years ago
Blaž Hrastnik 26dbdb70fb
Refactor push_jump so we're not needlessly fetching doc twice 2 years ago
Termina94 f1ae496860
Add shell insert commands to typable and config (#2589)
* Add shell insert commands to typable and config

* generate docs

Co-authored-by: Dean Revell <revell@gmail.com>
2 years ago
Michael Davis 1c2aaf3baf
ensure :quit and :quit! take no arguments (#2654) 2 years ago
yzwduck d24ca66dbb
Avoid modifying jumplist until jumping to ref (#2670)
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.
2 years ago
Kirawi 4f3d0a7706
append `set_line_ending` to document history (#2649) 2 years ago
Blaž Hrastnik 378f438fb0
fix: lsp: be more defensive about URI conversions 2 years ago
Blaž Hrastnik 6de6a3edbb
fix: lsp: be more defensive about URI conversions 2 years ago
Ryan Russell ae12c58f0f
Improve Readability (#2639) 2 years ago
Leoi Hung Kin 5c864922d8
Fix panic when reloading a shrunk file (#2506)
* fix panic when reloading a shrunk file

* linting

* use scrolloff
2 years ago
amaihoefner a5bc69c2b5
feat(commands): add log-open command (#2422) 2 years ago
Ben Lee-Cohen 09a17e4fa3
Making the 'set-option' command help more descriptive. (#2365)
* Making the 'set-option' command help more descriptive.

* Adding the generated docs

* Making the message multi-line

* Replace newline with break in generated docs
2 years ago
unrelentingtech 20162a426b
feat(commands): make it possible to disable format-on-save via the 'auto-format' option (#2321) 2 years ago
Vince Mutolo f9baced216
add reflow command (#2128)
* 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>
2 years ago
Ryosuke Hayashi f85f0b7272
Add run-shell-command for Commands (#1682)
* 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>
2 years ago