Skip to content

Commit

Permalink
Merge branch 'master' into pull-diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
SofusA committed Aug 3, 2024
2 parents c9074d1 + 0a4432b commit d8fd204
Show file tree
Hide file tree
Showing 91 changed files with 11,329 additions and 513 deletions.
230 changes: 124 additions & 106 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"helix-view",
"helix-term",
"helix-tui",
"helix-lsp-types",
"helix-lsp",
"helix-event",
"helix-dap",
Expand Down
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Surround](./surround.md)
- [Textobjects](./textobjects.md)
- [Syntax aware motions](./syntax-aware-motions.md)
- [Pickers](./pickers.md)
- [Keymap](./keymap.md)
- [Commands](./commands.md)
- [Language support](./lang-support.md)
Expand Down
3 changes: 2 additions & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
| glsl |||| |
| gn || | | |
| go |||| `gopls`, `golangci-lint-langserver` |
| godot-resource || | | |
| godot-resource || | | |
| gomod || | | `gopls` |
| gotmpl || | | `gopls` |
| gowork || | | `gopls` |
Expand All @@ -96,6 +96,7 @@
| java |||| `jdtls` |
| javascript |||| `typescript-language-server` |
| jinja || | | |
| jjdescription || | | |
| jsdoc || | | |
| json |||| `vscode-json-language-server` |
| json5 || | | |
Expand Down
2 changes: 2 additions & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ you to selectively add search terms to your selections.
## Picker

Keys to use within picker. Remapping currently not supported.
See the documentation page on [pickers](./pickers.md) for more info.
[Prompt](#prompt) keybinds also work in pickers, except where they conflict with picker keybinds.

| Key | Description |
| ----- | ------------- |
Expand Down
11 changes: 11 additions & 0 deletions book/src/pickers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Using pickers

Helix has a variety of pickers, which are interactive windows used to select various kinds of items. These include a file picker, global search picker, and more. Most pickers are accessed via keybindings in [space mode](./keymap.md#space-mode). Pickers have their own [keymap](./keymap.md#picker) for navigation.

### Filtering Picker Results

Most pickers perform fuzzy matching using [fzf syntax](https://github.com/junegunn/fzf?tab=readme-ov-file#search-syntax). Two exceptions are the global search picker, which uses regex, and the workspace symbol picker, which passes search terms to the LSP. Note that OR operations (`|`) are not currently supported.

If a picker shows multiple columns, you may apply the filter to a specific column by prefixing the column name with `%`. Column names can be shortened to any prefix, so `%p`, `%pa` or `%pat` all mean the same as `%path`. For example, a query of `helix %p .toml !lang` in the global search picker searches for the term "helix" within files with paths ending in ".toml" but not including "lang".

You can insert the contents of a [register](./registers.md) using `Ctrl-r` followed by a register name. For example, one could insert the currently selected text using `Ctrl-r`-`.`, or the directory of the current file using `Ctrl-r`-`%` followed by `Ctrl-w` to remove the last path section. The global search picker will use the contents of the [search register](./registers.md#default-registers) if you press `Enter` without typing a filter. For example, pressing `*`-`Space-/`-`Enter` will start a global search for the currently selected text.
7 changes: 4 additions & 3 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,13 @@ These scopes are used for theming the editor interface:
| `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) |
| `ui.statusline.separator` | Separator character in statusline |
| `ui.bufferline` | Style for the buffer line |
| `ui.bufferline.active` | Style for the active buffer in buffer line |
| `ui.bufferline.active` | Style for the active buffer in buffer line |
| `ui.bufferline.background` | Style for bufferline background |
| `ui.popup` | Documentation popups (e.g. Space + k) |
| `ui.popup.info` | Prompt for multiple key options |
| `ui.picker.header` | Column names in pickers with multiple columns |
| `ui.picker.header.active` | The column name in pickers with multiple columns where the cursor is entering into. |
| `ui.picker.header` | Header row area in pickers with multiple columns |
| `ui.picker.header.column` | Column names in pickers with multiple columns |
| `ui.picker.header.column.active` | The column name in pickers with multiple columns where the cursor is entering into. |
| `ui.window` | Borderlines separating splits |
| `ui.help` | Description box for commands |
| `ui.text` | Default text style, command prompts, popup text, etc. |
Expand Down
42 changes: 25 additions & 17 deletions contrib/completion/hx.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@
# Bash completion script for Helix editor

_hx() {
# $1 command name
# $2 word being completed
# $3 word preceding
local cur prev languages
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"

case "$3" in
-g | --grammar)
COMPREPLY="$(compgen -W 'fetch build' -- $2)"
;;
--health)
local languages=$(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g')
COMPREPLY="$(compgen -W """$languages""" -- $2)"
;;
*)
COMPREPLY="$(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- """$2""")"
;;
esac
case "$prev" in
-g | --grammar)
COMPREPLY=($(compgen -W 'fetch build' -- "$cur"))
return 0
;;
--health)
languages=$(hx --health | tail -n '+7' | awk '{print $1}' | sed 's/\x1b\[[0-9;]*m//g')
COMPREPLY=($(compgen -W """$languages""" -- "$cur"))
return 0
;;
esac

local IFS=$'\n'
COMPREPLY=($COMPREPLY)
case "$2" in
-*)
COMPREPLY=($(compgen -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- """$2"""))
return 0
;;
*)
COMPREPLY=($(compgen -fd -- """$2"""))
return 0
;;
esac
} && complete -o filenames -F _hx hx
8 changes: 6 additions & 2 deletions contrib/completion/hx.nu
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
# so it has not been specified here and will not be proposed in the autocompletion of Nushell.
# The help message won't be overriden though, so it will still be present here

def health_categories [] { ["all", "clipboard", "languages"] }
def health_categories [] {
let languages = ^hx --health languages | detect columns | get Language | filter { $in != null }
let completions = [ "all", "clipboard", "languages" ] | append $languages
return $completions
}

def grammar_categories [] { ["fetch", "build"] }

# A post-modern text editor.
export extern hx [
--help(-h), # Prints help information
--tutor, # Loads the tutorial
--health: string@health_categories = "all", # Checks for potential errors in editor setup
--health: string@health_categories, # Checks for potential errors in editor setup
--grammar(-g): string@grammar_categories, # Fetches or builds tree-sitter grammars listed in `languages.toml`
--config(-c): glob, # Specifies a file to use for configuration
-v, # Increases logging verbosity each use for up to 3 times
Expand Down
4 changes: 4 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Existing tests can be used as examples. Helpers can be found in
[helpers.rs][helpers.rs]. The log level can be set with the `HELIX_LOG_LEVEL`
environment variable, e.g. `HELIX_LOG_LEVEL=debug cargo integration-test`.

Contributors using MacOS might encounter `Too many open files (os error 24)`
failures while running integration tests. This can be resolved by increasing
the default value (e.g. to `10240` from `256`) by running `ulimit -n 10240`.

## Minimum Stable Rust Version (MSRV) Policy

Helix follows the MSRV of Firefox.
Expand Down
19 changes: 10 additions & 9 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

| Crate | Description |
| ----------- | ----------- |
| helix-core | Core editing primitives, functional. |
| helix-lsp | Language server client |
| helix-dap | Debug Adapter Protocol (DAP) client |
| helix-loader | Functions for building, fetching, and loading external resources |
| helix-view | UI abstractions for use in backends, imperative shell. |
| helix-term | Terminal UI |
| helix-tui | TUI primitives, forked from tui-rs, inspired by Cursive |
| Crate | Description |
| ----------- | ----------- |
| helix-core | Core editing primitives, functional. |
| helix-lsp | Language server client |
| helix-lsp-types | Language Server Protocol type definitions |
| helix-dap | Debug Adapter Protocol (DAP) client |
| helix-loader | Functions for building, fetching, and loading external resources |
| helix-view | UI abstractions for use in backends, imperative shell. |
| helix-term | Terminal UI |
| helix-tui | TUI primitives, forked from tui-rs, inspired by Cursive |


This document contains a high-level overview of Helix internals.
Expand Down
9 changes: 7 additions & 2 deletions helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
smallvec = "1.13"
smartstring = "1.0.1"
unicode-segmentation = "1.11"
unicode-width = "0.1"
# unicode-width is changing width definitions
# that both break our logic and disagree with common
# width definitions in terminals, we need to replace it.
# For now lets lock the version to avoid rendering glitches
# when installing without `--locked`
unicode-width = "=0.1.12"
unicode-general-category = "0.6"
slotmap.workspace = true
tree-sitter.workspace = true
Expand All @@ -41,7 +46,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.8"

imara-diff = "0.1.6"
imara-diff = "0.1.7"

encoding_rs = "0.8"

Expand Down
4 changes: 2 additions & 2 deletions helix-core/src/auto_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ impl From<(&char, &char)> for Pair {

impl AutoPairs {
/// Make a new AutoPairs set with the given pairs and default conditions.
pub fn new<'a, V: 'a, A>(pairs: V) -> Self
pub fn new<'a, V, A>(pairs: V) -> Self
where
V: IntoIterator<Item = A>,
V: IntoIterator<Item = A> + 'a,
A: Into<Pair>,
{
let mut auto_pairs = HashMap::new();
Expand Down
9 changes: 5 additions & 4 deletions helix-core/src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ fn is_first_in_line(node: Node, text: RopeSlice, new_line_byte_pos: Option<usize
/// This is usually constructed in one of 2 ways:
/// - Successively add indent captures to get the (added) indent from a single line
/// - Successively add the indent results for each line
/// The string that this indentation defines starts with the string contained in the align field (unless it is None), followed by:
/// The string that this indentation defines starts with the string contained in the align field (unless it is None), followed by:
/// - max(0, indent - outdent) tabs, if tabs are used for indentation
/// - max(0, indent - outdent)*indent_width spaces, if spaces are used for indentation
#[derive(Default, Debug, PartialEq, Eq, Clone)]
Expand Down Expand Up @@ -457,7 +457,7 @@ fn query_indents<'a>(
// Skip matches where not all custom predicates are fulfilled
if !query.general_predicates(m.pattern_index).iter().all(|pred| {
match pred.operator.as_ref() {
"not-kind-eq?" => match (pred.args.get(0), pred.args.get(1)) {
"not-kind-eq?" => match (pred.args.first(), pred.args.get(1)) {
(
Some(QueryPredicateArg::Capture(capture_idx)),
Some(QueryPredicateArg::String(kind)),
Expand All @@ -473,7 +473,7 @@ fn query_indents<'a>(
}
},
"same-line?" | "not-same-line?" => {
match (pred.args.get(0), pred.args.get(1)) {
match (pred.args.first(), pred.args.get(1)) {
(
Some(QueryPredicateArg::Capture(capt1)),
Some(QueryPredicateArg::Capture(capt2))
Expand All @@ -495,7 +495,7 @@ fn query_indents<'a>(
}
}
}
"one-line?" | "not-one-line?" => match pred.args.get(0) {
"one-line?" | "not-one-line?" => match pred.args.first() {
Some(QueryPredicateArg::Capture(capture_idx)) => {
let node = m.nodes_for_capture_index(*capture_idx).next();

Expand Down Expand Up @@ -786,6 +786,7 @@ fn init_indent_query<'a, 'b>(
/// - The line after the node. This is defined by:
/// - The scope `tail`.
/// - The scope `all` if this node is not the first node on its line.
///
/// Intuitively, `all` applies to everything contained in this node while `tail` applies to everything except for the first line of the node.
/// The indents from different nodes for the same line are then combined.
/// The result [Indentation] is simply the sum of the [Indentation] for all lines.
Expand Down
16 changes: 10 additions & 6 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,10 @@ impl Loader {
match capture {
InjectionLanguageMarker::Name(string) => self.language_config_for_name(string),
InjectionLanguageMarker::Filename(file) => self.language_config_for_file_name(file),
InjectionLanguageMarker::Shebang(shebang) => {
self.language_config_for_language_id(shebang)
}
InjectionLanguageMarker::Shebang(shebang) => self
.language_config_ids_by_shebang
.get(shebang)
.and_then(|&id| self.language_configs.get(id).cloned()),
}
}

Expand Down Expand Up @@ -1432,8 +1433,11 @@ impl Syntax {
// The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
// prevents them from being moved. But both of these values are really just
// pointers, so it's actually ok to move them.
let cursor_ref =
unsafe { mem::transmute::<_, &'static mut QueryCursor>(&mut cursor) };
let cursor_ref = unsafe {
mem::transmute::<&mut tree_sitter::QueryCursor, &mut tree_sitter::QueryCursor>(
&mut cursor,
)
};

// if reusing cursors & no range this resets to whole range
cursor_ref.set_byte_range(range.clone().unwrap_or(0..usize::MAX));
Expand Down Expand Up @@ -1738,7 +1742,7 @@ pub(crate) fn generate_edits(
}

use std::sync::atomic::{AtomicUsize, Ordering};
use std::{iter, mem, ops, str, usize};
use std::{iter, mem, ops, str};
use tree_sitter::{
Language as Grammar, Node, Parser, Point, Query, QueryCaptures, QueryCursor, QueryError,
QueryMatch, Range, TextProvider, Tree,
Expand Down
2 changes: 1 addition & 1 deletion helix-core/src/syntax/tree_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a> TreeCursor<'a> {

self.injection_ranges[start_idx..]
.iter()
.take_while(|range| range.start < end)
.take_while(|range| range.start < end || range.depth > 1)
.find_map(|range| (range.start <= start).then_some(range.layer_id))
.unwrap_or(self.root)
}
Expand Down
Loading

0 comments on commit d8fd204

Please sign in to comment.