Rust health check
To pass the helix rust health check hx --health rust
, there are 4 items which need to be addressed:
- (LSP) Language Server Protocol
- (DAP) Debug Adapter Protocol
- formatter
- queries
Example of how to set these up are in the Dockerfile below.
Currently (2024 Sep) there's an issue with the default apk helix package, so build from source
languages.toml
[[language]] name = "rust" formatter = { command = "rustfmt" }
Note: if making changes to language.debugger, need to include everything
Dockerfile
# temp dir for building ARG HELIX_BUILD_DIR=/helix # root dir for binary e.g. `/usr/bin/hx` ARG HELIX_BIN_DIR=/usr ARG HELIX_DEFAULT_RUNTIME=/usr/lib/helix/runtime #==rust== FROM docker.io/alpine AS rust RUN apk update && \ apk add --no-cache curl RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # update PATH for cargo ENV PATH="/root/.cargo/bin:$PATH" #==helix== FROM rust AS helix-build ARG HELIX_BUILD_DIR ARG HELIX_BIN_DIR ARG HELIX_DEFAULT_RUNTIME ENV HELIX_DEFAULT_RUNTIME=$HELIX_DEFAULT_RUNTIME # https://www.reddit.com/r/HelixEditor/comments/11sfobd/not_getting_syntax_highlighting_even_though/ ENV RUSTFLAGS="-C target-feature=-crt-static" RUN apk update && \ apk add git g++ RUN git clone https://github.com/helix-editor/helix $HELIX_BUILD_DIR WORKDIR $HELIX_BUILD_DIR RUN cargo install --path helix-term --locked --root $HELIX_BIN_DIR FROM rust AS helix ARG HELIX_BUILD_DIR ARG HELIX_BIN_DIR ARG HELIX_DEFAULT_RUNTIME ENV HELIX_DEFAULT_RUNTIME=$HELIX_DEFAULT_RUNTIME ARG HOME=/root ARG HELIX_CONFIG=$HOME/.config/helix/ # 1. (LSP) Language Server Protocol RUN rustup component add rust-analyzer # 2. (DAP) Debug Adapter Protocol # workaround for lldb-dap https://github.com/helix-editor/helix/issues/9964 RUN apk add lldb && \ ln -s /usr/bin/lldb-vscode /usr/bin/lldb-dap # 3. formatter RUN mkdir -p $HELIX_CONFIG COPY languages.toml $HELIX_CONFIG # 4. queries RUN mkdir -p $HELIX_DEFAULT_RUNTIME COPY --from=helix-build $HELIX_BUILD_DIR/runtime $HELIX_DEFAULT_RUNTIME # binary COPY --from=helix-build $HELIX_BIN_DIR/bin/hx $HELIX_BIN_DIR/bin/ CMD ["hx"]
Top comments (0)