rc: remove spurious tabs

This makes it easier to be consistent.

Also replace "<<-EOF" by "<<EOF", since the former only does trims
tabs, not spaces.
This commit is contained in:
Johannes Altmanninger 2021-04-17 11:51:25 +02:00
parent 787ff5d002
commit 3ab2b98ec3
10 changed files with 501 additions and 501 deletions

View File

@ -12,7 +12,7 @@ evaluate-commands %sh{
grey_dark_3="rgb:424242" grey_dark_3="rgb:424242"
grey_dark_4="rgb:212121" grey_dark_4="rgb:212121"
cat <<- EOF cat <<EOF
# For Code # For Code
set-face global keyword ${grey_dark_2} set-face global keyword ${grey_dark_2}

View File

@ -70,7 +70,7 @@ evaluate-commands %sh{
dark_grey="rgb:555555" dark_grey="rgb:555555"
# NOTE: Do not use any color that hasn't been defined above (no hardcoding) # NOTE: Do not use any color that hasn't been defined above (no hardcoding)
cat <<- EOF cat <<EOF
# For Code # For Code
set-face global keyword ${vibrant_blue} set-face global keyword ${vibrant_blue}

View File

@ -70,7 +70,7 @@ evaluate-commands %sh{
dark_grey="rgb:555555" dark_grey="rgb:555555"
# NOTE: Do not use any color that hasn't been defined above (no hardcoding) # NOTE: Do not use any color that hasn't been defined above (no hardcoding)
cat <<- EOF cat <<EOF
# For Code # For Code
set-face global keyword ${muted_indigo} set-face global keyword ${muted_indigo}

View File

@ -1,22 +1,22 @@
# Solarized Dark # Solarized Dark
evaluate-commands %sh{ evaluate-commands %sh{
base03='rgb:002b36' base03='rgb:002b36'
base02='rgb:073642' base02='rgb:073642'
base01='rgb:586e75' base01='rgb:586e75'
base00='rgb:657b83' base00='rgb:657b83'
base0='rgb:839496' base0='rgb:839496'
base1='rgb:93a1a1' base1='rgb:93a1a1'
base2='rgb:eee8d5' base2='rgb:eee8d5'
base3='rgb:fdf6e3' base3='rgb:fdf6e3'
yellow='rgb:b58900' yellow='rgb:b58900'
orange='rgb:cb4b16' orange='rgb:cb4b16'
red='rgb:dc322f' red='rgb:dc322f'
magenta='rgb:d33682' magenta='rgb:d33682'
violet='rgb:6c71c4' violet='rgb:6c71c4'
blue='rgb:268bd2' blue='rgb:268bd2'
cyan='rgb:2aa198' cyan='rgb:2aa198'
green='rgb:859900' green='rgb:859900'
echo " echo "
# code # code

View File

@ -98,8 +98,8 @@ define-command -hidden elixir-indent-on-new-line %{
# preserve previous line indent # preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> } try %{ execute-keys -draft <semicolon> K <a-&> }
# indent after line ending with: # indent after line ending with:
# try %{ execute-keys -draft k x <a-k> (\bdo|\belse|->)$ <ret> & } # try %{ execute-keys -draft k x <a-k> (\bdo|\belse|->)$ <ret> & }
# filter previous line # filter previous line
try %{ execute-keys -draft k : elixir-trim-indent <ret> } try %{ execute-keys -draft k : elixir-trim-indent <ret> }
# indent after lines ending with do or -> # indent after lines ending with do or ->
try %{ execute-keys -draft <semicolon> k x <a-k> ^.+(\bdo|->)$ <ret> j <a-gt> } try %{ execute-keys -draft <semicolon> k x <a-k> ^.+(\bdo|->)$ <ret> j <a-gt> }

View File

@ -35,10 +35,10 @@ require-module html
# ‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/hbs regions add-highlighter shared/hbs regions
add-highlighter shared/hbs/comment region \{\{!-- --\}\} fill comment add-highlighter shared/hbs/comment region \{\{!-- --\}\} fill comment
add-highlighter shared/hbs/comment_alt region \{\{! \}\} fill comment add-highlighter shared/hbs/comment_alt region \{\{! \}\} fill comment
add-highlighter shared/hbs/block-expression region \{\{[#/] \}\} regions add-highlighter shared/hbs/block-expression region \{\{[#/] \}\} regions
add-highlighter shared/hbs/expression region \{\{ \}\} regions add-highlighter shared/hbs/expression region \{\{ \}\} regions
define-command -hidden add-mutual-highlighters -params 1 %~ define-command -hidden add-mutual-highlighters -params 1 %~
add-highlighter "shared/hbs/%arg{1}/code" default-region group add-highlighter "shared/hbs/%arg{1}/code" default-region group

View File

@ -3,25 +3,25 @@
# Detection, see https://wiki.freepascal.org/file_types # Detection, see https://wiki.freepascal.org/file_types
hook global BufCreate .*\.(p|pp|pas|pascal)$ %{ hook global BufCreate .*\.(p|pp|pas|pascal)$ %{
set-option buffer filetype pascal set-option buffer filetype pascal
} }
hook global BufCreate .*\.(dpr|dpk|dfm)$ %{ hook global BufCreate .*\.(dpr|dpk|dfm)$ %{
set-option buffer filetype delphi set-option buffer filetype delphi
} }
hook global BufCreate .*\.(lpr|lfm)$ %{ hook global BufCreate .*\.(lpr|lfm)$ %{
set-option buffer filetype freepascal set-option buffer filetype freepascal
} }
hook global WinSetOption filetype=((free|object)?pascal|delphi) %[ hook global WinSetOption filetype=((free|object)?pascal|delphi) %[
require-module pascal require-module pascal
hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ }
set-option window static_words %opt{static_words} set-option window static_words %opt{static_words}
] ]
hook -group pascal-highlight global WinSetOption filetype=((free|object)?pascal|delphi) %[ hook -group pascal-highlight global WinSetOption filetype=((free|object)?pascal|delphi) %[
add-highlighter window/pascal ref pascal add-highlighter window/pascal ref pascal
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pascal } hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pascal }
] ]
provide-module pascal %§ provide-module pascal %§
@ -30,174 +30,174 @@ add-highlighter shared/pascal regions
add-highlighter shared/pascal/code default-region group add-highlighter shared/pascal/code default-region group
evaluate-commands %sh¶ evaluate-commands %sh¶
# This might seem like a lot of effort to highlight routines and # This might seem like a lot of effort to highlight routines and
# properties correctly but it is worth it # properties correctly but it is worth it
id='([_a-zA-Z][\w]{,126})\s*' # identifier for variables etc. id='([_a-zA-Z][\w]{,126})\s*' # identifier for variables etc.
id2="(?:$id\.)?$id(?:<.*?>)?" # (module|type).id id2="(?:$id\.)?$id(?:<.*?>)?" # (module|type).id
id4="(?:$id\.)?(?:$id\.)?(?:$id\.)?$id" # type.type.type.id id4="(?:$id\.)?(?:$id\.)?(?:$id\.)?$id" # type.type.type.id
type=":\s*(specialize\s+)?(?:(array\s+of\s+)?$id2)" # 1:attribute 2:keyword 3:module 4:type type=":\s*(specialize\s+)?(?:(array\s+of\s+)?$id2)" # 1:attribute 2:keyword 3:module 4:type
cat <<-EOF cat <<EOF
# routine without parameters # routine without parameters
add-highlighter shared/pascal/code/simple_routine regex \ add-highlighter shared/pascal/code/simple_routine regex \
"\b(?i)(function|procedure|constructor|destructor|operator)\s+$id4(?:$type)?" \ "\b(?i)(function|procedure|constructor|destructor|operator)\s+$id4(?:$type)?" \
2:type 3:type 4:type 5:function 6:attribute 7:keyword 8:module 9:type 2:type 3:type 4:type 5:function 6:attribute 7:keyword 8:module 9:type
add-highlighter shared/pascal/simple_property region \ add-highlighter shared/pascal/simple_property region \
"\b(?i)property\s+$id2:" ";" group "\b(?i)property\s+$id2:" ";" group
# routine with parameters # routine with parameters
add-highlighter shared/pascal/routine region \ add-highlighter shared/pascal/routine region \
"\b(?i)(function|procedure|constructor|destructor|operator)(\s+$id4)?\s*(<.*?>)?\s*\(" "\).*?;" regions "\b(?i)(function|procedure|constructor|destructor|operator)(\s+$id4)?\s*(<.*?>)?\s*\(" "\).*?;" regions
add-highlighter shared/pascal/property region \ add-highlighter shared/pascal/property region \
"\b(?i)property\s+$id4\[" "\].*?;" regions "\b(?i)property\s+$id4\[" "\].*?;" regions
add-highlighter shared/pascal/routine/parameters region -recurse \( \( \) regions add-highlighter shared/pascal/routine/parameters region -recurse \( \( \) regions
add-highlighter shared/pascal/property/parameters region -recurse \[ \[ \] regions add-highlighter shared/pascal/property/parameters region -recurse \[ \[ \] regions
EOF EOF
# Used to highlight "var1, var2, var3, var4 : type" declarations # Used to highlight "var1, var2, var3, var4 : type" declarations
x="(?:$id,\s*)?" x="(?:$id,\s*)?"
for r in property routine; do for r in property routine; do
cat <<-EOF cat <<EOF
add-highlighter shared/pascal/$r/parameters/default default-region group add-highlighter shared/pascal/$r/parameters/default default-region group
add-highlighter shared/pascal/$r/parameters/default/ regex \ add-highlighter shared/pascal/$r/parameters/default/ regex \
"(?i)(?:(constref|const|var|out|univ)\s+)?$x$x$x$x$x$id(?:$type)?" \ "(?i)(?:(constref|const|var|out|univ)\s+)?$x$x$x$x$x$id(?:$type)?" \
1:attribute 2:variable 3:variable 4:variable 5:variable 6:variable 7:variable 8:attribute 9:keyword 10:module 11:type 1:attribute 2:variable 3:variable 4:variable 5:variable 6:variable 7:variable 8:attribute 9:keyword 10:module 11:type
add-highlighter shared/pascal/$r/default default-region group add-highlighter shared/pascal/$r/default default-region group
EOF EOF
done done
cat <<-EOF cat <<EOF
add-highlighter shared/pascal/routine/default/ regex \ add-highlighter shared/pascal/routine/default/ regex \
"\b(?i)(function|procedure|constructor|destructor|operator)(?:\s+$id4)?" \ "\b(?i)(function|procedure|constructor|destructor|operator)(?:\s+$id4)?" \
1:keyword 2:type 3:type 4:type 5:function 1:keyword 2:type 3:type 4:type 5:function
add-highlighter shared/pascal/routine/default/return_type regex \ add-highlighter shared/pascal/routine/default/return_type regex \
"(?i)$type" 1:attribute 2:keyword 3:module 4:type "(?i)$type" 1:attribute 2:keyword 3:module 4:type
add-highlighter shared/pascal/routine/default/ regex \ add-highlighter shared/pascal/routine/default/ regex \
"(?i)(of\s+object|is\s+nested)" 1:keyword "(?i)(of\s+object|is\s+nested)" 1:keyword
EOF EOF
for r in property/default simple_property; do for r in property/default simple_property; do
cat <<-EOF cat <<EOF
add-highlighter shared/pascal/$r/ regex "\b(?i)(property)" 1:keyword add-highlighter shared/pascal/$r/ regex "\b(?i)(property)" 1:keyword
add-highlighter shared/pascal/$r/type regex ":\s*$id" 1:type add-highlighter shared/pascal/$r/type regex ":\s*$id" 1:type
# https://www.freepascal.org/docs-html/ref/refsu33.html # https://www.freepascal.org/docs-html/ref/refsu33.html
add-highlighter shared/pascal/$r/specifier regex \ add-highlighter shared/pascal/$r/specifier regex \
"\b(?i)(index|read|write|implements|(no)?default|stored)\b" 0:attribute "\b(?i)(index|read|write|implements|(no)?default|stored)\b" 0:attribute
EOF EOF
done done
for r in pascal pascal/routine pascal/routine/parameters pascal/property; do for r in pascal pascal/routine pascal/routine/parameters pascal/property; do
cat <<-EOF cat <<EOF
# Example string: 'You''re welcome!' # Example string: 'You''re welcome!'
add-highlighter shared/$r/string region \ add-highlighter shared/$r/string region \
-recurse %{(?<!')('')+(?!')} %{'} %{'(?!')|\$} group -recurse %{(?<!')('')+(?!')} %{'} %{'(?!')|\$} group
add-highlighter shared/$r/string/ fill string add-highlighter shared/$r/string/ fill string
add-highlighter shared/$r/string/escape regex "''" 0:+b add-highlighter shared/$r/string/escape regex "''" 0:+b
add-highlighter shared/$r/directive region \{\\$[a-zA-Z] \} fill meta add-highlighter shared/$r/directive region \{\\$[a-zA-Z] \} fill meta
# comments (https://www.freepascal.org/docs-html/ref/refse2.html) # comments (https://www.freepascal.org/docs-html/ref/refse2.html)
add-highlighter shared/$r/comment_old region -recurse \(\* \(\* \*\) fill comment add-highlighter shared/$r/comment_old region -recurse \(\* \(\* \*\) fill comment
add-highlighter shared/$r/comment_new region -recurse \{ \{ \} fill comment add-highlighter shared/$r/comment_new region -recurse \{ \{ \} fill comment
add-highlighter shared/$r/comment_oneline region // $ fill comment add-highlighter shared/$r/comment_oneline region // $ fill comment
EOF EOF
done done
# The types "string" and "file", the value "nil", and the modifiers # The types "string" and "file", the value "nil", and the modifiers
# "bitpacked" and "packed" are not included. # "bitpacked" and "packed" are not included.
reserved='and array as asm begin case class const constructor cppclass reserved='and array as asm begin case class const constructor cppclass
destructor dispinterface div do downto else end except exports destructor dispinterface div do downto else end except exports
finalization finally for function goto if implementation in finalization finally for function goto if implementation in
inherited initialization interface is label library mod not inherited initialization interface is label library mod not
object of operator or otherwise procedure program property raise object of operator or otherwise procedure program property raise
record repeat resourcestring set shl shr then threadvar to try record repeat resourcestring set shl shr then threadvar to try
type unit until uses var while with xor' type unit until uses var while with xor'
# These are not reserved words in Free Pascal, but for consistency # These are not reserved words in Free Pascal, but for consistency
# with other programming languages are highlighted as reserved words: # with other programming languages are highlighted as reserved words:
keywords='Break Continue Exit at on package' keywords='Break Continue Exit at on package'
# "at" is used in Delphi, e.g. 'raise object at address' # "at" is used in Delphi, e.g. 'raise object at address'
# https://www.freepascal.org/docs-html/ref/refsu3.html and # https://www.freepascal.org/docs-html/ref/refsu3.html and
# https://wiki.freepascal.org/Reserved_words # https://wiki.freepascal.org/Reserved_words
# "name" and "alias" are not included beacuse they produce too many # "name" and "alias" are not included beacuse they produce too many
# false positives. Some modifiers like "index" are only highlighted in # false positives. Some modifiers like "index" are only highlighted in
# certain places. # certain places.
modifiers='absolute abstract assembler automated bitpacked cdecl contains modifiers='absolute abstract assembler automated bitpacked cdecl contains
cppdecl cvar default deprecated dispid dynamic enumerator cppdecl cvar default deprecated dispid dynamic enumerator
experimental export external far far16 final forward generic experimental export external far far16 final forward generic
helper inline interrupt iocheck local near noreturn helper inline interrupt iocheck local near noreturn
nostackframe oldfpccall overload override packed pascal nostackframe oldfpccall overload override packed pascal
platform private protected public published readonly register platform private protected public published readonly register
reintroduce requires safecall saveregisters softfloat specialize reintroduce requires safecall saveregisters softfloat specialize
static stdcall strict syscall unaligned unimplemented varargs static stdcall strict syscall unaligned unimplemented varargs
virtual winapi writeonly' virtual winapi writeonly'
# https://wiki.freepascal.org/Category:Data_types # https://wiki.freepascal.org/Category:Data_types
# not highlighted for consistency with not built-in types # not highlighted for consistency with not built-in types
types='AnsiChar AnsiString Boolean Boolean16 Boolean32 Boolean64 Buffer types='AnsiChar AnsiString Boolean Boolean16 Boolean32 Boolean64 Buffer
Byte ByteBool Cardinal Char Comp Currency Double DWord Extended Byte ByteBool Cardinal Char Comp Currency Double DWord Extended
Int16 Int32 Int64 Int8 Integer IUnknown LongBool LongInt Longword Int16 Int32 Int64 Int8 Integer IUnknown LongBool LongInt Longword
NativeInt NativeUInt OleVariant PAnsiChar PAnsiString PBoolean PByte NativeInt NativeUInt OleVariant PAnsiChar PAnsiString PBoolean PByte
PByteArray PCardinal PChar PComp PCurrency PDate PDateTime PDouble PByteArray PCardinal PChar PComp PCurrency PDate PDateTime PDouble
PDWord PExtended PHandle PInt64 PInteger PLongInt PLongWord Pointer PDWord PExtended PHandle PInt64 PInteger PLongInt PLongWord Pointer
PPointer PQWord PShortInt PShortString PSingle PSmallInt PString PPointer PQWord PShortInt PShortString PSingle PSmallInt PString
PUnicodeChar PUnicodeString PVariant PWideChar PWideString PWord PUnicodeChar PUnicodeString PVariant PWideChar PWideString PWord
PWordArray PWordBool QWord QWordBool RawBytestring Real Real48 PWordArray PWordBool QWord QWordBool RawBytestring Real Real48
ShortInt ShortString Single SmallInt TClass TDate TDateTime Text ShortInt ShortString Single SmallInt TClass TDate TDateTime Text
TextFile THandle TObject TTime UInt16 UInt32 UInt8 UnicodeChar TextFile THandle TObject TTime UInt16 UInt32 UInt8 UnicodeChar
UnicodeString UTF16String UTF8String Variant WideChar WideString UnicodeString UTF16String UTF8String Variant WideChar WideString
Word WordBool file string' Word WordBool file string'
constants='False True nil MaxInt Self' constants='False True nil MaxInt Self'
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
echo declare-option str-list static_words $reserved $keywords $modifiers \ echo declare-option str-list static_words $reserved $keywords $modifiers \
$types $constants name index result constref out read write implements \ $types $constants name index result constref out read write implements \
nodefault stored message nodefault stored message
# Replace spaces with a pipe # Replace spaces with a pipe
join() { eval set -- $1; IFS='|'; echo "$*"; } join() { eval set -- $1; IFS='|'; echo "$*"; }
cat <<-EOF cat <<EOF
add-highlighter shared/pascal/code/keywords regex \ add-highlighter shared/pascal/code/keywords regex \
(?i)(?<!&)\b($(join "$reserved $keywords")|file\s+of)\b 0:keyword (?i)(?<!&)\b($(join "$reserved $keywords")|file\s+of)\b 0:keyword
add-highlighter shared/pascal/code/modifiers regex \ add-highlighter shared/pascal/code/modifiers regex \
(?i)(?<!\.)\b($(join "$modifiers"))\b(?!\()|message\s+(?!:) 0:attribute (?i)(?<!\.)\b($(join "$modifiers"))\b(?!\()|message\s+(?!:) 0:attribute
add-highlighter shared/pascal/code/index regex \ add-highlighter shared/pascal/code/index regex \
'\b(?i)(index)\s+\w+\s*;' 1:attribute '\b(?i)(index)\s+\w+\s*;' 1:attribute
EOF EOF
for r in code routine/parameters/default routine/default property/default simple_property; do for r in code routine/parameters/default routine/default property/default simple_property; do
cat <<-EOF cat <<EOF
add-highlighter shared/pascal/$r/ regex '[.:=<>@^*/+-]' 0:operator add-highlighter shared/pascal/$r/ regex '[.:=<>@^*/+-]' 0:operator
add-highlighter shared/pascal/$r/constants regex \ add-highlighter shared/pascal/$r/constants regex \
\b(?i)($(join "$constants"))\b 0:value \b(?i)($(join "$constants"))\b 0:value
# numbers (https://www.freepascal.org/docs-html/ref/refse6.html) # numbers (https://www.freepascal.org/docs-html/ref/refse6.html)
add-highlighter shared/pascal/$r/decimal regex \b\d+([eE][+-]?\d+)?\b 0:value add-highlighter shared/pascal/$r/decimal regex \b\d+([eE][+-]?\d+)?\b 0:value
add-highlighter shared/pascal/$r/hex regex \\$[\da-fA-F]+\b 0:value add-highlighter shared/pascal/$r/hex regex \\$[\da-fA-F]+\b 0:value
add-highlighter shared/pascal/$r/octal regex &[0-7]+\b 0:value add-highlighter shared/pascal/$r/octal regex &[0-7]+\b 0:value
add-highlighter shared/pascal/$r/binary regex \%[01]+\b 0:value add-highlighter shared/pascal/$r/binary regex \%[01]+\b 0:value
add-highlighter shared/pascal/$r/char regex '#\d+\b' 0:value add-highlighter shared/pascal/$r/char regex '#\d+\b' 0:value
EOF EOF
done done
define-command -hidden pascal-indent-on-new-line %{ define-command -hidden pascal-indent-on-new-line %{
evaluate-commands -no-hooks -draft -itersel %{ evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent # preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> } try %{ execute-keys -draft <semicolon> K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ execute-keys -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after certain keywords # indent after certain keywords
try %{ execute-keys -draft k<a-x><a-k>(?i)(asm|begin|const|else|except|exports|finalization|finally|label|of|otherwise|private|property|public|protected|published|record|repeat|resourcestring|threadvar|try|type|uses|var|:)\h*$<ret>j<a-gt> } try %{ execute-keys -draft k<a-x><a-k>(?i)(asm|begin|const|else|except|exports|finalization|finally|label|of|otherwise|private|property|public|protected|published|record|repeat|resourcestring|threadvar|try|type|uses|var|:)\h*$<ret>j<a-gt> }
} }
} }
§ §

View File

@ -92,9 +92,9 @@ define-command -hidden php-indent-on-new-line %<
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _ try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
# append " * " on lines starting a multiline /** or /* comment # append " * " on lines starting a multiline /** or /* comment
try %{ execute-keys -draft k <a-x> s ^\h*/[*][* ]? <ret> j gi i <space>*<space> } try %{ execute-keys -draft k <a-x> s ^\h*/[*][* ]? <ret> j gi i <space>*<space> }
# deindent closer token(s) when after cursor # deindent closer token(s) when after cursor
try %_ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> _ try %_ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> _
> >
> >

View File

@ -2,24 +2,24 @@
# Detection # Detection
hook global BufCreate .*[.](vhd[l]?) %[ hook global BufCreate .*[.](vhd[l]?) %[
set-option buffer filetype vhdl set-option buffer filetype vhdl
] ]
# Initialization # Initialization
hook global WinSetOption filetype=vhdl %[ hook global WinSetOption filetype=vhdl %[
require-module vhdl require-module vhdl
set-option window static_words %opt{vhdl_static_words} 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 \n vhdl-indent-on-new-line
hook -group vhdl-indent window InsertChar \) vhdl-indent-on-closing-parenthesis 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-insert window InsertChar \n vhdl-insert-on-new-line
# Cleanup trailing whitespaces on current line insert end. # Cleanup trailing whitespaces on current line insert end.
hook -group vhdl-trim-indent window ModeChange pop:insert:.* %[ try %[ execute-keys -draft <semicolon> <a-x> s ^\h+$ <ret> d ] ] hook -group vhdl-trim-indent window ModeChange pop:insert:.* %[ try %[ execute-keys -draft <semicolon> <a-x> s ^\h+$ <ret> d ] ]
hook -once -always window WinSetOption filetype=.* %[ remove-hooks window vhdl-.+ ] hook -once -always window WinSetOption filetype=.* %[ remove-hooks window vhdl-.+ ]
] ]
hook -group vhdl-highlight global WinSetOption filetype=vhdl %[ hook -group vhdl-highlight global WinSetOption filetype=vhdl %[
add-highlighter window/vhdl ref vhdl add-highlighter window/vhdl ref vhdl
hook -once -always window WinSetOption filetype=.* %[ remove-highlighter window/vhdl ] hook -once -always window WinSetOption filetype=.* %[ remove-highlighter window/vhdl ]
] ]
provide-module vhdl %§ provide-module vhdl %§
@ -43,100 +43,100 @@ add-highlighter shared/vhdl/code/ regex '\b\d+\.' 0:value
add-highlighter shared/vhdl/code/ regex '\b\d+\+\d+[jJ]\b' 0:value add-highlighter shared/vhdl/code/ regex '\b\d+\+\d+[jJ]\b' 0:value
evaluate-commands %sh[ evaluate-commands %sh[
values="true false note warning error failure" values="true false note warning error failure"
# LRM 5.2.4.1 # LRM 5.2.4.1
units="fs ps ns us ms sec min Å nm um mm cm m km" units="fs ps ns us ms sec min Å nm um mm cm m km"
# LRM 16.2 # LRM 16.2
predefined_attributes=" predefined_attributes="
base left right high low ascending length range reverse_range base left right high low ascending length range reverse_range
subtype image pos succ pred leftof rightof value val subtype image pos succ pred leftof rightof value val
designated_subtype reflect high low index element delayed designated_subtype reflect high low index element delayed
stable quiet transaction event active last_event last_active stable quiet transaction event active last_event last_active
last_value driving driving_value simple_name instance_name last_value driving driving_value simple_name instance_name
path_name record signal converse path_name record signal converse
" "
libraries="ieee std" libraries="ieee std"
packages=" packages="
math_real math_complex std_logic_1164 std_logic_textio numeric_bit numeric_std math_real math_complex std_logic_1164 std_logic_textio numeric_bit numeric_std
numeric_bit_unsigned numeric_std_unsigned fixed_float_types fixed_generic_pkg numeric_bit_unsigned numeric_std_unsigned fixed_float_types fixed_generic_pkg
fixed_pkg float_generic_pkg float_pkg fixed_pkg float_generic_pkg float_pkg
standard textio env standard textio env
" "
# LRM 15.10 # LRM 15.10
reserved_words=" reserved_words="
abs access after alias all and architecture array assert assume assume_guarantee attribute abs access after alias all and architecture array assert assume assume_guarantee attribute
begin block body buffer bus begin block body buffer bus
case component configuration constant context cover case component configuration constant context cover
default disconnect downto default disconnect downto
else elsif end entity exit else elsif end entity exit
fairness file for force function fairness file for force function
generate generic group guarded generate generic group guarded
if impure in inertial inout is if impure in inertial inout is
label library linkage literal loop label library linkage literal loop
map mod map mod
nand new next nor not null nand new next nor not null
of on open or others out of on open or others out
package parameter port postponed procedure process property protected pure package parameter port postponed procedure process property protected pure
range record register reject release rem report restrict restrict_guarantee return rol ror range record register reject release rem report restrict restrict_guarantee return rol ror
select sequence severity signal shared sla sll sra srl strong subtype select sequence severity signal shared sla sll sra srl strong subtype
then to transport type then to transport type
unaffected units until use unaffected units until use
variable view vpkg vmode vprop vunit variable view vpkg vmode vprop vunit
wait when while with wait when while with
xnor xor xnor xor
" "
types=" types="
bit bit_vector bit bit_vector
boolean boolean
file_open_state file_origin_kind file_open_state file_origin_kind
integer natural positive integer natural positive
line line_vector line line_vector
std_logic std_logic_vector std_logic std_logic_vector
std_ulogic std_ulogic_vector std_ulogic std_ulogic_vector
side side
signed unsigned signed unsigned
string text string text
time time
" "
functions=" functions="
find_leftmost find_rightmost divide reciprocal remainder modulo minimum maximum find_leftmost find_rightmost divide reciprocal remainder modulo minimum maximum
std_match add_carry scalb std_match add_carry scalb
resize to_ufixed to_sfixed to_unsigned to_signed to_real to_integer to_slv resize to_ufixed to_sfixed to_unsigned to_signed to_real to_integer to_slv
to_std_logic_vector to_stdlogicvector to_sulv to_std_ulogic_vector to_std_ulogicvector to_std_logic_vector to_stdlogicvector to_sulv to_std_ulogic_vector to_std_ulogicvector
to_01 is_x to_x01 to_ux01 to_x01z to_01 is_x to_x01 to_ux01 to_x01z
ufixed_high ufixed_low sfixed_high sfixed_low to_ufix to_sfix ufix_high ufix_low ufixed_high ufixed_low sfixed_high sfixed_low to_ufix to_sfix ufix_high ufix_low
sfix_high sfix_low sfix_high sfix_low
write read bwrite binary_write bread binary_read owrite oread octal_write octal_read write read bwrite binary_write bread binary_read owrite oread octal_write octal_read
hwrite hread hex_write hex_read to_string to_bstring to_binary_string to_ostring hwrite hread hex_write hex_read to_string to_bstring to_binary_string to_ostring
to_octal_string to_hstring to_hex_string from_string from_bstring from_binary_string to_octal_string to_hstring to_hex_string from_string from_bstring from_binary_string
from_ostring from_octal_string from_hstring from_hex_string from_ostring from_octal_string from_hstring from_hex_string
rising_edge falling_edge rising_edge falling_edge
" "
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s\\n "declare-option str-list vhdl_static_words $(join "${values} ${units} ${predefined_attributes} ${libraries} ${packages} ${reserved_words} ${types} ${functions}" ' ')" printf %s\\n "declare-option str-list vhdl_static_words $(join "${values} ${units} ${predefined_attributes} ${libraries} ${packages} ${reserved_words} ${types} ${functions}" ' ')"
# Highlight keywords # Highlight keywords
printf %s " printf %s "
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${values}" '|'))\b' 0:value add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${values}" '|'))\b' 0:value
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${units}" '|'))\b' 0:meta add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${units}" '|'))\b' 0:meta
add-highlighter shared/vhdl/code/ regex \"'(?i)\b($(join "${predefined_attributes}" '|'))\b\" 0:attribute add-highlighter shared/vhdl/code/ regex \"'(?i)\b($(join "${predefined_attributes}" '|'))\b\" 0:attribute
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${libraries}" '|'))\b' 0:builtin add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${libraries}" '|'))\b' 0:builtin
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${packages}" '|'))\b' 0:builtin add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${packages}" '|'))\b' 0:builtin
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${reserved_words}" '|'))\b' 0:keyword add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${reserved_words}" '|'))\b' 0:keyword
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${functions}" '|'))\b\(' 1:builtin add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${functions}" '|'))\b\(' 1:builtin
add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${types}" '|'))\b' 0:type add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${types}" '|'))\b' 0:type
add-highlighter shared/vhdl/code/ regex '^\h*(@[\w_.]+))' 1:attribute add-highlighter shared/vhdl/code/ regex '^\h*(@[\w_.]+))' 1:attribute
" "
] ]
add-highlighter shared/vhdl/code/ regex \(|\)|\;|\.|,|:|\| 0:attribute add-highlighter shared/vhdl/code/ regex \(|\)|\;|\.|,|:|\| 0:attribute
@ -162,247 +162,247 @@ add-highlighter shared/vhdl/code/ regex '[oO]"[01234567_]*"' 0:value
add-highlighter shared/vhdl/code/ regex '(?i)x"[0123456789abcdef_]*"' 0:value add-highlighter shared/vhdl/code/ regex '(?i)x"[0123456789abcdef_]*"' 0:value
define-command -hidden vhdl-insert-on-new-line %[ define-command -hidden vhdl-insert-on-new-line %[
# Handle comment lines. # Handle comment lines.
evaluate-commands -itersel %[ evaluate-commands -itersel %[
# Copy '--' comment prefix and following white spaces. # Copy '--' comment prefix and following white spaces.
try %[ try %[
# <a-lt> is needed because of "Preserve previous line indent" command. # <a-lt> is needed because of "Preserve previous line indent" command.
try %[ execute-keys -draft k <a-x> s ^\h*--\h* <ret> y j <a-lt> gh P ] try %[ execute-keys -draft k <a-x> s ^\h*--\h* <ret> y j <a-lt> gh P ]
] ]
] ]
evaluate-commands -save-regs x %[ evaluate-commands -save-regs x %[
# Save previous line indent in register x. # Save previous line indent in register x.
try %[ execute-keys -draft k<a-x>s^\h+<ret>"xy ] catch %[ reg x '' ] try %[ execute-keys -draft k<a-x>s^\h+<ret>"xy ] catch %[ reg x '' ]
# All "wisely add" commands share the same concept. # All "wisely add" commands share the same concept.
# Only "end if" has extra comments. # Only "end if" has extra comments.
# Wisely add "end if;". # Wisely add "end if;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
# Validate previous line and that it is not closed yet. # Validate previous line and that it is not closed yet.
execute-keys -draft k<a-x> <a-k>^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$)<ret> }i<a-x> <a-K>^<c-r>x(?i)end\b<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$)<ret> }i<a-x> <a-K>^<c-r>x(?i)end\b<ret>
# Don't add for "if ... generate", it requires "end generate;". # Don't add for "if ... generate", it requires "end generate;".
execute-keys -draft k<a-x> <a-K>(?i)\bgenerate\b<ret> execute-keys -draft k<a-x> <a-K>(?i)\bgenerate\b<ret>
execute-keys -draft o<c-r>xend<space>if<semicolon><esc> execute-keys -draft o<c-r>xend<space>if<semicolon><esc>
] ]
] ]
# Wisely add "end generate;". # Wisely add "end generate;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i).*\bgenerate$<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i).*\bgenerate$<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
# Don't add in case of comment line. # Don't add in case of comment line.
execute-keys -draft k<a-x> <a-K>^\h*--<ret> execute-keys -draft k<a-x> <a-K>^\h*--<ret>
execute-keys -draft o<c-r>xend<space>generate<semicolon><esc> execute-keys -draft o<c-r>xend<space>generate<semicolon><esc>
] ]
] ]
# Wisely add "end case;". # Wisely add "end case;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(case|.*\h*:\h*case)\b<ret> }i<a-x> <a-K>^<c-r>x(?i)end<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(case|.*\h*:\h*case)\b<ret> }i<a-x> <a-K>^<c-r>x(?i)end<ret>
execute-keys -draft o<c-r>xend<space>case<semicolon><esc> execute-keys -draft o<c-r>xend<space>case<semicolon><esc>
] ]
] ]
# Wisely add "begin" and "end block;". # Wisely add "begin" and "end block;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)((block|.*:\h*block)\b)<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)((block|.*:\h*block)\b)<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>block<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>block<semicolon><esc>
] ]
] ]
# Wisely add "begin" and "end process;". # Wisely add "begin" and "end process;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(.*:\h*)?(postponed\h+)?process\b<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(.*:\h*)?(postponed\h+)?process\b<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>process<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>process<semicolon><esc>
] ]
] ]
# Wisely add "end loop;". # Wisely add "end loop;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret>
execute-keys -draft o<c-r>xend<space>loop<semicolon><esc> execute-keys -draft o<c-r>xend<space>loop<semicolon><esc>
] ]
] ]
# Wisely add "end protected;". # Wisely add "end protected;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(type\b.*\bis\h+protected)$<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(type\b.*\bis\h+protected)$<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret>
execute-keys -draft o<c-r>xend<space>protected<semicolon><esc> execute-keys -draft o<c-r>xend<space>protected<semicolon><esc>
] ]
] ]
# Wisely add "end record;". # Wisely add "end record;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(type\b.*\bis\h+record\h*)$<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(type\b.*\bis\h+record\h*)$<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret>
execute-keys -draft o<c-r>xend<space>record<semicolon><esc> execute-keys -draft o<c-r>xend<space>record<semicolon><esc>
] ]
] ]
# Wisely add ");" for "type ... is (". # Wisely add ");" for "type ... is (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(type\b.*\bis\h+\(\h*)$<ret> }i<a-x> <a-K>^<c-r>x(\))<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(type\b.*\bis\h+\(\h*)$<ret> }i<a-x> <a-K>^<c-r>x(\))<ret>
execute-keys -draft o<c-r>x)<semicolon><esc> execute-keys -draft o<c-r>x)<semicolon><esc>
] ]
] ]
# Wisely add "end entity;". # Wisely add "end entity;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)\h*entity\b.*\bis$<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^(?i)\h*entity\b.*\bis$<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
execute-keys -draft o<c-r>xend<space>entity<semicolon><esc> execute-keys -draft o<c-r>xend<space>entity<semicolon><esc>
] ]
] ]
# Wisely add "begin" and "end function;". # Wisely add "begin" and "end function;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)(\h*\)?\h*return\b.*\bis$)<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^(?i)(\h*\)?\h*return\b.*\bis$)<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>function<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>function<semicolon><esc>
] ]
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$)<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$)<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>function<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>function<semicolon><esc>
] ]
] ]
# Wisely add "begin" and "end procedure;". # Wisely add "begin" and "end procedure;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)(\h*procedure\b.*\bis$)<ret> }i<a-x> <a-K>^<c-r>x(?i)\b(begin|end)\b<ret> execute-keys -draft k<a-x> <a-k>^(?i)(\h*procedure\b.*\bis$)<ret> }i<a-x> <a-K>^<c-r>x(?i)\b(begin|end)\b<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>procedure<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>procedure<semicolon><esc>
] ]
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)\h*\)\h*\bis$<ret> }i<a-x> <a-K>^<c-r>x(?i)\b(begin|end)\b<ret> execute-keys -draft k<a-x> <a-k>^(?i)\h*\)\h*\bis$<ret> }i<a-x> <a-K>^<c-r>x(?i)\b(begin|end)\b<ret>
# Verify that line with opening parenthesis contains "procedure" keyword. # Verify that line with opening parenthesis contains "procedure" keyword.
execute-keys -draft k<a-x> s\)<ret> <a-m><semicolon> <a-x><a-k> (?i)\bprocedure\b<ret> execute-keys -draft k<a-x> s\)<ret> <a-m><semicolon> <a-x><a-k> (?i)\bprocedure\b<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>procedure<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>procedure<semicolon><esc>
] ]
] ]
# Wisely add "end package;". # Wisely add "end package;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)(package\b)<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret> execute-keys -draft k<a-x> <a-k>^(?i)(package\b)<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret>
# Make sure it is not package body. # Make sure it is not package body.
execute-keys -draft k<a-x><a-K>(?i)\bbody\b<ret> execute-keys -draft k<a-x><a-K>(?i)\bbody\b<ret>
execute-keys -draft oend<space>package<semicolon><esc> execute-keys -draft oend<space>package<semicolon><esc>
] ]
] ]
# Wisely add "end package body;". # Wisely add "end package body;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)(package\h+body\b)<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret> execute-keys -draft k<a-x> <a-k>^(?i)(package\h+body\b)<ret> }i<a-x> <a-K>^<c-r>x(?i)(end)<ret>
execute-keys -draft oend<space>package<space>body<semicolon><esc> execute-keys -draft oend<space>package<space>body<semicolon><esc>
] ]
] ]
# Wisely add "begin" and "end architecture;". # Wisely add "begin" and "end architecture;".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^(?i)\h*architecture\b<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret> execute-keys -draft k<a-x> <a-k>^(?i)\h*architecture\b<ret> }i<a-x> <a-K>^<c-r>x(?i)(begin|end)<ret>
execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>architecture<semicolon><esc> execute-keys -draft o<c-r>xbegin<ret><c-r>xend<space>architecture<semicolon><esc>
] ]
] ]
# Wisely add ");" for "port (". # Wisely add ");" for "port (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)port\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)port\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret>
execute-keys -draft o<c-r>x)<semicolon><esc> execute-keys -draft o<c-r>x)<semicolon><esc>
] ]
] ]
# Wisely add ");" for "port map (". # Wisely add ");" for "port map (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)port\h+map\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)port\h+map\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret>
execute-keys -draft o<c-r>x)<semicolon><esc> execute-keys -draft o<c-r>x)<semicolon><esc>
] ]
] ]
# Wisely add ");" for "generic (". # Wisely add ");" for "generic (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)generic\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)generic\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret>
execute-keys -draft o<c-r>x)<semicolon><esc> execute-keys -draft o<c-r>x)<semicolon><esc>
] ]
] ]
# Wisely add ")" for "generic map (". # Wisely add ")" for "generic map (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)generic\h+map\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\))<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)generic\h+map\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\))<ret>
execute-keys -draft o<c-r>x)<esc> execute-keys -draft o<c-r>x)<esc>
] ]
] ]
# Wisely add ") return ;" for "[pure|impure] function ... (". # Wisely add ") return ;" for "[pure|impure] function ... (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\h*return.*)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\h*return.*)<ret>
execute-keys -draft o<c-r>x)<space>return<space><semicolon><esc> execute-keys -draft o<c-r>x)<space>return<space><semicolon><esc>
] ]
] ]
# Wisely add ");" for "procedure ... (". # Wisely add ");" for "procedure ... (".
evaluate-commands %[ evaluate-commands %[
try %[ try %[
execute-keys -draft k<a-x> <a-k>^\h*(?i)procedure\b.*\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\h*\;)<ret> execute-keys -draft k<a-x> <a-k>^\h*(?i)procedure\b.*\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\h*\;)<ret>
execute-keys -draft o<c-r>x)<semicolon><esc> execute-keys -draft o<c-r>x)<semicolon><esc>
] ]
] ]
] ]
] ]
define-command -hidden vhdl-indent-on-new-line %{ define-command -hidden vhdl-indent-on-new-line %{
evaluate-commands -itersel %{ evaluate-commands -itersel %{
# Align "then" to previous "if|elsif". # Align "then" to previous "if|elsif".
evaluate-commands -itersel -save-regs x %[ evaluate-commands -itersel -save-regs x %[
try %[ try %[
execute-keys -draft k <a-x> <a-k> (?i)^\h*then$ <ret> execute-keys -draft k <a-x> <a-k> (?i)^\h*then$ <ret>
try %[ execute-keys -draft <a-/>(?i)\b(if|elsif)\b<ret><a-x>s^\h+<ret>"xy ] catch %[ reg x '' ] try %[ execute-keys -draft <a-/>(?i)\b(if|elsif)\b<ret><a-x>s^\h+<ret>"xy ] catch %[ reg x '' ]
try %[ execute-keys -draft k <a-x>s^\h+<ret>d ] catch %[ ] try %[ execute-keys -draft k <a-x>s^\h+<ret>d ] catch %[ ]
execute-keys -draft kgh i<c-r>x<esc> execute-keys -draft kgh i<c-r>x<esc>
] ]
] ]
# Align "generate" to previous "if|for". # Align "generate" to previous "if|for".
evaluate-commands -itersel -save-regs x %[ evaluate-commands -itersel -save-regs x %[
try %[ try %[
execute-keys -draft k <a-x> <a-k> (?i)^\h*generate$ <ret> execute-keys -draft k <a-x> <a-k> (?i)^\h*generate$ <ret>
try %[ execute-keys -draft <a-/>(?i)\b(if|for)\b<ret><a-x>s^\h+<ret>"xy ] catch %[ reg x '' ] try %[ execute-keys -draft <a-/>(?i)\b(if|for)\b<ret><a-x>s^\h+<ret>"xy ] catch %[ reg x '' ]
try %[ execute-keys -draft k <a-x>s^\h+<ret>d ] catch %[ ] try %[ execute-keys -draft k <a-x>s^\h+<ret>d ] catch %[ ]
execute-keys -draft kgh i<c-r>x<esc> execute-keys -draft kgh i<c-r>x<esc>
] ]
] ]
# Preserve previous line indent. # Preserve previous line indent.
try %[ execute-keys -draft <semicolon> K <a-&> ] try %[ execute-keys -draft <semicolon> K <a-&> ]
# Cleanup trailing whitespaces from previous line. # Cleanup trailing whitespaces from previous line.
try %[ execute-keys -draft k <a-x> s \h+$ <ret> d ] try %[ execute-keys -draft k <a-x> s \h+$ <ret> d ]
# Increase indent after some keywords. # Increase indent after some keywords.
try %[ try %[
execute-keys -draft k<a-x><a-k> (?i)\b(begin|block|else|for|generate|if|is|loop|process|protected|record|select|then)$ <ret> execute-keys -draft k<a-x><a-k> (?i)\b(begin|block|else|for|generate|if|is|loop|process|protected|record|select|then)$ <ret>
# Does not indent if in comment line. # Does not indent if in comment line.
execute-keys -draft k<a-x><a-K>(?i)^\h*--<ret> execute-keys -draft k<a-x><a-K>(?i)^\h*--<ret>
# Handle case line in a bit different way. # Handle case line in a bit different way.
execute-keys -draft k<a-x><a-K>(?i)^\h*case\b<ret> execute-keys -draft k<a-x><a-K>(?i)^\h*case\b<ret>
execute-keys -draft <semicolon> <a-gt> execute-keys -draft <semicolon> <a-gt>
] ]
# Add "when " and increase indent after "case ... is". # Add "when " and increase indent after "case ... is".
try %[ try %[
execute-keys -draft k<a-x><a-k> (?i)\h*case\b.*\h+is$ <ret> execute-keys -draft k<a-x><a-k> (?i)\h*case\b.*\h+is$ <ret>
# Don't indent if in comment line. # Don't indent if in comment line.
execute-keys -draft k<a-x><a-K>(?i)^\h*--<ret> execute-keys -draft k<a-x><a-K>(?i)^\h*--<ret>
execute-keys -draft <semicolon>iwhen<space><esc><a-gt> execute-keys -draft <semicolon>iwhen<space><esc><a-gt>
] ]
# Copy the indentation of the matching if. # Copy the indentation of the matching if.
try %{ execute-keys -draft <space> k <a-x> <a-k> ^\h*(elsif\b|else$) <ret> gh [c^\h*(\S*\h*:\h*)?if\b,\bend\sif\b <ret> <a-x> <a-S> 1<a-&> <space> j K <a-&> } try %{ execute-keys -draft <space> k <a-x> <a-k> ^\h*(elsif\b|else$) <ret> gh [c^\h*(\S*\h*:\h*)?if\b,\bend\sif\b <ret> <a-x> <a-S> 1<a-&> <space> j K <a-&> }
# Increase indent after some operators. # Increase indent after some operators.
try %[ execute-keys -draft <semicolon> <space> k <a-x> <a-k> (\(|=>|<=|:=)$ <ret> j <a-gt> ] try %[ execute-keys -draft <semicolon> <space> k <a-x> <a-k> (\(|=>|<=|:=)$ <ret> j <a-gt> ]
} }
} }
define-command vhdl-indent-on-closing-parenthesis %[ define-command vhdl-indent-on-closing-parenthesis %[
evaluate-commands -itersel %[ evaluate-commands -itersel %[
# Decrease indent after ")" at the beginning of line. # Decrease indent after ")" at the beginning of line.
try %[ execute-keys -draft <a-x> <a-k> (^\h+\)$) <ret> <a-lt> ] try %[ execute-keys -draft <a-x> <a-k> (^\h+\)$) <ret> <a-lt> ]
] ]
] ]
§ §

View File

@ -47,7 +47,7 @@ define-command wayland-focus -params ..1 -client-completion -docstring '
wayland-focus [<kakoune_client>]: focus a given client''s window wayland-focus [<kakoune_client>]: focus a given client''s window
If no client is passed, then the current client is used' \ If no client is passed, then the current client is used' \
%{ %{
fail There is no way to focus another window on Wayland fail There is no way to focus another window on Wayland
} }
alias global focus wayland-focus alias global focus wayland-focus