mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-25 10:32:19 +03:00
Allow different type of pre-processing guards to be included in C
headers. This commit introduces the `c_include_guard_style` option, which can take one of the following values: "ifdef", "pragma", "none". The corresponding type of guard will be used accordingly to the value of this variable.
This commit is contained in:
parent
8f7c2ac636
commit
cbfc6d3cd0
@ -145,8 +145,19 @@ hook global WinSetOption filetype=(?!cpp$).* %[ rmhl cpp ]
|
||||
hook global WinSetOption filetype=objc %[ addhl ref objc ]
|
||||
hook global WinSetOption filetype=(?!objc$).* %[ rmhl objc ]
|
||||
|
||||
decl str c_include_guard_style "ifdef"
|
||||
def -hidden _c-family-insert-include-guards %{
|
||||
exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>
|
||||
%sh{
|
||||
case "${kak_opt_c_include_guard_style,,}" in
|
||||
ifdef)
|
||||
echo "exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>"
|
||||
;;
|
||||
pragma)
|
||||
echo "exec ggi#pragma<space>once<esc>"
|
||||
;;
|
||||
*);;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
hook global BufNew .*\.(h|hh|hpp|hxx|H) _c-family-insert-include-guards
|
||||
|
Loading…
Reference in New Issue
Block a user