Commit Graph

48 Commits (main)

Author SHA1 Message Date
Yomain 8afc0282f2
Fix crash when cwd is deleted (#7185) 10 months ago
Alex Vinyals 1698992de6
Fix `:log-open` when `--log` is specified (#7573) 11 months ago
Michael Davis 25ad534d64
Check for 'git' before fetching/building grammars (#7320)
Previously the error message for this potential failure-case was
confusing: "no such file or directory". `hx -g fetch`, `hx -g build` and
the helix-term builder should bail early if the git binary is not
available.
11 months ago
ZJPzjp 3b8c15618f
Fix warnings from clippy (#7013)
* Fix warnings from clippy

* revert MAIN_SEPARATOR_STR
1 year ago
Pascal Kuthe b7c62e200e
fix windows builds (#6845) 1 year ago
Pascal Kuthe 13cc44c65e
fix windows build (#6834) 1 year ago
Pascal Kuthe f5d38cee17
produce error when grammar build fails (#6795)
* produce error when grammar build fails

* print which grammar build failed
1 year ago
Pascal Kuthe ca65d312e7
always build grammars with c++14 and c11 (#6792) 1 year ago
Pascal Kuthe 896404c7ea
emit cargo metadata duiring build scripts to avoid outdated buildscript outputs (#6743)
* rebuild on revision change
* rerun grammar build if grammars change
1 year ago
Pascal Kuthe 5b3dd6a678 implement proper lsp-workspace support
fix typo

Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>
1 year ago
Pascal Kuthe 2d10a429eb add workspace config and manual LSP root management
fixup documentation

Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>

fixup typo

Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>
1 year ago
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
Miguel Madrid-Mencía d2d3024337
Fix clippy 1.67 warnings (#5697) 1 year ago
Pascal Kuthe e9dc9f4935
Switch from toml::from_slice to toml::from_str (#5659) 1 year ago
Pascal Kuthe 70d78123b9
properly handle detachted git worktrees (#5097) 1 year ago
Matouš Dzivjak 8abed3bd78
feat(lsp): pass client_info on initialization (#4904)
Pass client name ('helix') and client version (version / git hash)
to LSP server on initialization.
1 year ago
Blaž Hrastnik c2c1280f02
Resolve a bunch of upcoming clippy lints 2 years ago
Christian Speich 4b85aeb2b6 grammar: Don't require lower-case (#4346)
Currently we always lower-case the grammar name when loading it. While it
is somewhat of an convention to name tree-sitter grammars in lowercase
there is no rule to enforce it.

This patch removes the lower-casing to allow all possible grammar names.

Signed-off-by: Christian Speich <cspeich@emlix.com>
2 years ago
Riccardo Binetti 888f4fef6f
Split helix_core::find_root and helix_loader::find_local_config_dirs (#3929)
* Split helix_core::find_root and helix_loader::find_local_config_dirs

The documentation of find_root described the following priority for
detecting a project root:
- Top-most folder containing a root marker in current git repository
- Git repository root if no marker detected
- Top-most folder containing a root marker if not git repository detected
- Current working directory as fallback

The commit contained in https://github.com/helix-editor/helix/pull/1249
extracted and changed the implementation of find_root in find_root_impl,
actually reversing its result order (since that is the order that made
sense for the local configuration merge, from innermost to outermost
ancestors).

Since the two uses of find_root_impl have different requirements (and
it's not a matter of reversing the order of results since, e.g., the top
repository dir should be used by find_root only if there's not marker in
other dirs), this PR splits the two implementations in two different
specialized functions.

In doing so, find_root_impl is removed and the implementation is moved
back in find_root, moving it closer to the documented behaviour thus
making it easier to verify it's actually correct

* helix-core: remove Option from find_root return type

It always returns some result, so Option is not needed
2 years ago
Ben Noordhuis b5be72bff7 Canonicalize executable path
When looking up the runtime/ directory relative to the executable path,
canonicalize the path first in case the executable is a symbolic link.

Fixes #3768
2 years ago
Evan Richter 01ee42bb14
ordinals instead of indexes when listing grammar fetch errors (#3773) 2 years ago
Poliorcetics 6618cf2d68
feat: shorten output for grammar fetching and building (#3396)
New look:

```
Fetching 102 grammars
98 up to date git grammars
4 updated grammars
        bash      now on 275effdfc0edce774acf7d481f9ea195c6c403cd
        beancount now on 4cbd1f09cd07c1f1fabf867c2cf354f9da53cc4c
        c         now on f05e279aedde06a25801c3f2b2cc8ac17fac52ae
        c-sharp   now on 53a65a908167d6556e1fcdb67f1ee62aac101dda
```

```
Building 102 grammars
100 grammars already built
2 grammars built now
        ["bash", "rust"]
```
2 years ago
Michael Davis 5d33dbacac
add a CLI flag for specifying config file location (#2666) 2 years ago
yvt 6d16d2cbc9 feat: support grammar cross-compilation 2 years ago
yvt f6f054ae5b fix(loader): pass `cc::Tool::args()`
Certain targets, such as `aarch64-apple-*`, require additional compiler
flags to cross-compile for the intended target.
2 years ago
Philipp Mildenberger 235237ddc4
Refactor 'helix-loader::merge_toml_values' to use a 'merge-depth' instead of 'merge_toplevel_arrays' (#3080)
- This ensures that other values than just the arrays are overridden, like nested objects, where it makes sense
- merge_depth is set to 3 so that top-level language features are merged (like 'scope'), but everything deeper is overridden with the user-config
2 years ago
bootra b7fa9ba601
Fix non-msvc grammar compile on Windows (#3190) 2 years ago
Skyler Hawthorne 0f3c10a021 Fix initial selection of Document in new view
When a new View of a Document is created, a default cursor of 0, 0 is
created, and it does not get normalized to a single width cursor until
at least one movement of the cursor happens. This appears to have no
practical negative effect that I could find, but it makes tests difficult
to work with, since the initial selection is not what you expect it to be.

This changes the initial selection of a new View to be the width of the
first grapheme in the text.
2 years ago
Skyler Hawthorne 502d3290fb improve test harness
* Use new macro syntax for encoding sequences of keys
* Make convenience helpers for common test pattern
* Use indoc for inline indented raw strings
* Add feature flag for integration testing to disable rendering
2 years ago
Michael Davis 0035c29fc1
Use a minimal binary to fetch grammar sources in release CI (#2557)
This is an optimization for the release CI. The release CI can take
a while since it compiles release builds for all operating systems.
We cut down on duplicate work and overall time by fetching
tree-sitter grammar repositories and then using those repositories
in all later steps. Previously we built all of helix just to run

    helix_loader::grammar::fetch_grammars()

which is wasteful on time. With this change we only build the
helix-loader crate.
2 years ago
Frojdholm f7c27b604f
Ignore SendErrors when handling grammars (#2641)
When handling grammars, fetching and building is done in a thread
pool.  Results are communicated over channels and the receiving
channel is closed on first error. This causes subsequent sends to
fail causing a mess in stderr. This ignores all SendErrors causing
only the first error to be printed.
2 years ago
Michael Zeller b43074dad3
illumos linker doesn't currently have -z relro (#2602) 2 years ago
Michael Davis 93e6eac15a
mention the C++ compiler in the grammar build failure message (#2597)
Earlier in the builder we enable C++ (`.cpp(true)`) but only mention
the C compiler in the build failure message. Some grammars that have
C++ external scanners can provoke build failures in this step if a
C++ compiler isn't installed, so mentioning it in the error message
should help out debugging.
2 years ago
Blaž Hrastnik 9191af3f8d
helix-loader + helix-core now compile for WASM 2 years ago
Michael Davis 2c7f770aa9
Only merge top-level array when merging `languages.toml` (#2215)
* Revert "Revert "override nested arrays when merging TOML (#2145)""

This reverts commit 35d2693630.

* flip top-level table merging flag
2 years ago
Blaž Hrastnik 35d2693630
Revert "override nested arrays when merging TOML (#2145)"
Looks like there's some follow-up issues

This reverts commit c8cfd0b1a0.
2 years ago
Michael Davis c8cfd0b1a0
override nested arrays when merging TOML (#2145)
We merge the elements of arrays for the top-level array. For
`languages.toml`, this is the array of languages. For any nested
arrays, we simply take the `right` array as-is instead of using
the union of `left` and `right`.

closes #1000
2 years ago
Ben Lee-Cohen 2bddec02e7
Fixing (in two ways) a small typo (#2156) 2 years ago
Kirawi c2a40d9d52
Add support for local language configuration (#1249)
* add local configuration

* move config loading to Application::new

* simplify find_root_impl
2 years ago
Michael Davis b03421a8c0
remove hardcoded '/' from grammar source path (#1986) 2 years ago
Marcin Puc f2dd3d4469
Avoid using the format ident Rust feature (#1881) 2 years ago
Michael Davis c6bd105484
fix enum definition for use-grammars selections (#1818)
See https://github.com/helix-editor/helix/discussions/1817

It looks like we need the enums to have the `only`/`except` fields in order
to deserialize correctly.
2 years ago
Michael Davis 98851d1594
remove stray 'println!' from grammar building function (#1785) 2 years ago
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.
2 years ago
Michael Davis 6fcab90d16 only fetch git-sourced grammars
This is a bit of a micro-optimization: in the current setup we waste
a thread in the pool for a local grammar only to println! a message
saying we're skipping fetching because it's a local grammar.
2 years ago
Skyler Hawthorne a229f405cc shallow clone 2 years ago
Skyler Hawthorne 31b7596f09 fix context in error 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