Skip to content

Commit

Permalink
Merge branch 'master' into cmd-expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
ksdrar committed Apr 22, 2023
2 parents ffb40de + b7c62e2 commit f6fea44
Show file tree
Hide file tree
Showing 54 changed files with 1,096 additions and 384 deletions.
168 changes: 89 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap_at_text_width` is set | `80` |
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set | `80` |
| `workspace-lsp-roots` | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml` | `[]` |

### `[editor.statusline]` Section
Expand Down
5 changes: 5 additions & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| bicep || | | `bicep-langserver` |
| c |||| `clangd` |
| c-sharp ||| | `OmniSharp` |
| cabal || | | |
| cairo || | | |
| capnp || || |
| clojure || | | `clojure-lsp` |
Expand All @@ -27,6 +28,7 @@
| diff || | | |
| dockerfile || | | `docker-langserver` |
| dot || | | `dot-language-server` |
| dtd || | | |
| edoc || | | |
| eex || | | |
| ejs || | | |
Expand Down Expand Up @@ -70,6 +72,7 @@
| jsonnet || | | `jsonnet-language-server` |
| jsx |||| `typescript-language-server` |
| julia |||| `julia` |
| just |||| |
| kdl || | | |
| kotlin || | | `kotlin-language-server` |
| latex ||| | `texlab` |
Expand All @@ -80,6 +83,7 @@
| llvm-mir-yaml || || |
| lua |||| `lua-language-server` |
| make || | | |
| markdoc || | | `markdoc-ls` |
| markdown || | | `marksman` |
| markdown.inline || | | |
| matlab || | | |
Expand All @@ -95,6 +99,7 @@
| ocaml || || `ocamllsp` |
| ocaml-interface || | | `ocamllsp` |
| odin || | | `ols` |
| opencl |||| `clangd` |
| openscad || | | `openscad-lsp` |
| org || | | |
| pascal ||| | `pasls` |
Expand Down
40 changes: 21 additions & 19 deletions book/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ line.

## Linux, macOS, Windows and OpenBSD packaging status

Helix is available for Linux, macOS and Windows via the official repositories listed below.

[![Packaging status](https://repology.org/badge/vertical-allrepos/helix.svg)](https://repology.org/project/helix/versions)

## Linux
Expand All @@ -51,7 +49,7 @@ The following third party repositories are available:

### Ubuntu

Helix is available via [Maveonair's PPA](https://launchpad.net/~maveonair/+archive/ubuntu/helix-editor):
Add the `PPA` for Helix:

```sh
sudo add-apt-repository ppa:maveonair/helix-editor
Expand All @@ -61,7 +59,7 @@ sudo apt install helix

### Fedora/RHEL

Helix is available via `copr`:
Enable the `COPR` repository for Helix:

```sh
sudo dnf copr enable varlad/helix
Expand Down Expand Up @@ -92,8 +90,8 @@ If you are using a version of Nix without flakes enabled,

### AppImage

Install Helix using [AppImage](https://appimage.org/).
Download Helix AppImage from the [latest releases](https://github.com/helix-editor/helix/releases/latest) page.
Install Helix using the Linux [AppImage](https://appimage.org/) format.
Download the official Helix AppImage from the [latest releases](https://github.com/helix-editor/helix/releases/latest) page.

```sh
chmod +x helix-*.AppImage # change permission for executable mode
Expand Down Expand Up @@ -143,33 +141,37 @@ pacman -S mingw-w64-ucrt-x86_64-helix

## Building from source

Clone the repository:
Requirements:

- The [Rust toolchain](https://www.rust-lang.org/tools/install)
- The [Git version control system](https://git-scm.com/)
- A c++14 compatible compiler to build the tree-sitter grammars, for example GCC or Clang

If you are using the `musl-libc` standard library instead of `glibc` the following environment variable must be set during the build to ensure tree-sitter grammars can be loaded correctly:

```sh
RUSTFLAGS="-C target-feature=-crt-static"
```

1. Clone the repository:

```sh
git clone https://github.com/helix-editor/helix
cd helix
```

Compile from source:
2. Compile from source:

```sh
cargo install --path helix-term --locked
```

This command will create the `hx` executable and construct the tree-sitter
grammars in the local `runtime` folder. To build the tree-sitter grammars requires
a c++ compiler to be installed, for example `gcc-c++`.

> 💡 If you are using the musl-libc instead of glibc the following environment variable must be set during the build
> to ensure tree-sitter grammars can be loaded correctly:
>
> ```sh
> RUSTFLAGS="-C target-feature=-crt-static"
> ```
grammars in the local `runtime` folder.

> 💡 Tree-sitter grammars can be fetched and compiled if not pre-packaged. Fetch
> grammars with `hx --grammar fetch` (requires `git`) and compile them with
> `hx --grammar build` (requires a C++ compiler). This will install them in
> grammars with `hx --grammar fetch` and compile them with
> `hx --grammar build`. This will install them in
> the `runtime` directory within the user's helix config directory (more
> [details below](#multiple-runtime-directories)).
Expand Down
2 changes: 1 addition & 1 deletion book/src/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ These configuration keys are available:
| `config` | Language Server configuration |
| `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) |
| `formatter` | The formatter for the language, it will take precedence over the lsp when defined. The formatter must be able to take the original file as input from stdin and write the formatted file to stdout |
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap_at_text_width` is set, defaults to `editor.text-width` |
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set, defaults to `editor.text-width` |
| `workspace-lsp-roots` | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml`. Overwrites the setting of the same name in `config.toml` if set. |

### File-type detection and the `file-types` key
Expand Down
2 changes: 1 addition & 1 deletion helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ encoding_rs = "0.8"

chrono = { version = "0.4", default-features = false, features = ["alloc", "std"] }

etcetera = "0.4"
etcetera = "0.5"
textwrap = "0.16.0"

[dev-dependencies]
Expand Down
10 changes: 4 additions & 6 deletions helix-dap/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ impl Client {
if command.is_empty() {
return Result::Err(Error::Other(anyhow!("Command not provided")));
}
if transport == "tcp" && port_arg.is_some() {
Self::tcp_process(command, args, port_arg.unwrap(), id).await
} else if transport == "stdio" {
Self::stdio(command, args, id)
} else {
Result::Err(Error::Other(anyhow!("Incorrect transport {}", transport)))
match (transport, port_arg) {
("tcp", Some(port_arg)) => Self::tcp_process(command, args, port_arg, id).await,
("stdio", _) => Self::stdio(command, args, id),
_ => Result::Err(Error::Other(anyhow!("Incorrect transport {}", transport))),
}
}

Expand Down
46 changes: 28 additions & 18 deletions helix-dap/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,38 +230,48 @@ impl Transport {
}
}

async fn recv(
async fn recv_inner(
transport: Arc<Self>,
mut server_stdout: Box<dyn AsyncBufRead + Unpin + Send>,
client_tx: UnboundedSender<Payload>,
) {
) -> Result<()> {
let mut recv_buffer = String::new();
loop {
match Self::recv_server_message(&mut server_stdout, &mut recv_buffer).await {
Ok(msg) => {
transport
.process_server_message(&client_tx, msg)
.await
.unwrap();
}
Err(err) => {
error!("err: <- {:?}", err);
break;
}
}
let msg = Self::recv_server_message(&mut server_stdout, &mut recv_buffer).await?;
transport.process_server_message(&client_tx, msg).await?;
}
}

async fn send(
async fn recv(
transport: Arc<Self>,
server_stdout: Box<dyn AsyncBufRead + Unpin + Send>,
client_tx: UnboundedSender<Payload>,
) {
if let Err(err) = Self::recv_inner(transport, server_stdout, client_tx).await {
error!("err: <- {:?}", err);
}
}

async fn send_inner(
transport: Arc<Self>,
mut server_stdin: Box<dyn AsyncWrite + Unpin + Send>,
mut client_rx: UnboundedReceiver<Payload>,
) {
) -> Result<()> {
while let Some(payload) = client_rx.recv().await {
transport
.send_payload_to_server(&mut server_stdin, payload)
.await
.unwrap()
.await?;
}
Ok(())
}

async fn send(
transport: Arc<Self>,
server_stdin: Box<dyn AsyncWrite + Unpin + Send>,
client_rx: UnboundedReceiver<Payload>,
) {
if let Err(err) = Self::send_inner(transport, server_stdin, client_rx).await {
error!("err: <- {:?}", err);
}
}

Expand Down
5 changes: 3 additions & 2 deletions helix-loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/main.rs"
anyhow = "1"
serde = { version = "1.0", features = ["derive"] }
toml = "0.7"
etcetera = "0.4"
etcetera = "0.5"
tree-sitter = "0.20"
once_cell = "1.17"
log = "0.4"
Expand All @@ -27,6 +27,7 @@ log = "0.4"
# cloning/compiling tree-sitter grammars
cc = { version = "1" }
threadpool = { version = "1.0" }
tempfile = "3.5.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libloading = "0.7"
libloading = "0.8"
39 changes: 38 additions & 1 deletion helix-loader/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::borrow::Cow;
use std::path::Path;
use std::process::Command;

const VERSION: &str = include_str!("../VERSION");
Expand All @@ -11,7 +12,7 @@ fn main() {
.filter(|output| output.status.success())
.and_then(|x| String::from_utf8(x.stdout).ok());

let version: Cow<_> = match git_hash {
let version: Cow<_> = match &git_hash {
Some(git_hash) => format!("{} ({})", VERSION, &git_hash[..8]).into(),
None => VERSION.into(),
};
Expand All @@ -23,4 +24,40 @@ fn main() {

println!("cargo:rerun-if-changed=../VERSION");
println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);

if git_hash.is_none() {
return;
}

// we need to revparse because the git dir could be anywhere if you are
// using detached worktrees but there is no good way to obtain an OsString
// from command output so for now we can't accept non-utf8 paths here
// probably rare enouch where it doesn't matter tough we could use gitoxide
// here but that would be make it a hard dependency and slow compile times
let Some(git_dir): Option<String> = Command::new("git")
.args(["rev-parse", "--git-dir"])
.output()
.ok()
.filter(|output| output.status.success())
.and_then(|x| String::from_utf8(x.stdout).ok())
else{ return; };
// If heads starts pointing at something else (different branch)
// we need to return
let head = Path::new(&git_dir).join("HEAD");
if head.exists() {
println!("cargo:rerun-if-changed={}", head.display());
}
// if the thing head points to (branch) itself changes
// we need to return
let Some(head_ref): Option<String> = Command::new("git")
.args(["symbolic-ref", "HEAD"])
.output()
.ok()
.filter(|output| output.status.success())
.and_then(|x| String::from_utf8(x.stdout).ok())
else{ return; };
let head_ref = Path::new(&git_dir).join(head_ref);
if head_ref.exists() {
println!("cargo:rerun-if-changed={}", head_ref.display());
}
}
Loading

0 comments on commit f6fea44

Please sign in to comment.