helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.67k stars 2.5k forks source link

No Syntax Highlighting when building from source #5052

Closed rustftw closed 1 year ago

rustftw commented 1 year ago

Sorry if this is the wrong place for this question. I have tried searching all over and posting on reddit to no avail.

When I install the hx package (fedora) via the repo I have syntax highlighting. When I build from source, I don't. I do have the runtime in ~/.config/helix and it is not empty. Any ideas what I may be missing?

Cheers!

kirawi commented 1 year ago

Can you try setting your HELIX_RUNTIME environment variable to ~/.config/helix/runtime? Maybe it's not able to pick it up.

rustftw commented 1 year ago

Still nothing. This is also happening in my laptop, which is also running fedora.

gabydd commented 1 year ago

Two things could help diagnose this, first what does the logs say(:log-open). Also what is in the runtime folder you need to make sure that it has both queries and grammars.

rustftw commented 1 year ago

The log has some interesting info:

2022-12-07T12:49:53.617 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "ruby": Error opening dynamic library "/home/oahu/.config/helix/runtime/grammars/ruby.so"
2022-12-07T12:49:53.823 helix_lsp::transport [ERROR] err <- "Solargraph is listening on stdio PID=107021\n"

Runtime folder:

[oahu helix] $ pwd /home/oahu/.config/helix [oahu helix] $ ls runtime/ grammars queries themes tutor [oahu helix] $ ls runtime/grammars/ sources [oahu helix] $ ls runtime/grammars/sources/ astro c-sharp elvish gleam iex llvm openscad rust toml wgsl awk css embedded-template glsl ini llvm-mir org scala tsq wit bash cue env go java lua pascal scheme tsx xit bass d erlang godot-resource javascript make perl scss twig xml beancount dart esdl gomod jsdoc markdown php slint typescript yaml bicep devicetree fish gotmpl json markdown_inline prisma sml ungrammar zig c diff fortran gowork jsonnet meson protobuf solidity v cairo dockerfile gdscript graphql julia nickel python sql vala clojure dot gitattributes hare kdl nix qmljs sshclientconfig verilog cmake edoc git-commit haskell kotlin nu r svelte vhs comment eex git-config hcl latex ocaml regex swift vue cpon elixir gitignore heex lean ocaml-interface rescript tablegen wast cpp elm git-rebase html ledger odin ruby task wat [oahu helix] $

gabydd commented 1 year ago

This might have to do with linking maybe delete runtime and try and link again, I think it should be ln -s

rustftw commented 1 year ago

Thanks for responding. I removed my old runtime. I actually (cp -r)'d it instead of symlink thinking that might be the issue. I removed it and symlink'd it again but I have the same issue with the same error in the logfile:

2022-12-07T13:12:54.791 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "ruby": Error opening dynamic library "/h 2022-12-07T13:12:54.985 helix_lsp::transport [ERROR] err <- "Solargraph is listening on stdio PID=107348\n"
2022-12-07T13:12:59.781 helix_view::editor [ERROR] editor error: no such command: 'log'

Perhaps a dynamic lib not loading when building from source?

rustftw commented 1 year ago

I just added rust analyzer to see if that would help. Same issue in log:

2022-12-07T13:18:16.766 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "rust": Error opening dynamic library "/home/ohau/.config/helix/runtime/grammars/rust.so"

edit: Ah so there is no "/home/ohau/.config/helix/runtime/grammars/rust.so". grammars only has:

[oahu ~]$ ls .config/helix/runtime/grammars/ sources

I set my HELIX_RUNTIME to point to the one installed via dnf: [oahu ~]$ export HELIX_RUNTIME=/usr/share/helix/runtime

and now everything works. It seems as though building from source isn't building the grammar libs? Or I missed a build step?

Thanks again for all your help!

the-mikedavis commented 1 year ago

You may have missed the step to run hx -g fetch and hx -g build which download and compile tree-sitter parser shared objects. Those steps should create the .so files in runtime/grammars

gabydd commented 1 year ago

Beat me to it, cargo install --path helix-term should fetch and build the grammars though so maybe you used a different command to build?

rustftw commented 1 year ago

Great. Thank you all so much. I definitely missed that step.

David-Else commented 1 year ago

I am writing an install script and got this exact same problem! I am using the command cargo install --path helix-term but it is not building the .so files in runtime/grammars. Any idea what could be causing it?! I am testing it on Fedora 37, it seems to have the correct symlinks:

$ hx --health
Config file: /home/david/.config/helix/config.toml
Language file: /home/david/.config/helix/languages.toml
Log file: /home/david/.cache/helix/helix.log
Runtime directory: /home/david/.config/helix/runtime
Runtime directory is symlinked to /home/david/src/helix/runtime

There were no errors during installation.

#!/bin/bash

set -e # quit on error
source functions.bash

SOURCE_DIR=~/src/helix # helix source code directory
TERMINAL=kitty         # terminal program to use for desktop integration

# install the latest rust and rust-analyzer
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustup component add rust-analyzer

# symlink rust-analyzer executable, won't be needed after https://github.com/rust-lang/rustup/pull/3022
[ ! -e /usr/local/bin/rust-analyzer ] && sudo ln -s $(rustup which rust-analyzer) /usr/local/bin/rust-analyzer

# install helix from source and compile
mkdir -p $SOURCE_DIR
git clone https://github.com/helix-editor/helix $SOURCE_DIR
cd $SOURCE_DIR || exit
git checkout 0dbee9590baed10bef3c6c32420b8a5802204657 # hand picked stable point
cargo install --path helix-term

# add desktop files
cp contrib/Helix.desktop ~/.local/share/applications
cp contrib/helix.png ~/.local/share/icons
sed -i "s|Exec=hx %F|Exec=$TERMINAL hx %F|g" ~/.local/share/applications/Helix.desktop
sed -i "s|Terminal=true|Terminal=false|g" ~/.local/share/applications/Helix.desktop

# create the config files
stow --verbose --dir="$HOME/.dotfiles" --target="$HOME" helix
cd ~/.config/helix || exit
[ ! -e ./runtime ] && ln -s $SOURCE_DIR/runtime . # if there is no symlink create one to the source directory

display_text "
${BOLD}Finished!${RESET}

Helix has been installed and compiled from source

- Don't delete the source directory: $SOURCE_DIR
- Update with:

cd $SOURCE_DIR
git pull
cargo install --path helix-term

"

PS It relies on Stow and some other config for the actual config file installation, I can give more details if anyone is interested. The desktop files seems to mysteriously not work either... more debugging needed.

GTime commented 1 year ago

You may have missed the step to run hx -g fetch and hx -g build which download and compile tree-sitter parser shared objects. Those steps should create the .so files in runtime/grammars

This worked for me. Thanks

SylvanFranklin commented 1 year ago

You may have missed the step to run hx -g fetch and hx -g build which download and compile tree-sitter parser shared objects. Those steps should create the .so files in runtime/grammars

This worked for me. Thanks

worked for me too!