# https://nim-lang.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.nim(s|ble)? %{ set-option buffer filetype nim } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ regions -default code nim \ double_string '"' (? s ^\h*#\h* y jgh P } # preserve previous line indent try %{ exec -draft \; K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # indent after line ending with const, let, var, ':' or '=' try %{ exec -draft k x (:|=|const|let|var)$ j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group nim-highlight global WinSetOption filetype=nim %{ add-highlighter window ref nim } hook global WinSetOption filetype=nim %{ hook window InsertChar \n -group nim-indent nim-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window InsertEnd .* -group nim-indent %{ try %{ exec -draft \; s ^\h+$ d } } } hook -group nim-highlight global WinSetOption filetype=(?!nim).* %{ remove-highlighter window/nim } hook global WinSetOption filetype=(?!nim).* %{ remove-hooks window nim-indent }