# http://fishshell.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufSetOption mimetype=text/x-fish %{ set buffer filetype fish } hook global BufCreate .*[.](fish) %{ set buffer filetype fish } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ addhl -group / regions -default code fish \ double_string '"' (? s \h+$ d } } def -hidden _fish_indent_on_char %{ eval -draft -itersel %{ # deindent on (else|end) command insertion try %{ exec -draft w (else|end) } } } def -hidden _fish_indent_on_new_line %{ eval -draft -itersel %{ # preserve previous line indent try %{ exec -draft K } # filter previous line try %{ exec -draft k : _fish_filter_around_selections } # copy '#' comment prefix and following white spaces try %{ exec -draft k x s ^\h*\K#\h* y j p } # indent after (case|else) commands try %{ exec -draft k x (case|else) j } # indent after (begin|for|function|if|switch|while) commands and add 'end' command try %{ exec -draft k x (begin|for|function|(? x y p j a end k } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group fish-highlight global WinSetOption filetype=fish %{ addhl ref fish } hook global WinSetOption filetype=fish %{ hook window InsertEnd .* -group fish-hooks _fish_filter_around_selections hook window InsertChar .* -group fish-indent _fish_indent_on_char hook window InsertChar \n -group fish-indent _fish_indent_on_new_line } hool -group fish-highlight global WinSetOption filetype=(?!fish).* %{ rmhl fish } hook global WinSetOption filetype=(?!fish).* %{ rmhooks window fish-indent rmhooks window fish-hooks }