Open sgon00 opened 11 months ago
I have the same problem. For a temporary fix, you can try adding this config to ~/.config/helix/languages.toml
:
# https://docs.helix-editor.com/languages.html
[[language]]
name = "ini"
file-types = [
"conf",
# from https://github.com/helix-editor/helix/blob/master/languages.toml
"ini", "service", "automount", "device", "mount", "path", "service", "slice", "socket", "swap", "target", "timer", "container", "volume", "kube", "network",
]
[[language]]
name = "bash"
file-types = [
"nginx.conf",
# from https://github.com/helix-editor/helix/blob/master/languages.toml
"sh", "bash", "zsh", ".bash_login", ".bash_logout", ".bash_profile", ".bashrc", ".profile", ".zshenv", "zshenv", ".zlogin", "zlogin", ".zlogout", "zlogout", ".zprofile", "zprofile", ".zshrc", "zshrc", ".zimrc", "APKBUILD", "PKGBUILD", "eclass", "ebuild", "bazelrc", ".bash_aliases", "Renviron", ".Renviron",
]
(The file types can't be extended, related issue: #6896)
The first section will use ini
syntax highlighting for files with .conf
extension,
and the next one will use bash
for nginx.conf
.
You can also use toml
or ini
for Systemd services.
This is not ideal but it does the job for me.
@mahor1221 thanks a lot for the tip. It does the job. I am about to give up helix
because of this issue. I am getting headache to switch between vim
and helix
. Now, let me try to see if I can stay with helix
only.
One more question about file-types
in languages.toml
: is that possible to define a path and everything inside the path will use the configued language? For example, /etc/nginx/sites-enabled/*
will be bash
language. Thanks a lot.
Unfortunately it seems that that's not possible currently. There is a suffix
option to set the filetype for certain paths but it only accepts files not directories.
Personally, I'm using keybindings for commands like :set-language bash
, :set-language ini
and so on, until this issue is fixed. I don't wanna mess with vim or neovim configs in my lifetime again.
I know a little Rust, so if nobody fixed this issue, I would be happy to work on it myself but I probably can't do it in the upcoming weeks or months.
@mahor1221 thanks a lot for your help. Hopefully, helix team can put more attention on these kind of issues. I think they are very easy to be fixed and improved. It shouldn't take too much time. I don't want to switch between editors all the time. :)
https://github.com/helix-editor/helix/pull/8006 might address this.
IMHO, this should be the #1
/most important issue that needs to be addressed by the helix development team. Admittedly, writing a syntax file for .conf
is not an easy task, due to the amount of variation that occurs in configuration files with that file extension. Every other editor I know of has managed to address it, though.
Hi, I need to edit nginx config file a lot. Is that possible to enable nginx config syntax highlight? Thanks a lot.
Edited: I try to replace
vim
withhelix
, but I find out helix is missing many file type support. It does not support many linux config file types, such asnginx
,systemd
etc..