Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with syntax highlighting #1098

Closed
pfr-dev opened this issue Nov 14, 2021 · 22 comments
Closed

Help with syntax highlighting #1098

pfr-dev opened this issue Nov 14, 2021 · 22 comments

Comments

@pfr-dev
Copy link

pfr-dev commented Nov 14, 2021

I need some help getting syntax highlighting working. I'm not familiar with this tree-sitter business and really have no idea what I'm supposed to do. I think I need an idiots guide to setting syntax highlighting in Helix.

Thanks!

@archseer
Copy link
Member

archseer commented Nov 14, 2021

Can you give us some details (you didn't fill out the bug template)? What helix version? What programming language? What file are you trying to load? Are you using a package or installing from source?

@pfr-dev
Copy link
Author

pfr-dev commented Nov 15, 2021

Can you give us some details (you didn't fill out the bug template)?

Mostly because it's not a bug, I just need some help

What helix version?

v0.5.0

What programming language? What file are you trying to load?

This confuses me coming from vim where you just enable syntax highlighting and that's it. I am not a programmer, I'm just a hobbyist who likes colorful code. I'm mostly editing dot-files and configs in C, some in rust and and a handful of common lisp. But I just want The Kitchen Sink syntax highlighting package that does it all.

Are you using a package or installing from source?

I installed form source as per the installation instructions.

Extra info:
OS - NetBSD
Built on rustc-1.56.1

edit: spelling

@archseer
Copy link
Member

Yeah, Helix highlighting should also work out of the box, as long as you're using a language we support (currently any of the ones listed in https://github.com/helix-editor/helix/blob/master/languages.toml)

if you're not getting syntax highlighting for C or Rust files, did you follow the install steps:

Helix also needs its runtime files so make sure to copy or symlink the runtime/ directory into the config directory (for example ~/.config/helix/runtime on Linux/macOS). This location can be overriden via the HELIX_RUNTIME environment variable.

@pfr-dev
Copy link
Author

pfr-dev commented Nov 15, 2021

Yeah, I've copied the runtime/ directory to ~/.config/helix/runtime yet I still don't get any highlighting. Not even in bash or sh scripts.

@kirawi
Copy link
Member

kirawi commented Nov 16, 2021

Run Helix via hx -v on a file that's supposed to have syntax highlighting; what does it say in your log?

@pfr-dev
Copy link
Author

pfr-dev commented Nov 17, 2021

I removed Helix and started from the beginning. It seems to have worked this time.

Cheers

@pfr-dev pfr-dev closed this as completed Nov 17, 2021
@pfr-dev
Copy link
Author

pfr-dev commented Nov 25, 2021

While most syntax highlighting is working now (including sh scripts), for some unknown reason my ~/.shrc does not have syntax highlighting. Is there any syntax highlighting for rc files?

@pfr-dev pfr-dev reopened this Nov 25, 2021
@sudormrfbin
Copy link
Member

Support for file detection from shebang line landed in master a while ago (#1001), so you'll have to either build from source or wait for v0.6.

@pfr-dev
Copy link
Author

pfr-dev commented Nov 25, 2021

Support for file detection from shebang line landed in master a while ago (#1001), so you'll have to either build from source or wait for v0.6.

I did build from source, 11 days ago. Looks like those changes landed before I built helix

To be clear, my ~/.shrc does not begin with a shebang, the very first line is simply a comment # .shrc file for sh(1).

@sudormrfbin
Copy link
Member

Ah you need at the very least a proper shebang line like #!/bin/sh for it to work, since helix has no other way of detecting file type.

@pfr-dev
Copy link
Author

pfr-dev commented Nov 26, 2021

Ah you need at the very least a proper shebang line like #!/bin/sh for it to work, since helix has no other way of detecting file type.

I've added the shebang and it does work. I'm just a little unsure whether or not it'll have any unwanted consequences. Anyway, Closing again.
Cheers

@pfr-dev pfr-dev closed this as completed Nov 26, 2021
@koonopek
Copy link

koonopek commented Aug 8, 2022

I have same problem :(
My setup is ssh with putty to linux machine and hx was cross compiled from macos :)
Maybe this is the cause?
obraz

@koonopek
Copy link

koonopek commented Aug 8, 2022

Okey found this in log file?
(Couldn paste screen shot)
obraz
ANy idea how to solve that?

@archseer
Copy link
Member

archseer commented Aug 9, 2022

Are you building on latest master? Grammars weren't cross-compiled correctly before this change https://github.com/helix-editor/helix/pull/3137/files#diff-a51c059189ef3148ad3623783b405a650987fba714abf1b6c9343d86862c8dc1R323

@koonopek
Copy link

I wasn't, thanks for the information, I manage to fix it, by compliling on different machine with common architecture.

However, Im still not able to display colors properly when using tmux (I already tried everything from google search)

@akhildevelops
Copy link

akhildevelops commented Sep 9, 2022

TOML is in the list of supported of languages. Still I was unable to see any highlighting in my toml files.

I installed hx using Cargo and I can't see any app related files in my ~/.config/helix folder. Later I found the helix files are located in ~/tools/helix folder. Then I symlinked the ~/tools/helix folder to ~/.config/helix. Now syntax highlighting works.

@Lyreplus
Copy link

Lyreplus commented Nov 9, 2022

Same problem here. I've installed Helix from source on Arch Linux as the readme file says. I've also executed the command ln -s $PWD/runtime ~/.config/helix/runtime on my terminal, but nothing. The code analyzer works (I'm coding in Rust, in this case using rust-analyzer) but highlighting, text object and indent features don't work, as the command hx --health print. I've also executed "hx --grammar fetch" and "hx --grammar build", and everything is already built. Any ideas?

@archseer
Copy link
Member

archseer commented Nov 9, 2022

Why not use the helix-git AUR package that builds from source and sets everything up for you?

@Lyreplus
Copy link

Lyreplus commented Nov 9, 2022

Why not use the helix-git AUR package that builds from source and sets everything up for you?

yeah, you're right. It all works now, thanks

@beeb
Copy link
Contributor

beeb commented Dec 12, 2022

For anyone reading this and having the same problem as @Lyreplus above. For me what worked was to export a variable export HELIX_RUNTIME="$HOME/helix/runtime" pointing to the runtime folder inside the git repo that you cloned. It's important to not have a runtime folder inside the ~/.config/helix folder as well otherwise it didn't work for me. No hx -g fetch and hx -g build either otherwise there will be conflicting files.

@lBenevides
Copy link

@beeb Thanks!!! done that and just worked like magic!

@beeb
Copy link
Contributor

beeb commented Jan 18, 2023

@beeb Thanks!!! done that and just worked like magic!

Nice! Alternatively I think I later also got it working in the end by making a symlink inside .config/helix that points to the runtime folder inside the cloned repo, like indicates in the user instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants