Commit Graph

130 Commits (6ae0186ef19f7ce193e533257602af92990853a4)

Author SHA1 Message Date
paul-scott ce1fb9e64c
Generalised to multiple runtime directories with priorities (#5411)
* Generalised to multiple runtime directories with priorities

This is an implementation for #3346.

Previously, one of the following runtime directories were used:

1. `$HELIX_RUNTIME`
2. sibling directory to `$CARGO_MANIFEST_DIR`
3. subdirectory of user config directory
4. subdirectory of path to helix executable

The first directory provided / found to exist in this order was used as a
root for all runtime file searches (grammars, themes, queries).

This change lowers the priority of `$HELIX_RUNTIME` so that the user
config runtime has higher priority. More significantly, all of these
directories are now searched for runtime files, enabling a user to override
default or system-level runtime files. If the same file name appears
in multiple runtime directories, the following priority is now used:

1. sibling directory to `$CARGO_MANIFEST_DIR`
2. subdirectory of user config directory
3. `$HELIX_RUNTIME`
4. subdirectory of path to helix executable

One exception to this rule is that a user can have a `themes`
directory directly in the user config directory that has higher piority
to `themes` directories in runtime directories. That behaviour has been
preserved.

As part of implementing this feature `theme::Loader` was simplified
and the cycle detection logic of the theme inheritance was improved to
cover more cases and to be more explicit.

* Removed AsRef usage to avoid binary growth

* Health displaying ;-separated runtime dirs

* Changed HELIX_RUNTIME build from src instructions

* Updated doc for more detail on runtime directories

* Improved health symlink printing and theme cycle errors

The health display of runtime symlinks now prints both ends of the
link.

Separate errors are given when theme file is not found and when the
only theme file found would form an inheritence cycle.

* Satisfied clippy on passing Path

* Clarified highest priority runtime directory purpose

* Further clarified multiple runtime details in book

Also gave markdown headings to subsections.

Fixed a error with table indentation not building
table that also appears present on master.

---------

Co-authored-by: Paul Scott <paul.scott@anu.edu.au>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
1 year ago
Pascal Kuthe 6ed2348078
Hide duplicate symlinks from the picker (#5658)
* hide duplicate symlinks from the picker

* Apply suggestions from code review

Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com>

* minor stylistic fix

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

---------

Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Pascal Kuthe 4dcf1fe66b
rework positioning/rendering and enable softwrap/virtual text (#5420)
* rework positioning/rendering, enables softwrap/virtual text

This commit is a large rework of the core text positioning and
rendering code in helix to remove the assumption that on-screen
columns/lines correspond to text columns/lines.

A generic `DocFormatter` is introduced that positions graphemes on
and is used both for rendering and for movements/scrolling.
Both virtual text support (inline, grapheme overlay and multi-line)
and a capable softwrap implementation is included.

fix picker highlight

cleanup doc formatter, use word bondaries for wrapping

make visual vertical movement a seperate commnad

estimate line gutter width to improve performance

cache cursor position

cleanup and optimize doc formatter

cleanup documentation

fix typos

Co-authored-by: Daniel Hines <d4hines@gmail.com>

update documentation

fix panic in last_visual_line funciton

improve soft-wrap documentation

add extend_visual_line_up/down commands

fix non-visual vertical movement

streamline virtual text highlighting, add softwrap indicator

fix cursor position if softwrap is disabled

improve documentation of text_annotations module

avoid crashes if view anchor is out of bounds

fix: consider horizontal offset when traslation char_idx -> vpos

improve default configuration

fix: mixed up horizontal and vertical offset

reset view position after config reload

apply suggestions from review

disabled softwrap for very small screens to avoid endless spin

fix wrap_indicator setting

fix bar cursor disappearring on the EOF character

add keybinding for linewise vertical movement

fix: inconsistent gutter highlights

improve virtual text API

make scope idx lookup more ergonomic

allow overlapping overlays

correctly track char_pos for virtual text

adjust configuration

deprecate old position fucntions

fix infinite loop in highlight lookup

fix gutter style

fix formatting

document max-line-width interaction with softwrap

change wrap-indicator example to use empty string

fix: rare panic when view is in invalid state (bis)

* Apply suggestions from code review

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

* improve documentation for positoning functions

* simplify tests

* fix documentation of Grapheme::width

* Apply suggestions from code review

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

* add explicit drop invocation

* Add explicit MoveFn type alias

* add docuntation to Editor::cursor_cache

* fix a few typos

* explain use of allow(deprecated)

* make gj and gk extend in select mode

* remove unneded debug and TODO

* mark tab_width_at #[inline]

* add fast-path to move_vertically_visual in case softwrap is disabled

* rename first_line to first_visual_line

* simplify duplicate if/else

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 year ago
Dylan Bulfin c4b0eb8356
Fix autocompletion for paths with period (#5175)
* Bug fix

Updated bug fix

* Simplified conditionals

* Switched to use path separator constant
1 year ago
Alex Kladov e6a2df8c79
Better sorting in picker in case of ties (#5169) 1 year ago
Gokul Soumya 914d294499 Add DynamicPicker for updating options on every key 1 year ago
Pascal Kuthe 70d78123b9
properly handle detachted git worktrees (#5097) 1 year ago
Tshepang Mbambo a8a54be6bc
Fix nightly clippy lints (#4954) 2 years ago
A-Walrus 2f9ca3840a
Add preview for scratch buffers in buffer picker (#3454) 2 years ago
Matthias Deiml dee5b2a983
Add LSP workspace command picker (#3140)
* Add workspace command picker

* Make command typable

* Add optional argument to lsp-workspace-command
2 years ago
Skyler Hawthorne 8c667ef8de factor editor event handling into function 2 years ago
Pascal Kuthe 7af599e0af Treat space as a seperator instead of a character in fuzzy picker 2 years ago
A-Walrus f3958aa1fd
Cycled to end/beginning + no more matches msgs (#3176)
* Show status msg when next/prev cycles around

* Add msg when there is no wraparound

* Cleanup code

* Change msg to "Wrapped around document"
2 years ago
A-Walrus 57dc5fbe3a
Show "Invalid regex" message on enter (Validate) (#3049)
* Show "Invalid regex" message on enter (Validate)

* Reset selection on invalid regex

* Add popup for invalid regex

* Replace set_position with position

* Make popup auto close
2 years ago
A-Walrus cc47d3fb9d Add `text` to language completer 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
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).
2 years ago
ChrHorn a7ff39fe3e
remove duplicate entries from theme picker (#3439) 2 years ago
A-Walrus 6b84344e20
Add completion for nested settings (#3183)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
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
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
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
Michael Jones d8abd1eaf3
Sort themes, language & files by score & then name (#2675)
* Sort themes by score & then name

Previously the themes were appearing unordered after typing ':theme '.
This sorts them first by fuzzy score and then by name so that they
generally appear in a more ordered fashion in the initial list.

The sort by name does not really pay off when there is a score so an
alternative approach would be to sort by name if there is string to
fuzzy match against and otherwise sort by score.

I've lowercased the names as that avoids lower case & upper case letters
being sorted into separate groups. There might be a preferable approach
to that though.

* Sort language & files by score then name

And change to use sort_unstable_by instead of sort_unstable_by_key as it
allows us to avoid some allocations.

I don't fully understand the flow of the 'filename_impl' function but
this seems to deliver the desired results.

* Remove unnecessary reference

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

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
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
Blaž Hrastnik 23b5b1e25a Remove a couple more unwraps 2 years ago
Skyler Hawthorne ed950fcc56 Add more context; Editor::open doesn't need to own path 2 years ago
Roland Kovacs c2cc2037b5
Better handling of symlinks (#2718)
- Add file-picker.follow-symlinks configuration option (default is true), this
  also controls if filename and directory completers follow symlinks.

- Update FilePicker to set editor error if opening a file fails, instead of
  panicing.

Fix #1548
Fix #2246
2 years ago
Blaž Hrastnik b14c258a2c
prompt: If submitting empty prompt, use default (last used) 2 years ago
Roland Kovacs d962e06e91
Add runtime language configuration (#1794) (#1866)
* Add runtime language configuration (#1794)

* Add set-language typable command to change the language of current buffer.
* Add completer for available language options.

* Update set-language to refresh language server as well

* Add language id based config lookup on `syntax::Loader`.
* Add `Document::set_language3` to set programming language based on language
  id.
* Update `Editor::refresh_language_server` to try language detection only if
  language is not already set.

* Remove language detection from Editor::refresh_language_server

* Move document language detection to where the scratch buffer is saved.
* Rename Document::set_language3 to Document::set_language_by_language_id.

* Remove unnecessary clone in completers::language
2 years ago
Blaž Hrastnik 96a4eb8483
Remove more push_layer calls 2 years ago
Blaž Hrastnik 5c162ef995
Make regex_prompt directly call cx.push_layer 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
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
Michael Davis 4fc991fdec migrate grammar fetching/building code into helix-loader crate
This is a rather large refactor that moves most of the code for
loading, fetching, and building grammars into a new helix-loader
module. This works well with the [[grammars]] syntax for
languages.toml defined earlier: we only have to depend on the types
for GrammarConfiguration in helix-loader and can leave all the
[[language]] entries for helix-core.
2 years ago
Blaž Hrastnik 78fba8683b
Picker performance improvements 2 years ago
Philipp Mildenberger 49c5bc5934
Add jumplist support for the search (closes #1625) (#1718) 2 years ago
Daniel S Poulin bdbf423876
Minor cleanup of file picker file gathering logic (#1683)
* Refactor file picker filetype filter logic to remove panic, make clearer

An unwrap was unneccesarily present due to a prior contribution of mine
which was before I had any understanding of error handling in Rust. I've
also swapped a match for an if let, as was originally suggested in the
original pull request adding filetype filtering, but was merged before I
could address.

* Add some comments to the file picker code for clarity

* Switch to expect instead of ignoring type def error
2 years ago
Daniel S Poulin 700058f433
Always ignore the .git directory in file picker (#1604)
Some users (including myself) want to turn off filtering of files
prefixed with `.`, as they are often useful to edit. For example, `.env`
files, configuration for linters `.eslint.json` and the like.
2 years ago
Blaž Hrastnik c06155ace4 Extract a helper function for lsp::Location 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 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
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
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
Blaž Hrastnik 094a0aa3f9 Render code actions as a menu, allow adding padding to popup 2 years ago
Blaž Hrastnik 3e4f81547c fix: Use std::path::MAIN_SEPARATOR to determine completion
Refs #1439
2 years ago