Commit graph

569 commits

Author SHA1 Message Date
Hugo
89c6e8aa94
Remove unnecessary unwrap (#2599)
`strip_prefix` will itself check whether the string starts with the
prefix, so the extra call to `starts_with` was unnecessary.
2022-05-29 11:13:21 +09:00
dependabot[bot]
da29527258 build(deps): bump once_cell from 1.10.0 to 1.12.0
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.10.0 to 1.12.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.10.0...v1.12.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>
2022-05-25 21:25:47 +09:00
Andrey Tkachenko
62fd1f6999
Include macro attributes to impls, structs, enums, functions etc. textobjects (#2494) 2022-05-20 10:19:46 +09:00
dependabot[bot]
0258cf45f3
build(deps): bump etcetera from 0.3.2 to 0.4.0 (#2486)
Bumps [etcetera](https://github.com/arzg/etcetera) from 0.3.2 to 0.4.0.
- [Release notes](https://github.com/arzg/etcetera/releases)
- [Commits](https://github.com/arzg/etcetera/commits)

---
updated-dependencies:
- dependency-name: etcetera
  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>
2022-05-17 12:32:18 +09:00
EmmChriss
807cdc60bf
configurable lsp request timeout (#2405) 2022-05-11 09:54:35 +09:00
Matthew Toohey
a5f4925f53
feat(languages): git-ignore and git-attributes (#2397) 2022-05-05 08:47:28 -05:00
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>
2022-05-02 23:24:22 +09:00
Gokul Soumya
22ae1b92a6 Fix tests for surround primitives 2022-04-29 15:51:14 +09:00
Gokul Soumya
76175dbd6d Support m in surround delete and replace 2022-04-29 15:51:14 +09:00
Gokul Soumya
de15d70171 Add m textobject to select closest surround pair 2022-04-29 15:51:14 +09:00
chunghha
3a398eec56
fix typos (#2304) 2022-04-27 14:21:20 -05:00
Thomas
5d5b6bab9b
Add rulers option (#2060)
* Add color_column option

* Rename to ruler

Co-authored-by: DeviousStoat <devious@stoat.com>
2022-04-20 10:44:32 +09:00
Michael Davis
4e877de54d
Fix Golang textobject queries (#2153)
* log textobject query construction errors

The current behavior is that invalid queries are discarded silently
which makes it difficult to debug invalid textobjects (either invalid
syntax or an update may have come through that changed the valid set
of nodes).

* fix golang textobject query

`method_spec_list` used to be a named node but was removed (I think
for Helix, it was when updated to pull in the support for generics).
Instead of a named node for the list of method specs we have a bunch
of `method_spec` children nodes now. We can match on the set of them
with a `+` wildcard.

Example go for this query:

    type Shape interface {
       area() float64
       perimeter() float64
    }

Which is parsed as:

    (source_file
      (type_declaration
        (type_spec
          name: (type_identifier)
          type: (interface_type
            (method_spec
              name: (field_identifier)
              parameters: (parameter_list)
              result: (type_identifier))
            (method_spec
              name: (field_identifier)
              parameters: (parameter_list)
              result: (type_identifier))))))
2022-04-18 23:14:48 +08:00
Kirawi
c2a40d9d52
Add support for local language configuration (#1249)
* add local configuration

* move config loading to Application::new

* simplify find_root_impl
2022-04-18 12:10:51 +09:00
Ivan Tham
62283fdadb
Make textobject select last paragraph (#1992)
* Make textobject select last paragraph

Last paragraph shoud be selected if the cursor was placed on the
whitespace paragraph part and `map` is done, otherwise it would do
nothing useful, but now we select backwards for the last paragraph
which behaves similarly to kakoune, making `map` useful for the last
paragraph with whitespace. Example usecase is to copy and paste last
ledger cli paragraph quickly by `mapyp` to duplicate last entry.

* Fix typo in core textobject

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

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2022-04-13 10:02:53 +09:00
Michael Davis
19ff21eaa2
Remove usage of format ident feature from tests (#2028) 2022-04-08 21:26:50 +05:30
Danilo Spinella
6b80cb8a77
Fix toggle_comments command on multiple selections (#1882) 2022-04-05 10:01:58 +09:00
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
2022-04-05 09:56:14 +09:00
Ivan Tham
6fc6f87260
Fix next paragraph logic over muliple blank lines (#1951)
Fix #1928
2022-04-05 09:43:14 +09:00
Ivan Tham
ec21de0844 Add missing # back to test output 2022-04-03 00:46:53 +09:00
Ivan Tham
8b91ecde40 Rename _para to _paragraph 2022-04-03 00:46:53 +09:00
Gokul Soumya
64c2490f2d Refactor test print to be more readable 2022-04-03 00:46:53 +09:00
Ivan Tham
45b76db506 Change test mark from ^@ to #[|]# 2022-04-03 00:46:53 +09:00
Ivan Tham
8350ee9a0e Add paragraph textobject
Change parameter/argument key from p to a since paragraph only have p
but parameter are also called arguments sometimes and a is not used.
2022-04-03 00:46:53 +09:00
Ivan Tham
e2a6e33b98 Add next paragraph 2022-04-03 00:46:53 +09:00
Ivan Tham
8b02bf2ea8 Add (prev) paragraph motion
Also improved testing facility.

Fix #1580
2022-04-03 00:46:53 +09:00
antoyo
47fe739757
Jump to the next number on the line before incrementing (#1778)
* Jump to the next number on the line before incrementing

Partially fix #1645

* Refactor to avoid duplicating find_nth_next
2022-04-01 22:14:37 +09:00
Triton171
6bb2298391
Fix an issue that caused an empty indentation query to be used instead of using the fallback method of copying the indentation from the current line. (#1908)
Co-authored-by: Triton171 <triton0171@gmail.com>
2022-04-01 11:27:06 +09:00
Triton171
58758fee61
Indentation rework (#1562)
* WIP: Rework indentation system

* Add ComplexNode for context-aware indentation (including a proof of concept for assignment statements in rust)

* Add switch statements to Go indents.toml (fixes the second half of issue #1523)
Remove commented-out code

* Migrate all existing indentation queries.
Add more options to ComplexNode and use them to improve C/C++ indentation.

* Add comments & replace Option<Vec<_>> with Vec<_>

* Add more detailed documentation for tree-sitter indentation

* Improve code style in indent.rs

* Use tree-sitter queries for indentation instead of TOML config.
Migrate existing indent queries.

* Add documentation for the new indent queries.
Change xtask docgen to look for indents.scm instead of indents.toml

* Improve code style in indent.rs.
Fix an issue with the rust indent query.

* Move indentation test sources to separate files.
Add `#not-kind-eq?`, `#same-line?` and `#not-same-line` custom predicates.
Improve the rust and c indent queries.

* Fix indent test.
Improve rust indent queries.

* Move indentation tests to integration test folder.

* Improve code style in indent.rs.
Reuse tree-sitter cursors for indentation queries.

* Migrate HCL indent query

* Replace custom loading in indent tests with a designated languages.toml

* Update indent query file name for --health command.

* Fix single-space formatting in indent queries.

* Add explanation for unwrapping.

Co-authored-by: Triton171 <triton0171@gmail.com>
2022-03-31 00:08:07 +09:00
dependabot[bot]
3af0a7f3cb
build(deps): bump smartstring from 1.0.0 to 1.0.1 (#1873)
Bumps [smartstring](https://github.com/bodil/smartstring) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/bodil/smartstring/releases)
- [Changelog](https://github.com/bodil/smartstring/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bodil/smartstring/compare/v1.0.0...v1.0.1)

---
updated-dependencies:
- dependency-name: smartstring
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-29 09:07:07 +09:00
Slin Lee
79477ec6e7
Fix typo in query parsing error message (#1856) 2022-03-22 16:22:57 +05:30
Blaž Hrastnik
0b9620108d
ropey 1.4.1 fixes the issue 2022-03-17 12:03:15 +09:00
Blaž Hrastnik
2376fc875e
Temporarily turn on unicode-lines
Ropey's non-unicode lines impl has some bugs still
2022-03-17 10:53:50 +09:00
Blaž Hrastnik
16e2b2e36b
ropey 1.4.0 is out! 2022-03-17 09:29:47 +09:00
Blaž Hrastnik
f67e1ee172
Put esoteric line endings behind a feature flag 2022-03-17 09:29:47 +09:00
Blaž Hrastnik
b4a282fd36
Configure ropey to only use CR/CRLF line breaks by default
Fixes #1643
2022-03-17 09:29:47 +09:00
Blaž Hrastnik
59f05088b9
Optimize rendering by using Ropey::byte_slice
This avoids costly conversions via byte_to_char (which are then
reversed back into bytes internally in Ropey).

Reduces time spent in slice/byte_to_char from ~24% to ~5%.
2022-03-17 09:29:47 +09:00
Gokul Soumya
2b0835b295
Refactor :set to parse by deserializing values (#1799)
* Refactor :set to parse by deserializing values

* Implement serialize for idle_timeout config
2022-03-15 17:04:22 +09:00
Michael Davis
7044d7d804 rename '--fetch/build-grammars' flags into '--grammar fetch/build'
The old flags were a bit long. --grammar is also aliased to -g to make
it even easier.
2022-03-10 17:31:57 +09:00
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.
2022-03-10 17:31:57 +09:00
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.
2022-03-10 17:31:57 +09:00
Michael Davis
db3470d973 ensure rust grammar is available in CI 2022-03-10 17:31:57 +09:00
Michael Davis
8081e9f052 replace all submodule documentation with flags documentation 2022-03-10 17:31:57 +09:00
Michael Davis
c1f677ff75 rename tree_sitter_library in LanguageConfig to 'grammar'
This is not strictly speaking necessary. tree_sitter_library was used by
just one grammar: llvm-mir-yaml, which uses the yaml grammar. This will
make the language more consistent, though. Each language can explicitly
say that they use Some(grammar), defaulting when None to the grammar that
has a grammar_id matching the language's language_id.
2022-03-10 17:31:57 +09:00
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.
2022-03-10 17:31:57 +09:00
Michael Davis
c1f90a127b add tree-sitter sources to languages.toml
Here we add syntax to the languages.toml languge

    [[grammar]]
    name = "<name>"
    source = { .. }

Which can be used to specify a tree-sitter grammar separately of
the language that defines it, and we make this distinction for
two reasons:

* In later commits, we will separate this code from helix-core
  and bring it to a new helix-loader crate. Using separate schemas
  for language and grammar configurations allows for a nice divide
  between the types needed to be declared in helix-loader and in
  helix-core/syntax

* Two different languages may use the same grammar. This is currently
  the case with llvm-mir-yaml and yaml. We could accomplish a config
  that works for this with just `[[languages]]`, but it gets a bit
  dicey with languages depending on one another. If you enable
  llvm-mir-yaml and disable yaml, does helix still need to fetch and
  build tree-sitter-yaml? It could be a matter of interpretation.
2022-03-10 17:31:57 +09:00
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>
2022-03-08 14:25:46 +09:00
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>
2022-03-08 08:55:23 +08:00
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
2022-03-04 11:01:33 +09:00
Blaž Hrastnik
5d14f56fa9
Reuse visual_coords_at_pos function in view 2022-03-04 09:36:31 +09:00