aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules12
-rw-r--r--book/src/keymap.md33
-rw-r--r--docs/vision.md24
-rw-r--r--helix-syntax/build.rs3
m---------helix-syntax/languages/tree-sitter-lua0
m---------helix-syntax/languages/tree-sitter-ocaml0
m---------helix-syntax/languages/tree-sitter-yaml0
-rw-r--r--helix-term/src/commands.rs212
-rw-r--r--helix-term/src/keymap.rs2
-rw-r--r--languages.toml33
-rw-r--r--runtime/queries/lua/highlights.scm166
-rw-r--r--runtime/queries/lua/indents.toml24
-rw-r--r--runtime/queries/ocaml-interface/highlights.scm1
-rw-r--r--runtime/queries/ocaml/highlights.scm160
-rw-r--r--runtime/queries/ocaml/indents.toml13
-rw-r--r--runtime/queries/ocaml/locals.scm24
-rw-r--r--runtime/queries/yaml/highlights.scm33
-rw-r--r--runtime/queries/yaml/indents.toml3
18 files changed, 668 insertions, 75 deletions
diff --git a/.gitmodules b/.gitmodules
index 0e015658..f905b8c7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -102,6 +102,18 @@
path = helix-syntax/languages/tree-sitter-protobuf
url = https://github.com/yusdacra/tree-sitter-protobuf.git
shallow = true
+[submodule "helix-syntax/languages/tree-sitter-ocaml"]
+ path = helix-syntax/languages/tree-sitter-ocaml
+ url = https://github.com/tree-sitter/tree-sitter-ocaml
+ shallow = true
+[submodule "helix-syntax/languages/tree-sitter-lua"]
+ path = helix-syntax/languages/tree-sitter-lua
+ url = https://github.com/nvim-treesitter/tree-sitter-lua
+ shallow = true
+[submodule "helix-syntax/languages/tree-sitter-yaml"]
+ path = helix-syntax/languages/tree-sitter-yaml
+ url = https://github.com/ikatyang/tree-sitter-yaml
+ shallow = true
[submodule "helix-syntax/languages/tree-sitter-zig"]
path = helix-syntax/languages/tree-sitter-zig
url = https://github.com/maxxnino/tree-sitter-zig
diff --git a/book/src/keymap.md b/book/src/keymap.md
index d85fb936..861e46ac 100644
--- a/book/src/keymap.md
+++ b/book/src/keymap.md
@@ -110,27 +110,28 @@ in reverse, or searching via smartcase.
| `N` | Add next search match to selection | `extend_search_next` |
| `*` | Use current selection as the search pattern | `search_selection` |
-### Diagnostics
+### Unimpaired
-> NOTE: `[` and `]` will likely contain more pair mappings in the style of
-> [vim-unimpaired](https://github.com/tpope/vim-unimpaired)
+Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaired)
-| Key | Description | Command |
-| ----- | ----------- | ------- |
-| `[d` | Go to previous diagnostic | `goto_prev_diag` |
-| `]d` | Go to next diagnostic | `goto_next_diag` |
-| `[D` | Go to first diagnostic in document | `goto_first_diag` |
-| `]D` | Go to last diagnostic in document | `goto_last_diag` |
+| Key | Description | Command |
+| ----- | ----------- | ------- |
+| `[d` | Go to previous diagnostic | `goto_prev_diag` |
+| `]d` | Go to next diagnostic | `goto_next_diag` |
+| `[D` | Go to first diagnostic in document | `goto_first_diag` |
+| `]D` | Go to last diagnostic in document | `goto_last_diag` |
+| `[space` | Add newline above | `add_newline_above` |
+| `]space` | Add newline below | `add_newline_below` |
### Shell
-| Key | Description | Command |
-| ------ | ----------- | ------- |
-| `\|` | Pipe each selection through shell command, replacing with output | `shell_pipe` |
-| `A-\|` | Pipe each selection into shell command, ignoring output | `shell_pipe_to` |
-| `!` | Run shell command, inserting output before each selection | `shell_insert_output` |
-| `A-!` | Run shell command, appending output after each selection | `shell_append_output` |
-| `$` | Pipe each selection into shell command, removing if the command exits >0 | `shell_keep_pipe` |
+| Key | Description | Command |
+| ------ | ----------- | ------- |
+| `\|` | Pipe each selection through shell command, replacing with output | `shell_pipe` |
+| `A-\|` | Pipe each selection into shell command, ignoring output | `shell_pipe_to` |
+| `!` | Run shell command, inserting output before each selection | `shell_insert_output` |
+| `A-!` | Run shell command, appending output after each selection | `shell_append_output` |
+| `$` | Pipe each selection into shell command, keep selections where command returned 0 | `shell_keep_pipe` |
## Select / extend mode
diff --git a/docs/vision.md b/docs/vision.md
new file mode 100644
index 00000000..d49dd64d
--- /dev/null
+++ b/docs/vision.md
@@ -0,0 +1,24 @@
+The Helix project still has a ways to go before reaching its goals. This document outlines some of those goals and the overall vision for the project.
+
+# Vision
+
+An efficient, batteries-included editor you can take anywhere and be productive... if it's your kind of thing.
+
+* **Cross-platform.** Whether on Linux, Windows, or OSX, you should be able to take your editor with you.
+* **Terminal first.** Not all environments have a windowing system, and you shouldn't have to abandon your preferred editor in those cases.
+* **Native.** No Electron or HTML DOM here. We want an efficient, native-compiled editor that can run with minimal resources when needed. If you're working on a Raspberry Pi, your editor shouldn't consume half of your RAM.
+* **Batteries included.** Both the default configuration and bundled features should be enough to have a good editing experience and be productive. You shouldn't need a massive custom config or external executables and plugins for basic features and functionality.
+* **Don't try to be everything for everyone.** There are many great editors out there to choose from. Let's make Helix *one of* those great options, with its own take on things.
+
+# Goals
+
+Vision statements are all well and good, but are also vague and subjective. Here is a (non-exhaustive) list of some of Helix's more concrete goals, to help give a clearer idea of the project's direction:
+
+* **Modal.** Vim is a great idea.
+* **Selection -> Action**, not Verb -> Object. Interaction models aren't linguistics, and "selection first" lets you see what you're doing (among other benefits).
+* **We aren't playing code golf.** It's more important for the keymap to be consistent and easy to memorize than it is to save a key stroke or two when editing.
+* **Built-in tools** for working with code bases efficiently. Most projects aren't a single file, and an editor should handle that as a first-class use case. In Helix's case, this means (among other things) a fuzzy-search file navigator and LSP support.
+* **Edit anything** that comes up when coding, within reason. Whether it's a 200 MB XML file, a megabyte of minified javascript on a single line, or Japanese text encoded in ShiftJIS, you should be able to open it and edit it without problems. (Note: this doesn't mean handle every esoteric use case. Sometimes you do just need a specialized tool, and Helix isn't that.)
+* **Configurable**, within reason. Although the defaults should be good, not everyone will agree on what "good" is. Within the bounds of Helix's core interaction models, it should be reasonably configurable so that it can be "good" for more people. This means, for example, custom key maps among other things.
+* **Extensible**, within reason. Although we want Helix to be productive out-of-the-box, it's not practical or desirable to cram every useful feature and use case into the core editor. The basics should be built-in, but you should be able to extend it with additional functionality as needed. Right now we're thinking Wasm-based plugins.
+* **Clean code base.** Sometimes other factors (e.g. significant performance gains, important features, correctness, etc.) will trump strict readability, but we nevertheless want to keep the code base straightforward and easy to understand to the extent we can.
diff --git a/helix-syntax/build.rs b/helix-syntax/build.rs
index 75f8c970..473646fd 100644
--- a/helix-syntax/build.rs
+++ b/helix-syntax/build.rs
@@ -177,6 +177,7 @@ fn main() {
let ignore = vec![
"tree-sitter-typescript".to_string(),
"tree-sitter-haskell".to_string(), // aarch64 failures: https://github.com/tree-sitter/tree-sitter-haskell/issues/34
+ "tree-sitter-ocaml".to_string(),
];
let dirs = collect_tree_sitter_dirs(&ignore).unwrap();
@@ -202,4 +203,6 @@ fn main() {
build_dir("tree-sitter-typescript/tsx", "tsx");
build_dir("tree-sitter-typescript/typescript", "typescript");
+ build_dir("tree-sitter-ocaml/ocaml", "ocaml");
+ build_dir("tree-sitter-ocaml/interface", "ocaml-interface")
}
diff --git a/helix-syntax/languages/tree-sitter-lua b/helix-syntax/languages/tree-sitter-lua
new file mode 160000
+Subproject 6f5d40190ec8a0aa8c8410699353d820f4f7d7a
diff --git a/helix-syntax/languages/tree-sitter-ocaml b/helix-syntax/languages/tree-sitter-ocaml
new file mode 160000
+Subproject 23d419ba45789c5a47d31448061557716b02750
diff --git a/helix-syntax/languages/tree-sitter-yaml b/helix-syntax/languages/tree-sitter-yaml
new file mode 160000
+Subproject 0e36bed171768908f331ff7dff9d956bae016ef
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 4ff47574..7b2fd295 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -231,6 +231,8 @@ impl Command {
select_mode, "Enter selection extend mode",
exit_select_mode, "Exit selection mode",
goto_definition, "Goto definition",
+ add_newline_above, "Add newline above",
+ add_newline_below, "Add newline below",
goto_type_definition, "Goto type definition",
goto_implementation, "Goto implementation",
goto_file_start, "Goto file start/line",
@@ -1850,7 +1852,11 @@ mod cmd {
args: &[&str],
_event: PromptEvent,
) -> anyhow::Result<()> {
- let dir = args.first().context("target directory not provided")?;
+ let dir = helix_core::path::expand_tilde(
+ args.first()
+ .context("target directory not provided")?
+ .as_ref(),
+ );
if let Err(e) = std::env::set_current_dir(dir) {
bail!("Couldn't change the current working directory: {}", e);
@@ -4494,7 +4500,6 @@ enum ShellBehavior {
Ignore,
Insert,
Append,
- Filter,
}
fn shell_pipe(cx: &mut Context) {
@@ -4514,18 +4519,101 @@ fn shell_append_output(cx: &mut Context) {
}
fn shell_keep_pipe(cx: &mut Context) {
- shell(cx, "keep-pipe:".into(), ShellBehavior::Filter);
+ let prompt = Prompt::new(
+ "keep-pipe:".into(),
+ Some('|'),
+ |_input: &str| Vec::new(),
+ move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
+ let shell = &cx.editor.config.shell;
+ if event != PromptEvent::Validate {
+ return;
+ }
+ if input.is_empty() {
+ return;
+ }
+ let (view, doc) = current!(cx.editor);
+ let selection = doc.selection(view.id);
+
+ let mut ranges = SmallVec::with_capacity(selection.len());
+ let old_index = selection.primary_index();
+ let mut index: Option<usize> = None;
+ let text = doc.text().slice(..);
+
+ for (i, range) in selection.ranges().iter().enumerate() {
+ let fragment = range.fragment(text);
+ let (_output, success) = match shell_impl(shell, input, Some(fragment.as_bytes())) {
+ Ok(result) => result,
+ Err(err) => {
+ cx.editor.set_error(err.to_string());
+ return;
+ }
+ };
+
+ // if the process exits successfully, keep the selection
+ if success {
+ ranges.push(*range);
+ if i >= old_index && index.is_none() {
+ index = Some(ranges.len() - 1);
+ }
+ }
+ }
+
+ if ranges.is_empty() {
+ cx.editor.set_error("No selections remaining".to_string());
+ return;
+ }
+
+ let index = index.unwrap_or_else(|| ranges.len() - 1);
+ doc.set_selection(view.id, Selection::new(ranges, index));
+ },
+ );
+
+ cx.push_layer(Box::new(prompt));
}
-fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) {
+fn shell_impl(
+ shell: &[String],
+ cmd: &str,
+ input: Option<&[u8]>,
+) -> anyhow::Result<(Tendril, bool)> {
use std::io::Write;
use std::process::{Command, Stdio};
- if cx.editor.config.shell.is_empty() {
- cx.editor.set_error("No shell set".to_owned());
- return;
+ if shell.is_empty() {
+ bail!("No shell set");
+ }
+
+ let mut process = match Command::new(&shell[0])
+ .args(&shell[1..])
+ .arg(cmd)
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped())
+ .spawn()
+ {
+ Ok(process) => process,
+ Err(e) => {
+ log::error!("Failed to start shell: {}", e);
+ return Err(e.into());
+ }
+ };
+ if let Some(input) = input {
+ let mut stdin = process.stdin.take().unwrap();
+ stdin.write_all(input)?;
+ }
+ let output = process.wait_with_output()?;
+
+ if !output.stderr.is_empty() {
+ log::error!("Shell error: {}", String::from_utf8_lossy(&output.stderr));
}
+
+ let tendril = Tendril::try_from_byte_slice(&output.stdout)
+ .map_err(|_| anyhow!("Process did not output valid UTF-8"))?;
+ Ok((tendril, output.status.success()))
+}
+
+fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) {
let pipe = match behavior {
- ShellBehavior::Replace | ShellBehavior::Ignore | ShellBehavior::Filter => true,
+ ShellBehavior::Replace | ShellBehavior::Ignore => true,
ShellBehavior::Insert | ShellBehavior::Append => false,
};
let prompt = Prompt::new(
@@ -4533,70 +4621,42 @@ fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) {
Some('|'),
|_input: &str| Vec::new(),
move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
+ let shell = &cx.editor.config.shell;
if event != PromptEvent::Validate {
return;
}
- let shell = &cx.editor.config.shell;
+ if input.is_empty() {
+ return;
+ }
let (view, doc) = current!(cx.editor);
let selection = doc.selection(view.id);
let mut changes = Vec::with_capacity(selection.len());
+ let text = doc.text().slice(..);
for range in selection.ranges() {
- let mut process = match Command::new(&shell[0])
- .args(&shell[1..])
- .arg(input)
- .stdin(Stdio::piped())
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- {
- Ok(process) => process,
- Err(e) => {
- log::error!("Failed to start shell: {}", e);
- cx.editor.set_error("Failed to start shell".to_owned());
- return;
- }
- };
- if pipe {
- let stdin = process.stdin.as_mut().unwrap();
- let fragment = range.fragment(doc.text().slice(..));
- stdin.write_all(fragment.as_bytes()).unwrap();
- }
- let output = process.wait_with_output().unwrap();
-
- if behavior != ShellBehavior::Filter {
- if !output.status.success() {
- if !output.stderr.is_empty() {
- log::error!("Shell error: {}", String::from_utf8_lossy(&output.stderr));
- }
- cx.editor.set_error("Command failed".to_owned());
- return;
- }
- let tendril = match Tendril::try_from_byte_slice(&output.stdout) {
- Ok(tendril) => tendril,
- Err(_) => {
- cx.editor
- .set_error("Process did not output valid UTF-8".to_owned());
+ let fragment = range.fragment(text);
+ let (output, success) =
+ match shell_impl(shell, input, pipe.then(|| fragment.as_bytes())) {
+ Ok(result) => result,
+ Err(err) => {
+ cx.editor.set_error(err.to_string());
return;
}
};
- let (from, to) = match behavior {
- ShellBehavior::Replace => (range.from(), range.to()),
- ShellBehavior::Insert => (range.from(), range.from()),
- ShellBehavior::Append => (range.to(), range.to()),
- _ => (range.from(), range.from()),
- };
- changes.push((from, to, Some(tendril)));
- } else {
- // if the process exits successfully, keep the selection, otherwise delete it.
- let keep = output.status.success();
- changes.push((
- range.from(),
- if keep { range.from() } else { range.to() },
- None,
- ));
+
+ if !success {
+ cx.editor.set_error("Command failed".to_string());
+ return;
}
+
+ let (from, to) = match behavior {
+ ShellBehavior::Replace => (range.from(), range.to()),
+ ShellBehavior::Insert => (range.from(), range.from()),
+ ShellBehavior::Append => (range.to(), range.to()),
+ _ => (range.from(), range.from()),
+ };
+ changes.push((from, to, Some(output)));
}
if behavior != ShellBehavior::Ignore {
@@ -4614,3 +4674,37 @@ fn suspend(_cx: &mut Context) {
#[cfg(not(windows))]
signal_hook::low_level::raise(signal_hook::consts::signal::SIGTSTP).unwrap();
}
+
+fn add_newline_above(cx: &mut Context) {
+ add_newline_impl(cx, Open::Above);
+}
+
+fn add_newline_below(cx: &mut Context) {
+ add_newline_impl(cx, Open::Below)
+}
+
+fn add_newline_impl(cx: &mut Context, open: Open) {
+ let count = cx.count();
+ let (view, doc) = current!(cx.editor);
+ let selection = doc.selection(view.id);
+ let text = doc.text();
+ let slice = text.slice(..);
+
+ let changes = selection.into_iter().map(|range| {
+ let (start, end) = range.line_range(slice);
+ let line = match open {
+ Open::Above => start,
+ Open::Below => end + 1,
+ };
+ let pos = text.line_to_char(line);
+ (
+ pos,
+ pos,
+ Some(doc.line_ending.as_str().repeat(count).into()),
+ )
+ });
+
+ let transaction = Transaction::change(text, changes);
+ doc.apply(&transaction, view.id);
+ doc.append_changes_to_history(view.id);
+}
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index 706cf29f..1b04b5cd 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -412,10 +412,12 @@ impl Default for Keymaps {
"[" => { "Left bracket"
"d" => goto_prev_diag,
"D" => goto_first_diag,
+ "space" => add_newline_above,
},
"]" => { "Right bracket"
"d" => goto_next_diag,
"D" => goto_last_diag,
+ "space" => add_newline_below,
},
"/" => search,
diff --git a/languages.toml b/languages.toml
index d028f92c..1a557943 100644
--- a/languages.toml
+++ b/languages.toml
@@ -312,6 +312,39 @@ roots = []
comment-token = ";"
indent = { tab-width = 4, unit = " " }
+[[language]]
+name = "ocaml"
+scope = "source.ocaml"
+injection-regex = "ocaml"
+file-types = ["ml"]
+roots = []
+comment-token = "(**)"
+indent = { tab-width = 2, unit = " " }
+
+[[language]]
+name = "ocaml-interface"
+scope = "source.ocaml.interface"
+file-types = ["mli"]
+roots = []
+comment-token = "(**)"
+indent = { tab-width = 2, unit = " "}
+
+[[language]]
+name = "lua"
+scope = "source.lua"
+file-types = ["lua"]
+roots = []
+comment-token = "--"
+indent = { tab-width = 2, unit = " " }
+
+[[language]]
+name = "yaml"
+scope = "source.yaml"
+file-types = ["yml", "yaml"]
+roots = []
+comment-token = "#"
+indent = { tab-width = 2, unit = " " }
+
# [[language]]
# name = "haskell"
# scope = "source.haskell"
diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm
new file mode 100644
index 00000000..8e27a39a
--- /dev/null
+++ b/runtime/queries/lua/highlights.scm
@@ -0,0 +1,166 @@
+;;; Highlighting for lua
+
+;;; Builtins
+(self) @variable.builtin
+
+;; Keywords
+
+(if_statement
+[
+ "if"
+ "then"
+ "end"
+] @keyword.control.conditional)
+
+[
+ "else"
+ "elseif"
+ "then"
+] @keyword.control.conditional
+
+(for_statement
+[
+ "for"
+ "do"
+ "end"
+] @keyword.control.loop)
+
+(for_in_statement
+[
+ "for"
+ "do"
+ "end"
+] @keyword.control.loop)
+
+(while_statement
+[
+ "while"
+ "do"
+ "end"
+] @keyword.control.loop)
+
+(repeat_statement
+[
+ "repeat"
+ "until"
+] @keyword.control.loop)
+
+(do_statement
+[
+ "do"
+ "end"
+] @keyword)
+
+[
+ "in"
+ "local"
+ (break_statement)
+ "goto"
+ "return"
+] @keyword
+
+;; Operators
+
+[
+ "not"
+ "and"
+ "or"
+] @keyword.operator
+
+[
+"="
+"~="
+"=="
+"<="
+">="
+"<"
+">"
+"+"
+"-"
+"%"
+"/"
+"//"
+"*"
+"^"
+"&"
+"~"
+"|"
+">>"
+"<<"
+".."
+"#"
+ ] @operator
+
+;; Punctuation
+["," "." ":" ";"] @punctuation.delimiter
+
+;; Brackets
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+; ;; Constants
+[
+(false)
+(true)
+] @boolean
+(nil) @constant.builtin
+(spread) @constant ;; "..."
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+
+;; Parameters
+(parameters
+ (identifier) @parameter)
+
+; ;; Functions
+(function [(function_name) (identifier)] @function)
+(function ["function" "end"] @keyword.function)
+
+(function
+ (function_name
+ (function_name_field
+ (property_identifier) @function .)))
+
+(local_function (identifier) @function)
+(local_function ["function" "end"] @keyword.function)
+
+(variable_declaration
+ (variable_declarator (identifier) @function) (function_definition))
+(local_variable_declaration
+ (variable_declarator (identifier) @function) (function_definition))
+
+(function_definition ["function" "end"] @keyword.function)
+
+(function_call
+ [
+ ((identifier) @variable (method) @method)
+ ((_) (method) @method)
+ (identifier) @function
+ (field_expression (property_identifier) @function)
+ ]
+ . (arguments))
+
+;; Nodes
+(table ["{" "}"] @constructor)
+(comment) @comment
+(string) @string
+(number) @number
+(label_statement) @label
+; A bit of a tricky one, this will only match field names
+(field . (identifier) @property (_))
+(shebang) @comment
+
+;; Property
+(property_identifier) @property
+
+;; Variable
+(identifier) @variable
+
+;; Error
+(ERROR) @error
diff --git a/runtime/queries/lua/indents.toml b/runtime/queries/lua/indents.toml
new file mode 100644
index 00000000..df1a9752
--- /dev/null
+++ b/runtime/queries/lua/indents.toml
@@ -0,0 +1,24 @@
+indent = [
+ "function_definition",
+ "variable_declaration",
+ "local_variable_declaration",
+ "field",
+ "local_function",
+ "function",
+ "if_statement",
+ "for_statement",
+ "for_in_statement",
+ "repeat_statement",
+ "return_statement",
+ "while_statement",
+ "table",
+ "arguments",
+ "do_statement",
+]
+
+oudent = [
+ "end",
+ "until",
+ "}",
+ ")",
+]
diff --git a/runtime/queries/ocaml-interface/highlights.scm b/runtime/queries/ocaml-interface/highlights.scm
new file mode 100644
index 00000000..6d3dfbcf
--- /dev/null
+++ b/runtime/queries/ocaml-interface/highlights.scm
@@ -0,0 +1 @@
+; inherits: ocaml
diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm
new file mode 100644
index 00000000..093b3cce
--- /dev/null
+++ b/runtime/queries/ocaml/highlights.scm
@@ -0,0 +1,160 @@
+; Modules
+;--------
+
+[(module_name) (module_type_name)] @namespace
+
+; Types
+;------
+
+[(class_name) (class_type_name) (type_constructor)] @type
+
+[(constructor_name) (tag)] @constructor
+
+; Functions
+;----------
+
+(let_binding
+ pattern: (value_name) @function
+ (parameter))
+
+(let_binding
+ pattern: (value_name) @function
+ body: [(fun_expression) (function_expression)])
+
+(value_specification (value_name) @function)
+
+(external (value_name) @function)
+
+(method_name) @method
+
+; Variables
+;----------
+
+(value_pattern) @parameter
+
+; Application
+;------------
+
+(infix_expression
+ left: (value_path (value_name) @function)
+ (infix_operator) @operator
+ (#eq? @operator "@@"))
+
+(infix_expression
+ (infix_operator) @operator
+ right: (value_path (value_name) @function)
+ (#eq? @operator "|>"))
+
+(application_expression
+ function: (value_path (value_name) @function))
+
+; Properties
+;-----------
+
+[(label_name) (field_name) (instance_variable_name)] @property
+
+; Constants
+;----------
+
+[(boolean) (unit)] @constant
+
+[(number) (signed_number)] @number
+
+(character) @character
+
+(string) @string
+
+(quoted_string "{" @string "}" @string) @string
+
+(escape_sequence) @string.escape
+
+[
+ (conversion_specification)
+ (pretty_printing_indication)
+] @punctuation.special
+
+; Keywords
+;---------
+
+[
+ "and" "as" "assert" "begin" "class" "constraint"
+ "end" "external" "in"
+ "inherit" "initializer" "lazy" "let" "match" "method" "module"
+ "mutable" "new" "nonrec" "object" "of" "private" "rec" "sig" "struct"
+ "type" "val" "virtual" "when" "with"
+] @keyword
+
+["fun" "function" "functor"] @keyword.function
+
+["if" "then" "else"] @keyword.control.conditional
+
+["exception" "try"] @keyword.control.exception
+
+["include" "open"] @include
+
+["for" "to" "downto" "while" "do" "done"] @keyword.control.loop
+
+; Macros
+;-------
+
+(attribute ["[@" "]"] @attribute)
+(item_attribute ["[@@" "]"] @attribute)
+(floating_attribute ["[@@@" "]"] @attribute)
+(extension ["[%" "]"] @function.macro)
+(item_extension ["[%%" "]"] @function.macro)
+(quoted_extension ["{%" "}"] @function.macro)
+(quoted_item_extension ["{%%" "}"] @function.macro)
+"%" @function.macro
+
+["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
+
+(object_type ["<" ">"] @punctuation.bracket)
+
+[
+ "," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
+ "->" ";;" ":>" "+=" ":=" ".."
+] @punctuation.delimiter
+
+; Operators
+;----------
+
+[
+ (prefix_operator)
+ (sign_operator)
+ (infix_operator)
+ (hash_operator)
+ (indexing_operator)
+ (let_operator)
+ (and_operator)
+ (match_operator)
+] @operator
+
+(match_expression (match_operator) @keyword)
+
+(value_definition [(let_operator) (and_operator)] @keyword)
+
+;; TODO: this is an error now
+;(prefix_operator "!" @operator)
+
+(infix_operator ["&" "+" "-" "=" ">" "|" "%"] @operator)
+
+(signed_number ["+" "-"] @operator)
+
+["*" "#" "::" "<-"] @operator
+
+; Attributes
+;-----------
+
+(attribute_id) @property
+
+; Comments
+;---------
+
+[(comment) (line_number_directive) (directive) (shebang)] @comment
+
+(ERROR) @error
+
+; Blanket highlights
+; ------------------
+
+[(value_name) (type_variable)] @variable
diff --git a/runtime/queries/ocaml/indents.toml b/runtime/queries/ocaml/indents.toml
new file mode 100644
index 00000000..9b6462d8
--- /dev/null
+++ b/runtime/queries/ocaml/indents.toml
@@ -0,0 +1,13 @@
+indent = [
+ "let_binding",
+ "type_binding",
+ "structure",
+ "signature",
+ "record_declaration",
+ "function_expression",
+ "match_case",
+]
+
+oudent = [
+ "}",
+]
diff --git a/runtime/queries/ocaml/locals.scm b/runtime/queries/ocaml/locals.scm
new file mode 100644
index 00000000..8f3f3fdf
--- /dev/null
+++ b/runtime/queries/ocaml/locals.scm
@@ -0,0 +1,24 @@
+; Scopes
+;-------
+
+[
+ (let_binding)
+ (class_binding)
+ (class_function)
+ (method_definition)
+ (fun_expression)
+ (object_expression)
+ (for_expression)
+ (match_case)
+ (attribute_payload)
+] @local.scope
+
+; Definitions
+;------------
+
+(value_pattern) @local.definition
+
+; References
+;-----------
+
+(value_path . (value_name) @local.reference)
diff --git a/runtime/queries/yaml/highlights.scm b/runtime/queries/yaml/highlights.scm
new file mode 100644
index 00000000..4ebb4440
--- /dev/null
+++ b/runtime/queries/yaml/highlights.scm
@@ -0,0 +1,33 @@
+(block_mapping_pair key: (_) @property)
+(flow_mapping (_ key: (_) @property))
+(boolean_scalar) @boolean
+(null_scalar) @constant.builtin
+(double_quote_scalar) @string
+(single_quote_scalar) @string
+(escape_sequence) @string.escape
+(integer_scalar) @number
+(float_scalar) @number
+(comment) @comment
+(anchor_name) @type
+(alias_name) @type
+(tag) @type
+(yaml_directive) @keyword
+(ERROR) @error
+
+[
+","
+"-"
+":"
+">"
+"?"
+"|"
+] @punctuation.delimiter
+
+[
+"["
+"]"
+"{"
+"}"
+] @punctuation.bracket
+
+["*" "&"] @punctuation.special
diff --git a/runtime/queries/yaml/indents.toml b/runtime/queries/yaml/indents.toml
new file mode 100644
index 00000000..ddc3578b
--- /dev/null
+++ b/runtime/queries/yaml/indents.toml
@@ -0,0 +1,3 @@
+indent = [
+ "block_mapping_pair",
+]