Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create Pl#Match#Validate() for match list validation

  • Loading branch information...
commit 486a7e174d3e853113a55098337206a41e9aecbf 1 parent 3abe553
@Lokaltog Lokaltog authored
Showing with 21 additions and 1 deletion.
  1. +18 −1 autoload/Pl/Match.vim
  2. +3 −0  autoload/Pl/Parser.vim
View
19 autoload/Pl/Match.vim
@@ -2,7 +2,6 @@ function! Pl#Match#Add(pat, expr) " {{{
return [a:pat, a:expr]
endfunction " }}}
function! Pl#Match#Any(...) " {{{
- " Empty match array matches everything
let matches = []
for match_name in a:000
@@ -11,3 +10,21 @@ function! Pl#Match#Any(...) " {{{
return ['match', 'any', matches]
endfunction " }}}
+function! Pl#Match#Validate(match) " {{{
+ let [m, match, matches] = a:match
+
+ if ! len(matches)
+ " Empty match array matches everything
+ return 1
+ endif
+
+ if match == 'any'
+ for [eval, re] in matches
+ if match(eval(eval), '\v'. re) != -1
+ return 1
+ endif
+ endfor
+
+ return 0
+ endif
+endfunction " }}}
View
3  autoload/Pl/Parser.vim
@@ -141,6 +141,9 @@ function! s:HlCreate(hl) " {{{
\ )
exec hi_cmd
+
+ " Add command to Pl#HL list for caching
+ call add(g:Pl#HL, hi_cmd)
endif
" Return only the highlighting group name
Please sign in to comment.
Something went wrong with that request. Please try again.