mirror of
				https://git.davidovski.xyz/dot.git
				synced 2024-08-15 00:43:28 +00:00 
			
		
		
		
	initial commit
This commit is contained in:
		
						commit
						01ced0b7ce
					
				
					 184 changed files with 35358 additions and 0 deletions
				
			
		
							
								
								
									
										377
									
								
								config/vim/autoload/colorizer.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										377
									
								
								config/vim/autoload/colorizer.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,377 @@ | |||
| " colorizer.vim	Colorize all text in the form #rrggbb or #rgb; autoload functions | ||||
| " Maintainer:	lilydjwg <lilydjwg@gmail.com> | ||||
| " Version:	1.4.1 | ||||
| " License:	Vim License  (see vim's :help license) | ||||
| " | ||||
| " See plugin/colorizer.vim for more info. | ||||
| 
 | ||||
| let s:keepcpo = &cpo | ||||
| set cpo&vim | ||||
| 
 | ||||
| function! s:FGforBG(bg) "{{{1 | ||||
|   " takes a 6hex color code and returns a matching color that is visible | ||||
|   let pure = substitute(a:bg,'^#','','') | ||||
|   let r = eval('0x'.pure[0].pure[1]) | ||||
|   let g = eval('0x'.pure[2].pure[3]) | ||||
|   let b = eval('0x'.pure[4].pure[5]) | ||||
|   let fgc = g:colorizer_fgcontrast | ||||
|   if r*30 + g*59 + b*11 > 12000 | ||||
|     return s:predefined_fgcolors['dark'][fgc] | ||||
|   else | ||||
|     return s:predefined_fgcolors['light'][fgc] | ||||
|   end | ||||
| endfunction | ||||
| 
 | ||||
| function! s:Rgb2xterm(color) "{{{1 | ||||
|   " selects the nearest xterm color for a rgb value like #FF0000 | ||||
|   let best_match=0 | ||||
|   let smallest_distance = 10000000000 | ||||
|   let r = eval('0x'.a:color[1].a:color[2]) | ||||
|   let g = eval('0x'.a:color[3].a:color[4]) | ||||
|   let b = eval('0x'.a:color[5].a:color[6]) | ||||
|   let colortable = s:GetXterm2rgbTable() | ||||
|   for c in range(0,254) | ||||
|     let d = pow(colortable[c][0]-r,2) + pow(colortable[c][1]-g,2) + pow(colortable[c][2]-b,2) | ||||
|     if d<smallest_distance | ||||
|       let smallest_distance = d | ||||
|       let best_match = c | ||||
|     endif | ||||
|   endfor | ||||
|   return best_match | ||||
| endfunction | ||||
| 
 | ||||
| "" the 6 value iterations in the xterm color cube {{{1 | ||||
| let s:valuerange = [0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF] | ||||
| 
 | ||||
| "" 16 basic colors {{{1 | ||||
| let s:basic16 = [ | ||||
|       \ [0x00, 0x00, 0x00], [0xCD, 0x00, 0x00], | ||||
|       \ [0x00, 0xCD, 0x00], [0xCD, 0xCD, 0x00], | ||||
|       \ [0x00, 0x00, 0xEE], [0xCD, 0x00, 0xCD], | ||||
|       \ [0x00, 0xCD, 0xCD], [0xE5, 0xE5, 0xE5], | ||||
|       \ [0x7F, 0x7F, 0x7F], [0xFF, 0x00, 0x00], | ||||
|       \ [0x00, 0xFF, 0x00], [0xFF, 0xFF, 0x00], | ||||
|       \ [0x5C, 0x5C, 0xFF], [0xFF, 0x00, 0xFF], | ||||
|       \ [0x00, 0xFF, 0xFF], [0xFF, 0xFF, 0xFF]] | ||||
| 
 | ||||
| function! s:Xterm2rgb(color) "{{{1 | ||||
|   " 16 basic colors | ||||
|   let r = 0 | ||||
|   let g = 0 | ||||
|   let b = 0 | ||||
|   if a:color<16 | ||||
|     let r = s:basic16[a:color][0] | ||||
|     let g = s:basic16[a:color][1] | ||||
|     let b = s:basic16[a:color][2] | ||||
|   endif | ||||
| 
 | ||||
|   " color cube color | ||||
|   if a:color>=16 && a:color<=232 | ||||
|     let l:color=a:color-16 | ||||
|     let r = s:valuerange[(l:color/36)%6] | ||||
|     let g = s:valuerange[(l:color/6)%6] | ||||
|     let b = s:valuerange[l:color%6] | ||||
|   endif | ||||
| 
 | ||||
|   " gray tone | ||||
|   if a:color>=233 && a:color<=253 | ||||
|     let r=8+(a:color-232)*0x0a | ||||
|     let g=r | ||||
|     let b=r | ||||
|   endif | ||||
|   let rgb=[r,g,b] | ||||
|   return rgb | ||||
| endfunction | ||||
| 
 | ||||
| function! s:SetMatcher(color, pat) "{{{1 | ||||
|   " "color" is the converted color and "pat" is what to highlight | ||||
|   let group = 'Color' . strpart(a:color, 1) | ||||
|   if !hlexists(group) || s:force_group_update | ||||
|     let fg = g:colorizer_fgcontrast < 0 ? a:color : s:FGforBG(a:color) | ||||
|     if &t_Co == 256 | ||||
|       exe 'hi '.group.' ctermfg='.s:Rgb2xterm(fg).' ctermbg='.s:Rgb2xterm(a:color) | ||||
|     endif | ||||
|     " Always set gui* as user may switch to GUI version and it's cheap | ||||
|     exe 'hi '.group.' guifg='.fg.' guibg='.a:color | ||||
|   endif | ||||
|   if !exists("w:colormatches[a:pat]") | ||||
|     let w:colormatches[a:pat] = matchadd(group, a:pat) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| "ColorFinders {{{1 | ||||
| function! s:HexCode(str, lineno) "{{{2 | ||||
|   let ret = [] | ||||
|   let place = 0 | ||||
|   let colorpat = '#[0-9A-Fa-f]\{3\}\>\|#[0-9A-Fa-f]\{6\}\>' | ||||
|   while 1 | ||||
|     let foundcolor = matchstr(a:str, colorpat, place) | ||||
|     if foundcolor == '' | ||||
|       break | ||||
|     endif | ||||
|     let place = matchend(a:str, colorpat, place) | ||||
|     let pat = foundcolor . '\>' | ||||
|     if len(foundcolor) == 4 | ||||
|       let foundcolor = substitute(foundcolor, '[[:xdigit:]]', '&&', 'g') | ||||
|     endif | ||||
|     call add(ret, [foundcolor, pat]) | ||||
|   endwhile | ||||
|   return ret | ||||
| endfunction | ||||
| 
 | ||||
| function! s:RgbColor(str, lineno) "{{{2 | ||||
|   let ret = [] | ||||
|   let place = 0 | ||||
|   let colorpat = '\<rgb(\v\s*(\d+(\%)?)\s*,\s*(\d+%(\2))\s*,\s*(\d+%(\2))\s*\)' | ||||
|   while 1 | ||||
|     let foundcolor = matchlist(a:str, colorpat, place) | ||||
|     if empty(foundcolor) | ||||
|       break | ||||
|     endif | ||||
|     let place = matchend(a:str, colorpat, place) | ||||
|     if foundcolor[2] == '%' | ||||
|       let r = foundcolor[1] * 255 / 100 | ||||
|       let g = foundcolor[3] * 255 / 100 | ||||
|       let b = foundcolor[4] * 255 / 100 | ||||
|     else | ||||
|       let r = foundcolor[1] | ||||
|       let g = foundcolor[3] | ||||
|       let b = foundcolor[4] | ||||
|     endif | ||||
|     if r > 255 || g > 255 || b > 255 | ||||
|       break | ||||
|     endif | ||||
|     let pat = printf('\<rgb(\v\s*%s\s*,\s*%s\s*,\s*%s\s*\)', foundcolor[1], foundcolor[3], foundcolor[4]) | ||||
|     if foundcolor[2] == '%' | ||||
|       let pat = substitute(pat, '%', '\\%', 'g') | ||||
|     endif | ||||
|     let l:color = printf('#%02x%02x%02x', r, g, b) | ||||
|     call add(ret, [l:color, pat]) | ||||
|   endwhile | ||||
|   return ret | ||||
| endfunction | ||||
| 
 | ||||
| function! s:RgbaColor(str, lineno) "{{{2 | ||||
|   if has("gui_running") | ||||
|     let bg = synIDattr(synIDtrans(hlID("Normal")), "bg") | ||||
|     let bg_r = str2nr(bg[1].bg[2], 16) | ||||
|     let bg_g = str2nr(bg[3].bg[4], 16) | ||||
|     let bg_b = str2nr(bg[5].bg[6], 16) | ||||
|   else | ||||
|     " translucent colors would display incorrectly, so ignore the alpha value | ||||
|     return s:RgbaColorForTerm(a:str, a:lineno) | ||||
|   endif | ||||
|   let ret = [] | ||||
|   let place = 0 | ||||
|   let colorpat = '\<rgba(\v\s*(\d+(\%)?)\s*,\s*(\d+%(\2))\s*,\s*(\d+%(\2))\s*,\s*(-?[.[:digit:]]+)\s*\)' | ||||
|   while 1 | ||||
|     let foundcolor = matchlist(a:str, colorpat, place) | ||||
|     if empty(foundcolor) | ||||
|       break | ||||
|     endif | ||||
|     let place = matchend(a:str, colorpat, place) | ||||
|     if foundcolor[2] == '%' | ||||
|       let ar = foundcolor[1] * 255 / 100 | ||||
|       let ag = foundcolor[3] * 255 / 100 | ||||
|       let ab = foundcolor[4] * 255 / 100 | ||||
|     else | ||||
|       let ar = foundcolor[1] | ||||
|       let ag = foundcolor[3] | ||||
|       let ab = foundcolor[4] | ||||
|     endif | ||||
|     if ar > 255 || ag > 255 || ab > 255 | ||||
|       break | ||||
|     endif | ||||
|     let alpha = str2float(foundcolor[5]) | ||||
|     if alpha < 0 | ||||
|       let alpha = 0.0 | ||||
|     elseif alpha > 1 | ||||
|       let alpha = 1.0 | ||||
|     endif | ||||
|     let pat = printf('\<rgba(\v\s*%s\s*,\s*%s\s*,\s*%s\s*,\s*%s0*\s*\)', foundcolor[1], foundcolor[3], foundcolor[4], foundcolor[5]) | ||||
|     if foundcolor[2] == '%' | ||||
|       let pat = substitute(pat, '%', '\\%', 'g') | ||||
|     endif | ||||
|     let r = float2nr(ceil(ar * alpha) + ceil(bg_r * (1 - alpha))) | ||||
|     let g = float2nr(ceil(ag * alpha) + ceil(bg_g * (1 - alpha))) | ||||
|     let b = float2nr(ceil(ab * alpha) + ceil(bg_b * (1 - alpha))) | ||||
|     if r > 255 | ||||
|       let r = 255 | ||||
|     endif | ||||
|     if g > 255 | ||||
|       let g = 255 | ||||
|     endif | ||||
|     if b > 255 | ||||
|       let b = 255 | ||||
|     endif | ||||
|     let l:color = printf('#%02x%02x%02x', r, g, b) | ||||
|     call add(ret, [l:color, pat]) | ||||
|   endwhile | ||||
|   return ret | ||||
| endfunction | ||||
| 
 | ||||
| function! s:RgbaColorForTerm(str, lineno) "{{{2 | ||||
|   let ret = [] | ||||
|   let place = 0 | ||||
|   let colorpat = '\<rgba(\v\s*(\d+(\%)?)\s*,\s*(\d+%(\2))\s*,\s*(\d+%(\2))\s*,\s*(-?[.[:digit:]]+)\s*\)' | ||||
|   while 1 | ||||
|     let foundcolor = matchlist(a:str, colorpat, place) | ||||
|     if empty(foundcolor) | ||||
|       break | ||||
|     endif | ||||
|     let place = matchend(a:str, colorpat, place) | ||||
|     if foundcolor[2] == '%' | ||||
|       let ar = foundcolor[1] * 255 / 100 | ||||
|       let ag = foundcolor[3] * 255 / 100 | ||||
|       let ab = foundcolor[4] * 255 / 100 | ||||
|     else | ||||
|       let ar = foundcolor[1] | ||||
|       let ag = foundcolor[3] | ||||
|       let ab = foundcolor[4] | ||||
|     endif | ||||
|     if ar > 255 || ag > 255 || ab > 255 | ||||
|       break | ||||
|     endif | ||||
|     let pat = printf('\<rgba(\v\s*%s\s*,\s*%s\s*,\s*%s\s*,\ze\s*(-?[.[:digit:]]+)\s*\)', foundcolor[1], foundcolor[3], foundcolor[4]) | ||||
|     if foundcolor[2] == '%' | ||||
|       let pat = substitute(pat, '%', '\\%', 'g') | ||||
|     endif | ||||
|     let l:color = printf('#%02x%02x%02x', ar, ag, ab) | ||||
|     call add(ret, [l:color, pat]) | ||||
|   endwhile | ||||
|   return ret | ||||
| endfunction | ||||
| 
 | ||||
| function! s:PreviewColorInLine(where) "{{{1 | ||||
|   let line = getline(a:where) | ||||
|   for Func in s:ColorFinder | ||||
|     let ret = Func(line, a:where) | ||||
|     " returned a list of a list: color as #rrggbb, text pattern to highlight | ||||
|     for r in ret | ||||
|       call s:SetMatcher(r[0], r[1]) | ||||
|     endfor | ||||
|   endfor | ||||
| endfunction | ||||
| 
 | ||||
| function! s:CursorMoved() "{{{1 | ||||
|   if !exists('w:colormatches') | ||||
|     return | ||||
|   endif | ||||
|   if exists('b:colorizer_last_update') | ||||
|     if b:colorizer_last_update == b:changedtick | ||||
|       " Nothing changed | ||||
|       return | ||||
|     endif | ||||
|   endif | ||||
|   call s:PreviewColorInLine('.') | ||||
|   let b:colorizer_last_update = b:changedtick | ||||
| endfunction | ||||
| 
 | ||||
| function! s:TextChanged() "{{{1 | ||||
|   if !exists('w:colormatches') | ||||
|     return | ||||
|   endif | ||||
|   echomsg "TextChanged" | ||||
|   call s:PreviewColorInLine('.') | ||||
| endfunction | ||||
| 
 | ||||
| function! colorizer#ColorHighlight(update, ...) "{{{1 | ||||
|   if exists('w:colormatches') | ||||
|     if !a:update | ||||
|       return | ||||
|     endif | ||||
|     call s:ClearMatches() | ||||
|   endif | ||||
|   let w:colormatches = {} | ||||
|   if g:colorizer_fgcontrast != s:saved_fgcontrast || (exists("a:1") && a:1 == '!') | ||||
|     let s:force_group_update = 1 | ||||
|   endif | ||||
|   for i in range(1, line("$")) | ||||
|     call s:PreviewColorInLine(i) | ||||
|   endfor | ||||
|   let s:force_group_update = 0 | ||||
|   let s:saved_fgcontrast = g:colorizer_fgcontrast | ||||
|   augroup Colorizer | ||||
|     au! | ||||
|     if exists('##TextChanged') | ||||
|       autocmd TextChanged * silent call s:TextChanged() | ||||
|       if v:version > 704 || v:version == 704 && has('patch143') | ||||
|         autocmd TextChangedI * silent call s:TextChanged() | ||||
|       else | ||||
|         " TextChangedI does not work as expected | ||||
|         autocmd CursorMovedI * silent call s:CursorMoved() | ||||
|       endif | ||||
|     else | ||||
|       autocmd CursorMoved,CursorMovedI * silent call s:CursorMoved() | ||||
|     endif | ||||
|     " rgba handles differently, so need updating | ||||
|     autocmd GUIEnter * silent call colorizer#ColorHighlight(1) | ||||
|     autocmd BufRead * silent call colorizer#ColorHighlight(1) | ||||
|     autocmd WinEnter * silent call colorizer#ColorHighlight(1) | ||||
|     autocmd ColorScheme * let s:force_group_update=1 | silent call colorizer#ColorHighlight(1) | ||||
|   augroup END | ||||
| endfunction | ||||
| 
 | ||||
| function! colorizer#ColorClear() "{{{1 | ||||
|   augroup Colorizer | ||||
|     au! | ||||
|   augroup END | ||||
|   let save_tab = tabpagenr() | ||||
|   let save_win = winnr() | ||||
|   tabdo windo call s:ClearMatches() | ||||
|   exe 'tabn '.save_tab | ||||
|   exe save_win . 'wincmd w' | ||||
| endfunction | ||||
| 
 | ||||
| function! s:ClearMatches() "{{{1 | ||||
|   if !exists('w:colormatches') | ||||
|     return | ||||
|   endif | ||||
|   for i in values(w:colormatches) | ||||
|     call matchdelete(i) | ||||
|   endfor | ||||
|   unlet w:colormatches | ||||
| endfunction | ||||
| 
 | ||||
| function! colorizer#ColorToggle() "{{{1 | ||||
|   if exists('#Colorizer#BufRead') | ||||
|     call colorizer#ColorClear() | ||||
|     echomsg 'Disabled color code highlighting.' | ||||
|   else | ||||
|     call colorizer#ColorHighlight(0) | ||||
|     echomsg 'Enabled color code highlighting.' | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! s:GetXterm2rgbTable() | ||||
|   if !exists('s:table_xterm2rgb') | ||||
|     let s:table_xterm2rgb = [] | ||||
|     for c in range(0, 254) | ||||
|       let s:color = s:Xterm2rgb(c) | ||||
|       call add(s:table_xterm2rgb, s:color) | ||||
|     endfor | ||||
|   endif | ||||
|   return s:table_xterm2rgb | ||||
| endfun | ||||
| 
 | ||||
| " Setups {{{1 | ||||
| let s:ColorFinder = [function('s:HexCode'), function('s:RgbColor'), function('s:RgbaColor')] | ||||
| let s:force_group_update = 0 | ||||
| let s:predefined_fgcolors = {} | ||||
| let s:predefined_fgcolors['dark']  = ['#444444', '#222222', '#000000'] | ||||
| let s:predefined_fgcolors['light'] = ['#bbbbbb', '#dddddd', '#ffffff'] | ||||
| if !exists("g:colorizer_fgcontrast") | ||||
|   " Default to black / white | ||||
|   let g:colorizer_fgcontrast = len(s:predefined_fgcolors['dark']) - 1 | ||||
| elseif g:colorizer_fgcontrast >= len(s:predefined_fgcolors['dark']) | ||||
|   echohl WarningMsg | ||||
|   echo "g:colorizer_fgcontrast value invalid, using default" | ||||
|   echohl None | ||||
|   let g:colorizer_fgcontrast = len(s:predefined_fgcolors['dark']) - 1 | ||||
| endif | ||||
| let s:saved_fgcontrast = g:colorizer_fgcontrast | ||||
| 
 | ||||
| " Restoration and modelines {{{1 | ||||
| let &cpo = s:keepcpo | ||||
| unlet s:keepcpo | ||||
| " vim:ft=vim:fdm=marker:fmr={{{,}}}: | ||||
							
								
								
									
										2135
									
								
								config/vim/autoload/emmet.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2135
									
								
								config/vim/autoload/emmet.vim
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										52
									
								
								config/vim/autoload/emmet/lang.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								config/vim/autoload/emmet/lang.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,52 @@ | |||
| let s:exists = {} | ||||
| function! emmet#lang#exists(type) abort | ||||
|   if len(a:type) == 0 | ||||
|     return 0 | ||||
|   elseif has_key(s:exists, a:type) | ||||
|     return s:exists[a:type] | ||||
|   endif | ||||
|   let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0 | ||||
|   return s:exists[a:type] | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#type(type) abort | ||||
|   let type = a:type | ||||
|   let base = type | ||||
|   let settings = emmet#getSettings() | ||||
|   while base != '' | ||||
|     for b in split(base, '\.') | ||||
|       if emmet#lang#exists(b) | ||||
|         return b | ||||
|       endif | ||||
|       if has_key(settings, b) && has_key(settings[b], 'extends') | ||||
|         let base = settings[b].extends | ||||
|         break | ||||
|       else | ||||
|         let base = '' | ||||
|       endif | ||||
|     endfor | ||||
|   endwhile | ||||
|   return 'html' | ||||
| endfunction | ||||
| 
 | ||||
| " get all extends for a type recursively | ||||
| function! emmet#lang#getExtends(type) abort | ||||
|   let settings = emmet#getSettings() | ||||
| 
 | ||||
|   if !has_key(settings[a:type], 'extends') | ||||
|     return [] | ||||
|   endif | ||||
| 
 | ||||
|   let extends = settings[a:type].extends | ||||
|   if type(extends) ==# 1 | ||||
|     let tmp = split(extends, '\s*,\s*') | ||||
|     unlet! extends | ||||
|     let extends = tmp | ||||
|   endif | ||||
| 
 | ||||
|   for ext in extends | ||||
|     let extends = extends + emmet#lang#getExtends(ext) | ||||
|   endfor | ||||
| 
 | ||||
|   return extends | ||||
| endfunction | ||||
							
								
								
									
										385
									
								
								config/vim/autoload/emmet/lang/css.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										385
									
								
								config/vim/autoload/emmet/lang/css.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,385 @@ | |||
| function! emmet#lang#css#findTokens(str) abort | ||||
|   let tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '') | ||||
|   if tmp =~ '/' && tmp =~ '^[a-zA-Z0-9/_.]\+$' | ||||
|     " maybe path or something | ||||
|     return '' | ||||
|   endif | ||||
|   return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '') | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#parseIntoTree(abbr, type) abort | ||||
|   let abbr = a:abbr | ||||
|   let type = a:type | ||||
|   let prefix = 0 | ||||
|   let value = '' | ||||
| 
 | ||||
|   let indent = emmet#getIndentation(type) | ||||
|   let aliases = emmet#getResource(type, 'aliases', {}) | ||||
|   let snippets = emmet#getResource(type, 'snippets', {}) | ||||
|   let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1) | ||||
| 
 | ||||
|   let root = emmet#newNode() | ||||
| 
 | ||||
|   " emmet | ||||
|   let tokens = split(abbr, '+\ze[^+)!]') | ||||
|   let block = emmet#util#searchRegion('{', '}') | ||||
|   if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && type !=# 'styled' && block[0] ==# [0,0] && block[1] ==# [0,0] | ||||
|     let current = emmet#newNode() | ||||
|     let current.snippet = substitute(abbr, '\s\+$', '', '') . " {\n" . indent . "${cursor}\n}" | ||||
|     let current.name = '' | ||||
|     call add(root.child, deepcopy(current)) | ||||
|   else | ||||
|     for n in range(len(tokens)) | ||||
|       let token = tokens[n] | ||||
|       let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|x\|vh\|vw\|re\|rem\|%\)\{0,}-\{0,1}\|-auto\)*\)$') | ||||
|       if len(prop) | ||||
|         let token = substitute(prop[1], '^(\(.*\))', '\1', '') | ||||
|         if token =~# '^-' | ||||
|           let prefix = 1 | ||||
|           let token = token[1:] | ||||
|         endif | ||||
|         let value = '' | ||||
|         for vt in split(prop[2], '\a\+\zs') | ||||
|           let ut = matchstr(vt, '[a-z]\+$') | ||||
|           if ut == 'auto' | ||||
|             let ut = '' | ||||
|           endif | ||||
|           for v in split(vt, '\d\zs-') | ||||
|             if len(value) > 0 | ||||
|               let value .= ' ' | ||||
|             endif | ||||
|             if v !~ '[a-z]\+$' | ||||
|               let v .= ut | ||||
|             endif | ||||
|             if token =~# '^[z]' | ||||
|               " TODO | ||||
|               let value .= substitute(v, '[^0-9.]*$', '', '') | ||||
|             elseif v =~# 'em$' | ||||
|               let value .= v | ||||
|             elseif v =~# 'ex$' | ||||
|               let value .= v | ||||
|             elseif v =~# 'vh$' | ||||
|               let value .= v | ||||
|             elseif v =~# 'vw$' | ||||
|               let value .= v | ||||
|             elseif v =~# 'rem$' | ||||
|               let value .= v | ||||
|             elseif v ==# 'auto' | ||||
|               let value .= v | ||||
|             elseif v =~# 'p$' | ||||
|               let value .= substitute(v, 'p$', '%', '') | ||||
|             elseif v =~# '%$' | ||||
|               let value .= v | ||||
|             elseif v =~# 'e$' | ||||
|               let value .= substitute(v, 'e$', 'em', '') | ||||
|             elseif v =~# 'x$' | ||||
|               let value .= substitute(v, 'x$', 'ex', '') | ||||
|             elseif v =~# 're$' | ||||
|               let value .= substitute(v, 're$', 'rem', '') | ||||
|             elseif v =~# '\.' | ||||
|               let value .= v . 'em' | ||||
|             elseif v ==# '0' | ||||
|               let value .= '0' | ||||
|             else | ||||
|               let value .= v . 'px' | ||||
|             endif | ||||
|           endfor | ||||
|         endfor | ||||
|       endif | ||||
| 
 | ||||
|       let tag_name = token | ||||
|       if tag_name =~# '.!$' | ||||
|         let tag_name = tag_name[:-2] | ||||
|         let important = 1 | ||||
|       else | ||||
|         let important = 0 | ||||
|       endif | ||||
|       " make default node | ||||
|       let current = emmet#newNode() | ||||
|       let current.important = important | ||||
|       let current.name = tag_name | ||||
| 
 | ||||
|       " aliases | ||||
|       if has_key(aliases, tag_name) | ||||
|         let current.name = aliases[tag_name] | ||||
|       endif | ||||
| 
 | ||||
|       " snippets | ||||
|       if !empty(snippets) | ||||
|         let snippet_name = tag_name | ||||
|         if !has_key(snippets, snippet_name) | ||||
|           let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-\)') | ||||
|           let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') | ||||
|           if len(vv) == 0 | ||||
|             let vv = filter(sort(keys(snippets)), 'substitute(v:val, ":", "", "g") == snippet_name') | ||||
|           endif | ||||
|           if len(vv) > 0 | ||||
|             let snippet_name = vv[0] | ||||
|           else | ||||
|             let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-*\)') | ||||
|             let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') | ||||
|             if len(vv) == 0 | ||||
|               let pat = '^' . join(split(tag_name, '\zs'), '[^:]\{-}') | ||||
|               let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') | ||||
|               if len(vv) == 0 | ||||
|                 let pat = '^' . join(split(tag_name, '\zs'), '.\{-}') | ||||
|                 let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat') | ||||
|               endif | ||||
|             endif | ||||
|             let minl = -1 | ||||
|             for vk in vv | ||||
|               let vvs = snippets[vk] | ||||
|               if minl == -1 || len(vvs) < minl | ||||
|                 let snippet_name = vk | ||||
|                 let minl = len(vvs) | ||||
|               endif | ||||
|             endfor | ||||
|           endif | ||||
|         endif | ||||
|         if has_key(snippets, snippet_name) | ||||
|           let snippet = snippets[snippet_name] | ||||
|           if use_pipe_for_cursor | ||||
|             let snippet = substitute(snippet, '|', '${cursor}', 'g') | ||||
|           endif | ||||
|           let lines = split(snippet, "\n") | ||||
|           call map(lines, 'substitute(v:val, "\\(    \\|\\t\\)", escape(indent, "\\\\"), "g")') | ||||
|           let current.snippet = join(lines, "\n") | ||||
|           let current.name = '' | ||||
|           let current.snippet = substitute(current.snippet, ';', value . ';', '') | ||||
|           if use_pipe_for_cursor && len(value) > 0 | ||||
|             let current.snippet = substitute(current.snippet, '\${cursor}', '', 'g') | ||||
|           endif | ||||
|           if n < len(tokens) - 1 | ||||
|             let current.snippet .= "\n" | ||||
|           endif | ||||
|         endif | ||||
|       endif | ||||
| 
 | ||||
|       let current.pos = 0 | ||||
|       let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$') | ||||
|       if len(lg) == 0 | ||||
|         let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$') | ||||
|         if len(lg) | ||||
|           let [lg[1], lg[2], lg[3]] = ['linear', lg[1], lg[2]] | ||||
|         endif | ||||
|       endif | ||||
|       if len(lg) | ||||
|         let current.name = '' | ||||
|         let current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3]) | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", lg[2], lg[3]) | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", lg[2], lg[3]) | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", lg[2], lg[3]) | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = printf("background-image:linear-gradient(%s, %s);\n", lg[2], lg[3]) | ||||
|         call add(root.child, deepcopy(current)) | ||||
|       elseif prefix | ||||
|         let snippet = current.snippet | ||||
|         let current.snippet = '-webkit-' . snippet . "\n" | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = '-moz-' . snippet . "\n" | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = '-o-' . snippet . "\n" | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = '-ms-' . snippet . "\n" | ||||
|         call add(root.child, deepcopy(current)) | ||||
|         let current.snippet = snippet | ||||
|         call add(root.child, current) | ||||
|       elseif token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?' | ||||
|         let cs = split(token, '\.') | ||||
|         let current.name = '' | ||||
|         let [r,g,b] = [0,0,0] | ||||
|         if len(cs[0]) == 5 | ||||
|           let rgb = matchlist(cs[0], 'c#\(.\)\(.\)\(.\)') | ||||
|           let r = eval('0x'.rgb[1].rgb[1]) | ||||
|           let g = eval('0x'.rgb[2].rgb[2]) | ||||
|           let b = eval('0x'.rgb[3].rgb[3]) | ||||
|         elseif len(cs[0]) == 8 | ||||
|           let rgb = matchlist(cs[0], 'c#\(..\)\(..\)\(..\)') | ||||
|           let r = eval('0x'.rgb[1]) | ||||
|           let g = eval('0x'.rgb[2]) | ||||
|           let b = eval('0x'.rgb[3]) | ||||
|         endif | ||||
|         if len(cs) == 1 | ||||
|           let current.snippet = printf('color:rgb(%d, %d, %d);', r, g, b) | ||||
|         else | ||||
|           let current.snippet = printf('color:rgb(%d, %d, %d, %s);', r, g, b, string(str2float('0.'.cs[1]))) | ||||
|         endif | ||||
|         call add(root.child, current) | ||||
|       elseif token =~# '^c#' | ||||
|         let current.name = '' | ||||
|         let current.snippet = 'color:\${cursor};' | ||||
|         call add(root.child, current) | ||||
|       else | ||||
|         call add(root.child, current) | ||||
|       endif | ||||
|     endfor | ||||
|   endif | ||||
|   return root | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let current = a:current | ||||
|   let value = current.value[1:-2] | ||||
|   let tmp = substitute(value, '\${cursor}', '', 'g') | ||||
|   if tmp !~ '.*{[ \t\r\n]*}$' | ||||
|     if emmet#useFilter(a:filters, 'fc') | ||||
|       let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g') | ||||
|     else | ||||
|       let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g') | ||||
|     endif | ||||
|     if current.important | ||||
|       let value = substitute(value, ';', ' !important;', '') | ||||
|     endif | ||||
|   endif | ||||
|   return value | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#imageSize() abort | ||||
|   let img_region = emmet#util#searchRegion('{', '}') | ||||
|   if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) | ||||
|     return | ||||
|   endif | ||||
|   let content = emmet#util#getContent(img_region) | ||||
|   let fn = matchstr(content, '\<url(\zs[^)]\+\ze)') | ||||
|   let fn = substitute(fn, '[''" \t]', '', 'g') | ||||
|   if fn =~# '^\s*$' | ||||
|     return | ||||
|   elseif fn !~# '^\(/\|http\)' | ||||
|     let fn = simplify(expand('%:h') . '/' . fn) | ||||
|   endif | ||||
|   let [width, height] = emmet#util#getImageSize(fn) | ||||
|   if width == -1 && height == -1 | ||||
|     return | ||||
|   endif | ||||
|   let indent = emmet#getIndentation('css') | ||||
|   if content =~# '.*\<width\s*:[^;]*;.*' | ||||
|     let content = substitute(content, '\<width\s*:[^;]*;', 'width: ' . width . 'px;', '') | ||||
|   else | ||||
|     let content = substitute(content, '}', indent . 'width: ' . width . "px;\n}", '') | ||||
|   endif | ||||
|   if content =~# '.*\<height\s*:[^;]*;.*' | ||||
|     let content = substitute(content, '\<height\s*:[^;]*;', 'height: ' . height . 'px;', '') | ||||
|   else | ||||
|     let content = substitute(content, '}', indent . 'height: ' . height . "px;\n}", '') | ||||
|   endif | ||||
|   call emmet#util#setContent(img_region, content) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#imageEncode() abort | ||||
|   let img_region = emmet#util#searchRegion('url(', ')') | ||||
|   if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region) | ||||
|     return | ||||
|   endif | ||||
|   let content = emmet#util#getContent(img_region) | ||||
|   let fn = matchstr(content, '\<url(\zs[^)]\+\ze)') | ||||
|   let fn = substitute(fn, '[''" \t]', '', 'g') | ||||
|   if fn =~# '^\s*$' | ||||
|     return | ||||
|   elseif fn !~# '^\(/\|http\)' | ||||
|     let fn = simplify(expand('%:h') . '/' . fn) | ||||
|   endif | ||||
|   let encoded = emmet#util#imageEncodeDecode(fn, 0) | ||||
|   call emmet#util#setContent(img_region, 'url(' . encoded . ')') | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#parseTag(tag) abort | ||||
|   return {} | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#toggleComment() abort | ||||
|   let line = getline('.') | ||||
|   let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$' | ||||
|   if line =~# '{\s*$' | ||||
|     let block = emmet#util#searchRegion('/\*', '\*/\zs') | ||||
|     if emmet#util#regionIsValid(block) | ||||
|       let content = emmet#util#getContent(block) | ||||
|       let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '') | ||||
|       call emmet#util#setContent(block, content) | ||||
|     else | ||||
|       let node = expand('<cword>') | ||||
|       if len(node) | ||||
|         exe "normal ciw\<c-r>='/* '.node.' */'\<cr>" | ||||
|       endif | ||||
|     endif | ||||
|   else | ||||
|     if line =~# mx | ||||
|       let space = substitute(matchstr(line, mx), mx, '\1', '') | ||||
|       let line = substitute(matchstr(line, mx), mx, '\2', '') | ||||
|       let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g') | ||||
|     else | ||||
|       let mx = '^\(\s*\)\(''[^'']*''\|[^'']*\|;\)\s*$' | ||||
|       " TODO multi-property | ||||
|       "let mx = '^\(\s*\)\(\%(''[^'']*''\|[^'';]\+\)*;\{0,1}\)' | ||||
|       let line = substitute(line, mx, '\1/* \2 */', '') | ||||
|     endif | ||||
|     call setline('.', line) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#balanceTag(flag) range abort | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     let curpos = [0, line("'<"), col("'<"), 0] | ||||
|   else | ||||
|     let curpos = emmet#util#getcurpos() | ||||
|   endif | ||||
|   let block = emmet#util#getVisualBlock() | ||||
|   if !emmet#util#regionIsValid(block) | ||||
|     if a:flag > 0 | ||||
|       let block = emmet#util#searchRegion('^', ';') | ||||
|       if emmet#util#regionIsValid(block) | ||||
|         call emmet#util#selectRegion(block) | ||||
|         return | ||||
|       endif | ||||
|     endif | ||||
|   else | ||||
|     if a:flag > 0 | ||||
|       let content = emmet#util#getContent(block) | ||||
|       if content !~# '^{.*}$' | ||||
|         let block = emmet#util#searchRegion('{', '}') | ||||
|         if emmet#util#regionIsValid(block) | ||||
|           call emmet#util#selectRegion(block) | ||||
|           return | ||||
|         endif | ||||
|       endif | ||||
|     else | ||||
|       let pos = searchpos('.*;', 'nW') | ||||
|       if pos[0] != 0 | ||||
|         call setpos('.', [0, pos[0], pos[1], 0]) | ||||
|         let block = emmet#util#searchRegion('^', ';') | ||||
|         if emmet#util#regionIsValid(block) | ||||
|           call emmet#util#selectRegion(block) | ||||
|           return | ||||
|         endif | ||||
|       endif | ||||
|     endif | ||||
|   endif | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     silent! exe 'normal! gv' | ||||
|   else | ||||
|     call setpos('.', curpos) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#css#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#moveNextPrev(flag) abort | ||||
|   call search('""\|()\|\(:\s*\zs;\{1,0}$\)', a:flag ? 'Wbp' : 'Wp') | ||||
|   return '' | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#splitJoinTag() abort | ||||
|   " nothing to do | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#removeTag() abort | ||||
|   " nothing to do | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#css#mergeLines() abort | ||||
|   " nothing to do | ||||
| endfunction | ||||
							
								
								
									
										241
									
								
								config/vim/autoload/emmet/lang/elm.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										241
									
								
								config/vim/autoload/emmet/lang/elm.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,241 @@ | |||
| function! emmet#lang#elm#findTokens(str) abort | ||||
|   return emmet#lang#html#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#parseIntoTree(abbr, type) abort | ||||
|   let tree = emmet#lang#html#parseIntoTree(a:abbr, a:type) | ||||
|   if len(tree.child) < 2 | return tree | endif | ||||
| 
 | ||||
|   " Add ',' nodes between root elements. | ||||
|   let new_children = [] | ||||
|   for child in tree.child[0:-2] | ||||
|     let comma = emmet#newNode() | ||||
|     let comma.name = ',' | ||||
|     call add(new_children, child) | ||||
|     call add(new_children, comma) | ||||
|   endfor | ||||
|   call add(new_children, tree.child[-1]) | ||||
|   let tree.child = new_children | ||||
|   return tree | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#renderNode(node) | ||||
|   let elm_nodes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6' | ||||
|         \, 'div', 'p', 'hr', 'pre', 'blockquote' | ||||
|         \, 'span', 'a', 'code', 'em', 'strong', 'i', 'b', 'u', 'sub', 'sup', 'br' | ||||
|         \, 'ol', 'ul', 'li', 'dl', 'dt', 'dd' | ||||
|         \, 'img', 'iframe', 'canvas', 'math' | ||||
|         \, 'form', 'input', 'textarea', 'button', 'select', 'option' | ||||
|         \, 'section', 'nav', 'article', 'aside', 'header', 'footer', 'address', 'main_', 'body' | ||||
|         \, 'figure', 'figcaption' | ||||
|         \, 'table', 'caption', 'colgroup', 'col', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th' | ||||
|         \, 'fieldset', 'legend', 'label', 'datalist', 'optgroup', 'keygen', 'output', 'progress', 'meter' | ||||
|         \, 'audio', 'video', 'source', 'track' | ||||
|         \, 'embed', 'object', 'param' | ||||
|         \, 'ins', 'del' | ||||
|         \, 'small', 'cite', 'dfn', 'abbr', 'time', 'var', 'samp', 'kbd', 's', 'q' | ||||
|         \, 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'wbr' | ||||
|         \, 'details', 'summary', 'menuitem', 'menu'] | ||||
| 
 | ||||
|   if index(elm_nodes, a:node) >= 0 | ||||
|     return a:node | ||||
|   endif | ||||
|   return 'node "' . a:node . '"' | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#renderParam(param) | ||||
|   let elm_events = ["onClick", "onDoubleClick" | ||||
|         \, "onMouseDown", "onMouseUp" | ||||
|         \, "onMouseEnter", "onMouseLeave" | ||||
|         \, "onMouseOver", "onMouseOut" | ||||
|         \, "onInput", "onCheck", "onSubmit" | ||||
|         \, "onBlur", "onFocus" | ||||
|         \, "on", "onWithOptions", "Options", "defaultOptions" | ||||
|         \, "targetValue", "targetChecked", "keyCode"] | ||||
|   if index(elm_events, a:param) >= 0 | ||||
|     return a:param | ||||
|   endif | ||||
|   let elm_attributes = ["style", "map" , "class", "id", "title", "hidden" | ||||
|         \, "type", "type_", "value", "defaultValue", "checked", "placeholder", "selected" | ||||
|         \, "accept", "acceptCharset", "action", "autocomplete", "autofocus" | ||||
|         \, "disabled", "enctype", "formaction", "list", "maxlength", "minlength", "method", "multiple" | ||||
|         \, "name", "novalidate", "pattern", "readonly", "required", "size", "for", "form" | ||||
|         \, "max", "min", "step" | ||||
|         \, "cols", "rows", "wrap" | ||||
|         \, "href", "target", "download", "downloadAs", "hreflang", "media", "ping", "rel" | ||||
|         \, "ismap", "usemap", "shape", "coords" | ||||
|         \, "src", "height", "width", "alt" | ||||
|         \, "autoplay", "controls", "loop", "preload", "poster", "default", "kind", "srclang" | ||||
|         \, "sandbox", "seamless", "srcdoc" | ||||
|         \, "reversed", "start" | ||||
|         \, "align", "colspan", "rowspan", "headers", "scope" | ||||
|         \, "async", "charset", "content", "defer", "httpEquiv", "language", "scoped" | ||||
|         \, "accesskey", "contenteditable", "contextmenu", "dir", "draggable", "dropzone" | ||||
|         \, "itemprop", "lang", "spellcheck", "tabindex" | ||||
|         \, "challenge", "keytype" | ||||
|         \, "cite", "datetime", "pubdate", "manifest"] | ||||
| 
 | ||||
|   if index(elm_attributes, a:param) >= 0 | ||||
|     if a:param == 'type' | ||||
|       return 'type_' | ||||
|     endif | ||||
|     return a:param | ||||
|   endif | ||||
|   return 'attribute "' . a:param . '"' | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let settings = a:settings | ||||
|   let current = a:current | ||||
|   let type = a:type | ||||
|   let inline = a:inline | ||||
|   let filters = a:filters | ||||
|   let itemno = a:itemno | ||||
|   let indent = emmet#getIndentation(type) | ||||
|   let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) | ||||
|   let str = '' | ||||
| 
 | ||||
|   " comma between items with *, eg. li*3 | ||||
|   if itemno > 0 | ||||
|     let str = ", " | ||||
|   endif | ||||
| 
 | ||||
|   let current_name = current.name | ||||
|   if dollar_expr | ||||
|     let current_name = substitute(current.name, '\$$', itemno+1, '') | ||||
|   endif | ||||
| 
 | ||||
|   if len(current.name) > 0 | ||||
|     " inserted root comma nodes | ||||
|     if current_name == ',' | ||||
|       return "\n, " | ||||
|     endif | ||||
|     let str .= emmet#lang#elm#renderNode(current_name) | ||||
|     let tmp = '' | ||||
|     for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) | ||||
|       if !has_key(current.attr, attr) | ||||
|         continue | ||||
|       endif | ||||
|       let Val = current.attr[attr] | ||||
| 
 | ||||
|       let attr = emmet#lang#elm#renderParam(attr) | ||||
| 
 | ||||
|       if type(Val) == 2 && Val == function('emmet#types#true') | ||||
|         let tmp .= ', ' . attr . ' True' | ||||
|       else | ||||
|         if dollar_expr | ||||
|           while Val =~# '\$\([^#{]\|$\)' | ||||
|             let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|           endwhile | ||||
|           let attr = substitute(attr, '\$$', itemno+1, '') | ||||
|         endif | ||||
|         let valtmp = substitute(Val, '\${cursor}', '', '') | ||||
|         if attr ==# 'id' && len(valtmp) > 0 | ||||
|           let tmp .=', id "' . Val . '"' | ||||
|         elseif attr ==# 'class' && len(valtmp) > 0 | ||||
|           let tmp .= ', class "' . substitute(Val, '\.', ' ', 'g') . '"' | ||||
|         else | ||||
|           let tmp .= ', ' . attr . ' "' . Val . '"' | ||||
|         endif | ||||
|       endif | ||||
|     endfor | ||||
| 
 | ||||
|     if ! len(tmp) | ||||
|       let str .= ' []' | ||||
|     else | ||||
|       let tmp = strpart(tmp, 2) | ||||
|       let str .= ' [ ' . tmp . ' ]' | ||||
|     endif | ||||
| 
 | ||||
|     " No children quit early | ||||
|     if len(current.child) == 0 && len(current.value) == 0 | ||||
|       "Place cursor in node with no value or children | ||||
|       let str .= ' [${cursor}]' | ||||
|       return str | ||||
|     endif | ||||
| 
 | ||||
|     let inner = '' | ||||
| 
 | ||||
|     " Parent contex text | ||||
|     if len(current.value) > 0 | ||||
|       let text = current.value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|         " let str = substitute(str, '\$#', text, 'g') | ||||
|         let inner .= ', text "' . text . '"' | ||||
|       endif | ||||
|     endif | ||||
| 
 | ||||
| 
 | ||||
|     " Has children | ||||
|     for child in current.child | ||||
|       if len(child.name) == 0 && len(child.value) > 0 | ||||
|         "  Text node | ||||
|         let text = child.value[1:-2] | ||||
|         if dollar_expr | ||||
|           let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|           let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|           let text = substitute(text, '\\\$', '$', 'g') | ||||
|         endif | ||||
|         let inner .= ', text "' . text . '"' | ||||
|       else | ||||
|         " Other nodes | ||||
|         let inner .= ', ' . emmet#toString(child, type, inline, filters, 0, indent) | ||||
|       endif | ||||
|     endfor | ||||
| 
 | ||||
|     let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') | ||||
|     let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') | ||||
|     let inner = strpart(inner, 2) | ||||
| 
 | ||||
|     let inner = substitute(inner, '  ', '', 'g') | ||||
| 
 | ||||
|     if ! len(inner) | ||||
|       let str .= ' []' | ||||
|     else | ||||
|       let str .= ' [ ' . inner . ' ]' | ||||
|     endif | ||||
| 
 | ||||
|   else | ||||
|     let str = current.value[1:-2] | ||||
|     if dollar_expr | ||||
|       let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|       let str = substitute(str, '\${nr}', "\n", 'g') | ||||
|       let str = substitute(str, '\\\$', '$', 'g') | ||||
|     endif | ||||
|   endif | ||||
| 
 | ||||
|   let str .= "\n" | ||||
|   return str | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#imageEncode() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#parseTag(tag) abort | ||||
|   return {} | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#toggleComment() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#balanceTag(flag) range abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#elm#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#moveNextPrev(flag) abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#splitJoinTag() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#removeTag() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#elm#mergeLines() abort | ||||
| endfunction | ||||
							
								
								
									
										337
									
								
								config/vim/autoload/emmet/lang/haml.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										337
									
								
								config/vim/autoload/emmet/lang/haml.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,337 @@ | |||
| function! emmet#lang#haml#findTokens(str) abort | ||||
|   return emmet#lang#html#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#parseIntoTree(abbr, type) abort | ||||
|   return emmet#lang#html#parseIntoTree(a:abbr, a:type) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let settings = a:settings | ||||
|   let current = a:current | ||||
|   let type = a:type | ||||
|   let inline = a:inline | ||||
|   let filters = a:filters | ||||
|   let itemno = a:itemno | ||||
|   let indent = emmet#getIndentation(type) | ||||
|   let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) | ||||
|   let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash') | ||||
|   let str = '' | ||||
| 
 | ||||
|   let current_name = current.name | ||||
|   if dollar_expr | ||||
|     let current_name = substitute(current.name, '\$$', itemno+1, '') | ||||
|   endif | ||||
|   if len(current.name) > 0 | ||||
|     let str .= '%' . current_name | ||||
|     let tmp = '' | ||||
|     for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) | ||||
|       if !has_key(current.attr, attr) | ||||
|         continue | ||||
|       endif | ||||
|       let Val = current.attr[attr] | ||||
|       if type(Val) == 2 && Val == function('emmet#types#true') | ||||
|         if attribute_style ==# 'hash' | ||||
|           let tmp .= ' :' . attr . ' => true' | ||||
|         elseif attribute_style ==# 'html' | ||||
|           let tmp .= attr . '=true' | ||||
|         end | ||||
|       else | ||||
|         if dollar_expr | ||||
|           while Val =~# '\$\([^#{]\|$\)' | ||||
|             let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|           endwhile | ||||
|           let attr = substitute(attr, '\$$', itemno+1, '') | ||||
|         endif | ||||
|         let valtmp = substitute(Val, '\${cursor}', '', '') | ||||
|         if attr ==# 'id' && len(valtmp) > 0 | ||||
|           let str .= '#' . Val | ||||
|         elseif attr ==# 'class' && len(valtmp) > 0 | ||||
|           let str .= '.' . substitute(Val, ' ', '.', 'g') | ||||
|         else | ||||
|           if len(tmp) > 0  | ||||
|             if attribute_style ==# 'hash' | ||||
|               let tmp .= ','  | ||||
|             elseif attribute_style ==# 'html' | ||||
|               let tmp .= ' '  | ||||
|             endif | ||||
|           endif | ||||
|           if attribute_style ==# 'hash' | ||||
|             let tmp .= ' :' . attr . ' => "' . Val . '"' | ||||
|           elseif attribute_style ==# 'html' | ||||
|             let tmp .= attr . '="' . Val . '"' | ||||
|           end | ||||
|         endif | ||||
|       endif | ||||
|     endfor | ||||
|     if len(tmp) | ||||
|       if attribute_style ==# 'hash' | ||||
|         let str .= '{' . tmp . ' }' | ||||
|       elseif attribute_style ==# 'html' | ||||
|         let str .= '(' . tmp . ')' | ||||
|       end | ||||
|     endif | ||||
|     if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0 | ||||
|       let str .= '/' | ||||
|     endif | ||||
| 
 | ||||
|     let inner = '' | ||||
|     if len(current.value) > 0 | ||||
|       let text = current.value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|         let str = substitute(str, '\$#', text, 'g') | ||||
|       endif | ||||
|       let lines = split(text, "\n") | ||||
|       if len(lines) == 1 | ||||
|         let str .= ' ' . text | ||||
|       else | ||||
|         for line in lines | ||||
|           let str .= "\n" . indent . line . ' |' | ||||
|         endfor | ||||
|       endif | ||||
|     elseif len(current.child) == 0 | ||||
|       let str .= '${cursor}' | ||||
|     endif | ||||
|     if len(current.child) == 1 && len(current.child[0].name) == 0 | ||||
|       let text = current.child[0].value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|       endif | ||||
|       let lines = split(text, "\n") | ||||
|       if len(lines) == 1 | ||||
|         let str .= ' ' . text | ||||
|       else | ||||
|         for line in lines | ||||
|           let str .= "\n" . indent . line . ' |' | ||||
|         endfor | ||||
|       endif | ||||
|     elseif len(current.child) > 0 | ||||
|       for child in current.child | ||||
|         let inner .= emmet#toString(child, type, inline, filters, itemno, indent) | ||||
|       endfor | ||||
|       let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') | ||||
|       let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') | ||||
|       let str .= "\n" . indent . inner | ||||
|     endif | ||||
|   else | ||||
|     let str = current.value[1:-2] | ||||
|     if dollar_expr | ||||
|       let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|       let str = substitute(str, '\${nr}', "\n", 'g') | ||||
|       let str = substitute(str, '\\\$', '$', 'g') | ||||
|     endif | ||||
|   endif | ||||
|   let str .= "\n" | ||||
|   return str | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#imageSize() abort | ||||
|   let line = getline('.') | ||||
|   let current = emmet#lang#haml#parseTag(line) | ||||
|   if empty(current) || !has_key(current.attr, 'src') | ||||
|     return | ||||
|   endif | ||||
|   let fn = current.attr.src | ||||
|   if fn =~# '^\s*$' | ||||
|     return | ||||
|   elseif fn !~# '^\(/\|http\)' | ||||
|     let fn = simplify(expand('%:h') . '/' . fn) | ||||
|   endif | ||||
| 
 | ||||
|   let [width, height] = emmet#util#getImageSize(fn) | ||||
|   if width == -1 && height == -1 | ||||
|     return | ||||
|   endif | ||||
|   let current.attr.width = width | ||||
|   let current.attr.height = height | ||||
|   let current.attrs_order += ['width', 'height'] | ||||
|   let haml = emmet#toString(current, 'haml', 1) | ||||
|   let haml = substitute(haml, '\${cursor}', '', '') | ||||
|   call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", '', 'g')) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#imageEncode() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#parseTag(tag) abort | ||||
|   let current = emmet#newNode() | ||||
|   let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)' | ||||
|   let match = matchstr(a:tag, mx) | ||||
|   let current.name = substitute(match, mx, '\1', '') | ||||
|   let attrs = substitute(match, mx, '\2', '') | ||||
|   let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)' | ||||
|   while len(attrs) > 0 | ||||
|     let match = matchstr(attrs, mx) | ||||
|     if len(match) ==# 0 | ||||
|       break | ||||
|     endif | ||||
|     let attr_match = matchlist(match, mx) | ||||
|     let name = attr_match[1] | ||||
|     let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] | ||||
|     let current.attr[name] = value | ||||
|     let current.attrs_order += [name] | ||||
|     let attrs = attrs[stridx(attrs, match) + len(match):] | ||||
|   endwhile | ||||
|   return current | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#toggleComment() abort | ||||
|   let line = getline('.') | ||||
|   let space = matchstr(line, '^\s*') | ||||
|   if line =~# '^\s*-#' | ||||
|     call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*')) | ||||
|   elseif line =~# '^\s*%[a-z]' | ||||
|     call setline('.', space . '-# ' . line[len(space):]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#balanceTag(flag) range abort | ||||
|   let block = emmet#util#getVisualBlock() | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     let curpos = [0, line("'<"), col("'<"), 0] | ||||
|   else | ||||
|     let curpos = emmet#util#getcurpos() | ||||
|   endif | ||||
|   let n = curpos[1] | ||||
|   let ml = len(matchstr(getline(n), '^\s*')) | ||||
| 
 | ||||
|   if a:flag > 0 | ||||
|     if a:flag == 1 || !emmet#util#regionIsValid(block) | ||||
|       let n = line('.') | ||||
|     else | ||||
|       while n > 0 | ||||
|         let l = len(matchstr(getline(n), '^\s*\ze%[a-z]')) | ||||
|         if l > 0 && l < ml | ||||
|           let ml = l | ||||
|           break | ||||
|         endif | ||||
|         let n -= 1 | ||||
|       endwhile | ||||
|     endif | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   else | ||||
|     while n > 0 | ||||
|       let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) | ||||
|       if l > 0 && l > ml | ||||
|         let ml = l | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#haml#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#moveNextPrev(flag) abort | ||||
|   let pos = search('""', a:flag ? 'Wb' : 'W') | ||||
|   if pos != 0 | ||||
|     silent! normal! l | ||||
|     startinsert | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#splitJoinTag() abort | ||||
|   let n = line('.') | ||||
|   let sml = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|   while n > 0 | ||||
|     if getline(n) =~# '^\s*\ze%[a-z]' | ||||
|       if len(matchstr(getline(n), '^\s*%[a-z]')) < sml | ||||
|         break | ||||
|       endif | ||||
|       let line = getline(n) | ||||
|       call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', '')) | ||||
|       let sn = n | ||||
|       let n += 1 | ||||
|       let ml = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       if len(matchstr(getline(n), '^\s*')) > ml | ||||
|         while n <= line('$') | ||||
|           let l = len(matchstr(getline(n), '^\s*')) | ||||
|           if l <= ml | ||||
|             break | ||||
|           endif | ||||
|           exe n 'delete' | ||||
|         endwhile | ||||
|         call setpos('.', [0, sn, 1, 0]) | ||||
|       else | ||||
|         let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)') | ||||
|         let spaces = matchstr(getline(sn), '^\s*') | ||||
|         let settings = emmet#getSettings() | ||||
|         if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1 | ||||
|           call append(sn, spaces . '   ') | ||||
|           call setpos('.', [0, sn+1, 1, 0]) | ||||
|         else | ||||
|           call setpos('.', [0, sn, 1, 0]) | ||||
|         endif | ||||
|         startinsert! | ||||
|       endif | ||||
|       break | ||||
|     endif | ||||
|     let n -= 1 | ||||
|   endwhile | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#removeTag() abort | ||||
|   let n = line('.') | ||||
|   let ml = 0 | ||||
|   while n > 0 | ||||
|     if getline(n) =~# '^\s*\ze[a-z]' | ||||
|       let ml = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       break | ||||
|     endif | ||||
|     let n -= 1 | ||||
|   endwhile | ||||
|   let sn = n | ||||
|   while n < line('$') | ||||
|     let l = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|     if l > 0 && l <= ml | ||||
|       let n -= 1 | ||||
|       break | ||||
|     endif | ||||
|     let n += 1 | ||||
|   endwhile | ||||
|   if sn == n | ||||
|     exe 'delete' | ||||
|   else | ||||
|     exe sn ',' (n-1) 'delete' | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#haml#mergeLines() abort | ||||
| endfunction | ||||
							
								
								
									
										1036
									
								
								config/vim/autoload/emmet/lang/html.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1036
									
								
								config/vim/autoload/emmet/lang/html.vim
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										335
									
								
								config/vim/autoload/emmet/lang/jade.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										335
									
								
								config/vim/autoload/emmet/lang/jade.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,335 @@ | |||
| function! emmet#lang#jade#findTokens(str) abort | ||||
|   return emmet#lang#html#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#parseIntoTree(abbr, type) abort | ||||
|   return emmet#lang#html#parseIntoTree(a:abbr, a:type) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let settings = a:settings | ||||
|   let current = a:current | ||||
|   let type = a:type | ||||
|   let inline = a:inline | ||||
|   let filters = a:filters | ||||
|   let itemno = a:itemno | ||||
|   let indent = emmet#getIndentation(type) | ||||
|   let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) | ||||
|   let attribute_style = emmet#getResource('jade', 'attribute_style', 'hash') | ||||
|   let str = '' | ||||
| 
 | ||||
|   let current_name = current.name | ||||
|   if dollar_expr | ||||
|     let current_name = substitute(current.name, '\$$', itemno+1, '') | ||||
|   endif | ||||
|   if len(current.name) > 0 | ||||
|     let str .= '' . current_name | ||||
|     let tmp = '' | ||||
|     for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) | ||||
|       if !has_key(current.attr, attr) | ||||
|         continue | ||||
|       endif | ||||
|       let Val = current.attr[attr] | ||||
|       if type(Val) == 2 && Val == function('emmet#types#true') | ||||
|         if attribute_style ==# 'hash' | ||||
|           let tmp .= ' ' . attr . ' = true' | ||||
|         elseif attribute_style ==# 'html' | ||||
|           let tmp .= attr . '=true' | ||||
|         end | ||||
|       else | ||||
|         if dollar_expr | ||||
|           while Val =~# '\$\([^#{]\|$\)' | ||||
|             let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|           endwhile | ||||
|           let attr = substitute(attr, '\$$', itemno+1, '') | ||||
|         endif | ||||
|         let valtmp = substitute(Val, '\${cursor}', '', '') | ||||
|         if attr ==# 'id' && len(valtmp) > 0 | ||||
|           let str .= '#' . Val | ||||
|         elseif attr ==# 'class' && len(valtmp) > 0 | ||||
|           let str .= '.' . substitute(Val, ' ', '.', 'g') | ||||
|         else | ||||
|           if len(tmp) > 0 | ||||
|             if attribute_style ==# 'hash' | ||||
|               let tmp .= ', ' | ||||
|             elseif attribute_style ==# 'html' | ||||
|               let tmp .= ' ' | ||||
|             endif | ||||
|           endif | ||||
|           if attribute_style ==# 'hash' | ||||
|             let tmp .= '' . attr . '="' . Val . '"' | ||||
|           elseif attribute_style ==# 'html' | ||||
|             let tmp .= attr . '="' . Val . '"' | ||||
|           end | ||||
|         endif | ||||
|       endif | ||||
|     endfor | ||||
|     if len(tmp) | ||||
|       if attribute_style ==# 'hash' | ||||
|         let str .= '(' . tmp . ')' | ||||
|       elseif attribute_style ==# 'html' | ||||
|         let str .= '(' . tmp . ')' | ||||
|       end | ||||
|     endif | ||||
| 
 | ||||
|     let inner = '' | ||||
|     if len(current.value) > 0 | ||||
|       let text = current.value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|         let str = substitute(str, '\$#', text, 'g') | ||||
|       endif | ||||
|       let lines = split(text, "\n") | ||||
|       if len(lines) == 1 | ||||
|         let str .= ' ' . text | ||||
|       else | ||||
|         for line in lines | ||||
|           let str .= "\n" . indent . line . ' |' | ||||
|         endfor | ||||
|       endif | ||||
|     elseif len(current.child) == 0 | ||||
|       let str .= '${cursor}' | ||||
|     endif | ||||
|     if len(current.child) == 1 && len(current.child[0].name) == 0 | ||||
|       let text = current.child[0].value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|       endif | ||||
|       let lines = split(text, "\n") | ||||
|       if len(lines) == 1 | ||||
|         let str .= ' ' . text | ||||
|       else | ||||
|         for line in lines | ||||
|           let str .= "\n" . indent . line . ' |' | ||||
|         endfor | ||||
|       endif | ||||
|     elseif len(current.child) > 0 | ||||
|       for child in current.child | ||||
|         let inner .= emmet#toString(child, type, inline, filters, itemno, indent) | ||||
|       endfor | ||||
|       let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') | ||||
|       let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') | ||||
|       let str .= "\n" . indent . inner | ||||
|     endif | ||||
|   else | ||||
|     let str = current.value[1:-2] | ||||
|     if dollar_expr | ||||
|       let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|       let str = substitute(str, '\${nr}', "\n", 'g') | ||||
|       let str = substitute(str, '\\\$', '$', 'g') | ||||
|     endif | ||||
|   endif | ||||
|   let str .= "\n" | ||||
|   return str | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#imageSize() abort | ||||
|   let line = getline('.') | ||||
|   let current = emmet#lang#jade#parseTag(line) | ||||
|   if empty(current) || !has_key(current.attr, 'src') | ||||
|     return | ||||
|   endif | ||||
|   let fn = current.attr.src | ||||
|   if fn =~# '^\s*$' | ||||
|     return | ||||
|   elseif fn !~# '^\(/\|http\)' | ||||
|     let fn = simplify(expand('%:h') . '/' . fn) | ||||
|   endif | ||||
| 
 | ||||
|   let [width, height] = emmet#util#getImageSize(fn) | ||||
|   if width == -1 && height == -1 | ||||
|     return | ||||
|   endif | ||||
|   let current.attr.width = width | ||||
|   let current.attr.height = height | ||||
|   let current.attrs_order += ['width', 'height'] | ||||
|   let jade = emmet#toString(current, 'jade', 1) | ||||
|   let jade = substitute(jade, '\${cursor}', '', '') | ||||
|   call setline('.', substitute(matchstr(line, '^\s*') . jade, "\n", '', 'g')) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#imageEncode() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#parseTag(tag) abort | ||||
|   let current = emmet#newNode() | ||||
|   let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)' | ||||
|   let match = matchstr(a:tag, mx) | ||||
|   let current.name = substitute(match, mx, '\1', '') | ||||
|   let attrs = substitute(match, mx, '\2', '') | ||||
|   let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)' | ||||
|   while len(attrs) > 0 | ||||
|     let match = matchstr(attrs, mx) | ||||
|     if len(match) ==# 0 | ||||
|       break | ||||
|     endif | ||||
|     let attr_match = matchlist(match, mx) | ||||
|     let name = attr_match[1] | ||||
|     let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] | ||||
|     let current.attr[name] = value | ||||
|     let current.attrs_order += [name] | ||||
|     let attrs = attrs[stridx(attrs, match) + len(match):] | ||||
|   endwhile | ||||
|   return current | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#toggleComment() abort | ||||
|   let line = getline('.') | ||||
|   let space = matchstr(line, '^\s*') | ||||
|   if line =~# '^\s*-#' | ||||
|     call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*')) | ||||
|   elseif line =~# '^\s*%[a-z]' | ||||
|     call setline('.', space . '-# ' . line[len(space):]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#balanceTag(flag) range abort | ||||
|   let block = emmet#util#getVisualBlock() | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     let curpos = [0, line("'<"), col("'<"), 0] | ||||
|   else | ||||
|     let curpos = emmet#util#getcurpos() | ||||
|   endif | ||||
|   let n = curpos[1] | ||||
|   let ml = len(matchstr(getline(n), '^\s*')) | ||||
| 
 | ||||
|   if a:flag > 0 | ||||
|     if a:flag == 1 || !emmet#util#regionIsValid(block) | ||||
|       let n = line('.') | ||||
|     else | ||||
|       while n > 0 | ||||
|         let l = len(matchstr(getline(n), '^\s*\ze%[a-z]')) | ||||
|         if l > 0 && l < ml | ||||
|           let ml = l | ||||
|           break | ||||
|         endif | ||||
|         let n -= 1 | ||||
|       endwhile | ||||
|     endif | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   else | ||||
|     while n > 0 | ||||
|       let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) | ||||
|       if l > 0 && l > ml | ||||
|         let ml = l | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#jade#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#moveNextPrev(flag) abort | ||||
|   let pos = search('""', a:flag ? 'Wb' : 'W') | ||||
|   if pos != 0 | ||||
|     silent! normal! l | ||||
|     startinsert | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#splitJoinTag() abort | ||||
|   let n = line('.') | ||||
|   let sml = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|   while n > 0 | ||||
|     if getline(n) =~# '^\s*\ze%[a-z]' | ||||
|       if len(matchstr(getline(n), '^\s*%[a-z]')) < sml | ||||
|         break | ||||
|       endif | ||||
|       let line = getline(n) | ||||
|       call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', '')) | ||||
|       let sn = n | ||||
|       let n += 1 | ||||
|       let ml = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       if len(matchstr(getline(n), '^\s*')) > ml | ||||
|         while n <= line('$') | ||||
|           let l = len(matchstr(getline(n), '^\s*')) | ||||
|           if l <= ml | ||||
|             break | ||||
|           endif | ||||
|           exe n 'delete' | ||||
|         endwhile | ||||
|         call setpos('.', [0, sn, 1, 0]) | ||||
|       else | ||||
|         let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)') | ||||
|         let spaces = matchstr(getline(sn), '^\s*') | ||||
|         let settings = emmet#getSettings() | ||||
|         if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1 | ||||
|           call append(sn, spaces . '   ') | ||||
|           call setpos('.', [0, sn+1, 1, 0]) | ||||
|         else | ||||
|           call setpos('.', [0, sn, 1, 0]) | ||||
|         endif | ||||
|         startinsert! | ||||
|       endif | ||||
|       break | ||||
|     endif | ||||
|     let n -= 1 | ||||
|   endwhile | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#removeTag() abort | ||||
|   let n = line('.') | ||||
|   let ml = 0 | ||||
|   while n > 0 | ||||
|     if getline(n) =~# '^\s*\ze[a-z]' | ||||
|       let ml = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|       break | ||||
|     endif | ||||
|     let n -= 1 | ||||
|   endwhile | ||||
|   let sn = n | ||||
|   while n < line('$') | ||||
|     let l = len(matchstr(getline(n), '^\s*%[a-z]')) | ||||
|     if l > 0 && l <= ml | ||||
|       let n -= 1 | ||||
|       break | ||||
|     endif | ||||
|     let n += 1 | ||||
|   endwhile | ||||
|   if sn == n | ||||
|     exe 'delete' | ||||
|   else | ||||
|     exe sn ',' (n-1) 'delete' | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#jade#mergeLines() abort | ||||
|   " nothing to do | ||||
| endfunction | ||||
							
								
								
									
										51
									
								
								config/vim/autoload/emmet/lang/less.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								config/vim/autoload/emmet/lang/less.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,51 @@ | |||
| function! emmet#lang#less#findTokens(str) abort | ||||
|   return emmet#lang#html#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#parseIntoTree(abbr, type) abort | ||||
|   return emmet#lang#scss#parseIntoTree(a:abbr, a:type) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   return emmet#lang#scss#toString(a:settings, a:current, a:type, a:inline, a:filters, a:itemno, a:indent) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#imageSize() abort | ||||
|   call emmet#lang#css#imageSize() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#imageEncode() abort | ||||
|   return emmet#lang#css#imageEncode() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#parseTag(tag) abort | ||||
|   return emmet#lang#css#parseTag(a:tag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#toggleComment() abort | ||||
|   call emmet#lang#css#toggleComment() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#balanceTag(flag) range abort | ||||
|   call emmet#lang#scss#balanceTag(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#less#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#moveNextPrev(flag) abort | ||||
|   call emmet#lang#scss#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#splitJoinTag() abort | ||||
|   call emmet#lang#css#splitJoinTag() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#removeTag() abort | ||||
|   call emmet#lang#css#removeTag() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#less#mergeLines() abort | ||||
|   call emmet#lang#css#mergeLines() | ||||
| endfunction | ||||
							
								
								
									
										163
									
								
								config/vim/autoload/emmet/lang/sass.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								config/vim/autoload/emmet/lang/sass.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,163 @@ | |||
| function! emmet#lang#sass#findTokens(str) abort | ||||
|   return emmet#lang#css#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#parseIntoTree(abbr, type) abort | ||||
|     return emmet#lang#css#parseIntoTree(a:abbr, a:type) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let settings = a:settings | ||||
|   let current = a:current | ||||
|   let type = a:type | ||||
|   let inline = a:inline | ||||
|   let filters = a:filters | ||||
|   let itemno = a:itemno | ||||
|   let indent = a:indent | ||||
|   let str = '' | ||||
| 
 | ||||
|   let current_name = current.name | ||||
|   let current_name = substitute(current.name, '\$$', itemno+1, '') | ||||
|   if len(current.name) > 0 | ||||
|     let str .= current_name | ||||
|     let tmp = '' | ||||
|     for attr in keys(current.attr) | ||||
|       let val = current.attr[attr] | ||||
|       while val =~# '\$\([^#{]\|$\)' | ||||
|         let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|       endwhile | ||||
|       let attr = substitute(attr, '\$$', itemno+1, '') | ||||
|       if attr ==# 'id' | ||||
|         let str .= '#' . val | ||||
|       elseif attr ==# 'class' | ||||
|         let str .= '.' . val | ||||
|       else | ||||
|         let tmp .= attr . ': ' . val | ||||
|       endif | ||||
|     endfor | ||||
|     if len(tmp) > 0 | ||||
|       let str .= "\n" | ||||
|       for line in split(tmp, "\n") | ||||
|         let str .= indent . line . "\n" | ||||
|       endfor | ||||
|     else | ||||
|       let str .= "\n" | ||||
|     endif | ||||
| 
 | ||||
|     let inner = '' | ||||
|     for child in current.child | ||||
|       let tmp = emmet#toString(child, type, inline, filters, itemno, indent) | ||||
|       let tmp = substitute(tmp, "\n", "\n" . escape(indent, '\'), 'g') | ||||
|       let tmp = substitute(tmp, "\n" . escape(indent, '\') . '$', '${cursor}\n', 'g') | ||||
|       let inner .= tmp | ||||
|     endfor | ||||
|     if len(inner) > 0 | ||||
|       let str .= indent . inner | ||||
|     endif | ||||
|   else | ||||
|     let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) | ||||
|     let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g') | ||||
|     return text | ||||
|   endif | ||||
|   return str | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#imageSize() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#imageEncode() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#parseTag(tag) abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#toggleComment() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#balanceTag(flag) range abort | ||||
|   let block = emmet#util#getVisualBlock() | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     let curpos = [0, line("'<"), col("'<"), 0] | ||||
|   else | ||||
|     let curpos = emmet#util#getcurpos() | ||||
|   endif | ||||
|   let n = curpos[1] | ||||
|   let ml = len(matchstr(getline(n), '^\s*')) | ||||
| 
 | ||||
|   if a:flag > 0 | ||||
|     if a:flag == 1 || !emmet#util#regionIsValid(block) | ||||
|       let n = line('.') | ||||
|     else | ||||
|       while n > 0 | ||||
|         let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) | ||||
|         if l > 0 && l < ml | ||||
|           let ml = l | ||||
|           break | ||||
|         endif | ||||
|         let n -= 1 | ||||
|       endwhile | ||||
|     endif | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   else | ||||
|     while n > 0 | ||||
|       let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) | ||||
|       if l > 0 && l > ml | ||||
|         let ml = l | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#sass#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#moveNextPrev(flag) abort | ||||
|   let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp') | ||||
|   if pos == 2 | ||||
|     startinsert! | ||||
|   elseif pos != 0 | ||||
|     silent! normal! l | ||||
|     startinsert | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#splitJoinTag() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#removeTag() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#sass#mergeLines() abort | ||||
| endfunction | ||||
							
								
								
									
										129
									
								
								config/vim/autoload/emmet/lang/scss.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								config/vim/autoload/emmet/lang/scss.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,129 @@ | |||
| function! emmet#lang#scss#findTokens(str) abort | ||||
|   return emmet#lang#css#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#parseIntoTree(abbr, type) abort | ||||
|   if a:abbr =~# '>' | ||||
|     return emmet#lang#html#parseIntoTree(a:abbr, a:type) | ||||
|   else | ||||
|     return emmet#lang#css#parseIntoTree(a:abbr, a:type) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let settings = a:settings | ||||
|   let current = a:current | ||||
|   let type = a:type | ||||
|   let inline = a:inline | ||||
|   let filters = a:filters | ||||
|   let itemno = a:itemno | ||||
|   let indent = a:indent | ||||
|   let str = '' | ||||
| 
 | ||||
|   let current_name = substitute(current.name, '\$$', itemno+1, '') | ||||
|   if len(current.name) > 0 | ||||
|     let str .= current_name | ||||
|     let tmp = '' | ||||
|     for attr in keys(current.attr) | ||||
|       let val = current.attr[attr] | ||||
|       while val =~# '\$\([^#{]\|$\)' | ||||
|         let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|       endwhile | ||||
|       let attr = substitute(attr, '\$$', itemno+1, '') | ||||
|       if attr ==# 'id' | ||||
|         let str .= '#' . val | ||||
|       elseif attr ==# 'class' | ||||
|         let str .= '.' . val | ||||
|       else | ||||
|         let tmp .= attr . ': ' . val . ';' | ||||
|       endif | ||||
|     endfor | ||||
|     if len(tmp) > 0 | ||||
|       let str .= " {\n" | ||||
|       for line in split(tmp, "\n") | ||||
|         let str .= indent . line . "\n" | ||||
|       endfor | ||||
|     else | ||||
|       let str .= " {\n" | ||||
|     endif | ||||
| 
 | ||||
|     let inner = '' | ||||
|     for child in current.child | ||||
|       let inner .= emmet#toString(child, type, inline, filters, itemno) | ||||
|     endfor | ||||
|     let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') | ||||
|     let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') | ||||
|     let str .= indent . inner . "${cursor}\n}\n" | ||||
|   else | ||||
|     return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) | ||||
|   endif | ||||
|   return str | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#imageSize() abort | ||||
|   call emmet#lang#css#imageSize() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#imageEncode() abort | ||||
|   return emmet#lang#css#imageEncode() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#parseTag(tag) abort | ||||
|   return emmet#lang#css#parseTag(a:tag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#toggleComment() abort | ||||
|   call emmet#lang#css#toggleComment() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#balanceTag(flag) range abort | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     let curpos = [0, line("'<"), col("'<"), 0] | ||||
|     call setpos('.', curpos) | ||||
|   else | ||||
|     let curpos = emmet#util#getcurpos() | ||||
|   endif | ||||
|   if a:flag < 0 | ||||
|     let ret = searchpair('}', '', '.\zs{') | ||||
|   else | ||||
|     let ret = searchpair('{', '', '}', 'bW') | ||||
|   endif | ||||
|   if ret > 0 | ||||
|     let pos1 = emmet#util#getcurpos()[1:2] | ||||
|     if a:flag < 0 | ||||
|       let pos2 = searchpairpos('{', '', '}') | ||||
|     else | ||||
|       let pos2 = searchpairpos('{', '', '}') | ||||
|     endif | ||||
|     let block = [pos1, pos2] | ||||
|     if emmet#util#regionIsValid(block) | ||||
|       call emmet#util#selectRegion(block) | ||||
|       return | ||||
|     endif | ||||
|   endif | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     silent! exe 'normal! gv' | ||||
|   else | ||||
|     call setpos('.', curpos) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#scss#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#moveNextPrev(flag) abort | ||||
|   call emmet#lang#css#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#splitJoinTag() abort | ||||
|   call emmet#lang#css#splitJoinTag() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#removeTag() abort | ||||
|   call emmet#lang#css#removeTag() | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#scss#mergeLines() abort | ||||
|   call emmet#lang#css#mergeLines() | ||||
| endfunction | ||||
							
								
								
									
										284
									
								
								config/vim/autoload/emmet/lang/slim.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										284
									
								
								config/vim/autoload/emmet/lang/slim.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,284 @@ | |||
| function! emmet#lang#slim#findTokens(str) abort | ||||
|   return emmet#lang#html#findTokens(a:str) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#parseIntoTree(abbr, type) abort | ||||
|   return emmet#lang#html#parseIntoTree(a:abbr, a:type) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) abort | ||||
|   let current = a:current | ||||
|   let type = a:type | ||||
|   let inline = a:inline | ||||
|   let filters = a:filters | ||||
|   let itemno = a:itemno | ||||
|   let indent = emmet#getIndentation(type) | ||||
|   let dollar_expr = emmet#getResource(type, 'dollar_expr', 1) | ||||
|   let str = '' | ||||
| 
 | ||||
|   let current_name = current.name | ||||
|   if dollar_expr | ||||
|     let current_name = substitute(current.name, '\$$', itemno+1, '') | ||||
|   endif | ||||
|   if len(current.name) > 0 | ||||
|     let str .= current_name | ||||
|     for attr in emmet#util#unique(current.attrs_order + keys(current.attr)) | ||||
|       if !has_key(current.attr, attr) | ||||
|         continue | ||||
|       endif | ||||
|       let Val = current.attr[attr] | ||||
|       if type(Val) == 2 && Val == function('emmet#types#true') | ||||
|         let str .= ' ' . attr . '=true' | ||||
|       else | ||||
|         if dollar_expr | ||||
|           while Val =~# '\$\([^#{]\|$\)' | ||||
|             let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|           endwhile | ||||
|         endif | ||||
|         let attr = substitute(attr, '\$$', itemno+1, '') | ||||
|         let str .= ' ' . attr . '="' . Val . '"' | ||||
|       endif | ||||
|     endfor | ||||
| 
 | ||||
|     let inner = '' | ||||
|     if len(current.value) > 0 | ||||
|       let str .= "\n" | ||||
|       let text = current.value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|         let str = substitute(str, '\$#', text, 'g') | ||||
|       endif | ||||
|       for line in split(text, "\n") | ||||
|         let str .= indent . '| ' . line . "\n" | ||||
|       endfor | ||||
|     elseif len(current.child) == 0 | ||||
|       let str .= '${cursor}' | ||||
|     endif | ||||
|     if len(current.child) == 1 && len(current.child[0].name) == 0 | ||||
|       let str .= "\n" | ||||
|       let text = current.child[0].value[1:-2] | ||||
|       if dollar_expr | ||||
|         let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|         let text = substitute(text, '\${nr}', "\n", 'g') | ||||
|         let text = substitute(text, '\\\$', '$', 'g') | ||||
|       endif | ||||
|       for line in split(text, "\n") | ||||
|         let str .= indent . '| ' . line . "\n" | ||||
|       endfor | ||||
|     elseif len(current.child) > 0 | ||||
|       for child in current.child | ||||
|         let inner .= emmet#toString(child, type, inline, filters, itemno, indent) | ||||
|       endfor | ||||
|       let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') | ||||
|       let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') | ||||
|       let str .= "\n" . indent . inner | ||||
|     endif | ||||
|   else | ||||
|     let str = current.value[1:-2] | ||||
|     if dollar_expr | ||||
|       let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') | ||||
|       let str = substitute(str, '\${nr}', "\n", 'g') | ||||
|       let str = substitute(str, '\\\$', '$', 'g') | ||||
|     endif | ||||
|   endif | ||||
|   if str !~# "\n$" | ||||
|     let str .= "\n" | ||||
|   endif | ||||
|   return str | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#imageSize() abort | ||||
|   let line = getline('.') | ||||
|   let current = emmet#lang#slim#parseTag(line) | ||||
|   if empty(current) || !has_key(current.attr, 'src') | ||||
|     return | ||||
|   endif | ||||
|   let fn = current.attr.src | ||||
|   if fn =~# '^\s*$' | ||||
|     return | ||||
|   elseif fn !~# '^\(/\|http\)' | ||||
|     let fn = simplify(expand('%:h') . '/' . fn) | ||||
|   endif | ||||
| 
 | ||||
|   let [width, height] = emmet#util#getImageSize(fn) | ||||
|   if width == -1 && height == -1 | ||||
|     return | ||||
|   endif | ||||
|   let current.attr.width = width | ||||
|   let current.attr.height = height | ||||
|   let current.attrs_order += ['width', 'height'] | ||||
|   let slim = emmet#toString(current, 'slim', 1) | ||||
|   let slim = substitute(slim, '\${cursor}', '', '') | ||||
|   call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", '', 'g')) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#imageEncode() abort | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#parseTag(tag) abort | ||||
|   let current = emmet#newNode() | ||||
|   let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)' | ||||
|   let match = matchstr(a:tag, mx) | ||||
|   let current.name = substitute(match, mx, '\1', '') | ||||
|   let attrs = substitute(match, mx, '\2', '') | ||||
|   let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)' | ||||
|   while len(attrs) > 0 | ||||
|     let match = matchstr(attrs, mx) | ||||
|     if len(match) == 0 | ||||
|       break | ||||
|     endif | ||||
|     let attr_match = matchlist(match, mx) | ||||
|     let name = attr_match[1] | ||||
|     let value = len(attr_match[2]) ? attr_match[2] : attr_match[3] | ||||
|     let current.attr[name] = value | ||||
|     let current.attrs_order += [name] | ||||
|     let attrs = attrs[stridx(attrs, match) + len(match):] | ||||
|   endwhile | ||||
|   return current | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#toggleComment() abort | ||||
|   let line = getline('.') | ||||
|   let space = matchstr(line, '^\s*') | ||||
|   if line =~# '^\s*/' | ||||
|     call setline('.', space . line[len(space)+1:]) | ||||
|   elseif line =~# '^\s*[a-z]' | ||||
|     call setline('.', space . '/' . line[len(space):]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#balanceTag(flag) range abort | ||||
|   let block = emmet#util#getVisualBlock() | ||||
|   if a:flag == -2 || a:flag == 2 | ||||
|     let curpos = [0, line("'<"), col("'<"), 0] | ||||
|   else | ||||
|     let curpos = emmet#util#getcurpos() | ||||
|   endif | ||||
|   let n = curpos[1] | ||||
|   let ml = len(matchstr(getline(n), '^\s*')) | ||||
| 
 | ||||
|   if a:flag > 0 | ||||
|     if a:flag == 1 || !emmet#util#regionIsValid(block) | ||||
|       let n = line('.') | ||||
|     else | ||||
|       while n > 0 | ||||
|         let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) | ||||
|         if l > 0 && l < ml | ||||
|           let ml = l | ||||
|           break | ||||
|         endif | ||||
|         let n -= 1 | ||||
|       endwhile | ||||
|     endif | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   else | ||||
|     while n > 0 | ||||
|       let l = len(matchstr(getline(n), '^\s*\ze[a-z]')) | ||||
|       if l > 0 && l > ml | ||||
|         let ml = l | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     let sn = n | ||||
|     if n == 0 | ||||
|       let ml = 0 | ||||
|     endif | ||||
|     while n < line('$') | ||||
|       let l = len(matchstr(getline(n), '^\s*[a-z]')) | ||||
|       if l > 0 && l <= ml | ||||
|         let n -= 1 | ||||
|         break | ||||
|       endif | ||||
|       let n += 1 | ||||
|     endwhile | ||||
|     call setpos('.', [0, n, 1, 0]) | ||||
|     normal! V | ||||
|     call setpos('.', [0, sn, 1, 0]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#moveNextPrevItem(flag) abort | ||||
|   return emmet#lang#slim#moveNextPrev(a:flag) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#moveNextPrev(flag) abort | ||||
|   let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp') | ||||
|   if pos == 2 | ||||
|     startinsert! | ||||
|   elseif pos != 0 | ||||
|     silent! normal! l | ||||
|     startinsert | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#splitJoinTag() abort | ||||
|   let n = line('.') | ||||
|   while n > 0 | ||||
|     if getline(n) =~# '^\s*\ze[a-z]' | ||||
|       let sn = n | ||||
|       let n += 1 | ||||
|       if getline(n) =~# '^\s*|' | ||||
|         while n <= line('$') | ||||
|           if getline(n) !~# '^\s*|' | ||||
|             break | ||||
|           endif | ||||
|           exe n 'delete' | ||||
|         endwhile | ||||
|         call setpos('.', [0, sn, 1, 0]) | ||||
|       else | ||||
|         let spaces = matchstr(getline(sn), '^\s*') | ||||
|         call append(sn, spaces . '  | ') | ||||
|         call setpos('.', [0, sn+1, 1, 0]) | ||||
|         startinsert! | ||||
|       endif | ||||
|       break | ||||
|     endif | ||||
|     let n -= 1 | ||||
|   endwhile | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#removeTag() abort | ||||
|   let n = line('.') | ||||
|   let ml = 0 | ||||
|   while n > 0 | ||||
|     if getline(n) =~# '^\s*\ze[a-z]' | ||||
|       let ml = len(matchstr(getline(n), '^\s*[a-z]')) | ||||
|       break | ||||
|     endif | ||||
|     let n -= 1 | ||||
|   endwhile | ||||
|   let sn = n | ||||
|   while n < line('$') | ||||
|     let l = len(matchstr(getline(n), '^\s*[a-z]')) | ||||
|     if l > 0 && l <= ml | ||||
|       let n -= 1 | ||||
|       break | ||||
|     endif | ||||
|     let n += 1 | ||||
|   endwhile | ||||
|   if sn == n | ||||
|     exe 'delete' | ||||
|   else | ||||
|     exe sn ',' (n-1) 'delete' | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#lang#slim#mergeLines() abort | ||||
| endfunction | ||||
							
								
								
									
										65
									
								
								config/vim/autoload/emmet/lorem/en.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								config/vim/autoload/emmet/lorem/en.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,65 @@ | |||
| function! emmet#lorem#en#expand(command) abort | ||||
|   let wcount = matchstr(a:command, '\(\d*\)$') | ||||
|   let wcount = wcount > 0 ? wcount : 30 | ||||
|    | ||||
|   let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit'] | ||||
|   let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet', | ||||
|   \            'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi', | ||||
|   \            'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi', | ||||
|   \            'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos', | ||||
|   \            'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum', | ||||
|   \            'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus', | ||||
|   \            'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus', | ||||
|   \            'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum', | ||||
|   \            'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem', | ||||
|   \            'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus', | ||||
|   \            'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente', | ||||
|   \            'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet', | ||||
|   \            'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta', | ||||
|   \            'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima', | ||||
|   \            'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim', | ||||
|   \            'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores', | ||||
|   \            'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias', | ||||
|   \            'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea', | ||||
|   \            'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt', | ||||
|   \            'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate', | ||||
|   \            'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius', | ||||
|   \            'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos', | ||||
|   \            'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore', | ||||
|   \            'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo', | ||||
|   \            'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi', | ||||
|   \            'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam', | ||||
|   \            'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique', | ||||
|   \            'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere', | ||||
|   \            'maxime', 'corrupti'] | ||||
|   let ret = [] | ||||
|   let sentence = 0 | ||||
|   for i in range(wcount) | ||||
|     let arr = common | ||||
|     if sentence > 0 | ||||
|       let arr += words | ||||
|     endif | ||||
|     let r = emmet#util#rand() | ||||
|     let word = arr[r % len(arr)] | ||||
|     if sentence == 0 | ||||
|       let word = substitute(word, '^.', '\U&', '') | ||||
|     endif | ||||
|     let sentence += 1 | ||||
|     call add(ret, word) | ||||
|     if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1 | ||||
|       if i == wcount - 1 | ||||
|         let endc = '?!...'[emmet#util#rand() % 5] | ||||
|         call add(ret, endc) | ||||
|       else | ||||
|         let endc = '?!,...'[emmet#util#rand() % 6] | ||||
|         call add(ret, endc . ' ') | ||||
|       endif | ||||
|       if endc !=# ',' | ||||
|         let sentence = 0 | ||||
|       endif | ||||
|     else | ||||
|       call add(ret, ' ') | ||||
|     endif | ||||
|   endfor | ||||
|   return join(ret, '') | ||||
| endfunction | ||||
							
								
								
									
										27
									
								
								config/vim/autoload/emmet/lorem/ja.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								config/vim/autoload/emmet/lorem/ja.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| scriptencoding utf-8 | ||||
| 
 | ||||
| function! emmet#lorem#ja#expand(command) abort | ||||
|   let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '') | ||||
|   let wcount = wcount > 0 ? wcount : 30 | ||||
| 
 | ||||
|   let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html" | ||||
|   let content = emmet#util#cache(url) | ||||
|   if len(content) == 0 | ||||
|     let content = emmet#util#getContentFromURL(url) | ||||
|     let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>') | ||||
|     let content = substitute(content, '[ \r]', '', 'g') | ||||
|     let content = substitute(content, '<br[^>]*>', "\n", 'g') | ||||
|     let content = substitute(content, '<[^>]\+>', '', 'g') | ||||
|     let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n") | ||||
|     call emmet#util#cache(url, content) | ||||
|   endif | ||||
|    | ||||
|   let content = substitute(content, "、\n", "、", "g") | ||||
|   let clines = split(content, '\n') | ||||
|   let lines = filter(clines, 'len(substitute(v:val,".",".","g"))<=wcount') | ||||
|   if len(lines) == 0 | ||||
|     let lines = clines | ||||
|   endif | ||||
|   let r = emmet#util#rand() | ||||
|   return lines[r % len(lines)] | ||||
| endfunction | ||||
							
								
								
									
										410
									
								
								config/vim/autoload/emmet/util.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										410
									
								
								config/vim/autoload/emmet/util.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,410 @@ | |||
| "============================================================================== | ||||
| " region utils | ||||
| "============================================================================== | ||||
| " deleteContent : delete content in region | ||||
| "   if region make from between '<foo>' and '</foo>' | ||||
| "   -------------------- | ||||
| "   begin:<foo> | ||||
| "   </foo>:end | ||||
| "   -------------------- | ||||
| "   this function make the content as following | ||||
| "   -------------------- | ||||
| "   begin::end | ||||
| "   -------------------- | ||||
| function! emmet#util#deleteContent(region) abort | ||||
|   let lines = getline(a:region[0][0], a:region[1][0]) | ||||
|   call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) | ||||
|   silent! exe 'delete '.(a:region[1][0] - a:region[0][0]) | ||||
|   call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]]) | ||||
| endfunction | ||||
| 
 | ||||
| " change_content : change content in region | ||||
| "   if region make from between '<foo>' and '</foo>' | ||||
| "   -------------------- | ||||
| "   begin:<foo> | ||||
| "   </foo>:end | ||||
| "   -------------------- | ||||
| "   and content is | ||||
| "   -------------------- | ||||
| "   foo | ||||
| "   bar | ||||
| "   baz | ||||
| "   -------------------- | ||||
| "   this function make the content as following | ||||
| "   -------------------- | ||||
| "   begin:foo | ||||
| "   bar | ||||
| "   baz:end | ||||
| "   -------------------- | ||||
| function! emmet#util#setContent(region, content) abort | ||||
|   let newlines = split(a:content, '\n', 1) | ||||
|   let oldlines = getline(a:region[0][0], a:region[1][0]) | ||||
|   call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) | ||||
|   silent! exe 'delete '.(a:region[1][0] - a:region[0][0]) | ||||
|   if len(newlines) == 0 | ||||
|     let tmp = '' | ||||
|     if a:region[0][1] > 1 | ||||
|       let tmp = oldlines[0][:a:region[0][1]-2] | ||||
|     endif | ||||
|     if a:region[1][1] >= 1 | ||||
|       let tmp .= oldlines[-1][a:region[1][1]:] | ||||
|     endif | ||||
|     call setline(line('.'), tmp) | ||||
|   elseif len(newlines) == 1 | ||||
|     if a:region[0][1] > 1 | ||||
|       let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0] | ||||
|     endif | ||||
|     if a:region[1][1] >= 1 | ||||
|       let newlines[0] .= oldlines[-1][a:region[1][1]:] | ||||
|     endif | ||||
|     call setline(line('.'), newlines[0]) | ||||
|   else | ||||
|     if a:region[0][1] > 1 | ||||
|       let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0] | ||||
|     endif | ||||
|     if a:region[1][1] >= 1 | ||||
|       let newlines[-1] .= oldlines[-1][a:region[1][1]:] | ||||
|     endif | ||||
|     call setline(line('.'), newlines[0]) | ||||
|     call append(line('.'), newlines[1:]) | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| " select_region : select region | ||||
| "   this function make a selection of region | ||||
| function! emmet#util#selectRegion(region) abort | ||||
|   call setpos('.', [0, a:region[1][0], a:region[1][1], 0]) | ||||
|   normal! v | ||||
|   call setpos('.', [0, a:region[0][0], a:region[0][1], 0]) | ||||
| endfunction | ||||
| 
 | ||||
| " point_in_region : check point is in the region | ||||
| "   this function return 0 or 1 | ||||
| function! emmet#util#pointInRegion(point, region) abort | ||||
|   if !emmet#util#regionIsValid(a:region) | return 0 | endif | ||||
|   if a:region[0][0] > a:point[0] | return 0 | endif | ||||
|   if a:region[1][0] < a:point[0] | return 0 | endif | ||||
|   if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif | ||||
|   if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif | ||||
|   return 1 | ||||
| endfunction | ||||
| 
 | ||||
| " cursor_in_region : check cursor is in the region | ||||
| "   this function return 0 or 1 | ||||
| function! emmet#util#cursorInRegion(region) abort | ||||
|   if !emmet#util#regionIsValid(a:region) | return 0 | endif | ||||
|   let cur = emmet#util#getcurpos()[1:2] | ||||
|   return emmet#util#pointInRegion(cur, a:region) | ||||
| endfunction | ||||
| 
 | ||||
| " region_is_valid : check region is valid | ||||
| "   this function return 0 or 1 | ||||
| function! emmet#util#regionIsValid(region) abort | ||||
|   if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif | ||||
|   return 1 | ||||
| endfunction | ||||
| 
 | ||||
| " search_region : make region from pattern which is composing start/end | ||||
| "   this function return array of position | ||||
| function! emmet#util#searchRegion(start, end) abort | ||||
|   let b = searchpairpos(a:start, '', a:end, 'bcnW') | ||||
|   if b == [0, 0] | ||||
|     return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')] | ||||
|   else | ||||
|     return [b, searchpairpos(a:start, '', a:end. '', 'nW')] | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| " get_content : get content in region | ||||
| "   this function return string in region | ||||
| function! emmet#util#getContent(region) abort | ||||
|   if !emmet#util#regionIsValid(a:region) | ||||
|     return '' | ||||
|   endif | ||||
|   let lines = getline(a:region[0][0], a:region[1][0]) | ||||
|   if a:region[0][0] == a:region[1][0] | ||||
|     let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1] | ||||
|   else | ||||
|     let lines[0] = lines[0][a:region[0][1]-1:] | ||||
|     let lines[-1] = lines[-1][:a:region[1][1]-1] | ||||
|   endif | ||||
|   return join(lines, "\n") | ||||
| endfunction | ||||
| 
 | ||||
| " region_in_region : check region is in the region | ||||
| "   this function return 0 or 1 | ||||
| function! emmet#util#regionInRegion(outer, inner) abort | ||||
|   if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer) | ||||
|     return 0 | ||||
|   endif | ||||
|   return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer) | ||||
| endfunction | ||||
| 
 | ||||
| " get_visualblock : get region of visual block | ||||
| "   this function return region of visual block | ||||
| function! emmet#util#getVisualBlock() abort | ||||
|   return [[line("'<"), col("'<")], [line("'>"), col("'>")]] | ||||
| endfunction | ||||
| 
 | ||||
| "============================================================================== | ||||
| " html utils | ||||
| "============================================================================== | ||||
| function! emmet#util#getContentFromURL(url) abort | ||||
|   let res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', '')))) | ||||
|   while res =~# '^HTTP/1.\d 3' || res =~# '^HTTP/1\.\d 200 Connection established' || res =~# '^HTTP/1\.\d 100 Continue' | ||||
|     let pos = stridx(res, "\r\n\r\n") | ||||
|     if pos != -1 | ||||
|       let res = strpart(res, pos+4) | ||||
|     else | ||||
|       let pos = stridx(res, "\n\n") | ||||
|       let res = strpart(res, pos+2) | ||||
|     endif | ||||
|   endwhile | ||||
|   let pos = stridx(res, "\r\n\r\n") | ||||
|   if pos != -1 | ||||
|     let content = strpart(res, pos+4) | ||||
|   else | ||||
|     let pos = stridx(res, "\n\n") | ||||
|     let content = strpart(res, pos+2) | ||||
|   endif | ||||
|   let header = res[:pos-1] | ||||
|   let charset = matchstr(content, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>') | ||||
|   if len(charset) == 0 | ||||
|     let charset = matchstr(content, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>') | ||||
|   endif | ||||
|   if len(charset) == 0 | ||||
|     let charset = matchstr(header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze') | ||||
|   endif | ||||
|   if len(charset) == 0 | ||||
|     let s1 = len(split(content, '?')) | ||||
|     let utf8 = iconv(content, 'utf-8', &encoding) | ||||
|     let s2 = len(split(utf8, '?')) | ||||
|     return (s2 == s1 || s2 >= s1 * 2) ? utf8 : content | ||||
|   endif | ||||
|   return iconv(content, charset, &encoding) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#getTextFromHTML(buf) abort | ||||
|   let threshold_len = 100 | ||||
|   let threshold_per = 0.1 | ||||
|   let buf = a:buf | ||||
| 
 | ||||
|   let buf = strpart(buf, stridx(buf, '</head>')) | ||||
|   let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g') | ||||
|   let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g') | ||||
|   let res = '' | ||||
|   let max = 0 | ||||
|   let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)' | ||||
|   let m = split(buf, mx) | ||||
|   for str in m | ||||
|     let c = split(str, '<[^>]*?>') | ||||
|     let str = substitute(str, '<[^>]\{-}>', ' ', 'g') | ||||
|     let str = substitute(str, '>', '>', 'g') | ||||
|     let str = substitute(str, '<', '<', 'g') | ||||
|     let str = substitute(str, '"', '"', 'g') | ||||
|     let str = substitute(str, ''', '''', 'g') | ||||
|     let str = substitute(str, ' ', ' ', 'g') | ||||
|     let str = substitute(str, '¥', '\¥', 'g') | ||||
|     let str = substitute(str, '&', '\&', 'g') | ||||
|     let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '') | ||||
|     let str = substitute(str, '\s\+', ' ', 'g') | ||||
|     let l = len(str) | ||||
|     if l > threshold_len | ||||
|       let per = (l+0.0) / len(c) | ||||
|       if max < l && per > threshold_per | ||||
|         let max = l | ||||
|         let res = str | ||||
|       endif | ||||
|     endif | ||||
|   endfor | ||||
|   let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g') | ||||
|   return res | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#getImageSize(fn) abort | ||||
|   let fn = a:fn | ||||
| 
 | ||||
|   if emmet#util#isImageMagickInstalled() | ||||
|     return emmet#util#imageSizeWithImageMagick(fn) | ||||
|   endif | ||||
| 
 | ||||
|   if filereadable(fn) | ||||
|     let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g') | ||||
|   else | ||||
|     if fn !~# '^\w\+://' | ||||
|       let path = fnamemodify(expand('%'), ':p:gs?\\?/?') | ||||
|       if has('win32') || has('win64') | | ||||
|         let path = tolower(path) | ||||
|       endif | ||||
|       for k in keys(g:emmet_docroot) | ||||
|         let root = fnamemodify(k, ':p:gs?\\?/?') | ||||
|         if has('win32') || has('win64') | | ||||
|           let root = tolower(root) | ||||
|         endif | ||||
|         if stridx(path, root) == 0 | ||||
|           let v = g:emmet_docroot[k] | ||||
|           let fn = (len(v) == 0 ? k : v) . fn | ||||
|           break | ||||
|         endif | ||||
|       endfor | ||||
|     endif | ||||
|     let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g') | ||||
|   endif | ||||
| 
 | ||||
|   let [width, height] = [-1, -1] | ||||
|   if hex =~# '^89504e470d0a1a0a' | ||||
|     let width = eval('0x'.hex[32:39]) | ||||
|     let height = eval('0x'.hex[40:47]) | ||||
|   endif | ||||
|   if hex =~# '^ffd8' | ||||
|     let pos = 4 | ||||
|     while pos < len(hex) | ||||
|       let bs = hex[pos+0:pos+3] | ||||
|       let pos += 4 | ||||
|       if bs ==# 'ffc0' || bs ==# 'ffc2' | ||||
|         let pos += 6 | ||||
|         let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3]) | ||||
|         let pos += 4 | ||||
|         let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3]) | ||||
|         break | ||||
|       elseif bs =~# 'ffd[9a]' | ||||
|         break | ||||
|       elseif bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)' | ||||
|         let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2 | ||||
|       endif | ||||
|     endwhile | ||||
|   endif | ||||
|   if hex =~# '^47494638' | ||||
|     let width = eval('0x'.hex[14:15].hex[12:13]) | ||||
|     let height = eval('0x'.hex[18:19].hex[16:17]) | ||||
|   endif | ||||
| 
 | ||||
|   return [width, height] | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#imageSizeWithImageMagick(fn) abort | ||||
|   let img_info = system('identify -format "%wx%h" "'.a:fn.'"') | ||||
|   let img_size = split(substitute(img_info, '\n', '', ''), 'x') | ||||
|   if len(img_size) != 2 | ||||
|     return [-1, -1] | ||||
|   endif | ||||
|   return img_size | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#isImageMagickInstalled() abort | ||||
|   if !get(g:, 'emmet_use_identify', 1) | ||||
|     return 0 | ||||
|   endif | ||||
|   return executable('identify') | ||||
| endfunction | ||||
| 
 | ||||
| function! s:b64encode(bytes, table, pad) | ||||
|   let b64 = [] | ||||
|   for i in range(0, len(a:bytes) - 1, 3) | ||||
|     let n = a:bytes[i] * 0x10000 | ||||
|           \ + get(a:bytes, i + 1, 0) * 0x100 | ||||
|           \ + get(a:bytes, i + 2, 0) | ||||
|     call add(b64, a:table[n / 0x40000]) | ||||
|     call add(b64, a:table[n / 0x1000 % 0x40]) | ||||
|     call add(b64, a:table[n / 0x40 % 0x40]) | ||||
|     call add(b64, a:table[n % 0x40]) | ||||
|   endfor | ||||
|   if len(a:bytes) % 3 == 2 | ||||
|     let b64[-1] = a:pad | ||||
|   elseif len(a:bytes) % 3 == 1 | ||||
|     let b64[-1] = a:pad | ||||
|     let b64[-2] = a:pad | ||||
|   endif | ||||
|   return b64 | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#imageEncodeDecode(fn, flag) abort | ||||
|   let fn = a:fn | ||||
| 
 | ||||
|   if filereadable(fn) | ||||
|     let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g') | ||||
|   else | ||||
|     if fn !~# '^\w\+://' | ||||
|       let path = fnamemodify(expand('%'), ':p:gs?\\?/?') | ||||
|       if has('win32') || has('win64') | | ||||
|         let path = tolower(path) | ||||
|       endif | ||||
|       for k in keys(g:emmet_docroot) | ||||
|         let root = fnamemodify(k, ':p:gs?\\?/?') | ||||
|         if has('win32') || has('win64') | | ||||
|           let root = tolower(root) | ||||
|         endif | ||||
|         if stridx(path, root) == 0 | ||||
|           let v = g:emmet_docroot[k] | ||||
|           let fn = (len(v) == 0 ? k : v) . fn | ||||
|           break | ||||
|         endif | ||||
|       endfor | ||||
|     endif | ||||
|     let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g') | ||||
|   endif | ||||
| 
 | ||||
|   let bin = map(split(hex, '..\zs'), 'eval("0x" . v:val)') | ||||
|   let table = split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', '\zs') | ||||
|   let ret = 'data:image/' | ||||
|   if hex =~# '^89504e470d0a1a0a' | ||||
|     let ret .= 'png' | ||||
|   elseif hex =~# '^ffd8' | ||||
|     let ret .= 'jpeg' | ||||
|   elseif hex =~# '^47494638' | ||||
|     let ret .= 'gif' | ||||
|   else | ||||
|     let ret .= 'unknown' | ||||
|   endif | ||||
|   return ret . ';base64,' . join(s:b64encode(bin, table, '='), '') | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#unique(arr) abort | ||||
|   let m = {} | ||||
|   let r = [] | ||||
|   for i in a:arr | ||||
|     if !has_key(m, i) | ||||
|       let m[i] = 1 | ||||
|       call add(r, i) | ||||
|     endif | ||||
|   endfor | ||||
|   return r | ||||
| endfunction | ||||
| 
 | ||||
| let s:seed = localtime() | ||||
| function! emmet#util#srand(seed) abort | ||||
|   let s:seed = a:seed | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#rand() abort | ||||
|   let s:seed = s:seed * 214013 + 2531011 | ||||
|   return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000 | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#cache(name, ...) abort | ||||
|   let content = get(a:000, 0, '') | ||||
|   let dir = expand('~/.emmet/cache') | ||||
|   if !isdirectory(dir) | ||||
|     call mkdir(dir, 'p', 0700) | ||||
|   endif | ||||
|   let file = dir . '/' . substitute(a:name, '\W', '_', 'g') | ||||
|   if len(content) == 0 | ||||
|     if !filereadable(file) | ||||
|       return '' | ||||
|     endif | ||||
| 	return join(readfile(file), "\n") | ||||
|   endif | ||||
|   call writefile(split(content, "\n"), file) | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#getcurpos() abort | ||||
|   let pos = getpos('.') | ||||
|   if mode(0) ==# 'i' && pos[2] > 0 | ||||
|     let pos[2] -=1 | ||||
|   endif | ||||
|   return pos | ||||
| endfunction | ||||
| 
 | ||||
| function! emmet#util#closePopup() abort | ||||
|   return pumvisible() ? "\<c-e>" : '' | ||||
| endfunction | ||||
							
								
								
									
										98
									
								
								config/vim/autoload/rainbow_parentheses.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								config/vim/autoload/rainbow_parentheses.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,98 @@ | |||
| "============================================================================== | ||||
| "  Description: Rainbow colors for parentheses, based on rainbow_parenthsis.vim | ||||
| "               by Martin Krischik and others. | ||||
| "               2011-10-12: Use less code.  Leave room for deeper levels. | ||||
| "============================================================================== | ||||
| 
 | ||||
| let s:pairs = [ | ||||
| 	\ ['brown',       'RoyalBlue3'], | ||||
| 	\ ['Darkblue',    'SeaGreen3'], | ||||
| 	\ ['darkgray',    'DarkOrchid3'], | ||||
| 	\ ['darkgreen',   'firebrick3'], | ||||
| 	\ ['darkcyan',    'RoyalBlue3'], | ||||
| 	\ ['darkred',     'SeaGreen3'], | ||||
| 	\ ['darkmagenta', 'DarkOrchid3'], | ||||
| 	\ ['brown',       'firebrick3'], | ||||
| 	\ ['gray',        'RoyalBlue3'], | ||||
| 	\ ['black',       'SeaGreen3'], | ||||
| 	\ ['darkmagenta', 'DarkOrchid3'], | ||||
| 	\ ['Darkblue',    'firebrick3'], | ||||
| 	\ ['darkgreen',   'RoyalBlue3'], | ||||
| 	\ ['darkcyan',    'SeaGreen3'], | ||||
| 	\ ['darkred',     'DarkOrchid3'], | ||||
| 	\ ['red',         'firebrick3'], | ||||
| 	\ ] | ||||
| let s:pairs = exists('g:rbpt_colorpairs') ? g:rbpt_colorpairs : s:pairs | ||||
| let s:max = exists('g:rbpt_max') ? g:rbpt_max : max([len(s:pairs), 16]) | ||||
| let s:loadtgl = exists('g:rbpt_loadcmd_toggle') ? g:rbpt_loadcmd_toggle : 0 | ||||
| let s:types = [['(',')'],['\[','\]'],['{','}'],['<','>']] | ||||
| 
 | ||||
| func! s:extend() | ||||
| 	if s:max > len(s:pairs) | ||||
| 		cal extend(s:pairs, s:pairs) | ||||
| 		cal s:extend() | ||||
| 	elseif s:max < len(s:pairs) | ||||
| 		cal remove(s:pairs, s:max, -1) | ||||
| 	endif | ||||
| endfunc | ||||
| cal s:extend() | ||||
| 
 | ||||
| func! rainbow_parentheses#activate() | ||||
| 	let [id, s:active] = [1, 1] | ||||
| 	for [ctermfg, guifg] in s:pairs | ||||
| 		exe 'hi default level'.id.'c ctermfg='.ctermfg.' guifg='.guifg | ||||
| 		let id += 1 | ||||
| 	endfor | ||||
| endfunc | ||||
| 
 | ||||
| func! rainbow_parentheses#clear() | ||||
| 	for each in range(1, s:max) | ||||
| 		exe 'hi clear level'.each.'c' | ||||
| 	endfor | ||||
| 	let s:active = 0 | ||||
| endfunc | ||||
| 
 | ||||
| func! rainbow_parentheses#toggle() | ||||
| 	if !exists('s:active') | ||||
| 		cal rainbow_parentheses#load(0) | ||||
| 	endif | ||||
| 	let afunc = exists('s:active') && s:active ? 'clear' : 'activate' | ||||
| 	cal call('rainbow_parentheses#'.afunc, []) | ||||
| endfunc | ||||
| 
 | ||||
| func! rainbow_parentheses#toggleall() | ||||
| 	if !exists('s:active') | ||||
| 		cal rainbow_parentheses#load(0) | ||||
| 		cal rainbow_parentheses#load(1) | ||||
| 		cal rainbow_parentheses#load(2) | ||||
| 	endif | ||||
| 	if exists('s:active') && s:active | ||||
| 		cal rainbow_parentheses#clear() | ||||
| 	else | ||||
| 		cal rainbow_parentheses#activate() | ||||
| 	endif | ||||
| endfunc | ||||
| 
 | ||||
| func! s:cluster() | ||||
| 	let levels = join(map(range(1, s:max), '"level".v:val'), ',') | ||||
| 	exe 'sy cluster rainbow_parentheses contains=@TOP'.levels.',NoInParens' | ||||
| endfunc | ||||
| cal s:cluster() | ||||
| 
 | ||||
| func! rainbow_parentheses#load(...) | ||||
| 	let [level, grp, type] = ['', '', s:types[a:1]] | ||||
| 	let alllvls = map(range(1, s:max), '"level".v:val') | ||||
| 	if !exists('b:loaded') | ||||
| 		let b:loaded = [0,0,0,0] | ||||
| 	endif | ||||
| 	let b:loaded[a:1] = s:loadtgl && b:loaded[a:1] ? 0 : 1 | ||||
| 	for each in range(1, s:max) | ||||
| 		let region = 'level'. each .(b:loaded[a:1] ? '' : 'none') | ||||
| 		let grp = b:loaded[a:1] ? 'level'.each.'c' : 'Normal' | ||||
| 		let cmd = 'sy region %s matchgroup=%s start=/%s/ end=/%s/ contains=TOP,%s,NoInParens' | ||||
| 		exe printf(cmd, region, grp, type[0], type[1], join(alllvls, ',')) | ||||
| 		cal remove(alllvls, 0) | ||||
| 	endfor | ||||
| endfunc | ||||
| 
 | ||||
| " vim:ts=2:sw=2:sts=2 | ||||
							
								
								
									
										62
									
								
								config/vim/plugin/colorizer.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								config/vim/plugin/colorizer.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,62 @@ | |||
| " colorizer.vim	Colorize all text in the form #rrggbb or #rgb; entrance | ||||
| " Maintainer:	lilydjwg <lilydjwg@gmail.com> | ||||
| " Version:	1.4.1 | ||||
| " Licence:	Vim license. See ':help license' | ||||
| " Derived From: css_color.vim | ||||
| " 		http://www.vim.org/scripts/script.php?script_id=2150 | ||||
| " Thanks To:	Niklas Hofer (Author of css_color.vim), Ingo Karkat, rykka, | ||||
| "		KrzysztofUrban, blueyed, shanesmith | ||||
| " Usage: | ||||
| " | ||||
| " This plugin defines three commands: | ||||
| " | ||||
| " 	ColorHighlight	- start/update highlighting | ||||
| " 	ColorClear      - clear all highlights | ||||
| " 	ColorToggle     - toggle highlights | ||||
| " | ||||
| " By default, <leader>tc is mapped to ColorToggle. If you want to use another | ||||
| " key map, do like this: | ||||
| " 	nmap ,tc <Plug>Colorizer | ||||
| " | ||||
| " If you want completely not to map it, set the following in your vimrc: | ||||
| "	let g:colorizer_nomap = 1 | ||||
| " | ||||
| " To use solid color highlight, set this in your vimrc (later change won't | ||||
| " probably take effect unless you use ':ColorHighlight!' to force update): | ||||
| "	let g:colorizer_fgcontrast = -1 | ||||
| " set it to 0 or 1 to use a softened foregroud color. | ||||
| " | ||||
| " If you don't want to enable colorizer at startup, set the following: | ||||
| "	let g:colorizer_startup = 0 | ||||
| " | ||||
| " Note: if you modify a color string in normal mode, if the cursor is still on | ||||
| " that line, it'll take 'updatetime' seconds to update. You can use | ||||
| " :ColorHighlight (or your key mapping) again to force update. | ||||
| " | ||||
| " Performace Notice: In terminal, it may take several seconds to highlight 240 | ||||
| " different colors. GUI version is much quicker. | ||||
| 
 | ||||
| " Reload guard and 'compatible' handling {{{1 | ||||
| if exists("loaded_colorizer") || v:version < 700 || !(has("gui_running") || &t_Co == 256) | ||||
|   finish | ||||
| endif | ||||
| let loaded_colorizer = 1 | ||||
| 
 | ||||
| let s:save_cpo = &cpo | ||||
| set cpo&vim | ||||
| 
 | ||||
| "Define commands {{{1 | ||||
| command! -bar -bang ColorHighlight call colorizer#ColorHighlight(1, "<bang>") | ||||
| command! -bar ColorClear call colorizer#ColorClear() | ||||
| command! -bar ColorToggle call colorizer#ColorToggle() | ||||
| nnoremap <silent> <Plug>Colorizer :ColorToggle<CR> | ||||
| if !hasmapto("<Plug>Colorizer") && (!exists("g:colorizer_nomap") || g:colorizer_nomap == 0) | ||||
|   nmap <unique> <Leader>tc <Plug>Colorizer | ||||
| endif | ||||
| if !exists('g:colorizer_startup') || g:colorizer_startup | ||||
|   call colorizer#ColorHighlight(0) | ||||
| endif | ||||
| 
 | ||||
| " Cleanup and modelines {{{1 | ||||
| let &cpo = s:save_cpo | ||||
| " vim:ft=vim:fdm=marker:fmr={{{,}}}: | ||||
							
								
								
									
										191
									
								
								config/vim/plugin/emmet.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										191
									
								
								config/vim/plugin/emmet.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,191 @@ | |||
| "============================================================================= | ||||
| " File: emmet.vim | ||||
| " Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> | ||||
| " Last Change: 26-Jul-2015. | ||||
| " Version: 0.86 | ||||
| " WebPage: http://github.com/mattn/emmet-vim | ||||
| " Description: vim plugins for HTML and CSS hi-speed coding. | ||||
| " SeeAlso: http://emmet.io/ | ||||
| " Usage: | ||||
| " | ||||
| "   This is vim script support expanding abbreviation like emmet. | ||||
| "   ref: http://emmet.io/ | ||||
| " | ||||
| "   Type abbreviation | ||||
| "      +------------------------------------- | ||||
| "      | html:5_ | ||||
| "      +------------------------------------- | ||||
| "   "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma) | ||||
| "   NOTE: Don't worry about key map. you can change it easily. | ||||
| "      +------------------------------------- | ||||
| "      | <!DOCTYPE HTML> | ||||
| "      | <html lang="en"> | ||||
| "      | <head> | ||||
| "      |     <title></title> | ||||
| "      |     <meta charset="UTF-8"> | ||||
| "      | </head> | ||||
| "      | <body> | ||||
| "      |      _ | ||||
| "      | </body> | ||||
| "      | </html> | ||||
| "      +------------------------------------- | ||||
| "   Type following | ||||
| "      +------------------------------------- | ||||
| "      | div#foo$*2>div.bar | ||||
| "      +------------------------------------- | ||||
| "   And type "<c-y>," | ||||
| "      +------------------------------------- | ||||
| "      |<div id="foo1"> | ||||
| "      |    <div class="bar">_</div> | ||||
| "      |</div> | ||||
| "      |<div id="foo2"> | ||||
| "      |    <div class="bar"></div> | ||||
| "      |</div> | ||||
| "      +------------------------------------- | ||||
| " | ||||
| " Tips: | ||||
| " | ||||
| "   You can customize behavior of expanding with overriding config. | ||||
| "   This configuration will be merged at loading plugin. | ||||
| " | ||||
| "     let g:user_emmet_settings = { | ||||
| "     \  'indentation' : '  ', | ||||
| "     \  'perl' : { | ||||
| "     \    'aliases' : { | ||||
| "     \      'req' : 'require ' | ||||
| "     \    }, | ||||
| "     \    'snippets' : { | ||||
| "     \      'use' : "use strict\nuse warnings\n\n", | ||||
| "     \      'warn' : "warn \"|\";", | ||||
| "     \    } | ||||
| "     \  } | ||||
| "     \} | ||||
| " | ||||
| "   You can set language attribute in html using 'emmet_settings.lang'. | ||||
| " | ||||
| " GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim | ||||
| " script type: plugin | ||||
| 
 | ||||
| if &compatible || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim) | ||||
|   finish | ||||
| endif | ||||
| let g:loaded_emmet_vim = 1 | ||||
| 
 | ||||
| let s:save_cpo = &cpoptions | ||||
| set cpoptions&vim | ||||
| 
 | ||||
| if !exists('g:emmet_html5') | ||||
|   let g:emmet_html5 = 1 | ||||
| endif | ||||
| 
 | ||||
| if !exists('g:emmet_docroot') | ||||
|   let g:emmet_docroot = {} | ||||
| endif | ||||
| 
 | ||||
| if !exists('g:emmet_debug') | ||||
|   let g:emmet_debug = 0 | ||||
| endif | ||||
| 
 | ||||
| if !exists('g:emmet_curl_command') | ||||
|   let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0' | ||||
| endif | ||||
| 
 | ||||
| if !exists('g:user_emmet_leader_key') | ||||
|   let g:user_emmet_leader_key = '<c-y>' | ||||
| endif | ||||
| 
 | ||||
| function! s:install_plugin(mode, buffer) | ||||
|   let buffer = a:buffer ? '<buffer>' : '' | ||||
|   let items = [ | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(0,"")<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(3,"")<cr>'}, | ||||
|   \ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(2,"")<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(1,"")<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': ':call emmet#expandAbbr(1,"")<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#updateTag()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': ':call emmet#updateTag()<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(1)<cr>'}, | ||||
|   \ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'}, | ||||
|   \ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(0)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(1)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': ':call emmet#moveNextPrev(1)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': '<esc>:call emmet#moveNextPrevItem(0)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': ':call emmet#moveNextPrevItem(0)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': '<esc>:call emmet#moveNextPrevItem(1)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': ':call emmet#moveNextPrevItem(1)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageSize()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': ':call emmet#imageSize()<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageEncode()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': ':call emmet#imageEncode()<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#toggleComment()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': ':call emmet#toggleComment()<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': '<esc>:call emmet#splitJoinTag()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': ':call emmet#splitJoinTag()<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#removeTag()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': ':call emmet#removeTag()<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(0)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'}, | ||||
|   \ {'mode': 'i', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#mergeLines()<cr>'}, | ||||
|   \ {'mode': 'n', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'}, | ||||
|   \ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'}, | ||||
|   \] | ||||
| 
 | ||||
|   let only_plug = get(g:, 'emmet_install_only_plug', 0) | ||||
|   for item in items | ||||
|     if a:mode !=# 'a' && stridx(a:mode, item.mode) == -1 | ||||
|       continue | ||||
|     endif | ||||
|     exe item.mode . 'noremap '. buffer .' <plug>(' . item.plug . ') ' . item.func | ||||
|     if item.var != '' && !only_plug | ||||
|       if exists('g:' . item.var) | ||||
|         let key = eval('g:' . item.var) | ||||
|       else | ||||
|         let key = g:user_emmet_leader_key . item.key | ||||
|       endif | ||||
|       if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode)) | ||||
|         exe item.mode . 'map ' . buffer . ' <unique> ' . key . ' <plug>(' . item.plug . ')' | ||||
|       endif | ||||
|     endif | ||||
|   endfor | ||||
| 
 | ||||
|   if exists('g:user_emmet_complete_tag') && g:user_emmet_complete_tag | ||||
|     if get(g:, 'user_emmet_install_global', 1) | ||||
|       set omnifunc=emmet#completeTag | ||||
|     else | ||||
|       setlocal omnifunc=emmet#completeTag | ||||
|     endif | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| command! -nargs=0 -bar EmmetInstall call <SID>install_plugin(get(g:, 'user_emmet_mode', 'a'), 1) | ||||
| 
 | ||||
| if get(g:, 'user_emmet_install_global', 1) | ||||
|   call s:install_plugin(get(g:, 'user_emmet_mode', 'a'), 0) | ||||
| endif | ||||
| 
 | ||||
| if get(g:, 'user_emmet_install_command', 1) | ||||
|   command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>) | ||||
| endif | ||||
| 
 | ||||
| function! s:setup_styledEmmetAbbreviation() abort | ||||
|   if index(['javascript', 'javascriptreact', 'typescript', 'typescriptreact'], &filetype) != -1 | ||||
|     syntax match styledEmmetAbbreviation "[a-z0-9#+!%]\+" containedin=styledDefinition contained | ||||
|   endif | ||||
| endfunction | ||||
| 
 | ||||
| augroup ___emmet_setup___ | ||||
|   au! | ||||
|   autocmd Syntax * call s:setup_styledEmmetAbbreviation() | ||||
| augroup END | ||||
| 
 | ||||
| let &cpoptions = s:save_cpo | ||||
| unlet s:save_cpo | ||||
| 
 | ||||
| " vim:set et: | ||||
							
								
								
									
										45
									
								
								config/vim/plugin/pickachu.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								config/vim/plugin/pickachu.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| "Script: Pickachu | ||||
| "Version: 0.0.1 | ||||
| "Copyright: Copyright (C) 2018 Doug Beney | ||||
| "Licence:  | ||||
| "Website: https://dougie.io | ||||
| 
 | ||||
| if !has('python3') | ||||
| 	echo "You need Vim Python3 support to use this plugin. If you're using NeoVim, try running `pip3 install neovim` to resolve this issue." | ||||
| endif | ||||
| 
 | ||||
| if !exists('g:pickachu_default_app') | ||||
| 	let g:pickachu_default_app = "color" | ||||
| endif | ||||
| 
 | ||||
| if !exists("g:pickachu_default_command") | ||||
| 	let g:pickachu_default_command = "zenity" | ||||
| endif | ||||
| 
 | ||||
| if !exists("g:pickachu_default_date_format") | ||||
| 	let g:pickachu_default_date_format = "%m/%d/%Y" | ||||
| endif | ||||
| 
 | ||||
| if !exists("g:pickachu_default_color_format") | ||||
| 	let g:pickachu_default_color_format = "hex" | ||||
| endif | ||||
| 
 | ||||
| function! s:pickachuCompletion(ArgLead, CmdLine, CursorPos) | ||||
| 	let options = ['color', 'date', 'file'] | ||||
| 	return options | ||||
| endfunction | ||||
| 
 | ||||
| command! -nargs=* -complete=customlist,<SID>pickachuCompletion Pickachu call Pickachu(<f-args>) | ||||
| 
 | ||||
| python3 import sys | ||||
| python3 import vim | ||||
| python3 sys.path.append(vim.eval('expand("<sfile>:h")')) | ||||
| 
 | ||||
| function! Pickachu(...) | ||||
| python3 << EOF | ||||
| from pickachu.main import MainFunction | ||||
| MainFunction() | ||||
| EOF | ||||
| endfunction | ||||
| 
 | ||||
| " vim: noexpandtab | ||||
							
								
								
									
										0
									
								
								config/vim/plugin/pickachu/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								config/vim/plugin/pickachu/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										68
									
								
								config/vim/plugin/pickachu/apps.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								config/vim/plugin/pickachu/apps.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,68 @@ | |||
| import vim | ||||
| import subprocess | ||||
| from . import processors | ||||
| 
 | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| # name:        apps.py | ||||
| # description: this function contains a dictionary object | ||||
| #              where you can easily add new apps with processor | ||||
| #              functions to handle their output. Note: a | ||||
| #              processor is optional. | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| 
 | ||||
| ZENITY_COMMAND = vim.eval("g:pickachu_default_command") | ||||
| # Note: This is not the final date format that displays on | ||||
| #       the users' buffer. This is the format we force | ||||
| #       Zenity/Qarma to provide us. | ||||
| RETURNED_DATE_FORMAT = "%m/%d/%Y" | ||||
| if ZENITY_COMMAND == 'qarma': | ||||
| 	RETURNED_DATE_FORMAT = "MM/dd/yy" | ||||
| 
 | ||||
| apps = { | ||||
| 	'date': { | ||||
| 		'cmd': ZENITY_COMMAND, | ||||
| 		'processor': processors.dateProcessor, | ||||
| 		'options': [ | ||||
| 			'--calendar', | ||||
| 			'--date-format=' + RETURNED_DATE_FORMAT | ||||
| 		] | ||||
| 	}, | ||||
| 	'file': { | ||||
| 		'cmd': ZENITY_COMMAND, | ||||
| 		'options': [ | ||||
|             '--file-selection' | ||||
|         ] | ||||
| 	}, | ||||
| 	'color': { | ||||
| 		'cmd': ZENITY_COMMAND, | ||||
| 		'options': [ | ||||
| 			'--color-selection' | ||||
|     ], | ||||
| 		'processor': processors.colorProcessor | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| def runApp(choosenApp, format=None): | ||||
| 	app = apps.get(choosenApp, None) | ||||
| 	if app: | ||||
| 		output = None | ||||
| 		try: | ||||
| 			command_array = [app['cmd']] | ||||
| 			if app.get('options', False): | ||||
| 				for option in app['options']: | ||||
| 					command_array.append(option) | ||||
| 			# Logging | ||||
| 			command_array.append('2> /tmp/pickachu_log') | ||||
| 			output = subprocess.check_output(command_array).decode('utf-8') | ||||
| 		except: | ||||
| 			return None | ||||
| 
 | ||||
| 		if app.get('processor', None): | ||||
| 			if format: | ||||
| 				return app['processor'](output.rstrip(), format) | ||||
| 			else: | ||||
| 				return app['processor'](output.rstrip()) | ||||
| 		else: | ||||
| 			return output.rstrip() | ||||
| 	else: | ||||
| 		print("App does not exist.") | ||||
							
								
								
									
										36
									
								
								config/vim/plugin/pickachu/main.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								config/vim/plugin/pickachu/main.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| import vim | ||||
| from . import apps | ||||
| 
 | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| # name:        main.py | ||||
| # description: This file evaluates the command arguments | ||||
| #              provided by the user, calls the runApp function, | ||||
| #              and inserts valid output to the user's buffer. | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| 
 | ||||
| DEFAULT_APP = vim.eval('g:pickachu_default_app') | ||||
| 
 | ||||
| 
 | ||||
| def MainFunction(): | ||||
| 	# This section is for getting the | ||||
| 	# arguments from the user's Vim | ||||
| 	# command. | ||||
| 	arglength = int(vim.eval('a:0')) | ||||
| 	CHOOSEN_APP = DEFAULT_APP | ||||
| 	CHOOSEN_FORMAT = None | ||||
| 	if arglength > 0: | ||||
| 		CHOOSEN_APP = vim.eval('a:1') | ||||
| 	if arglength > 1: | ||||
| 		CHOOSEN_FORMAT = vim.eval('a:2') | ||||
| 
 | ||||
| 	# We run apps.py's runApp function to get an output. | ||||
| 	output = apps.runApp(CHOOSEN_APP, CHOOSEN_FORMAT) | ||||
| 
 | ||||
| 	# Now, if runApp gave us an output, we can use the | ||||
| 	# Vim API to print the output to the user's buffer. | ||||
| 	if output: | ||||
| 		pos_y, pos_x = vim.current.window.cursor | ||||
| 		vim.current.line = vim.current.line[:pos_x+1] + output + vim.current.line[pos_x+1:] | ||||
| 		vim.current.window.cursor = (pos_y, pos_x + len(output)) | ||||
| 	else: | ||||
| 		print('Pickachu - Canceled') | ||||
							
								
								
									
										80
									
								
								config/vim/plugin/pickachu/processors.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								config/vim/plugin/pickachu/processors.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,80 @@ | |||
| import vim | ||||
| from datetime import datetime | ||||
| 
 | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| # name:				 processors.py | ||||
| # description: this file contains functions that process data | ||||
| #							 from the runapp function (in app.py). | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| 
 | ||||
| DEFAULT_DATE_FORMAT = vim.eval("g:pickachu_default_date_format") | ||||
| DEFAULT_COLOR_FORMAT = vim.eval("g:pickachu_default_color_format") | ||||
| 
 | ||||
| def dateProcessor(input, format=DEFAULT_DATE_FORMAT): | ||||
| 	try: | ||||
| 		dateObj = datetime.strptime(input, '%m/%d/%Y') | ||||
| 	except(ValueError): | ||||
| 		dateObj = datetime.strptime(input, '%m/%d/%y') | ||||
| 	return dateObj.strftime(format) | ||||
| 
 | ||||
| def colorProcessor(input, format=DEFAULT_COLOR_FORMAT): | ||||
| 	# The system color picker returned an rgba value | ||||
| 	if 'rgba' in input: | ||||
| 		strip = input.strip('rgba)(') | ||||
| 		array = strip.split(',') | ||||
| 		# Round the alpha value to two decimal placed | ||||
| 		array[3] = round(float(array[3]), 2) | ||||
| 		rgba_string = "rgba(" | ||||
| 		values = ",".join(str(x) for x in array) | ||||
| 		rgba_string += values + ")" | ||||
| 		return rgba_string | ||||
| 	# The system color picker returned an rgb value | ||||
| 	elif 'rgb' in input: | ||||
| 		# RGB as input | ||||
| 		if format == 'rgb': | ||||
| 			return input | ||||
| 		else: | ||||
| 			# Strip 'rgb' and parenthesis | ||||
| 			strip = input.strip('rgb)(') | ||||
| 			array = strip.split(',') | ||||
| 
 | ||||
| 			if format == 'hex': | ||||
| 				hex = '#%02x%02x%02x' % (int(array[0]), int(array[1]), int(array[2])) | ||||
| 				return hex.upper() | ||||
| 			elif format == 'rgba': | ||||
| 				rgba_string = "rgba(" | ||||
| 				array.append(1) | ||||
| 				values = ",".join(str(x) for x in array) | ||||
| 				rgba_string += values + ")" | ||||
| 				return rgba_string | ||||
| 		return array | ||||
| 	# The system olor picker returned a hex | ||||
| 	elif '#' in input: | ||||
| 		# If there is a '#' in input, | ||||
| 		# they are most likely using Qarma instead of Zenity | ||||
| 		# or any other program that outputs hex | ||||
| 		if format == 'hex': | ||||
| 			return input | ||||
| 		else: | ||||
| 			hex = input.lstrip('#') | ||||
| 			rgb_array = tuple(int(hex[i:i+2], 16) for i in (0, 2 ,4)) | ||||
| 
 | ||||
| 			if format == 'rgb': | ||||
| 				rgb_string = "rgb(" | ||||
| 				for i in range(0, len(rgb_array)): | ||||
| 					rgb_string += str(rgb_array[i]) | ||||
| 					if i < len(rgb_array) - 1: | ||||
| 						rgb_string += ", " | ||||
| 					else: | ||||
| 						rgb_string += ")" | ||||
| 				return rgb_string | ||||
| 			elif format == 'rgba': | ||||
| 				rgba_string = "rgba(" | ||||
| 				for i in range(0, len(rgb_array)): | ||||
| 					rgba_string += str(rgb_array[i]) | ||||
| 					if i < len(rgb_array) - 1: | ||||
| 						rgba_string += ", " | ||||
| 					else: | ||||
| 						rgba_string += ", 1)" | ||||
| 				return rgba_string | ||||
| 	return None | ||||
							
								
								
									
										13
									
								
								config/vim/plugin/rainbow_parentheses.vim
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								config/vim/plugin/rainbow_parentheses.vim
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| "============================================================================== | ||||
| "  Description: Rainbow colors for parentheses, based on rainbow_parenthsis.vim | ||||
| "               by Martin Krischik and others. | ||||
| "============================================================================== | ||||
| "  GetLatestVimScripts: 3772 1 :AutoInstall: rainbow_parentheses.zip | ||||
| 
 | ||||
| com! RainbowParenthesesToggle       cal rainbow_parentheses#toggle() | ||||
| com! RainbowParenthesesToggleAll    cal rainbow_parentheses#toggleall() | ||||
| com! RainbowParenthesesActivate     cal rainbow_parentheses#activate() | ||||
| com! RainbowParenthesesLoadRound    cal rainbow_parentheses#load(0) | ||||
| com! RainbowParenthesesLoadSquare   cal rainbow_parentheses#load(1) | ||||
| com! RainbowParenthesesLoadBraces   cal rainbow_parentheses#load(2) | ||||
| com! RainbowParenthesesLoadChevrons cal rainbow_parentheses#load(3) | ||||
							
								
								
									
										
											BIN
										
									
								
								config/vim/spell/fr.utf-8.spl
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/spell/fr.utf-8.spl
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								config/vim/spell/fr.utf-8.sug
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/spell/fr.utf-8.sug
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								config/vim/viminfo
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								config/vim/viminfo
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										34
									
								
								config/vim/vimrc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								config/vim/vimrc
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| set viminfo+=n~/.config/vim/viminfo | ||||
| set runtimepath+=~/.config/vim,~/.config/vim/after | ||||
| set autoindent | ||||
| set wrap | ||||
| set linebreak | ||||
| set mouse=a | ||||
| set autowrite | ||||
| 
 | ||||
| set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab | ||||
| 
 | ||||
| set nocompatible | ||||
| 
 | ||||
| set spelllang=en_gb | ||||
| 
 | ||||
| set number relativenumber | ||||
| 
 | ||||
| syntax on  | ||||
| 
 | ||||
| nnoremap <silent> <C-l> :nohl<CR><C-l> | ||||
| 
 | ||||
| inoremap { {}<ESC>ha | ||||
| inoremap [ []<ESC>ha | ||||
| inoremap " ""<ESC>ha | ||||
| inoremap ( ()<ESC>ha | ||||
| 
 | ||||
| inoremap <C-space> <C-n> | ||||
| 
 | ||||
| inoremap <C-down> <C-E> | ||||
| inoremap <C-up> <C-Y> | ||||
| 
 | ||||
| nnoremap <C-J> <C-W><C-J> | ||||
| nnoremap <C-K> <C-W><C-K> | ||||
| nnoremap <C-L> <C-W><C-L> | ||||
| nnoremap <C-H> <C-W><C-H> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue