mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.84k stars 710 forks source link

Handlebars (.hbs) not highlighting correctly #3230

Open velrest opened 4 years ago

velrest commented 4 years ago

On opening a *.hbs file i see following error message in *debug*:

error running hook WinSetOption(filetype=hbs)/hbs-highlight: 2:6: 'maybe-add-hbs-to-html' 1:2: 'evaluate-commands' 2:14: 'add-highlighter' no such id: 'html'

This is probably caused by this line.

Steps

Outcome

Expected

lenormf commented 4 years ago

The file needs a require-module html, after line 12. Want to test that and create a PR? :)

velrest commented 4 years ago

Sure :+1:

velrest commented 4 years ago

@lenormf The error is now gone but now recursive call of hook WinSetOption/filetype=hbs, not executing occurs and still no syntax highlighting. Sorry im new to kakoune and do not yet understand the hooks completely.

lenormf commented 4 years ago

The following fixes it for me:

diff --git a/rc/filetype/hbs.kak b/rc/filetype/hbs.kak
index df854076..eb788b8b 100644
--- a/rc/filetype/hbs.kak
+++ b/rc/filetype/hbs.kak
@@ -10,6 +10,7 @@ hook global BufCreate .*[.](hbs) %{

 hook global WinSetOption filetype=hbs %{
     require-module hbs
+    require-module html

     hook window ModeChange pop:insert:.* -group hbs-trim-indent hbs-trim-indent
     hook window InsertChar \n -group hbs-indent hbs-indent-on-new-line

I'm just concerned now about maybe-add-hbs-to-html, hbs_highlighters_enabled and the reason for their existence.

The default regions should probably be HTML, and sub-regions highlight handlebars code - as opposed to having the module inject its highlighters into html.

velrest commented 4 years ago

Ah true for me too, sorry not sure what i did wrong earlier. Thanks! Should i close this or leave it open for this issue?

I'm just concerned now about maybe-add-hbs-to-html, hbs_highlighters_enabled and the reason for their existence.

The default regions should probably be HTML, and sub-regions highlight handlebars code - as opposed to having the module inject its highlighters into html.

lenormf commented 4 years ago

You can still create a PR if you're up for it (ideally fixing the script to highlight everything in HTML by default, to remove maybe-add-hbs-to-html and hbs_highlighters_enabled).

The commit message should end with "Fixes #3230", and this issue will be closed automatically upon merging.

velrest commented 4 years ago

@lenormf Sure, i would be glad to! It might take some time though since i really just started with kakoune and need some time to figure out how kakoune actually works :sweat_smile:.

lenormf commented 4 years ago

You've got one commit figured out already (requiring html). For the second commit, you need to make it so .hbs buffers are highlighted as HTML by default, with handlebars highlighters on top.

The following file does exactly that, for another language: https://github.com/kakoune-editor/kakoune-extra-filetypes/blob/master/rc/clearsilver.kak#L32

velrest commented 4 years ago

@lenormf Hey, sorry for the long wait but i haven't had the time to work myself into the kakoune highlighters (sorry) so i opened a PR for the missing module part only (at least for now).

lenormf commented 4 years ago

No problem, thanks.