Merge branch 'master' into cursor-shape-new

pull/1154/head
Gokul Soumya 3 years ago
commit b3b4e78585

10
.gitmodules vendored

@ -177,7 +177,7 @@
[submodule "helix-syntax/languages/tree-sitter-llvm-mir"] [submodule "helix-syntax/languages/tree-sitter-llvm-mir"]
path = helix-syntax/languages/tree-sitter-llvm-mir path = helix-syntax/languages/tree-sitter-llvm-mir
url = https://github.com/Flakebi/tree-sitter-llvm-mir.git url = https://github.com/Flakebi/tree-sitter-llvm-mir.git
shallow = true shallow = true
[submodule "helix-syntax/languages/tree-sitter-git-diff"] [submodule "helix-syntax/languages/tree-sitter-git-diff"]
path = helix-syntax/languages/tree-sitter-git-diff path = helix-syntax/languages/tree-sitter-git-diff
url = https://github.com/the-mikedavis/tree-sitter-git-diff.git url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
@ -190,3 +190,11 @@
path = helix-syntax/languages/tree-sitter-git-rebase path = helix-syntax/languages/tree-sitter-git-rebase
url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git
shallow = true shallow = true
[submodule "helix-syntax/languages/tree-sitter-regex"]
path = helix-syntax/languages/tree-sitter-regex
url = https://github.com/tree-sitter/tree-sitter-regex.git
shallow = true
[submodule "helix-syntax/languages/tree-sitter-make"]
path = helix-syntax/languages/tree-sitter-make
url = https://github.com/alemuller/tree-sitter-make
shallow = true

@ -58,7 +58,7 @@ of the terminal environment, only the primary cursor can change shape.
[insert mode]: ./keymap.md#insert-mode [insert mode]: ./keymap.md#insert-mode
[select mode]: ./keymap.md#select--extend-mode [select mode]: ./keymap.md#select--extend-mode
### `[editor.filepicker]` Section ### `[editor.file-picker]` Section
Sets options for file picker and global search. All but the last key listed in Sets options for file picker and global search. All but the last key listed in
the default file-picker configuration below are IgnoreOptions: whether hidden the default file-picker configuration below are IgnoreOptions: whether hidden

@ -18,7 +18,7 @@
| go | ✓ | ✓ | ✓ | `gopls` | | go | ✓ | ✓ | ✓ | `gopls` |
| html | ✓ | | | | | html | ✓ | | | |
| java | ✓ | | | | | java | ✓ | | | |
| javascript | ✓ | | ✓ | | | javascript | ✓ | | ✓ | `typescript-language-server` |
| json | ✓ | | ✓ | | | json | ✓ | | ✓ | |
| julia | ✓ | | | `julia` | | julia | ✓ | | | `julia` |
| latex | ✓ | | | | | latex | ✓ | | | |
@ -27,6 +27,7 @@
| llvm-mir | ✓ | ✓ | ✓ | | | llvm-mir | ✓ | ✓ | ✓ | |
| llvm-mir-yaml | ✓ | | ✓ | | | llvm-mir-yaml | ✓ | | ✓ | |
| lua | ✓ | | ✓ | | | lua | ✓ | | ✓ | |
| make | ✓ | | | |
| markdown | ✓ | | | | | markdown | ✓ | | | |
| mint | | | | `mint` | | mint | | | | `mint` |
| nix | ✓ | | ✓ | `rnix-lsp` | | nix | ✓ | | ✓ | `rnix-lsp` |
@ -38,6 +39,7 @@
| protobuf | ✓ | | ✓ | | | protobuf | ✓ | | ✓ | |
| python | ✓ | ✓ | ✓ | `pylsp` | | python | ✓ | ✓ | ✓ | `pylsp` |
| racket | | | | `racket` | | racket | | | | `racket` |
| regex | ✓ | | | |
| ruby | ✓ | | ✓ | `solargraph` | | ruby | ✓ | | ✓ | `solargraph` |
| rust | ✓ | ✓ | ✓ | `rust-analyzer` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` |
| scala | ✓ | | ✓ | `metals` | | scala | ✓ | | ✓ | `metals` |

@ -1,14 +1,14 @@
# Themes # Themes
First you'll need to place selected themes in your `themes` directory (i.e `~/.config/helix/themes`), the directory might have to be created beforehand. To use a theme add `theme = "<name>"` to your [`config.toml`](./configuration.md) at the very top of the file before the first section or select it during runtime using `:theme <name>`.
To use a custom theme add `theme = <name>` to your [`config.toml`](./configuration.md) or override it during runtime using `:theme <name>`. ## Creating a theme
The default theme.toml can be found [here](https://github.com/helix-editor/helix/blob/master/theme.toml), and user submitted themes [here](https://github.com/helix-editor/helix/blob/master/runtime/themes). Create a file with the name of your theme as file name (i.e `mytheme.toml`) and place it in your `themes` directory (i.e `~/.config/helix/themes`). The directory might have to be created beforehand.
## Creating a theme The names "default" and "base16_default" are reserved for the builtin themes and cannot be overridden by user defined themes.
First create a file with the name of your theme as file name (i.e `mytheme.toml`) and place it in your `themes` directory (i.e `~/.config/helix/themes`). The default theme.toml can be found [here](https://github.com/helix-editor/helix/blob/master/theme.toml), and user submitted themes [here](https://github.com/helix-editor/helix/blob/master/runtime/themes).
Each line in the theme file is specified as below: Each line in the theme file is specified as below:
@ -147,6 +147,7 @@ We use a similar set of scopes as
- `repeat` - `for`, `while`, `loop` - `repeat` - `for`, `while`, `loop`
- `import` - `import`, `export` - `import` - `import`, `export`
- `return` - `return`
- `exception`
- `operator` - `or`, `in` - `operator` - `or`, `in`
- `directive` - Preprocessor directives (`#if` in C) - `directive` - Preprocessor directives (`#if` in C)
- `function` - `fn`, `func` - `function` - `fn`, `func`
@ -171,8 +172,9 @@ We use a similar set of scopes as
- `bold` - `bold`
- `italic` - `italic`
- `link` - `link`
- `url` - `url` - urls pointed to by links
- `label` - `label` - non-url link references
- `text` - url and image descriptions in links
- `quote` - `quote`
- `raw` - `raw`
- `inline` - `inline`

@ -12,7 +12,7 @@ pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: &Selection)
.root_node() .root_node()
.descendant_for_byte_range(from, to) .descendant_for_byte_range(from, to)
.and_then(|node| { .and_then(|node| {
if node.child_count() == 0 || (node.start_byte() == from && node.end_byte() == to) { if node.start_byte() == from && node.end_byte() == to {
node.parent() node.parent()
} else { } else {
Some(node) Some(node)

@ -175,7 +175,6 @@ fn build_dir(dir: &str, language: &str) {
fn main() { fn main() {
let ignore = vec![ let ignore = vec![
"tree-sitter-typescript".to_string(), "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(), "tree-sitter-ocaml".to_string(),
]; ];
let dirs = collect_tree_sitter_dirs(&ignore).unwrap(); let dirs = collect_tree_sitter_dirs(&ignore).unwrap();

@ -1 +1 @@
Subproject commit 237f4eb4417c28f643a29d795ed227246afb66f9 Subproject commit b6ec26f181dd059eedd506fa5fbeae1b8e5556c8

@ -0,0 +1 @@
Subproject commit a4b9187417d6be349ee5fd4b6e77b4172c6827dd

@ -0,0 +1 @@
Subproject commit e1cfca3c79896ff79842f057ea13e529b66af636

@ -20,14 +20,18 @@ pub struct LspConfig {
pub display_messages: bool, pub display_messages: bool,
} }
#[test] #[cfg(test)]
fn parsing_keymaps_config_file() { mod tests {
use crate::keymap; use super::*;
use crate::keymap::Keymap;
use helix_core::hashmap; #[test]
use helix_view::document::Mode; fn parsing_keymaps_config_file() {
use crate::keymap;
let sample_keymaps = r#" use crate::keymap::Keymap;
use helix_core::hashmap;
use helix_view::document::Mode;
let sample_keymaps = r#"
[keys.insert] [keys.insert]
y = "move_line_down" y = "move_line_down"
S-C-a = "delete_selection" S-C-a = "delete_selection"
@ -36,19 +40,20 @@ fn parsing_keymaps_config_file() {
A-F12 = "move_next_word_end" A-F12 = "move_next_word_end"
"#; "#;
assert_eq!( assert_eq!(
toml::from_str::<Config>(sample_keymaps).unwrap(), toml::from_str::<Config>(sample_keymaps).unwrap(),
Config { Config {
keys: Keymaps(hashmap! { keys: Keymaps(hashmap! {
Mode::Insert => Keymap::new(keymap!({ "Insert mode" Mode::Insert => Keymap::new(keymap!({ "Insert mode"
"y" => move_line_down, "y" => move_line_down,
"S-C-a" => delete_selection, "S-C-a" => delete_selection,
})), })),
Mode::Normal => Keymap::new(keymap!({ "Normal mode" Mode::Normal => Keymap::new(keymap!({ "Normal mode"
"A-F12" => move_next_word_end, "A-F12" => move_next_word_end,
})), })),
}), }),
..Default::default() ..Default::default()
} }
); );
}
} }

@ -296,53 +296,58 @@ impl TryFrom<Value> for ThemePalette {
} }
} }
#[test] #[cfg(test)]
fn test_parse_style_string() { mod tests {
let fg = Value::String("#ffffff".to_string()); use super::*;
let mut style = Style::default(); #[test]
let palette = ThemePalette::default(); fn test_parse_style_string() {
palette.parse_style(&mut style, fg).unwrap(); let fg = Value::String("#ffffff".to_string());
assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255))); let mut style = Style::default();
} let palette = ThemePalette::default();
palette.parse_style(&mut style, fg).unwrap();
#[test] assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255)));
fn test_palette() { }
use helix_core::hashmap;
let fg = Value::String("my_color".to_string());
let mut style = Style::default(); #[test]
let palette = fn test_palette() {
ThemePalette::new(hashmap! { "my_color".to_string() => Color::Rgb(255, 255, 255) }); use helix_core::hashmap;
palette.parse_style(&mut style, fg).unwrap(); let fg = Value::String("my_color".to_string());
assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255))); let mut style = Style::default();
} let palette =
ThemePalette::new(hashmap! { "my_color".to_string() => Color::Rgb(255, 255, 255) });
palette.parse_style(&mut style, fg).unwrap();
#[test] assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255)));
fn test_parse_style_table() { }
let table = toml::toml! {
"keyword" = {
fg = "#ffffff",
bg = "#000000",
modifiers = ["bold"],
}
};
let mut style = Style::default(); #[test]
let palette = ThemePalette::default(); fn test_parse_style_table() {
if let Value::Table(entries) = table { let table = toml::toml! {
for (_name, value) in entries { "keyword" = {
palette.parse_style(&mut style, value).unwrap(); fg = "#ffffff",
bg = "#000000",
modifiers = ["bold"],
}
};
let mut style = Style::default();
let palette = ThemePalette::default();
if let Value::Table(entries) = table {
for (_name, value) in entries {
palette.parse_style(&mut style, value).unwrap();
}
} }
}
assert_eq!( assert_eq!(
style, style,
Style::default() Style::default()
.fg(Color::Rgb(255, 255, 255)) .fg(Color::Rgb(255, 255, 255))
.bg(Color::Rgb(0, 0, 0)) .bg(Color::Rgb(0, 0, 0))
.add_modifier(Modifier::BOLD) .add_modifier(Modifier::BOLD)
); );
}
} }

@ -128,6 +128,7 @@ roots = []
comment-token = "//" comment-token = "//"
# TODO: highlights-jsx, highlights-params # TODO: highlights-jsx, highlights-params
language-server = { command = "typescript-language-server", args = ["--stdio"] }
indent = { tab-width = 2, unit = " " } indent = { tab-width = 2, unit = " " }
[[language]] [[language]]
@ -389,6 +390,13 @@ indent = { tab-width = 2, unit = " " }
language-server = { command = "cmake-language-server" } language-server = { command = "cmake-language-server" }
injection-regex = "cmake" injection-regex = "cmake"
[[language]]
name = "make"
scope = "source.make"
file-types = ["Makefile", "makefile", "justfile", ".justfile"]
roots =[]
comment-token = "#"
[[language]] [[language]]
name = "glsl" name = "glsl"
scope = "source.glsl" scope = "source.glsl"
@ -530,3 +538,10 @@ file-types = ["git-rebase-todo"]
injection-regex = "git-rebase" injection-regex = "git-rebase"
comment-token = "#" comment-token = "#"
indent = { tab-width = 2, unit = " " } indent = { tab-width = 2, unit = " " }
[[language]]
name = "regex"
scope = "source.regex"
injection-regex = "regex"
file-types = ["regex"]
roots = []

@ -1,2 +1,9 @@
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#match? @_sigil_name "^(r|R)$")
(#set! injection.language "regex")
(#set! injection.combined))

@ -1,45 +1,125 @@
(variable) @variable ;; ----------------------------------------------------------------------------
(operator) @operator ;; Literals and comments
(exp_name (constructor) @constructor)
(constructor_operator) @operator
(module) @namespace
(type) @type
(type) @class
(constructor) @constructor
(pragma) @pragma
(comment) @comment
(signature name: (variable) @type)
(function name: (variable) @function)
(constraint class: (class_name (type)) @class)
(class (class_head class: (class_name (type)) @class))
(instance (instance_head class: (class_name (type)) @class))
(integer) @constant.numeric.integer (integer) @constant.numeric.integer
(exp_negation) @constant.numeric.integer
(exp_literal (float)) @constant.numeric.float (exp_literal (float)) @constant.numeric.float
(char) @constant.character (char) @constant.character
(con_unit) @literal (string) @string
(con_list) @literal
(tycon_arrow) @operator (con_unit) @constant.builtin ; unit, as in ()
(where) @keyword
"module" @keyword (comment) @comment
"let" @keyword
"in" @keyword
"class" @keyword ;; ----------------------------------------------------------------------------
"instance" @keyword ;; Punctuation
"data" @keyword
"newtype" @keyword
"family" @keyword
"type" @keyword
"import" @keyword
"qualified" @keyword
"as" @keyword
"deriving" @keyword
"via" @keyword
"stock" @keyword
"anyclass" @keyword
"do" @keyword
"mdo" @keyword
"rec" @keyword
[ [
"(" "("
")" ")"
"{"
"}"
"["
"]"
] @punctuation.bracket ] @punctuation.bracket
[
(comma)
";"
] @punctuation.delimiter
;; ----------------------------------------------------------------------------
;; Keywords, operators, includes
(pragma) @constant.macro
[
"if"
"then"
"else"
"case"
"of"
] @keyword.control.conditional
[
"import"
"qualified"
"module"
] @keyword.control.import
[
(operator)
(constructor_operator)
(type_operator)
(tycon_arrow)
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
(all_names)
(wildcard)
"="
"|"
"::"
"=>"
"->"
"<-"
"\\"
"`"
"@"
] @operator
(qualified_module (module) @constructor)
(qualified_type (module) @namespace)
(qualified_variable (module) @namespace)
(import (module) @namespace)
[
(where)
"let"
"in"
"class"
"instance"
"data"
"newtype"
"family"
"type"
"as"
"hiding"
"deriving"
"via"
"stock"
"anyclass"
"do"
"mdo"
"rec"
"forall"
"∀"
"infix"
"infixl"
"infixr"
] @keyword
;; ----------------------------------------------------------------------------
;; Functions and variables
(signature name: (variable) @type)
(function name: (variable) @function)
(variable) @variable
"_" @variable.builtin
(exp_infix (variable) @operator) ; consider infix functions as operators
("@" @namespace) ; "as" pattern operator, e.g. x@Constructor
;; ----------------------------------------------------------------------------
;; Types
(type) @type
(constructor) @constructor
; True or False
((constructor) @_bool (#match? @_bool "(True|False)")) @constant.builtin.boolean

@ -0,0 +1,170 @@
[
"("
")"
"{"
"}"
] @punctuation.bracket
[
":"
"&:"
"::"
"|"
";"
"\""
"'"
","
] @punctuation.delimiter
[
"$"
"$$"
] @punctuation.special
(automatic_variable
[ "@" "%" "<" "?" "^" "+" "/" "*" "D" "F"] @punctuation.special)
(automatic_variable
"/" @error . ["D" "F"])
[
"="
":="
"::="
"?="
"+="
"!="
"@"
"-"
"+"
] @operator
[
(text)
(string)
(raw_text)
] @string
(variable_assignment (word) @string)
[
"ifeq"
"ifneq"
"ifdef"
"ifndef"
"else"
"endif"
"if"
"or" ; boolean functions are conditional in make grammar
"and"
] @keyword.control.conditional
"foreach" @keyword.control.repeat
[
"define"
"endef"
"vpath"
"undefine"
"export"
"unexport"
"override"
"private"
; "load"
] @keyword
[
"include"
"sinclude"
"-include"
] @keyword.control.import
[
"subst"
"patsubst"
"strip"
"findstring"
"filter"
"filter-out"
"sort"
"word"
"words"
"wordlist"
"firstword"
"lastword"
"dir"
"notdir"
"suffix"
"basename"
"addsuffix"
"addprefix"
"join"
"wildcard"
"realpath"
"abspath"
"call"
"eval"
"file"
"value"
"shell"
] @keyword.function
[
"error"
"warning"
"info"
] @keyword.control.exception
;; Variable
(variable_assignment
name: (word) @variable)
(variable_reference
(word) @variable)
(comment) @comment
((word) @clean @string.regexp
(#match? @clean "[%\*\?]"))
(function_call
function: "error"
(arguments (text) @error))
(function_call
function: "warning"
(arguments (text) @warning))
(function_call
function: "info"
(arguments (text) @info))
;; Install Command Categories
;; Others special variables
;; Variables Used by Implicit Rules
[
"VPATH"
".RECIPEPREFIX"
] @constant.builtin
(variable_assignment
name: (word) @clean @constant.builtin
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS)$"))
(variable_reference
(word) @clean @constant.builtin
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS\.VARIABLES|\.FEATURES|\.INCLUDE_DIRS|\.LOADED)$"))
;; Standart targets
(targets
(word) @constant.macro
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
(targets
(word) @constant.macro
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
;; Builtin targets
(targets
(word) @constant.macro
(#match? @constant.macro "^\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX)$"))

@ -21,6 +21,11 @@
(link_destination) @markup.link.url (link_destination) @markup.link.url
(link_label) @markup.link.label (link_label) @markup.link.label
[
(link_text)
(image_description)
] @markup.link.text
[ [
(list_marker_plus) (list_marker_plus)
(list_marker_minus) (list_marker_minus)

@ -0,0 +1,53 @@
; upstream: https://github.com/tree-sitter/tree-sitter-regex/blob/e1cfca3c79896ff79842f057ea13e529b66af636/queries/highlights.scm
[
"("
")"
"(?"
"(?:"
"(?<"
">"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
"*"
"+"
"|"
"="
"<="
"!"
"<!"
"?"
] @operator
[
(identity_escape)
(control_letter_escape)
(character_class_escape)
(control_escape)
(start_assertion)
(end_assertion)
(boundary_assertion)
(non_boundary_assertion)
] @constant.character.escape
(group_name) @property
(count_quantifier
[
(decimal_digits) @constant.numeric
"," @punctuation.delimiter
])
(character_class
[
"^" @operator
(class_range "-" @operator)
])
(class_character) @constant.character
(pattern_character) @string

@ -10,3 +10,17 @@
(token_tree) @injection.content) (token_tree) @injection.content)
(#set! injection.language "rust") (#set! injection.language "rust")
(#set! injection.include-children)) (#set! injection.include-children))
(call_expression
function: (scoped_identifier
path: (identifier) @_regex (#eq? @_regex "Regex")
name: (identifier) @_new (#eq? @_new "new"))
arguments: (arguments (raw_string_literal) @injection.content)
(#set! injection.language "regex"))
(call_expression
function: (scoped_identifier
path: (scoped_identifier (identifier) @_regex (#eq? @_regex "Regex") .)
name: (identifier) @_new (#eq? @_new "new"))
arguments: (arguments (raw_string_literal) @injection.content)
(#set! injection.language "regex"))

@ -32,6 +32,7 @@ label = "honey"
"markup.bold" = { modifiers = ["bold"] } "markup.bold" = { modifiers = ["bold"] }
"markup.italic" = { modifiers = ["italic"] } "markup.italic" = { modifiers = ["italic"] }
"markup.link.url" = { fg = "silver", modifiers = ["underlined"] } "markup.link.url" = { fg = "silver", modifiers = ["underlined"] }
"markup.link.text" = "almond"
"markup.raw" = "almond" "markup.raw" = "almond"
"diff.plus" = "#35bf86" "diff.plus" = "#35bf86"

Loading…
Cancel
Save