From f4f97835f9bf4447cf1fcb09184fc23e862dd4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kruszewski?= Date: Tue, 3 Nov 2020 19:35:05 +0100 Subject: [PATCH] VHDL filetype: fix auto inserting when indentation is mixed. --- rc/filetype/vhdl.kak | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/rc/filetype/vhdl.kak b/rc/filetype/vhdl.kak index 93108d2f..894ab57d 100644 --- a/rc/filetype/vhdl.kak +++ b/rc/filetype/vhdl.kak @@ -181,7 +181,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 k ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) J}iJ ^x(?i)(else|end|elsif)\b + execute-keys -draft k ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) }i ^x(?i)end\b # Don't add for "if ... generate", it requires "end generate;". execute-keys -draft k (?i)\bgenerate\b execute-keys -draft oxendif @@ -190,7 +190,7 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end generate;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i).*\bgenerate$ J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^\h*(?i).*\bgenerate$ }i ^x(?i)(begin|end) # Don't add in case of comment line. execute-keys -draft k ^\h*-- execute-keys -draft oxendgenerate @@ -199,78 +199,78 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end case;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(case|.*\h*:\h*case)\b J}iJ ^x(?i)end + execute-keys -draft k ^\h*(?i)(case|.*\h*:\h*case)\b }i ^x(?i)end execute-keys -draft oxendcase ] ] # Wisely add "begin" and "end block;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)((block|.*:\h*block)\b) J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^\h*(?i)((block|.*:\h*block)\b) }i ^x(?i)(begin|end) execute-keys -draft oxbeginxendblock ] ] # Wisely add "begin" and "end process;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b }i ^x(?i)(begin|end) execute-keys -draft oxbeginxendprocess ] ] # Wisely add "end loop;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ J}iJ ^x(?i)(end) + execute-keys -draft k ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ }i ^x(?i)(end) execute-keys -draft oxendloop ] ] # Wisely add "end protected;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+protected)$ J}iJ ^x(?i)(end) + execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+protected)$ }i ^x(?i)(end) execute-keys -draft oxendprotected ] ] # Wisely add "end record;". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+record\h*)$ J}iJ ^x(?i)(end) + execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+record\h*)$ }i ^x(?i)(end) execute-keys -draft oxendrecord ] ] # Wisely add ");" for "type ... is (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+\(\h*)$ J}iJ ^x(\)) + execute-keys -draft k ^\h*(?i)(type\b.*\bis\h+\(\h*)$ }i ^x(\)) execute-keys -draft ox) ] ] # Wisely add "end entity;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)\h*entity\b.*\bis$ J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^(?i)\h*entity\b.*\bis$ }i ^x(?i)(begin|end) execute-keys -draft oxendentity ] ] # Wisely add "begin" and "end function;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(\h*\)?\h*return\b.*\bis$) J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^(?i)(\h*\)?\h*return\b.*\bis$) }i ^x(?i)(begin|end) execute-keys -draft oxbeginxendfunction ] try %[ - execute-keys -draft k ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) }i ^x(?i)(begin|end) execute-keys -draft oxbeginxendfunction ] ] # Wisely add "begin" and "end procedure;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(\h*procedure\b.*\bis$) J}iJ ^x(?i)\b(begin|end)\b + execute-keys -draft k ^(?i)(\h*procedure\b.*\bis$) }i ^x(?i)\b(begin|end)\b execute-keys -draft oxbeginxendprocedure ] try %[ - execute-keys -draft k ^(?i)\h*\)\h*\bis$ J}iJ ^x(?i)\b(begin|end)\b + execute-keys -draft k ^(?i)\h*\)\h*\bis$ }i ^x(?i)\b(begin|end)\b # Verify that line with opening parenthesis contains "procedure" keyword. execute-keys -draft k s\) (?i)\bprocedure\b execute-keys -draft oxbeginxendprocedure @@ -279,7 +279,7 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end package;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(package\b) J}iJ ^x(?i)(end) + execute-keys -draft k ^(?i)(package\b) }i ^x(?i)(end) # Make sure it is not package body. execute-keys -draft k(?i)\bbody\b execute-keys -draft oendpackage @@ -288,56 +288,56 @@ define-command -hidden vhdl-insert-on-new-line %[ # Wisely add "end package body;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)(package\h+body\b) J}iJ ^x(?i)(end) + execute-keys -draft k ^(?i)(package\h+body\b) }i ^x(?i)(end) execute-keys -draft oendpackagebody ] ] # Wisely add "begin" and "end architecture;". evaluate-commands %[ try %[ - execute-keys -draft k ^(?i)\h*architecture\b J}iJ ^x(?i)(begin|end) + execute-keys -draft k ^(?i)\h*architecture\b }i ^x(?i)(begin|end) execute-keys -draft oxbeginxendarchitecture ] ] # Wisely add ");" for "port (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)port\h*\($ J}iJ ^x(\)\;) + execute-keys -draft k ^\h*(?i)port\h*\($ }i ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "port map (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)port\h+map\h*\($ J}iJ ^x(\)\;) + execute-keys -draft k ^\h*(?i)port\h+map\h*\($ }i ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "generic (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)generic\h*\($ J}iJ ^x(\)\;) + execute-keys -draft k ^\h*(?i)generic\h*\($ }i ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ")" for "generic map (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)generic\h+map\h*\($ J}iJ ^x(\)) + execute-keys -draft k ^\h*(?i)generic\h+map\h*\($ }i ^x(\)) execute-keys -draft ox) ] ] # Wisely add ") return ;" for "[pure|impure] function ... (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ J}iJ ^x(\)\h*return.*) + execute-keys -draft k ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ }i ^x(\)\h*return.*) execute-keys -draft ox)return ] ] # Wisely add ");" for "procedure ... (". evaluate-commands %[ try %[ - execute-keys -draft k ^\h*(?i)procedure\b.*\h*\($ J}iJ ^x(\)\h*\;) + execute-keys -draft k ^\h*(?i)procedure\b.*\h*\($ }i ^x(\)\h*\;) execute-keys -draft ox) ] ]