@@ -71,7 +71,8 @@ let s:default_errlevel.EVL204 = s:DEF_NON
7171let s: default_errlevel .EVL205 = s: DEF_WRN
7272let s: default_errlevel .EVL206 = s: DEF_NON
7373let s: default_errlevel .EVL207 = s: DEF_NON
74- let s: default_errlevel .EVL301 = s: DEF_WRN
74+ let s: default_errlevel .EVL301 = s: DEF_NON
75+ let s: default_errlevel .EVL302 = s: DEF_NON
7576let s: default_errlevel .EVL901 = s: DEF_WRN
7677let s: default_errlevel .EVL902 = s: DEF_WRN
7778let s: def_var_name = ' :'
@@ -843,6 +844,40 @@ function! s:reconstruct_varstack_st(self, env, p) abort " {{{
843844endfunction " }}}
844845" @vimlint(EVL103, 0, a:self)
845846
847+ function ! s: VimlLint .abbrev_if (vl, node) abort " {{{
848+ for node in a: node .elseif
849+ call a: vl .abbrev_common (node)
850+ endfor
851+ if a: node .else isnot s: vlp .NIL
852+ call a: vl .abbrev_common (a: node .else )
853+ endif
854+ call a: vl .abbrev_common (a: node .endif )
855+ endfunction " }}}
856+ function ! s: VimlLint .abbrev_for (vl, node) abort " {{{
857+ call a: vl .abbrev_common (a: node .endfor )
858+ endfunction " }}}
859+ function ! s: VimlLint .abbrev_while (vl, node) abort " {{{
860+ call a: vl .abbrev_common (a: node .endwhile )
861+ endfunction " }}}
862+ function ! s: VimlLint .abbrev_try (vl, node) abort " {{{
863+ for node in a: node .catch
864+ call a: vl .abbrev_common (node)
865+ endfor
866+ if a: node .finally isnot s: vlp .NIL
867+ call a: vl .abbrev_common (a: node .finally )
868+ endif
869+ call a: vl .abbrev_common (a: node .endtry )
870+ endfunction " }}}
871+ function ! s: VimlLint .abbrev_func (vl, node) abort " {{{
872+ call a: vl .abbrev_common (a: node .endfunction )
873+ endfunction " }}}
874+ function ! s: VimlLint .abbrev_common (node) abort " {{{
875+ let line = self .lines [a: node .pos.lnum - 1 ]
876+ if match (line , ' ^' . a: node .ea .cmd.name . ' \>' , a: node .pos.col - 1 ) < 0
877+ call self .error_mes (a: node , ' EVL302' , ' use the full command name `' . a: node .ea .cmd.name . ' ` instead of the abbreviation' , a: node )
878+ endif
879+ endfunction " }}}
880+
846881function s: VimlLint .compile (node, refchk) abort " {{{
847882 if type (a: node ) == # type ({}) && has_key (a: node , ' type' )
848883 if a: node .type != 2 && g: vimlint #debug > 2 || g: vimlint #debug >= 5
@@ -860,6 +895,14 @@ function s:VimlLint.compile(node, refchk) abort " {{{
860895 " echo a:node
861896 " throw "stop"
862897 " endtry
898+ if has_key (a: node , ' ea' )
899+ if has_key (self .excmd_abbrev, a: node .type )
900+ call self .excmd_abbrev[a: node .type ](self , a: node )
901+ elseif has_key (a: node .ea .cmd, ' name' )
902+ call self .abbrev_common (a: node )
903+ endif
904+ endif
905+
863906
864907 return call (self .compile_funcs[a: node .type ], [a: node , a: refchk ], self )
865908
@@ -2232,6 +2275,13 @@ let s:VimlLint.compile_funcs[s:vlp.NODE_CURLYNAME] = s:VimlLint.compile_curlynam
22322275let s: VimlLint .compile_funcs[s: vlp .NODE_ENV] = s: VimlLint .compile_env
22332276let s: VimlLint .compile_funcs[s: vlp .NODE_REG] = s: VimlLint .compile_reg
22342277
2278+ let s: VimlLint .excmd_abbrev = {}
2279+ let s: VimlLint .excmd_abbrev[s: vlp .NODE_IF] = s: VimlLint .abbrev_if
2280+ let s: VimlLint .excmd_abbrev[s: vlp .NODE_FOR] = s: VimlLint .abbrev_for
2281+ let s: VimlLint .excmd_abbrev[s: vlp .NODE_WHILE] = s: VimlLint .abbrev_while
2282+ let s: VimlLint .excmd_abbrev[s: vlp .NODE_TRY] = s: VimlLint .abbrev_try
2283+ let s: VimlLint .excmd_abbrev[s: vlp .NODE_FUNCTION] = s: VimlLint .abbrev_func
2284+
22352285let &cpo = s: save_cpo
22362286unlet s: save_cpo
22372287
0 commit comments