diff --git a/rc/filetype/vhdl.kak b/rc/filetype/vhdl.kak index afe0e6b7..78d00389 100644 --- a/rc/filetype/vhdl.kak +++ b/rc/filetype/vhdl.kak @@ -9,9 +9,9 @@ hook global BufCreate .*[.](vhd[l]?) %[ hook global WinSetOption filetype=vhdl %[ require-module vhdl set-option window static_words %opt{vhdl_static_words} - hook -group vhdl-indent window InsertChar \n vhdl-indent-on-new-line - hook -group vhdl-indent window InsertChar \) vhdl-indent-on-closing-parenthesis - hook -group vhdl-insert window InsertChar \n vhdl-insert-on-new-line + hook -group vhdl-indent window InsertChar \n vhdl-indent-on-new-line + hook -group vhdl-indent window InsertChar \) vhdl-indent-on-closing-parenthesis + hook -group vhdl-insert window InsertChar \n vhdl-insert-on-new-line # Cleanup trailing whitespaces on current line insert end. hook -group vhdl-trim-indent window ModeChange pop:insert:.* %[ try %[ execute-keys -draft x s ^\h+$ d ] ] hook -once -always window WinSetOption filetype=.* %[ remove-hooks window vhdl-.+ ] @@ -182,7 +182,7 @@ define-command -hidden vhdl-insert-on-new-line %[ evaluate-commands %[ try %[ # Validate previous line and that it is not closed yet. - execute-keys -draft kx ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) }ix ^x(?i)end\b + execute-keys -draft kx ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) j}ijx ^x(?i)end\b # Don't add for "if ... generate", it requires "end generate;". execute-keys -draft kx (?i)\bgenerate\b execute-keys -draft oxendif @@ -191,7 +191,7 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end generate;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i).*\bgenerate$ }ix ^x(?i)(begin|end) + execute-keys -draft kx ^\h*(?i).*\bgenerate$ j}ijx ^x(?i)(begin|end|else)\b # Don't add in case of comment line. execute-keys -draft kx ^\h*-- execute-keys -draft oxendgenerate @@ -200,85 +200,87 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end case;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(case|.*\h*:\h*case)\b }ix ^x(?i)end + # TODO: Case needs special handling. + execute-keys -draft kx ^\h*(?i)(case|.*\h*:\h*case)\b }ix ^x(?i)(end|when) execute-keys -draft oxendcase ] ] # Wisely add "begin" and "end block;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)((block|.*:\h*block)\b) }ix ^x(?i)(begin|end) + execute-keys -draft kx ^\h*(?i)((block|.*:\h*block)\b) j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendblock ] ] # Wisely add "begin" and "end process;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b }ix ^x(?i)(begin|end) + execute-keys -draft kx ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b j}ijx ^x(?i)(begin|end) execute-keys -draft oxbeginxendprocess ] ] # Wisely add "end loop;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ }ix ^x(?i)(end) + execute-keys -draft kx ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ j}ijx ^x(?i)(end) execute-keys -draft oxendloop ] ] # Wisely add "end protected;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+protected)$ }ix ^x(?i)(end) + execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+protected)$ j}ijx ^x(?i)(end) execute-keys -draft oxendprotected ] ] # Wisely add "end protected body;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)(\h*type\h+\w+\h+is\h+protected\h+body$) }ix ^x(?i)end\h+protected\h+body\b + execute-keys -draft kx ^(?i)(\h*type\h+\w+\h+is\h+protected\h+body$) j}ijx ^x(?i)end\h+protected\h+body\b execute-keys -draft oxendprotectedbody ] ] # Wisely add "end record;". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+record\h*)$ }ix ^x(?i)(end) + execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+record\h*)$ j}ijx ^x(?i)(end) execute-keys -draft oxendrecord ] ] # Wisely add ");" for "type ... is (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+\(\h*)$ }ix ^x(\)) + # FIXME: There is some problem. + execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+\(\h*)$ j}ijx ^x(\)) execute-keys -draft ox) ] ] # Wisely add "end entity;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)\h*entity\b.*\bis$ }ix ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)\h*entity\b.*\bis$ j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxendentity ] ] # Wisely add "begin" and "end function;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)(\h*\)?\h*return\b.*\bis$) }ix ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)(\h*\)?\h*return\b.*\bis$) j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendfunction ] try %[ - execute-keys -draft kx ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) }ix ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendfunction ] ] # Wisely add "begin" and "end procedure;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)(\h*procedure\b.*\bis$) }ix ^x(?i)\b(begin|end)\b + execute-keys -draft kx ^(?i)(\h*procedure\b.*\bis$) j}ijx ^x(?i)\b(begin|end)\b execute-keys -draft oxbeginxendprocedure ] try %[ - execute-keys -draft kx ^(?i)\h*\)\h*\bis$ }ix ^x(?i)\b(begin|end)\b + execute-keys -draft kx ^(?i)\h*\)\h*\bis$ j}ijx ^x(?i)\b(begin|end)\b # Verify that line with opening parenthesis contains "procedure" keyword. execute-keys -draft kx s\) x (?i)\bprocedure\b execute-keys -draft oxbeginxendprocedure @@ -287,7 +289,7 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end package;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)(package\b) }ix ^x(?i)(end) + execute-keys -draft kx ^(?i)(package\b) j}ijx ^x(?i)(end)\b # Make sure it is not package body. execute-keys -draft kx(?i)\bbody\b execute-keys -draft oendpackage @@ -296,56 +298,56 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end package body;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)(package\h+body\b) }ix ^x(?i)(end) + execute-keys -draft kx ^(?i)(package\h+body\b) j}ijx ^x(?i)(end)\b execute-keys -draft oendpackagebody ] ] # Wisely add "begin" and "end architecture;". evaluate-commands %[ try %[ - execute-keys -draft kx ^(?i)\h*architecture\b }ix ^x(?i)(begin|end) + execute-keys -draft kx ^(?i)\h*architecture\b j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendarchitecture ] ] # Wisely add ");" for "port (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)port\h*\($ }ix ^x(\)\;) + execute-keys -draft kx ^\h*(?i)port\h*\($ j}ijx ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "port map (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)port\h+map\h*\($ }ix ^x(\)\;) + execute-keys -draft kx ^\h*(?i)port\h+map\h*\($ j}ijx ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "generic (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)generic\h*\($ }ix ^x(\)\;) + execute-keys -draft kx ^\h*(?i)generic\h*\($ j}ijx ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ")" for "generic map (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)generic\h+map\h*\($ }ix ^x(\)) + execute-keys -draft kx ^\h*(?i)generic\h+map\h*\($ j}ijx ^x(\)) execute-keys -draft ox) ] ] # Wisely add ") return ;" for "[pure|impure] function ... (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ }ix ^x(\)\h*return.*) + execute-keys -draft kx ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ j}ijx ^x(\)\h*return.*) execute-keys -draft ox)return ] ] # Wisely add ");" for "procedure ... (". evaluate-commands %[ try %[ - execute-keys -draft kx ^\h*(?i)procedure\b.*\h*\($ }ix ^x(\)\h*\;) + execute-keys -draft kx ^\h*(?i)procedure\b.*\h*\($ j}ijx ^x(\)\h*\;) execute-keys -draft ox) ] ]