diff --git a/Cargo.lock b/Cargo.lock index 96c39fd5..69ba8444 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,9 +57,9 @@ checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "arc-swap" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "983cd8b9d4b02a6dc6ffa557262eb5858a27a0038ffffe21a0f133eaa819a164" +checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "atoi" @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "clipboard-win" -version = "4.4.2" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ab1b92798304eedc095b53942963240037c0516452cb11aeba709d420b2219" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" dependencies = [ "error-code", "str-buf", @@ -541,9 +541,9 @@ dependencies = [ [[package]] name = "git-actor" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7def29b46f25f95a2e196323cfb336eae9965e0a3c7c35ad9506f295c3a8e234" +checksum = "d9e5fd7bc63ad527d64584f8d01f99b89c051f5fbb8144b58ae5f812775065cf" dependencies = [ "bstr 1.0.1", "btoi", @@ -555,9 +555,9 @@ dependencies = [ [[package]] name = "git-attributes" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0affaed361598fdd06b2a184a566c823d0b5817b09f576018248fb267193a96" +checksum = "f8013dfce47c1e29236d732308933e2c77af5355ec5105755d26faf7764d3f7b" dependencies = [ "bstr 1.0.1", "compact_str", @@ -589,18 +589,18 @@ dependencies = [ [[package]] name = "git-command" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6b98a6312fef79b326c0a6e15d576c2bd30f7f9d0b7964998d166049e0d7b9e" +checksum = "215145cc1686a45bc6f9872b153a0d3f3c40a1b94173a928325e1b53dfa5e2af" dependencies = [ "bstr 1.0.1", ] [[package]] name = "git-config" -version = "0.13.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ff189268cfb19d5151529ac30b6b708072ebfa1075643d785232675456ec320" +checksum = "c9da662fd64ac69772158dcf04777da6266f0f36bc9a310b3eb2d805bb696315" dependencies = [ "bstr 1.0.1", "git-config-value", @@ -632,9 +632,9 @@ dependencies = [ [[package]] name = "git-credentials" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28da3d029be10258007699d002321a3b1ebe45e67b0e140a4cf464ba3ee79b32" +checksum = "97cd6bbe001afd6356b35ef13f2a6b0f0abc0133d1b2ecaec1033bdd769616d6" dependencies = [ "bstr 1.0.1", "git-command", @@ -648,9 +648,9 @@ dependencies = [ [[package]] name = "git-date" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2874ce2f3a77cb144167901ea830969e5c991eac7bfee85e6e3f53ef9fcdf2" +checksum = "412c9b89026505bd24d5f8acafa578de6eea3b271ece307a73b8e646e671302a" dependencies = [ "bstr 1.0.1", "itoa", @@ -660,9 +660,9 @@ dependencies = [ [[package]] name = "git-diff" -version = "0.24.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f30011a43908645c492dfbea7b004e10528be6bd667bf5cdc12ff4297fe1e3c" +checksum = "ca87474422d26d606d04cec6bedfabcd92a0a74102cd7936785358ced6a4a25a" dependencies = [ "git-hash", "git-object", @@ -672,9 +672,9 @@ dependencies = [ [[package]] name = "git-discover" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93c244b1cf7cf45501116e948506c25324e33ddc613f00557ff5bfded2132009" +checksum = "1e9e26e0bc434643228cd418185bd28ca5c7cf831bde1da434807391c27ac40e" dependencies = [ "bstr 1.0.1", "git-hash", @@ -686,9 +686,9 @@ dependencies = [ [[package]] name = "git-features" -version = "0.25.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f98e6ede7b790dfba16bf3c62861ae75c3719485d675b522cf7d7e748a4011c" +checksum = "5ff74064fa007c5beefa89a64bb72834f32b3c497750a56c79c6802bbdb311f9" dependencies = [ "crc32fast", "flate2", @@ -733,9 +733,9 @@ dependencies = [ [[package]] name = "git-index" -version = "0.10.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20627f71f3a884b0ae50f9f3abb3a07d9b117d06e16110d25b85da4d71d478c0" +checksum = "485da97dd4f69c7d9a8dc238cd6f4a726387ffc34573489e8e0d2bee266e3454" dependencies = [ "atoi", "bitflags", @@ -766,9 +766,9 @@ dependencies = [ [[package]] name = "git-mailmap" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90e3ee2eaeebda8a12d17f4d99dff5b19d81536476020bcebb99ee121820466" +checksum = "0316b4346f3e162ade368209efb8a609b587793c74aa3b8de0ec01a4f3580120" dependencies = [ "bstr 1.0.1", "git-actor", @@ -777,9 +777,9 @@ dependencies = [ [[package]] name = "git-object" -version = "0.24.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35b658f1e3e149d88cb3e0a2234be749bb0cab65887405975dbe6f3190cf6571" +checksum = "3f8563e2d6f524d7053f3106714f99ecdc3adbba2cb7108c09d71a02579f2e19" dependencies = [ "bstr 1.0.1", "btoi", @@ -796,9 +796,9 @@ dependencies = [ [[package]] name = "git-odb" -version = "0.38.1" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55333419bbb25aa6d39e29155f747ad8e1777fe385f70f447be9d680824d23dd" +checksum = "616115a0e3daff6e08842758d24547b37a6eb6d0e2eedd95a740c3aaa2750333" dependencies = [ "arc-swap", "git-features", @@ -814,9 +814,9 @@ dependencies = [ [[package]] name = "git-pack" -version = "0.28.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed3c9af66949553af9795b9eac9d450a5bdceee9959352cda468997ddce0d2f" +checksum = "7cd16b88f4b66041f41ca510c28bd81c4ee7363c5a544b3d62b4170432965871" dependencies = [ "bytesize", "clru", @@ -872,9 +872,9 @@ dependencies = [ [[package]] name = "git-ref" -version = "0.21.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c97b7d719e4320179fb64d081016e7faca56fed4a8ee4cf84e4697faad9235a3" +checksum = "5e6767925a6fc4af5c5a81e348d1d851c1b3ab2b512bd7f562ac11be37c14468" dependencies = [ "git-actor", "git-features", @@ -891,9 +891,9 @@ dependencies = [ [[package]] name = "git-refspec" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d478e9db0956d60cd386d3348b5ec093e3ae613105a7a75ff6084b886254eba8" +checksum = "ddf310ed5f2829ac0af96e7d4aebd4ae4b89f0718a7ae3666d09b02b2c5a1dfd" dependencies = [ "bstr 1.0.1", "git-hash", @@ -905,9 +905,9 @@ dependencies = [ [[package]] name = "git-repository" -version = "0.30.2" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1925a65a9fea6587e969a7a85cb239c8e1e438cf6dc520406df1b4c9d0e83bdc" +checksum = "993277960cb7e2d3991a11c1ec6951c1d142de052c26a18d2db64304e52d3741" dependencies = [ "git-actor", "git-attributes", @@ -948,9 +948,9 @@ dependencies = [ [[package]] name = "git-revision" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7516b1db551756b4d3176c4b7d18ccc4b79d35dcc5e74f768c90f5bb11bb6c9" +checksum = "4f9a6bd28c9d1676bb96f428cd09614ae18a0087d7cea1cebfd177e25f99b2af" dependencies = [ "bstr 1.0.1", "git-date", @@ -989,9 +989,9 @@ dependencies = [ [[package]] name = "git-traverse" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5141dde56d0c4861193c760e01fb61c7e03a32d0840ba93a0ac1c597588d4d" +checksum = "bd356da21ec00f69b9d4f105df4cb85543c746b18f4b7fc81529ce77713cdb29" dependencies = [ "git-hash", "git-hashtable", @@ -1001,9 +1001,9 @@ dependencies = [ [[package]] name = "git-url" -version = "0.12.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8651924c9692a778f09141ca44d1bf2dada229fe9b240f1ff1bdecd9621a1a93" +checksum = "c85af407ed0dbb8d8da2a7241827d2fd5681186d9dab3570fc8dd8d6152ec48f" dependencies = [ "bstr 1.0.1", "git-features", @@ -1025,9 +1025,9 @@ dependencies = [ [[package]] name = "git-worktree" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d748c54c3d904c914b987654a1416c7abe7cf048fdc83eeae69e6ac3d76f20" +checksum = "ca3bc63878f134e08ed52dba5d82422798c01a3f2e48c38ae9a2f7ff9194f362" dependencies = [ "bstr 1.0.1", "git-attributes", @@ -1585,9 +1585,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "parking_lot" @@ -1666,9 +1666,9 @@ dependencies = [ [[package]] name = "prodash" -version = "22.1.0" +version = "23.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e2b91fcc982d0d8ae5e9d477561c73e09c24c5c19bac4858e202f6f065a13e" +checksum = "5d8c414345b4a98cbcd0e8d8829c8f54b47a7ed4fb771c45b7c5c6c0ae23dc4c" dependencies = [ "bytesize", "dashmap", @@ -1751,9 +1751,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -1783,9 +1783,9 @@ dependencies = [ [[package]] name = "ropey" -version = "1.5.1-alpha" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917e62c0dee8926492dd13164b3cefaad2b0e03ab49f48c0d41635797a7409b3" +checksum = "a4f832915525613e83f275694cb8c184f5df13ca26a9ef0ea6ce736921964c8e" dependencies = [ "smallvec", "str_indices", @@ -2121,9 +2121,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.23.0" +version = "1.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" +checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae" dependencies = [ "autocfg", "bytes", diff --git a/README.md b/README.md index c1f30218..5b7b54f4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ If you would like to build from source: ```shell git clone https://github.com/helix-editor/helix cd helix -cargo install --path helix-term +cargo install --locked --path helix-term ``` This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars in `./runtime/grammars`. @@ -70,7 +70,7 @@ mklink /D runtime "\runtime" The runtime location can be overridden via the `HELIX_RUNTIME` environment variable. -> NOTE: if `HELIX_RUNTIME` is set prior to calling `cargo install --path helix-term`, +> NOTE: if `HELIX_RUNTIME` is set prior to calling `cargo install --locked --path helix-term`, > tree-sitter grammars will be built in `$HELIX_RUNTIME/grammars`. If you plan on keeping the repo locally, an alternative to copying/symlinking @@ -98,6 +98,7 @@ If installing from source, to use Helix in desktop environments that supports [X ```bash cp contrib/Helix.desktop ~/.local/share/applications +cp contrib/helix.png ~/.local/share/icons ``` To use another terminal than the default, you will need to modify the `.desktop` file. For example, to use `kitty`: @@ -107,8 +108,6 @@ sed -i "s|Exec=hx %F|Exec=kitty hx %F|g" ~/.local/share/applications/Helix.deskt sed -i "s|Terminal=true|Terminal=false|g" ~/.local/share/applications/Helix.desktop ``` -Please note: there is no icon for Helix yet, so the system default will be used. - ## macOS Helix can be installed on macOS through homebrew: diff --git a/book/src/configuration.md b/book/src/configuration.md index 85af7590..af80b177 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -98,6 +98,7 @@ The following statusline elements can be configured: | `mode` | The current editor mode (`mode.normal`/`mode.insert`/`mode.select`) | | `spinner` | A progress spinner indicating LSP activity | | `file-name` | The path/name of the opened file | +| `file-base-name` | The basename of the opened file | | `file-encoding` | The encoding of the opened file if it differs from UTF-8 | | `file-line-ending` | The file line endings (CRLF or LF) | | `total-line-numbers` | The total line numbers of the opened file | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 1a3aed79..00e6a91e 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -16,12 +16,13 @@ | common-lisp | ✓ | | | `cl-lsp` | | cpon | ✓ | | ✓ | | | cpp | ✓ | ✓ | ✓ | `clangd` | -| crystal | ✓ | | | | +| crystal | ✓ | ✓ | | | | css | ✓ | | | `vscode-css-language-server` | | cue | ✓ | | | `cuelsp` | | d | ✓ | ✓ | ✓ | `serve-d` | | dart | ✓ | | ✓ | `dart` | | devicetree | ✓ | | | | +| dhall | ✓ | ✓ | | `dhall-lsp-server` | | diff | ✓ | | | | | dockerfile | ✓ | | | `docker-langserver` | | dot | ✓ | | | `dot-language-server` | @@ -93,6 +94,7 @@ | pascal | ✓ | ✓ | | `pasls` | | perl | ✓ | ✓ | ✓ | | | php | ✓ | ✓ | ✓ | `intelephense` | +| ponylang | ✓ | ✓ | ✓ | | | prisma | ✓ | | | `prisma-language-server` | | prolog | | | | `swipl` | | protobuf | ✓ | | ✓ | | @@ -120,7 +122,7 @@ | swift | ✓ | | | `sourcekit-lsp` | | tablegen | ✓ | ✓ | ✓ | | | task | ✓ | | | | -| tfvars | | | | `terraform-ls` | +| tfvars | ✓ | | ✓ | `terraform-ls` | | toml | ✓ | | | `taplo` | | tsq | ✓ | | | | | tsx | ✓ | ✓ | ✓ | `typescript-language-server` | diff --git a/book/src/install.md b/book/src/install.md index 44f13584..bf0ff079 100644 --- a/book/src/install.md +++ b/book/src/install.md @@ -69,17 +69,21 @@ choco install helix **MSYS2:** +Choose the proper command for your system from below: + + - For 32 bit Windows 7 or above: + ``` pacman -S mingw-w64-i686-helix ``` -or + - For 64 bit Windows 7 or above: ``` pacman -S mingw-w64-x86_64-helix ``` -or + - For 64 bit Windows 8.1 or above: ``` pacman -S mingw-w64-ucrt-x86_64-helix @@ -90,7 +94,7 @@ pacman -S mingw-w64-ucrt-x86_64-helix ``` git clone https://github.com/helix-editor/helix cd helix -cargo install --path helix-term +cargo install --path helix-term --locked ``` This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars in `./runtime/grammars`. @@ -123,7 +127,7 @@ mklink /D runtime "\runtime" The runtime location can be overridden via the `HELIX_RUNTIME` environment variable. -> NOTE: if `HELIX_RUNTIME` is set prior to calling `cargo install --path helix-term`, +> NOTE: if `HELIX_RUNTIME` is set prior to calling `cargo install --path helix-term --locked`, > tree-sitter grammars will be built in `$HELIX_RUNTIME/grammars`. If you plan on keeping the repo locally, an alternative to copying/symlinking diff --git a/book/src/keymap.md b/book/src/keymap.md index 3be151cf..1eb48a6f 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -325,8 +325,8 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire | `[p` | Go to previous paragraph | `goto_prev_paragraph` | | `]g` | Go to next change | `goto_next_change` | | `[g` | Go to previous change | `goto_prev_change` | -| `]G` | Go to first change | `goto_first_change` | -| `[G` | Go to last change | `goto_last_change` | +| `[G` | Go to first change | `goto_first_change` | +| `]G` | Go to last change | `goto_last_change` | | `[Space` | Add newline above | `add_newline_above` | | `]Space` | Add newline below | `add_newline_below` | diff --git a/book/src/languages.md b/book/src/languages.md index e45ef910..ff06dc00 100644 --- a/book/src/languages.md +++ b/book/src/languages.md @@ -35,7 +35,7 @@ Each language is configured by adding a `[[language]]` section to a [[language]] name = "mylang" scope = "source.mylang" -injection-regex = "^mylang$" +injection-regex = "mylang" file-types = ["mylang", "myl"] comment-token = "#" indent = { tab-width = 2, unit = " " } diff --git a/book/src/themes.md b/book/src/themes.md index b1e6cec5..37ee0924 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -185,6 +185,8 @@ We use a similar set of scopes as - `type` - Types - `builtin` - Primitive types provided by the language (`int`, `usize`) + - `enum` + - `variant` - `constructor` - `constant` (TODO: constant.other.placeholder for %v) @@ -247,6 +249,8 @@ We use a similar set of scopes as - `namespace` +- `special` + - `markup` - `heading` - `marker` diff --git a/flake.nix b/flake.nix index fe1c6b44..673f3cf6 100644 --- a/flake.nix +++ b/flake.nix @@ -82,7 +82,8 @@ packages = with common.pkgs; [lld_13 cargo-flamegraph rust-analyzer] ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin) - ++ (lib.optional stdenv.isLinux lldb); + ++ (lib.optional stdenv.isLinux lldb) + ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation); env = [ { name = "HELIX_RUNTIME"; @@ -94,10 +95,10 @@ } { name = "RUSTFLAGS"; - value = + eval = if common.pkgs.stdenv.isLinux - then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment" - else ""; + then "$RUSTFLAGS\" -C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment\"" + else "$RUSTFLAGS"; } ]; }; diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index 31b6546f..ca6cd51e 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -17,7 +17,7 @@ integration = [] [dependencies] helix-loader = { version = "0.6", path = "../helix-loader" } -ropey = { version = "1.5.1-alpha", default-features = false, features = ["simd"] } +ropey = { version = "1.5.1", default-features = false, features = ["simd"] } smallvec = "1.10" smartstring = "1.0.1" unicode-segmentation = "1.10" @@ -26,7 +26,7 @@ unicode-general-category = "0.6" # slab = "0.4.2" slotmap = "1.0" tree-sitter = "0.20" -once_cell = "1.16" +once_cell = "1.17" arc-swap = "1" regex = "1" bitflags = "1.3" diff --git a/helix-core/src/auto_pairs.rs b/helix-core/src/auto_pairs.rs index 072c93d0..31f9d364 100644 --- a/helix-core/src/auto_pairs.rs +++ b/helix-core/src/auto_pairs.rs @@ -17,7 +17,7 @@ pub const DEFAULT_PAIRS: &[(char, char)] = &[ ]; /// The type that represents the collection of auto pairs, -/// keyed by the opener. +/// keyed by both opener and closer. #[derive(Debug, Clone)] pub struct AutoPairs(HashMap); diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index 371cf303..e72d290e 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -70,7 +70,7 @@ impl Client { process: Option, ) -> Result<(Self, UnboundedReceiver)> { let (server_rx, server_tx) = Transport::start(rx, tx, err, id); - let (client_rx, client_tx) = unbounded_channel(); + let (client_tx, client_rx) = unbounded_channel(); let client = Self { id, @@ -86,9 +86,9 @@ impl Client { quirks: DebuggerQuirks::default(), }; - tokio::spawn(Self::recv(server_rx, client_rx)); + tokio::spawn(Self::recv(server_rx, client_tx)); - Ok((client, client_tx)) + Ok((client, client_rx)) } pub async fn tcp( diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml index 760205e1..a3d14584 100644 --- a/helix-loader/Cargo.toml +++ b/helix-loader/Cargo.toml @@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] } toml = "0.5" etcetera = "0.4" tree-sitter = "0.20" -once_cell = "1.16" +once_cell = "1.17" log = "0.4" # TODO: these two should be on !wasm32 only diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml index d04edcd5..d31731d2 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.23", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } +tokio = { version = "1.24", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } tokio-stream = "0.1.11" which = "4.2" diff --git a/helix-lsp/src/jsonrpc.rs b/helix-lsp/src/jsonrpc.rs index 75ac9309..69d02707 100644 --- a/helix-lsp/src/jsonrpc.rs +++ b/helix-lsp/src/jsonrpc.rs @@ -170,6 +170,10 @@ impl Params { serde_json::from_value(value) .map_err(|err| Error::invalid_params(format!("Invalid params: {}.", err))) } + + pub fn is_none(&self) -> bool { + self == &Params::None + } } impl From for Value { @@ -187,7 +191,7 @@ impl From for Value { pub struct MethodCall { pub jsonrpc: Option, pub method: String, - #[serde(default = "default_params")] + #[serde(default = "default_params", skip_serializing_if = "Params::is_none")] pub params: Params, pub id: Id, } @@ -197,7 +201,7 @@ pub struct MethodCall { pub struct Notification { pub jsonrpc: Option, pub method: String, - #[serde(default = "default_params")] + #[serde(default = "default_params", skip_serializing_if = "Params::is_none")] pub params: Params, } @@ -334,6 +338,33 @@ fn notification_serialize() { ); } +#[test] +fn serialize_skip_none_params() { + use serde_json; + + let m = MethodCall { + jsonrpc: Some(Version::V2), + method: "shutdown".to_owned(), + params: Params::None, + id: Id::Num(1), + }; + + let serialized = serde_json::to_string(&m).unwrap(); + assert_eq!( + serialized, + r#"{"jsonrpc":"2.0","method":"shutdown","id":1}"# + ); + + let n = Notification { + jsonrpc: Some(Version::V2), + method: "exit".to_owned(), + params: Params::None, + }; + + let serialized = serde_json::to_string(&n).unwrap(); + assert_eq!(serialized, r#"{"jsonrpc":"2.0","method":"exit"}"#); +} + #[test] fn success_output_deserialize() { use serde_json; diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 9f2e5188..895a0882 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -35,7 +35,7 @@ helix-vcs = { version = "0.6", path = "../helix-vcs" } helix-loader = { version = "0.6", path = "../helix-loader" } anyhow = "1" -once_cell = "1.16" +once_cell = "1.17" which = "4.2" @@ -45,7 +45,7 @@ crossterm = { version = "0.25", features = ["event-stream"] } signal-hook = "0.3" tokio-stream = "0.1" futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false } -arc-swap = { version = "1.5.1" } +arc-swap = { version = "1.6.0" } # Logging fern = "0.6" diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 56bd9080..62f87a5d 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -409,34 +409,53 @@ impl Application { self.editor.refresh_config(); } + /// refresh language config after config change + fn refresh_language_config(&mut self) -> Result<(), Error> { + let syntax_config = helix_core::config::user_syntax_loader() + .map_err(|err| anyhow::anyhow!("Failed to load language config: {}", err))?; + + self.syn_loader = std::sync::Arc::new(syntax::Loader::new(syntax_config)); + self.editor.syn_loader = self.syn_loader.clone(); + for document in self.editor.documents.values_mut() { + document.detect_language(self.syn_loader.clone()); + } + + Ok(()) + } + /// Refresh theme after config change - fn refresh_theme(&mut self, config: &Config) { + fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> { if let Some(theme) = config.theme.clone() { let true_color = self.true_color(); - match self.theme_loader.load(&theme) { - Ok(theme) => { - if true_color || theme.is_16_color() { - self.editor.set_theme(theme); - } else { - self.editor - .set_error("theme requires truecolor support, which is not available"); - } - } - Err(err) => { - let err_string = format!("failed to load theme `{}` - {}", theme, err); - self.editor.set_error(err_string); - } + let theme = self + .theme_loader + .load(&theme) + .map_err(|err| anyhow::anyhow!("Failed to load theme `{}`: {}", theme, err))?; + + if true_color || theme.is_16_color() { + self.editor.set_theme(theme); + } else { + anyhow::bail!("theme requires truecolor support, which is not available") } } + + Ok(()) } fn refresh_config(&mut self) { - match Config::load_default() { - Ok(config) => { - self.refresh_theme(&config); + let mut refresh_config = || -> Result<(), Error> { + let default_config = Config::load_default() + .map_err(|err| anyhow::anyhow!("Failed to load config: {}", err))?; + self.refresh_language_config()?; + self.refresh_theme(&default_config)?; + // Store new config + self.config.store(Arc::new(default_config)); + Ok(()) + }; - // Store new config - self.config.store(Arc::new(config)); + match refresh_config() { + Ok(_) => { + self.editor.set_status("Config refreshed"); } Err(err) => { self.editor.set_error(err.to_string()); diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index b93e6e2d..5d5ea2d0 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2057,16 +2057,10 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) { let selection = doc.selection(view.id).clone().transform(|range| { let (start_line, end_line) = range.line_range(text.slice(..)); - let start = text.line_to_char(match extend { - Extend::Above => start_line.saturating_sub(count - 1), - Extend::Below => start_line, - }); + let start = text.line_to_char(start_line); let end = text.line_to_char( - match extend { - Extend::Above => end_line + 1, // the start of next line - Extend::Below => end_line + count, - } - .min(text.len_lines()), + (end_line + 1) // newline of end_line + .min(text.len_lines()), ); // extend to previous/next line if current line is selected @@ -2080,8 +2074,11 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) { } } else { match extend { - Extend::Above => (end, start), - Extend::Below => (start, end), + Extend::Above => (end, text.line_to_char(start_line.saturating_sub(count - 1))), + Extend::Below => ( + start, + text.line_to_char((end_line + count).min(text.len_lines())), + ), } }; @@ -3214,8 +3211,7 @@ pub mod insert { let on_auto_pair = doc .auto_pairs(cx.editor) .and_then(|pairs| pairs.get(prev)) - .and_then(|pair| if pair.close == curr { Some(pair) } else { None }) - .is_some(); + .map_or(false, |pair| pair.open == prev && pair.close == curr); let local_offs = if on_auto_pair { let inner_indent = indent.clone() + doc.indent_style.as_str(); diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 085a18e7..4b0ec0e0 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -65,6 +65,7 @@ fn open(cx: &mut compositor::Context, args: &[Cow], event: PromptEvent) -> ensure!(!args.is_empty(), "wrong argument count"); for arg in args { let (path, pos) = args::parse_file(arg); + let path = helix_core::path::expand_tilde(&path); // If the path is a directory, open a file picker on that directory and update the status // message if let Ok(true) = std::fs::canonicalize(&path).map(|p| p.is_dir()) { @@ -1821,7 +1822,7 @@ fn run_shell_command( let shell = &cx.editor.config().shell; let (output, success) = shell_impl(shell, &args.join(" "), None)?; if success { - cx.editor.set_status("Command succeed"); + cx.editor.set_status("Command succeeded"); } else { cx.editor.set_error("Command failed"); } diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs index 9dad3620..2e4a2e20 100644 --- a/helix-term/src/compositor.rs +++ b/helix-term/src/compositor.rs @@ -1,4 +1,4 @@ -// Each component declares it's own size constraints and gets fitted based on it's parent. +// Each component declares its own size constraints and gets fitted based on its parent. // Q: how does this work with popups? // cursive does compositor.screen_mut().add_layer_at(pos::absolute(x, y), ) use helix_core::Position; @@ -97,6 +97,7 @@ impl Compositor { self.area = area; } + /// Add a layer to be rendered in front of all existing layers. pub fn push(&mut self, mut layer: Box) { let size = self.size(); // trigger required_size on init @@ -136,7 +137,8 @@ impl Compositor { let mut consumed = false; // propagate events through the layers until we either find a layer that consumes it or we - // run out of layers (event bubbling) + // run out of layers (event bubbling), starting at the front layer and then moving to the + // background. for layer in self.layers.iter_mut().rev() { match layer.handle_event(event, cx) { EventResult::Consumed(Some(callback)) => { diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 27331f3e..ea6d9b7e 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -467,20 +467,30 @@ pub mod completers { use ignore::WalkBuilder; use std::path::Path; - let is_tilde = input.starts_with('~') && input.len() == 1; + let is_tilde = input == "~"; let path = helix_core::path::expand_tilde(Path::new(input)); let (dir, file_name) = if input.ends_with(std::path::MAIN_SEPARATOR) { (path, None) } else { - let file_name = path - .file_name() - .and_then(|file| file.to_str().map(|path| path.to_owned())); - - let path = match path.parent() { - Some(path) if !path.as_os_str().is_empty() => path.to_path_buf(), - // Path::new("h")'s parent is Some("")... - _ => std::env::current_dir().expect("couldn't determine current directory"), + let is_period = (input.ends_with((format!("{}.", std::path::MAIN_SEPARATOR)).as_str()) + && input.len() > 2) + || input == "."; + let file_name = if is_period { + Some(String::from(".")) + } else { + path.file_name() + .and_then(|file| file.to_str().map(|path| path.to_owned())) + }; + + let path = if is_period { + path + } else { + match path.parent() { + Some(path) if !path.as_os_str().is_empty() => path.to_path_buf(), + // Path::new("h")'s parent is Some("")... + _ => std::env::current_dir().expect("couldn't determine current directory"), + } }; (path, file_name) diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs index 62a6785a..5a95c1bb 100644 --- a/helix-term/src/ui/popup.rs +++ b/helix-term/src/ui/popup.rs @@ -42,6 +42,10 @@ impl Popup { } } + /// Set the anchor position next to which the popup should be drawn. + /// + /// Note that this is not the position of the top-left corner of the rendered popup itself, + /// but rather the screen-space position of the information to which the popup refers. pub fn position(mut self, pos: Option) -> Self { self.position = pos; self @@ -51,6 +55,10 @@ impl Popup { self.position } + /// Set the popup to prefer to render above or below the anchor position. + /// + /// This preference will be ignored if the viewport doesn't have enough space in the + /// chosen direction. pub fn position_bias(mut self, bias: Open) -> Self { self.position_bias = bias; self @@ -78,6 +86,8 @@ impl Popup { self } + /// Calculate the position where the popup should be rendered and return the coordinates of the + /// top left corner. pub fn get_rel_position(&mut self, viewport: Rect, cx: &Context) -> (u16, u16) { let position = self .position diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 501faea3..a25b4540 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -139,6 +139,7 @@ where match element_id { helix_view::editor::StatusLineElement::Mode => render_mode, helix_view::editor::StatusLineElement::Spinner => render_lsp_spinner, + helix_view::editor::StatusLineElement::FileBaseName => render_file_base_name, helix_view::editor::StatusLineElement::FileName => render_file_name, helix_view::editor::StatusLineElement::FileEncoding => render_file_encoding, helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending, @@ -426,6 +427,26 @@ where write(context, title, None); } +fn render_file_base_name(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option