Created
July 25, 2012 11:36
-
-
Save dahu/3175660 to your computer and use it in GitHub Desktop.
neongenesis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let s:neongenesis = [ | |
| \ ['q', ['d', '+']], | |
| \ ['d', ['s', '+']], | |
| \ ['s', ['d', '-']], | |
| \ ['d', ['q', '-']] | |
| \] | |
| function! NeonIn(neon, n) | |
| let s = a:neon[1][0] | |
| let s .= a:n*2 | |
| let s .= '\>\|\<' | |
| let s .= a:neon[1][0] | |
| let s .= (a:n*2)+1 | |
| return s | |
| endfunction | |
| function! NeonOut(neon, n) | |
| let s = a:neon[1][0] | |
| let s .= a:n/2 | |
| return s | |
| endfunction | |
| function! NeonMatch(reg) | |
| let s = '\<' . a:reg | |
| let [r,n] = matchlist(a:reg, '^\(\a\)\(\d\+\)')[1:2] | |
| for neon in s:neongenesis | |
| if neon[0] == r | |
| let s .= '\>\|\<' | |
| if neon[1][1] == '+' | |
| let s .= NeonIn(neon, n) | |
| else | |
| let s .= NeonOut(neon, n) | |
| endif | |
| endif | |
| endfor | |
| let s .= '\>' | |
| exe 'match Search /' . s . '/' | |
| endfunction | |
| nnoremap <leader>n :call NeonMatch(expand('<cword>'))<cr> | |
| nnoremap <leader>N :match<cr> | |
| finish | |
| s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 | |
| q0 q1 q2 q3 q4 | |
| d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 | |
| Anything that matches q<n> should also match d<2*n> and | |
| d<2*n+1>, and anything that matches d<n> should also | |
| match s<2*n> and s<2*n+1>, and anything that matches s<n> | |
| should also match d<n/2>, and anything that matches d<n> | |
| should match q<n/2> | |
| Phase two consideration not considered :p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment