From 98d62b6ae29ce338f4ddfcf1c1331032c81e8c99 Mon Sep 17 00:00:00 2001 From: Jonas DOREL Date: Fri, 1 Oct 2021 15:44:01 +0200 Subject: [PATCH] feat(variables): add SPACECLASS --- autoload/coc/source/template.vim | 1 + doc/template.txt | 5 +++++ plugin/templates.vim | 2 ++ syntax/vim-template.vim | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/coc/source/template.vim b/autoload/coc/source/template.vim index 43543a3..0be7176 100644 --- a/autoload/coc/source/template.vim +++ b/autoload/coc/source/template.vim @@ -16,6 +16,7 @@ let s:dict = [ \ 'CLASS', \ 'MACROCLASS', \ 'CAMELCLASS', + \ 'SPACECLASS', \ 'HERE', \ ] diff --git a/doc/template.txt b/doc/template.txt index 6c56f8a..104b6d5 100644 --- a/doc/template.txt +++ b/doc/template.txt @@ -258,6 +258,11 @@ templates: File name, without extension, with the first character of every work capitalised, and underscores removed. +`%SPACECLASS%` + File name, without extension, with the first character of + every work capitalised, and underscores and dashed replaced + with space. + `%HERE%` Expands to nothing, but ensures that the cursor will be placed in the position where this variable appears after expanding the template. diff --git a/plugin/templates.vim b/plugin/templates.vim index 44ca148..8be7b8c 100644 --- a/plugin/templates.vim +++ b/plugin/templates.vim @@ -361,6 +361,7 @@ function TExpandVars() let l:class = substitute(l:filen, "\\([a-zA-Z]\\+\\)", "\\u\\1\\e", "g") let l:macroclass = toupper(l:class) let l:camelclass = substitute(l:class, "_", "", "g") + let l:spaceclass = substitute(l:class, "[_,-]", " ", "g") " Define license variable if executable('licensee') && g:templates_use_licensee @@ -402,6 +403,7 @@ function TExpandVars() call TExpand("CLASS", l:class) call TExpand("MACROCLASS", l:macroclass) call TExpand("CAMELCLASS", l:camelclass) + call TExpand("SPACECLASS", l:spaceclass) call TExpand("LICENSE", l:license) " Perform expansions for user-defined variables diff --git a/syntax/vim-template.vim b/syntax/vim-template.vim index 52cdb07..c724d32 100644 --- a/syntax/vim-template.vim +++ b/syntax/vim-template.vim @@ -12,7 +12,7 @@ if b:vim_template_subtype != "" unlet b:current_syntax endif -syn match vimtemplateVariable "%\%(DAY\|YEAR\|MONTH\|MONTHSHORT\|MONTHFULL\|DATE\|TIME\|FILE\|FFILE\|EXT\|MAIL\|USER\|HOST\|GUARD\|CLASS\|MACROCLASS\|CAMELCLASS\|HERE\)%" containedin=ALL +syn match vimtemplateVariable "%\%(DAY\|YEAR\|MONTH\|MONTHSHORT\|MONTHFULL\|DATE\|TIME\|FILE\|FFILE\|EXT\|MAIL\|USER\|HOST\|GUARD\|CLASS\|MACROCLASS\|CAMELCLASS\|SPACECLASS\|HERE\)%" containedin=ALL let b:current_syntax = "vim-template"