Skip to content

Commit 2ff14b3

Browse files
committed
Filter out forbidden syntax keyword arguments
This is a bug fix / improvement to the new syntax keyword usage introduced in b6f8757. Also relevant is issue #68 on GitHub, see #68
1 parent 0a64a81 commit 2ff14b3

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

autoload/xolox/easytags.vim

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: July 9, 2014
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '3.6.1'
6+
let g:xolox#easytags#version = '3.6.2'
77

88
" Plug-in initialization. {{{1
99

@@ -375,10 +375,33 @@ endfunction
375375
function! s:is_keyword_compatible(tag)
376376
let name = get(a:tag, 'name', '')
377377
if !empty(name)
378-
return name =~ '^\k\+$' && len(name) <= 80
378+
" Make sure the tag contains only `keyword characters' (included in the
379+
" &iskeyword option) and is not longer than 80 characters (these
380+
" limitations are documented under :help :syn-keyword).
381+
if name =~ '^\k\+$' && len(name) <= 80
382+
" Make sure the tag doesn't conflict with one of the named options
383+
" accepted by the `:syntax keyword' command (using these named options
384+
" improperly, e.g. without a mandatory argument, will raise an error).
385+
return !has_key(s:invalid_keywords, name)
379386
endif
387+
return 0
380388
endfunction
381389

390+
" These are documented under :help E395, except for "contains" which is not
391+
" documented as being forbidden but when used definitely triggers an error.
392+
let s:invalid_keywords = {
393+
\ 'cchar': 1,
394+
\ 'conceal': 1,
395+
\ 'contained': 1,
396+
\ 'containedin': 1,
397+
\ 'contains': 1,
398+
\ 'nextgroup': 1,
399+
\ 'skipempty': 1,
400+
\ 'skipnl': 1,
401+
\ 'skipwhite': 1,
402+
\ 'transparent': 1,
403+
\ }
404+
382405
" Public supporting functions (might be useful to others). {{{1
383406

384407
function! xolox#easytags#get_tagsfile() " {{{2

0 commit comments

Comments
 (0)