Commit Graph

1402 Commits (d3c8286ea0c984f69bbab09a480530a827647192)

Author SHA1 Message Date
Michael Davis 08ee949dcb add 'use-grammars' to languages.toml
The vision with 'use-grammars' is to allow the long-requested feature
of being able to declare your own set of grammars that you would like.
A simple schema with only/except grammar names controls the list
of grammars that is fetched and built. It does not (yet) control which
grammars may be loaded at runtime if they already exist.
3 years ago
Michael Davis 00b2d616eb implement build_grammars and fetch_grammars
build_grammars adapts the functionality that previously came from
helix-syntax to be used at runtime from the command line flags.

fetch_grammars wraps command-line git to perform the same actions
previously done in the scripts in #1560.
3 years ago
Michael Davis 8330f6af20 add --fetch-grammars and --build-grammars CLI flags 3 years ago
Michael Davis eeb3f8e963 migrate helix-syntax crate into helix-core and helix-term
helix-syntax mostly existed for the sake of the build task which
checks and compiles the submodules. Since we won't be relying on
that process anymore, it doesn't end up making much sense to have
a very thin crate just for some functions that we could port to
helix-core.

The remaining build-related code is moved to helix-term which will
be able to provide grammar builds through the --build-grammars CLI
flag.
3 years ago
Joe 8d7a25b4d4
Add --edit-config flag to directly open config.toml (#1771)
Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
3 years ago
Emil Fresk bfa533fe78
Fix bug in LSP when creating a file in a folder that does not exist (#1775) 3 years ago
Gokul Soumya 194b09fbc1
Add --health command for troubleshooting (#1669)
* Move runtime file location definitions to core

* Add basic --health command

* Add language specific --health

* Show summary for all langs with bare --health

* Use TsFeature from xtask for --health

* cargo fmt

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
3 years ago
Daniel S Poulin 24352b2729
Add arrow key mappings for tree-sitter parent/child/sibling nav (#1724)
* Add arrow key mappings for tree-sitter parent/child/sibling nav

This helps my use case, where I use a non-qwerty layout with a
programmable mechanical keyboard, and use a layer switching key (think
fn) to send left down up right from the traditional hjkl positions.

* Add new bindings to docs
3 years ago
Gokul Soumya bde0307c87 Allow highlighting additional spans in md renderer 3 years ago
Gokul Soumya 970a111aa3 Extract markdown code block highlighting function 3 years ago
Blaž Hrastnik 5a60989efe
Bump dependencies 3 years ago
dependabot[bot] b67686d318
build(deps): bump once_cell from 1.9.0 to 1.10.0 (#1768)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.9.0 to 1.10.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.9.0...v1.10.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>
3 years ago
Gokul Soumya b0aaf08995
Change parameter object keybind from `p` to `a` (#1708)
This is largely to avoid a collision with the soon
to be merged paragraph object which takes up the p key.
3 years ago
Blaž Hrastnik 19247ff0ec
Split out typable commands into a separate file 3 years ago
Daniel S Poulin 9bfb0caf1b
Add comment textobject for surround selection and navigation (#1605) 3 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
3 years ago
Blaž Hrastnik 5d14f56fa9
Reuse visual_coords_at_pos function in view 3 years ago
Gokul Soumya 74a9dd51ff
Fallback to broader scope if theme scope not found (#1714) 3 years ago
Gokul Soumya c484b08923
Rename infobox theme scopes (#1741)
This makes it play nicely with https://github.com/helix-editor/helix/pull/1714
3 years ago
Blaž Hrastnik 0062af6a19
minor: Remove some outdated comments 3 years ago
Blaž Hrastnik 737282d0e9
Extract a common function for paste_before/_after 3 years ago
Blaž Hrastnik 68bad148a5
Extract idle timeout code into ui/editor.rs 3 years ago
Blaž Hrastnik 78fba8683b
Picker performance improvements 3 years ago
Blaž Hrastnik c0b86afdc8 Refactor align_selection by simplifying the calculation 3 years ago
Bob Qi 1c1aee74b4 refactor align_selection using kakoune logic 3 years ago
Gokul Soumya 5c810e5e52
Fix bug with auto replacing components in compositor (#1711)
* Fix bug with auto replacing components in compositor

This was last known to be working with 5995568c at the
time of commit, but now doesn't work with latest rust
stable.

The issue probably stems from using
std::any::type_name() for finding a component in the
compositor, for which the docs explicitly warn against
considering it as a unique identifier for types.

`replace_or_push()` takes a boxed `Component` and
passes it to `find_id()` which compares this with a
bare Component. `type_name()` returns `Box<T>` for
the former and `T` for latter and we have a false
negative. This has been solved by using a generics
instead of trait objects to pass in a `T: Component`
and then use it for comparison.

I'm not exactly sure how this worked fine at the
time of commit of 5995568c; maybe the internal
implementation of `type_name()` changed to properly
indicate indirection with Box.

* Do not compare by type name in compositor find_id
3 years ago
Philipp Mildenberger 49c5bc5934
Add jumplist support for the search (closes #1625) (#1718) 3 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>
3 years ago
Daniel S Poulin 78d37fd332
Implement bulk buffer closing commands (#1677)
* Implement buffer-close-all

* Implement buffer-close-others

* Refactor all buffer close variants to use shared logic

* Fix clippy lint

* Docgen for new commands

* Shorten error message for attempting to close buffers that don't exist

* Refactor shared buffer methods to pass only editor, not whole compositor

* Switch signature of bulk buffer closing to use slice of DocumentIds

Addresses feedback that accepting an IntoIterator implementor is too
much for an internal. Also possibly saves some moving?
3 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
3 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>
3 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
3 years ago
Triton171 f044059a2a
Implement LSP `workspace/configuration` and `workspace/didChangeConfiguration` (#1684)
* Implement LSP `workspace/configuration` request

* Implement LSP `workspace/didChangeConfiguration` notification.

* Simplify retrieval of LSP configuration

* Implement suggestions from PR discussion

Co-authored-by: Triton171 <triton0171@gmail.com>
3 years ago
Gokul Soumya c15996aff5
Show surround delete and replace errors in editor (#1709)
* Refactor surround commands to use early returns

* Show surround delete and replace errors in editor
3 years ago
Michael Davis 39f7ba36e0
ignore Enter keypress when menu has no selection (#1704)
* ignore Enter keypress when menu has no selection

supersedes #1622

Builds on the work in #1285. I want to allow Enter to create a newline
when there is no selection in the autocomplete menu.

This occurs somewhat often when using LSP autocomplete in Elixir which
uses `do/end` blocks (and I set the autocomplete menu delay to 0 which
exacerbates the problem):

```elixir
defmodule MyModule do
  def do_foo(x) do
    x
  end
  def other_function(y) do|
end
```

Here the cursor is `|` in insert mode. The LSP suggests `do_foo` but I
want to create a newline. Hitting Enter currently closes the menu,
so I end up having to hit Enter twice when the module contains any
local with a `do` prefix, which can be inconsistent. With this change,
we ignore the Enter keypress to end up creating the newline in this case.

* pop compositor layer when ignoring Enter keypress

* move closing function out of consumed event result closure

* explicitly label close_fn as an 'Option<Callback>'
3 years ago
Gokul Soumya 8e07e1b898
Alert if LSP is inactive when command is invoked (#1703) 3 years ago
Matouš Dzivjak 951fd1c80e
fix(commands): don't indent empty lines (#1653)
* fix(commands): don't indent empty lines

Fixes: https://github.com/helix-editor/helix/issues/1642

* Apply suggestions

* Update helix-term/src/commands.rs

* Update helix-term/src/commands.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
3 years ago
Skyler Hawthorne a494f47a5d
Configurable auto pairs (#1624)
* impl auto pairs config

Implements configuration for which pairs of tokens get auto completed.

In order to help with this, the logic for when *not* to auto complete
has been generalized from a specific hardcoded list of characters to
simply testing if the next/prev char is alphanumeric.

It is possible to configure a global list of pairs as well as at the
language level. The language config will take precedence over the
global config.

* rename AutoPair -> Pair

* clean up insert_char command

* remove Rc

* remove some explicit cloning with another impl

* fix lint

* review comments

* global auto-pairs = false takes precedence over language settings

* make clippy happy

* print out editor config on startup

* move auto pairs accessor into Document

* rearrange auto pair doc comment

* use pattern in Froms
3 years ago
Blaž Hrastnik b935fac957
Fix 1.60 lints 3 years ago
Blaž Hrastnik 9712bbb23b
Use which to resolve lsp/dap binaries
This resolves the following issue: https://github.com/helix-editor/helix/discussions/962#discussioncomment-1580046
3 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
3 years ago
Blaž Hrastnik 24f86017a6
fix: ui: Markdown popups stopped taking vertical padding into account
Fix #1688
3 years ago
Blaž Hrastnik 1ca6ba03ca
Simplify some code 3 years ago
Alex d5ba0b5162
Allow separate styles for markup headings (#1618)
* update markdown highlighting to use separate heading themes

* remove markdown theme scopes in ui
3 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.
3 years ago
Blaž Hrastnik c7b326be04
ui: prompt: Render aliases + border on the doc 3 years ago
Blaž Hrastnik 2af04325d8
fix: Allow multi-line prompt documentation 3 years ago
Blaž Hrastnik a449156702 Extract a lsp position helper 3 years ago
Blaž Hrastnik 5af9136aec Extract some duplication in lsp goto_ calls 3 years ago
Blaž Hrastnik 1cd710fe01 Extract jump_to_location 3 years ago
Blaž Hrastnik 4e845409b6 Extract a common "language server or return" macro 3 years ago
Blaž Hrastnik c06155ace4 Extract a helper function for lsp::Location 3 years ago
Blaž Hrastnik 504d5ce8bd Move most LSP specific commmands to commands::lsp 3 years ago
Blaž Hrastnik 7b1d682fe5 dap: fix runInTerminal with lldb-vscode 3 years ago
Blaž Hrastnik 4e1b3b12f3 Refactor symbol picker to share code 3 years ago
Michael Davis a8cf0c6b90
filter git revision on git command success exit code (#1674)
The unwrap (or '.ok()' rather) triggers for some errors but not
negative status codes. In the case where helix is being packaged
in an empty git repository, the existing mechanism will fail because

    git init
    git rev-parse HEAD

gives a negative exit code and prints to stderr

    stderr: "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree....

with a stdout of "HEAD\n" (too short to slice with [..8]).
3 years ago
tomKPZ 368064e316
Fix bug when launching hx file.rs:10 (#1676) 3 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>
3 years ago
Blaž Hrastnik 24f90ba8d8 Manually recalculate initial completion where it matters 3 years ago
Blaž Hrastnik af21e2a5b4 Pass through Editor instead of Context 3 years ago
Cole Helbling e023a78919 WIP: show all buffers that couldn't be closed 3 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).
3 years ago
Cole Helbling a1207fd768 helix-term/commands: display buffer id in picker 3 years ago
Blaž Hrastnik d11b652139 Allow static strings in set_status/set_error so API is nicer 3 years ago
Blaž Hrastnik fd0e4b1159 dap: Reduce amount of block_on uses 3 years ago
Gokul Soumya 966fbc5984 Add tree-sitter based function, class navigation 3 years ago
Blaž Hrastnik 1422449537 .. 3 years ago
Blaž Hrastnik eeb9b39857 Fix build on master 3 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
3 years ago
Kirawi 23907a063c
use PathBuf::to_string_lossy() instead of to_str() (#1655) 3 years ago
Gokul Soumya 4c424d5ee4
Refactor language config loading (#1658) 3 years ago
Blaž Hrastnik 97d4b2b5fe Mark DAP as experimental 3 years ago
Blaž Hrastnik bd549d8a20 Merge remote-tracking branch 'origin/master' into debug 3 years ago
Cydiater 7083b98a38
postpone clone after found (#1656) 3 years ago
Blaž Hrastnik 1bcb624ae6 Instant is more suitable than SystemTime for spinners 3 years ago
Blaž Hrastnik f88c077f99 Replace tendril with smartstring
Slightly smaller API surface, less dependencies.
3 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
3 years ago
Gokul Soumya bf773db451 Show infobox with register contents 3 years ago
Gokul Soumya 5995568c1d Prevent multiple code action popups 3 years ago
Gokul Soumya 547c3ecd0c Preselect first item in code action popup menu 3 years ago
Gokul Soumya e90276df0b Replace if let with early return 3 years ago
Blaž Hrastnik 23553bd37c Update dependencies (crossterm 0.23, tree-sitter 0.20.4)
Fixes #677
3 years ago
Blaž Hrastnik e7f5ec5561 fix: There is no such thing as markup.normal, use ui.text 3 years ago
Blaž Hrastnik 6ea477ab60 Don't use block_on in jobs.finish(), we can .await 3 years ago
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.
3 years ago
Blaž Hrastnik 36b975c4ce ui: menu: Don't allocate scrollbar space if options fit 3 years ago
Blaž Hrastnik f10a06f4de ui: Only render menu scrollbar if it doesn't fit 3 years ago
Blaž Hrastnik 094a0aa3f9 Render code actions as a menu, allow adding padding to popup 3 years ago
Blaž Hrastnik f7f55143a1 Improve code action picker by displaying it inline 3 years ago
Blaž Hrastnik 62561e9d23 Stop collecting highlight_iter events then turning back into iter 3 years ago
Blaž Hrastnik 5aead46f4b Remove some unnecessary clippy tags 3 years ago
Blaž Hrastnik 2a7ae963e1 Automatically commit changes to history if not in insert mode
Fixes #1500
3 years ago
CossonLeo d49e5323f9
Use markup scopes for the Markdown component (#1363) 3 years ago
Benjamin 4044c70eb2
Fix picker won't scroll down when it hits the bottom #1544 (#1567) 3 years ago
Ivan Tham 759b850859
Allow specifying file start position (#445)
Like helix-term/src/commands.rs:3426:15
3 years ago
Blaž Hrastnik e2d2f19fd0
Merge pull request #1154 from sudormrfbin/cursor-shape-new
Change cursor shape on mode change
3 years ago
Blaž Hrastnik add3be8528 Slicing micro-optimization 3 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%.
3 years ago
Blaž Hrastnik 53d881f172 Store theme scopes on the loader, this way theme isn't passed around 3 years ago
Blaž Hrastnik 6728e44490 syntax: Split parsing and highlighting 3 years ago