hook global WinSetOption filetype=fennel %{
    set-option buffer lsp_servers %{
        [fennel-ls]
        root_globs = [".git", ".hg", "fennel.lua"]
        command = "/home/ANT.AMAZON.COM/dugajame/fennel-ls/fennel-ls"
    }
    lsp-enable-buffer
    softtab-enable
}

hook global ModuleLoaded fennel %{
    # By default, Kakoune highlights colon strings in the "keyword" face.
    # This is incorrect - they should be highlighted as strings.
    # So, we override the builtin highlighter with our own.
    remove-highlighter shared/fennel/colon-string
    add-highlighter shared/fennel/colon-string region '\W\K:[-\w?\\^_!$%&*+./@|<=>]' '(?![-\w?\\^_!$%&*+./@|<=>])' fill string

    # Kakoune's default fennel support also doesn't properly highlight values,
    # so we patch the lua highlighter in here
    remove-highlighter shared/fennel/code/value
    add-highlighter shared/fennel/code/value regex \b(false|nil|true|self|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F]+)\b 0:value
}
