diff --git a/Cargo.lock b/Cargo.lock index 86ae08159c232..1d1dac9565309 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1096,9 +1096,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.18.2" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ "bytes", "libc", @@ -1127,9 +1127,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" +checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9" dependencies = [ "futures-core", "pin-project-lite", diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 1d9b89a407776..980b3bdc9a96a 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -15,10 +15,10 @@ | edoc | ✓ | | | | | eex | ✓ | | | | | ejs | ✓ | | | | -| elixir | ✓ | | | `elixir-ls` | +| elixir | ✓ | ✓ | | `elixir-ls` | | elm | ✓ | | | `elm-language-server` | | erb | ✓ | | | | -| erlang | ✓ | | | `erlang_ls` | +| erlang | ✓ | ✓ | | `erlang_ls` | | fish | ✓ | ✓ | ✓ | | | gdscript | ✓ | | ✓ | | | git-attributes | ✓ | | | | @@ -27,7 +27,7 @@ | git-diff | ✓ | | | | | git-ignore | ✓ | | | | | git-rebase | ✓ | | | | -| gleam | ✓ | | | | +| gleam | ✓ | ✓ | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | gomod | ✓ | | | `gopls` | diff --git a/flake.lock b/flake.lock index 8fb4a46671e91..50a7b77b02a9a 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "crane": { "flake": false, "locked": { - "lastModified": 1644785799, - "narHash": "sha256-VpAJO1L0XeBvtCuNGK4IDKp6ENHIpTrlaZT7yfBCvwo=", + "lastModified": 1654444508, + "narHash": "sha256-4OBvQ4V7jyt7afs6iKUvRzJ1u/9eYnKzVQbeQdiamuY=", "owner": "ipetkov", "repo": "crane", - "rev": "fc7a94f841347c88f2cb44217b2a3faa93e2a0b2", + "rev": "db5482bf225acc3160899124a1df5a617cfa27b5", "type": "github" }, "original": { @@ -17,19 +17,13 @@ } }, "devshell": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixCargoIntegration", - "nixpkgs" - ] - }, + "flake": false, "locked": { - "lastModified": 1652959711, - "narHash": "sha256-wpQhlE/NocxlU3jLiMoF1KYHOEFD5MEFJZkyXXVVef8=", + "lastModified": 1653917170, + "narHash": "sha256-FyxOnEE/V4PNEcMU62ikY4FfYPo349MOhMM97HS0XEo=", "owner": "numtide", "repo": "devshell", - "rev": "a5327cd01e58d2848c73062f2661278ad615748f", + "rev": "fc7a3e3adde9bbcab68af6d1e3c6eb738e296a92", "type": "github" }, "original": { @@ -45,6 +39,10 @@ "nixpkgs" ], "crane": "crane", + "devshell": [ + "nixCargoIntegration", + "devshell" + ], "flake-utils-pre-commit": [ "nixCargoIntegration", "nixpkgs" @@ -75,11 +73,11 @@ ] }, "locked": { - "lastModified": 1653135531, - "narHash": "sha256-pYwJrEQrG8BgeVcI+lveK3KbOBDx9MT28HxV09v+jgI=", + "lastModified": 1654451959, + "narHash": "sha256-yWztC96o8Dw65jDbmNUxV1i61T3uLqvqhC3ziwnB/Fk=", "owner": "nix-community", "repo": "dream2nix", - "rev": "4b3dfb101fd2fdbe25bd128072f138276aa4bc82", + "rev": "90b353682ef927bd39b59085e0dc6b7454888de7", "type": "github" }, "original": { @@ -89,21 +87,6 @@ } }, "flake-utils": { - "locked": { - "lastModified": 1642700792, - "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { "locked": { "lastModified": 1637014545, "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", @@ -130,11 +113,11 @@ ] }, "locked": { - "lastModified": 1653286465, - "narHash": "sha256-CEI2prA74sy9SgAJKdDpyAMv1nnp91c8e5Fw9QbtR/Q=", + "lastModified": 1654531591, + "narHash": "sha256-DtDAwkl2Pn8w1BW1z2OssT/bWjVhMZQBBpr2uDY7tHY=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "95efd76ab68b20aba45b7d647460319b88c2a4c0", + "rev": "c935099d6851d0ff94098e9a12f42147524f0c5b", "type": "github" }, "original": { @@ -145,11 +128,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1653060744, - "narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=", + "lastModified": 1654230545, + "narHash": "sha256-8Vlwf0x8ow6pPOK2a04bT+pxIeRnM1+O0Xv9/CuDzRs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "dfd82985c273aac6eced03625f454b334daae2e8", + "rev": "236cc2971ac72acd90f0ae3a797f9f83098b17ec", "type": "github" }, "original": { @@ -168,17 +151,17 @@ }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1653273659, - "narHash": "sha256-dHXYaNL1axhZZyiZXxt1WKhvZrYXq7bjCs3y5VjgyGI=", + "lastModified": 1654483484, + "narHash": "sha256-Ki/sMgrUEj+31P3YMzZZp5Nea7+MQVVTdaRWQVS1PL4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "0fa3e01da1ce98e3b40063b8e2678095943402b1", + "rev": "6bc59b9c4ad1cc1089219e935aa727a96d948c5d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 495e441a85738..1949580dc528a 100644 --- a/flake.nix +++ b/flake.nix @@ -14,10 +14,14 @@ }; }; - outputs = inputs@{ nixCargoIntegration, ... }: + outputs = inputs @ { + nixpkgs, + nixCargoIntegration, + ... + }: nixCargoIntegration.lib.makeOutputs { root = ./.; - renameOutputs = { "helix-term" = "helix"; }; + renameOutputs = {"helix-term" = "helix";}; # Set default app to hx (binary is from helix-term release build) # Set default package to helix-term release build defaultOutputs = { @@ -25,41 +29,70 @@ package = "helix"; }; overrides = { - cCompiler = common: if common.pkgs.stdenv.isLinux then common.pkgs.gcc else common.pkgs.clang; + cCompiler = common: + with common.pkgs; + if stdenv.isLinux + then gcc + else clang; crateOverrides = common: _: { - helix-term = prev: - let - inherit (common) pkgs; - grammars = pkgs.callPackage ./grammars.nix { }; - runtimeDir = pkgs.runCommand "helix-runtime" { } '' - mkdir -p $out - ln -s ${common.root}/runtime/* $out - rm -r $out/grammars - ln -s ${grammars} $out/grammars - ''; - in - { - # disable fetching and building of tree-sitter grammars in the helix-term build.rs - HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1"; - # link languages and theme toml files since helix-term expects them (for tests) - preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} .."; - buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; + helix-term = prev: let + inherit (common) pkgs; + mkRootPath = rel: + builtins.path { + path = "${common.root}/${rel}"; + name = rel; + }; + grammars = pkgs.callPackage ./grammars.nix {}; + runtimeDir = pkgs.runCommandNoCC "helix-runtime" {} '' + mkdir -p $out + ln -s ${mkRootPath "runtime"}/* $out + rm -r $out/grammars + ln -s ${grammars} $out/grammars + ''; + in { + # disable fetching and building of tree-sitter grammars in the helix-term build.rs + HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1"; + # link languages and theme toml files since helix-term expects them (for tests) + preConfigure = + pkgs.lib.concatMapStringsSep + "\n" + (path: "ln -sf ${mkRootPath path} ..") + ["languages.toml" "theme.toml" "base16_theme.toml"]; + buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib]; + nativeBuildInputs = [pkgs.makeWrapper]; - postFixup = '' - if [ -f "$out/bin/hx" ]; then - wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}" - fi - ''; - }; + postFixup = '' + if [ -f "$out/bin/hx" ]; then + wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}" + fi + ''; + }; }; shell = common: prev: { - packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]); - env = prev.env ++ [ - { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; } - { name = "RUST_BACKTRACE"; value = "1"; } - { name = "RUSTFLAGS"; value = if common.pkgs.stdenv.isLinux then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment" else ""; } - ]; + packages = + prev.packages + ++ ( + with common.pkgs; [lld_13 lldb cargo-tarpaulin cargo-flamegraph] + ); + env = + prev.env + ++ [ + { + name = "HELIX_RUNTIME"; + eval = "$PWD/runtime"; + } + { + name = "RUST_BACKTRACE"; + value = "1"; + } + { + name = "RUSTFLAGS"; + value = + if common.pkgs.stdenv.isLinux + then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment" + else ""; + } + ]; }; }; }; diff --git a/grammars.nix b/grammars.nix index ada14aaf98472..2f50662eb72ff 100644 --- a/grammars.nix +++ b/grammars.nix @@ -1,17 +1,23 @@ -{ stdenv, lib, runCommand, yj }: -let +{ + stdenv, + lib, + runCommandLocal, + runCommandNoCC, + yj, +}: let # HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON # before parsing - languages-json = runCommand "languages-toml-to-json" { } '' + languages-json = runCommandLocal "languages-toml-to-json" {} '' ${yj}/bin/yj -t < ${./languages.toml} > $out ''; - languagesConfig = if lib.versionAtLeast builtins.nixVersion "2.6.0" then - builtins.fromTOML (builtins.readFile ./languages.toml) - else - builtins.fromJSON (builtins.readFile (builtins.toPath languages-json)); - isGitGrammar = (grammar: - builtins.hasAttr "source" grammar && builtins.hasAttr "git" grammar.source - && builtins.hasAttr "rev" grammar.source); + languagesConfig = + if lib.versionAtLeast builtins.nixVersion "2.6.0" + then builtins.fromTOML (builtins.readFile ./languages.toml) + else builtins.fromJSON (builtins.readFile (builtins.toPath languages-json)); + isGitGrammar = grammar: + builtins.hasAttr "source" grammar + && builtins.hasAttr "git" grammar.source + && builtins.hasAttr "rev" grammar.source; isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git; toGitHubFetcher = url: let match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url; @@ -20,33 +26,36 @@ let repo = builtins.elemAt match 1; }; gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar; - buildGrammar = grammar: - let - gh = toGitHubFetcher grammar.source.git; - sourceGit = builtins.fetchTree { - type = "git"; - url = grammar.source.git; - rev = grammar.source.rev; - ref = grammar.source.ref or "HEAD"; - shallow = true; - }; - sourceGitHub = builtins.fetchTree { - type = "github"; - owner = gh.owner; - repo = gh.repo; - inherit (grammar.source) rev; - }; - source = if isGitHubGrammar grammar then sourceGitHub else sourceGit; - in stdenv.mkDerivation rec { + buildGrammar = grammar: let + gh = toGitHubFetcher grammar.source.git; + sourceGit = builtins.fetchTree { + type = "git"; + url = grammar.source.git; + rev = grammar.source.rev; + ref = grammar.source.ref or "HEAD"; + shallow = true; + }; + sourceGitHub = builtins.fetchTree { + type = "github"; + owner = gh.owner; + repo = gh.repo; + inherit (grammar.source) rev; + }; + source = + if isGitHubGrammar grammar + then sourceGitHub + else sourceGit; + in + stdenv.mkDerivation rec { # see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix pname = "helix-tree-sitter-${grammar.name}"; version = grammar.source.rev; - src = if builtins.hasAttr "subpath" grammar.source then - "${source}/${grammar.source.subpath}" - else - source; + src = + if builtins.hasAttr "subpath" grammar.source + then "${source}/${grammar.source.subpath}" + else source; dontUnpack = true; dontConfigure = true; @@ -93,14 +102,17 @@ let runHook postFixup ''; }; - builtGrammars = builtins.map (grammar: { - inherit (grammar) name; - artifact = buildGrammar grammar; - }) gitGrammars; - grammarLinks = builtins.map (grammar: - "ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so") + builtGrammars = + builtins.map (grammar: { + inherit (grammar) name; + artifact = buildGrammar grammar; + }) + gitGrammars; + grammarLinks = + builtins.map (grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/${grammar.name}.so") builtGrammars; -in runCommand "consolidated-helix-grammars" { } '' - mkdir -p $out - ${builtins.concatStringsSep "\n" grammarLinks} -'' +in + runCommandNoCC "consolidated-helix-grammars" {} '' + mkdir -p $out + ${builtins.concatStringsSep "\n" grammarLinks} + '' diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml index 6eec89f03b272..fb36758f03490 100644 --- a/helix-lsp/Cargo.toml +++ b/helix-lsp/Cargo.toml @@ -23,6 +23,6 @@ lsp-types = { version = "0.93", features = ["proposed"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -tokio = { version = "1.18", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } -tokio-stream = "0.1.8" +tokio = { version = "1.19", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } +tokio-stream = "0.1.9" which = "4.2" diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs index 5f78c3cc4d6b7..452730025d3ee 100644 --- a/helix-term/src/ui/markdown.rs +++ b/helix-term/src/ui/markdown.rs @@ -171,6 +171,8 @@ impl Markdown { Event::Start(Tag::List(list)) => list_stack.push(list), Event::End(Tag::List(_)) => { list_stack.pop(); + // whenever list closes, new line + lines.push(Spans::default()); } Event::Start(Tag::Item) => { tags.push(Tag::Item); @@ -186,11 +188,19 @@ impl Markdown { | Tag::Paragraph | Tag::CodeBlock(CodeBlockKind::Fenced(_)) | Tag::Item => { - // whenever code block or paragraph closes, new line let spans = std::mem::take(&mut spans); if !spans.is_empty() { lines.push(Spans::from(spans)); } + } + _ => (), + } + + // whenever heading, code block or paragraph closes, new line + match tag { + Tag::Heading(_, _, _) + | Tag::Paragraph + | Tag::CodeBlock(CodeBlockKind::Fenced(_)) => { lines.push(Spans::default()); } _ => (), diff --git a/languages.toml b/languages.toml index 7ab8ff84507ac..6ab394b76f452 100644 --- a/languages.toml +++ b/languages.toml @@ -1049,7 +1049,7 @@ language-server = { command = "erlang_ls" } [[grammar]] name = "erlang" -source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "481e7f8ddf27f07a47d1531b6e2b154b89ece31d" } +source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "c0ebc82600caaf4339f2b00691f958e9df97c065" } [[language]] name = "kotlin" diff --git a/runtime/queries/elixir/textobjects.scm b/runtime/queries/elixir/textobjects.scm new file mode 100644 index 0000000000000..52a6f66de4fb7 --- /dev/null +++ b/runtime/queries/elixir/textobjects.scm @@ -0,0 +1,27 @@ +; Function heads and guards have no body at all, so `keywords` and `do_block` nodes are both optional +((call + target: (identifier) @_keyword + (arguments + [ + (call + (arguments (_)? @parameter.inside)) + ; function has a guard + (binary_operator + left: + (call + (arguments (_)? @parameter.inside))) + ] + ; body is "do: body" instead of a do-block + (keywords + (pair + value: (_) @function.inside))?)? + (do_block (_)* @function.inside)?) + (#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around + +(anonymous_function + (stab_clause right: (body) @function.inside)) @function.around + +((call + target: (identifier) @_keyword + (do_block (_)* @class.inside)) + (#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index bea3871a683b6..0cb60ca999778 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -58,7 +58,7 @@ (#eq? @keyword "(spec|callback)")) ; Functions -(function name: (atom) @function) +(function_clause name: (atom) @function) (call module: (atom) @module) (call function: (atom) @function) (stab_clause name: (atom) @function) diff --git a/runtime/queries/erlang/textobjects.scm b/runtime/queries/erlang/textobjects.scm new file mode 100644 index 0000000000000..c46b5c6f64c35 --- /dev/null +++ b/runtime/queries/erlang/textobjects.scm @@ -0,0 +1,8 @@ +(function_clause + pattern: (arguments (_)? @parameter.inside) + body: (_) @function.inside) @function.around + +(anonymous_function + (stab_clause body: (_) @function.inside)) @function.around + +(comment (comment_content) @comment.inside) @comment.around diff --git a/runtime/queries/gleam/textobjects.scm b/runtime/queries/gleam/textobjects.scm new file mode 100644 index 0000000000000..b382f4bd0078f --- /dev/null +++ b/runtime/queries/gleam/textobjects.scm @@ -0,0 +1,6 @@ +(function + parameters: (function_parameters (function_parameter)? @parameter.inside) + body: (function_body) @function.inside) @function.around + +(anonymous_function + body: (function_body) @function.inside) @function.around diff --git a/runtime/queries/rust/textobjects.scm b/runtime/queries/rust/textobjects.scm index b2769c1393ef0..ba86050b51773 100644 --- a/runtime/queries/rust/textobjects.scm +++ b/runtime/queries/rust/textobjects.scm @@ -7,6 +7,8 @@ (function_item body: (_) @function.inside)) @function.around +(closure_expression body: (_) @function.inside) @function.around + ( [ (attribute_item)+ diff --git a/runtime/themes/catpuccin.toml b/runtime/themes/catppuccin.toml similarity index 100% rename from runtime/themes/catpuccin.toml rename to runtime/themes/catppuccin.toml diff --git a/shell.nix b/shell.nix index c0d998e3d494f..d5e1a215bddb6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,9 +1,8 @@ # Flake's devShell for non-flake-enabled nix instances let - compat = - builtins.fetchGit { - url = "https://github.com/edolstra/flake-compat.git"; - rev = "b4a34015c698c7793d592d66adbab377907a2be8"; - }; + compat = builtins.fetchGit { + url = "https://github.com/edolstra/flake-compat.git"; + rev = "b4a34015c698c7793d592d66adbab377907a2be8"; + }; in -(import compat { src = ./.; }).shellNix.default + (import compat {src = ./.;}).shellNix.default