diff options
-rw-r--r-- | Cargo.lock | 16 | ||||
-rw-r--r-- | book/src/keymap.md | 8 | ||||
-rw-r--r-- | helix-core/Cargo.toml | 4 | ||||
-rw-r--r-- | helix-lsp/Cargo.toml | 6 | ||||
m--------- | helix-syntax/languages/tree-sitter-zig | 0 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 100 | ||||
-rw-r--r-- | runtime/queries/zig/highlights.scm | 197 | ||||
-rw-r--r-- | runtime/queries/zig/indents.toml | 9 | ||||
-rw-r--r-- | runtime/themes/nord.toml | 84 |
9 files changed, 275 insertions, 149 deletions
@@ -599,9 +599,9 @@ dependencies = [ [[package]] name = "lsp-types" -version = "0.89.2" +version = "0.90.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852e0dedfd52cc32325598b2631e0eba31b7b708959676a9f837042f276b09a2" +checksum = "a7404037aab080771c90b0a499836d9d8a10336ecd07badf969567b65c6d51a1" dependencies = [ "bitflags", "serde", @@ -966,9 +966,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf11003835e462f07851028082d2a1c89d956180ce4b4b50e07fb085ec4131a" +checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3" [[package]] name = "slab" @@ -987,9 +987,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "str-buf" @@ -1074,9 +1074,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce" +checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" dependencies = [ "autocfg", "bytes", diff --git a/book/src/keymap.md b/book/src/keymap.md index 78bac0cf..156b1d99 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -88,10 +88,10 @@ | `,` | Keep only the primary selection | `keep_primary_selection` | | `C` | Copy selection onto the next line | `copy_selection_on_next_line` | | `Alt-C` | Copy selection onto the previous line | `copy_selection_on_prev_line` | -| `(` | Rotate main selection forward | `rotate_selections_backward` | -| `)` | Rotate main selection backward | `rotate_selections_forward` | -| `Alt-(` | Rotate selection contents forward | `rotate_selection_contents_backward` | -| `Alt-)` | Rotate selection contents backward | `rotate_selection_contents_forward` | +| `(` | Rotate main selection backward | `rotate_selections_backward` | +| `)` | Rotate main selection forward | `rotate_selections_forward` | +| `Alt-(` | Rotate selection contents backward | `rotate_selection_contents_backward` | +| `Alt-)` | Rotate selection contents forward | `rotate_selection_contents_forward` | | `%` | Select entire file | `select_all` | | `x` | Select current line, if already selected, extend to next line | `extend_line` | | `X` | Extend selection to line bounds (line-wise selection) | `extend_to_line_bounds` | diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index e6843375..27adceb2 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -17,7 +17,7 @@ helix-syntax = { version = "0.4", path = "../helix-syntax" } helix-dap = { version = "0.4", path = "../helix-dap" } ropey = "1.3" -smallvec = "1.4" +smallvec = "1.7" tendril = "0.4.2" unicode-segmentation = "1.8" unicode-width = "0.1" @@ -31,7 +31,7 @@ regex = "1" serde = { version = "1.0", features = ["derive"] } toml = "0.5" -similar = "2.0" +similar = "2.1" etcetera = "0.3" diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml index aaa7e8a1..1252172a 100644 --- a/helix-lsp/Cargo.toml +++ b/helix-lsp/Cargo.toml @@ -19,9 +19,9 @@ futures-executor = "0.3" futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false } jsonrpc-core = { version = "18.0", default-features = false } # don't pull in all of futures log = "0.4" -lsp-types = { version = "0.89", features = ["proposed"] } +lsp-types = { version = "0.90", features = ["proposed"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -tokio = { version = "1.11", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } -tokio-stream = "0.1" +tokio = { version = "1.12", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } +tokio-stream = "0.1.7" diff --git a/helix-syntax/languages/tree-sitter-zig b/helix-syntax/languages/tree-sitter-zig -Subproject 049162bea8a44e1a4acd01b06e1c8672d9231a8 +Subproject 1f27fd1dfe7f352408f01b4894c7825f3a1d6c4 diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index f3f62d6b..9cf912cf 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1310,6 +1310,7 @@ fn global_search(cx: &mut Context) { cx.push_layer(Box::new(prompt)); + let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); let show_picker = async move { let all_matches: Vec<(usize, PathBuf)> = UnboundedReceiverStream::new(all_matches_rx).collect().await; @@ -1321,7 +1322,13 @@ fn global_search(cx: &mut Context) { } let picker = FilePicker::new( all_matches, - move |(_line_num, path)| path.to_str().unwrap().into(), + move |(_line_num, path)| { + path.strip_prefix(&root) + .unwrap_or(path) + .to_str() + .unwrap() + .into() + }, move |editor: &mut Editor, (line_num, path), action| { match editor.open(path.into(), action) { Ok(_) => {} @@ -1504,7 +1511,7 @@ mod cmd { #[derive(Clone)] pub struct TypableCommand { pub name: &'static str, - pub alias: Option<&'static str>, + pub aliases: &'static [&'static str], pub doc: &'static str, // params, flags, helper, completer pub fun: fn(&mut compositor::Context, &[&str], PromptEvent) -> anyhow::Result<()>, @@ -2178,238 +2185,238 @@ mod cmd { pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", - alias: Some("q"), + aliases: &["q"], doc: "Close the current view.", fun: quit, completer: None, }, TypableCommand { name: "quit!", - alias: Some("q!"), + aliases: &["q!"], doc: "Close the current view.", fun: force_quit, completer: None, }, TypableCommand { name: "open", - alias: Some("o"), + aliases: &["o"], doc: "Open a file from disk into the current view.", fun: open, completer: Some(completers::filename), }, TypableCommand { name: "write", - alias: Some("w"), + aliases: &["w"], doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)", fun: write, completer: Some(completers::filename), }, TypableCommand { name: "new", - alias: Some("n"), + aliases: &["n"], doc: "Create a new scratch buffer.", fun: new_file, completer: Some(completers::filename), }, TypableCommand { name: "format", - alias: Some("fmt"), + aliases: &["fmt"], doc: "Format the file using a formatter.", fun: format, completer: None, }, TypableCommand { name: "indent-style", - alias: None, + aliases: &[], doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)", fun: set_indent_style, completer: None, }, TypableCommand { name: "line-ending", - alias: None, + aliases: &[], doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.", fun: set_line_ending, completer: None, }, TypableCommand { name: "earlier", - alias: Some("ear"), + aliases: &["ear"], doc: "Jump back to an earlier point in edit history. Accepts a number of steps or a time span.", fun: earlier, completer: None, }, TypableCommand { name: "later", - alias: Some("lat"), + aliases: &["lat"], doc: "Jump to a later point in edit history. Accepts a number of steps or a time span.", fun: later, completer: None, }, TypableCommand { name: "write-quit", - alias: Some("wq"), + aliases: &["wq", "x"], doc: "Writes changes to disk and closes the current view. Accepts an optional path (:wq some/path.txt)", fun: write_quit, completer: Some(completers::filename), }, TypableCommand { name: "write-quit!", - alias: Some("wq!"), + aliases: &["wq!", "x!"], doc: "Writes changes to disk and closes the current view forcefully. Accepts an optional path (:wq! some/path.txt)", fun: force_write_quit, completer: Some(completers::filename), }, TypableCommand { name: "write-all", - alias: Some("wa"), + aliases: &["wa"], doc: "Writes changes from all views to disk.", fun: write_all, completer: None, }, TypableCommand { name: "write-quit-all", - alias: Some("wqa"), + aliases: &["wqa", "xa"], doc: "Writes changes from all views to disk and close all views.", fun: write_all_quit, completer: None, }, TypableCommand { name: "write-quit-all!", - alias: Some("wqa!"), + aliases: &["wqa!", "xa!"], doc: "Writes changes from all views to disk and close all views forcefully (ignoring unsaved changes).", fun: force_write_all_quit, completer: None, }, TypableCommand { name: "quit-all", - alias: Some("qa"), + aliases: &["qa"], doc: "Close all views.", fun: quit_all, completer: None, }, TypableCommand { name: "quit-all!", - alias: Some("qa!"), + aliases: &["qa!"], doc: "Close all views forcefully (ignoring unsaved changes).", fun: force_quit_all, completer: None, }, TypableCommand { name: "theme", - alias: None, + aliases: &[], doc: "Change the theme of current view. Requires theme name as argument (:theme <name>)", fun: theme, completer: Some(completers::theme), }, TypableCommand { name: "clipboard-yank", - alias: None, + aliases: &[], doc: "Yank main selection into system clipboard.", fun: yank_main_selection_to_clipboard, completer: None, }, TypableCommand { name: "clipboard-yank-join", - alias: None, + aliases: &[], doc: "Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc. fun: yank_joined_to_clipboard, completer: None, }, TypableCommand { name: "primary-clipboard-yank", - alias: None, + aliases: &[], doc: "Yank main selection into system primary clipboard.", fun: yank_main_selection_to_primary_clipboard, completer: None, }, TypableCommand { name: "primary-clipboard-yank-join", - alias: None, + aliases: &[], doc: "Yank joined selections into system primary clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc. fun: yank_joined_to_primary_clipboard, completer: None, }, TypableCommand { name: "clipboard-paste-after", - alias: None, + aliases: &[], doc: "Paste system clipboard after selections.", fun: paste_clipboard_after, completer: None, }, TypableCommand { name: "clipboard-paste-before", - alias: None, + aliases: &[], doc: "Paste system clipboard before selections.", fun: paste_clipboard_before, completer: None, }, TypableCommand { name: "clipboard-paste-replace", - alias: None, + aliases: &[], doc: "Replace selections with content of system clipboard.", fun: replace_selections_with_clipboard, completer: None, }, TypableCommand { name: "primary-clipboard-paste-after", - alias: None, + aliases: &[], doc: "Paste primary clipboard after selections.", fun: paste_primary_clipboard_after, completer: None, }, TypableCommand { name: "primary-clipboard-paste-before", - alias: None, + aliases: &[], doc: "Paste primary clipboard before selections.", fun: paste_primary_clipboard_before, completer: None, }, TypableCommand { name: "primary-clipboard-paste-replace", - alias: None, + aliases: &[], doc: "Replace selections with content of system primary clipboard.", fun: replace_selections_with_primary_clipboard, completer: None, }, TypableCommand { name: "show-clipboard-provider", - alias: None, + aliases: &[], doc: "Show clipboard provider name in status bar.", fun: show_clipboard_provider, completer: None, }, TypableCommand { name: "change-current-directory", - alias: Some("cd"), + aliases: &["cd"], doc: "Change the current working directory (:cd <dir>).", fun: change_current_directory, completer: Some(completers::directory), }, TypableCommand { name: "show-directory", - alias: Some("pwd"), + aliases: &["pwd"], doc: "Show the current working directory.", fun: show_current_directory, completer: None, }, TypableCommand { name: "encoding", - alias: None, + aliases: &[], doc: "Set encoding based on `https://encoding.spec.whatwg.org`", fun: set_encoding, completer: None, }, TypableCommand { name: "reload", - alias: None, + aliases: &[], doc: "Discard changes and reload from the source file.", fun: reload, completer: None, }, TypableCommand { name: "tree-sitter-scopes", - alias: None, + aliases: &[], doc: "Display tree sitter scopes, primarily for theming and development.", fun: tree_sitter_scopes, completer: None, @@ -2437,14 +2444,14 @@ mod cmd { }, TypableCommand { name: "vsplit", - alias: Some("vs"), + aliases: &["vs"], doc: "Open the file in a vertical split.", fun: vsplit, completer: Some(completers::filename), }, TypableCommand { name: "hsplit", - alias: Some("sp"), + aliases: &["hs", "sp"], doc: "Open the file in a horizontal split.", fun: hsplit, completer: Some(completers::filename), @@ -2452,16 +2459,13 @@ mod cmd { ]; pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| { - let mut map = HashMap::new(); - - for cmd in TYPABLE_COMMAND_LIST { - map.insert(cmd.name, cmd); - if let Some(alias) = cmd.alias { - map.insert(alias, cmd); - } - } - - map + TYPABLE_COMMAND_LIST + .iter() + .flat_map(|cmd| { + std::iter::once((cmd.name, cmd)) + .chain(cmd.aliases.iter().map(move |&alias| (alias, cmd))) + }) + .collect() }); } diff --git a/runtime/queries/zig/highlights.scm b/runtime/queries/zig/highlights.scm index 5a3d62dc..404a8682 100644 --- a/runtime/queries/zig/highlights.scm +++ b/runtime/queries/zig/highlights.scm @@ -4,82 +4,89 @@ (line_comment) ] @comment -; field in top level decl, and in struct, union... -(ContainerField - (IDENTIFIER) @property - (SuffixExpr (IDENTIFIER) @type)? -) +[ + variable: (IDENTIFIER) + variable_type_function: (IDENTIFIER) +] @variable -; error.OutOfMemory; -(SuffixExpr - "error" - "." - (IDENTIFIER) @constant +parameter: (IDENTIFIER) @variable.parameter + +[ + field_member: (IDENTIFIER) + field_access: (IDENTIFIER) +] @variable.property + +;; assume TitleCase is a type +( + [ + variable_type_function: (IDENTIFIER) + field_access: (IDENTIFIER) + parameter: (IDENTIFIER) + ] @type + (#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$") +) +;; assume camelCase is a function +( + [ + variable_type_function: (IDENTIFIER) + field_access: (IDENTIFIER) + parameter: (IDENTIFIER) + ] @function + (#match? @function "^[a-z]+([A-Z][a-z0-9]*)+$") ) -; var x: IDENTIFIER -type: (SuffixExpr (IDENTIFIER) @type) +;; assume all CAPS_1 is a constant +( + [ + variable_type_function: (IDENTIFIER) + field_access: (IDENTIFIER) + ] @constant + (#match? @constant "^[A-Z][A-Z_0-9]+$") +) -; IDENTIFIER{} -constructor: (SuffixExpr (IDENTIFIER) @constructor) +[ + function_call: (IDENTIFIER) + function: (IDENTIFIER) +] @function -; fields -(FieldInit (IDENTIFIER) @property) +exception: "!" @function.macro -; foo.bar.baz.function() calls ( - (SuffixOp - (IDENTIFIER) @function - ) - . - (FnCallArguments) + (IDENTIFIER) @variable.builtin + (#eq? @variable.builtin "_") ) -; function() calls +(PtrTypeStart "c" @variable.builtin) + ( - ( - (IDENTIFIER) @function + (ContainerDeclType + [ + (ErrorUnionExpr) + "enum" + ] ) - . - (FnCallArguments) + (ContainerField (IDENTIFIER) @constant) ) -; functionn decl -(FnProto - (IDENTIFIER) @function - (SuffixExpr (IDENTIFIER) @type)? - ("!")? @function.macro -) +field_constant: (IDENTIFIER) @constant -; function parameters and types -(ParamDecl - (IDENTIFIER) @variable.parameter - ":" - [ - (ParamType (SuffixExpr (IDENTIFIER) @type)) - (ParamType) - ] -) +(BUILTINIDENTIFIER) @function.builtin -; switch -(SwitchItem - (SuffixExpr - "." - . - (IDENTIFIER) @constant - ) -) +((BUILTINIDENTIFIER) @keyword.control.import + (#any-of? @keyword.control.import "@import" "@cImport")) (INTEGER) @number (FLOAT) @number [ - (STRINGLITERAL) + (LINESTRING) (STRINGLITERALSINGLE) ] @string -(CHAR_LITERAL) @string +(CHAR_LITERAL) @constant.character +(EscapeSequence) @escape +(FormatSequence) @string.special [ "allowzero" @@ -95,6 +102,9 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) [ "true" "false" +] @constant.builtin.boolean + +[ "undefined" "unreachable" "null" @@ -104,21 +114,18 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) "else" "if" "switch" +] @keyword.control.conditional + +[ "for" "while" - "return" - "break" - "continue" - "defer" - "errdefer" - "async" - "nosuspend" - "await" - "suspend" - "resume" - "try" - "catch" -] @keyword.control +] @keyword.control.repeat + +[ + "or" + "and" + "orelse" +] @operator [ "struct" @@ -127,21 +134,48 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) "error" "packed" "opaque" - "test" - "usingnamespace" - "export" - "extern" - "const" - "var" - "comptime" - "threadlocal" ] @keyword [ - "pub" + "try" + "error" + "catch" +] @function.macro + +; VarDecl +[ + "comptime" + "threadlocal" "fn" ] @keyword.function +[ + "const" + "var" + "test" + "pub" + "usingnamespace" +] @keyword + +[ + "return" + "break" + "continue" +] @keyword.control + +; Macro +[ + "defer" + "errdefer" + "async" + "nosuspend" + "await" + "suspend" + "resume" + "export" + "extern" +] @function.macro + ; PrecProc [ "inline" @@ -149,10 +183,9 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) "asm" "callconv" "noalias" -] @attribute +] @keyword.directive [ - (BUILTINIDENTIFIER) "linksection" "align" ] @function.builtin @@ -164,9 +197,6 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) (AdditionOp) (MultiplyOp) (PrefixOp) - "or" - "and" - "orelse" "*" "**" "->" @@ -174,6 +204,7 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) ".?" ".*" "=" + "?" ] @operator [ @@ -186,6 +217,9 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) [ ".." "..." +] @punctuation.special + +[ "[" "]" "(" @@ -195,4 +229,7 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor) (Payload "|") (PtrPayload "|") (PtrIndexPayload "|") -] @punctuation +] @punctuation.bracket + +; Error +(ERROR) @keyword diff --git a/runtime/queries/zig/indents.toml b/runtime/queries/zig/indents.toml index e119078b..88f88e16 100644 --- a/runtime/queries/zig/indents.toml +++ b/runtime/queries/zig/indents.toml @@ -1,8 +1,9 @@ indent = [ - "block", - "match_block", - "arguments", - "parameters" + "Block", + "BlockExpr", + "ContainerDecl", + "SwitchExpr", + "InitList" ] outdent = [ diff --git a/runtime/themes/nord.toml b/runtime/themes/nord.toml new file mode 100644 index 00000000..c6a0e172 --- /dev/null +++ b/runtime/themes/nord.toml @@ -0,0 +1,84 @@ +# Author : RayGervais<raygervais@hotmail.ca> + +# "ui.linenr.selected" = { fg = "#d8dee9" } +# "ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] } +# "ui.menu.selected" = { fg = "#e5ded6", bg = "#313f4e" } + +# "info" = "#b48ead" +# "hint" = "#a3be8c" + +# Polar Night +# nord0 - background color +"ui.background" = { bg = "#2e3440" } +"ui.statusline.inactive" = { fg = "#d8dEE9", bg = "#2e3440" } + + +# nord1 - status bars, panels, modals, autocompletion +"ui.statusline" = { fg = "#88c0d0", bg = "#3b4252" } +"ui.popup" = { bg = "#232d38" } +"ui.window" = { bg = "#232d38" } +"ui.help" = { bg = "#232d38", fg = "#e5ded6" } + +# nord2 - active line, highlighting +"ui.selection" = { bg = "#434c5e" } +"ui.cursor.match" = { bg = "434c5e" } + +# nord3 - comments +"comment" = "#4c566a" +"ui.linenr" = { fg = "#4c566a" } + +# Snow Storm +# nord4 - cursor, variables, constants, attributes, fields +"ui.cursor.primary" = { fg = "#d8dee9", modifiers = ["reversed"] } +"attribute" = "#d8dee9" +"variable" = "#d8dee9" +"constant" = "#d8dee9" +"variable.builtin" = "#d8dee9" +"constant.builtin" = "#d8dee9" +"namespace" = "#d8dee9" + +# nord5 - suble UI text + +# nord6 - base text, punctuation +"ui.text" = { fg = "#eceff4" } +"punctuation" = "#eceff4" + +# Frost +# nord7 - classes, types, primiatives +"type" = "#8fbcbb" +"type.builtin" = { fg = "#8fbcbb"} +"label" = "#8fbcbb" + +# nord8 - declaration, methods, routines +"constructor" = "#88c0d0" +"function" = "#88c0d0" +"function.macro" = { fg = "#88c0d0" } +"function.builtin" = { fg = "#88c0d0" } + +# nord9 - operator, tags, units, punctuations +"punctuation.delimiter" = "#81a1c1" +"operator" = { fg = "#81a1c1" } +"property" = "#81a1c1" + +# nord10 - keywords, special +"keyword" = { fg = "#5e81ac" } +"keyword.directive" = "#5e81ac" +"variable.parameter" = "#5e81ac" + +# Aurora +# nord11 - error +"error" = "#bf616a" + +# nord12 - annotations, decorators +"special" = "#d08770" +"module" = "#d08770" + +# nord13 - warnings, escape characters, regex +"warning" = "#ebcb8b" +"escape" = { fg = "#ebcb8b" } + +# nord14 - strings +"string" = "#a3be8c" + +# nord15 - integer, floating point +"number" = "#b48ead" |