Merge pull request #43 from mattn/use-setlocal

Use setlocal
This commit is contained in:
Konstantin
2019-12-18 20:41:51 +01:00
committed by GitHub

View File

@@ -122,11 +122,11 @@ function! s:VimCssInit(update)
if a:update==1 if a:update==1
call s:ClearMatches() call s:ClearMatches()
endif endif
:set isk+=- setlocal isk+=-
:set isk+=# setlocal isk+=#
:set isk+=. setlocal isk+=.
if !exists("b:color_pattern") if !exists('b:color_pattern')
let b:color_pattern = {} let b:color_pattern = {}
return return
endif endif
@@ -333,12 +333,12 @@ function! s:PreviewCSSColor(str)
for exp in keys(colorexps) for exp in keys(colorexps)
let place=0 let place=0
if exists("foundcolor") if exists('foundcolor')
unlet foundcolor unlet foundcolor
endif endif
while 1 while 1
if exp=='rgba'||exp=='hsla' if exp ==# 'rgba' || exp ==# 'hsla'
let foundcolor = matchlist(a:str, colorexps[exp], place) let foundcolor = matchlist(a:str, colorexps[exp], place)
else else
let foundcolor = matchstr(a:str, colorexps[exp], place) let foundcolor = matchstr(a:str, colorexps[exp], place)
@@ -350,21 +350,21 @@ function! s:PreviewCSSColor(str)
break break
endif endif
if exp=='hex' if exp ==# 'hex'
let part = foundcolor.'\>' let part = foundcolor.'\>'
else else
let part = foundcolor[0] let part = foundcolor[0]
endif endif
if exp=='hex' if exp ==# 'hex'
if len(foundcolor) == 4 if len(foundcolor) == 4
let foundcolor = substitute(foundcolor, '[[:xdigit:]]', '&&', 'g') let foundcolor = substitute(foundcolor, '[[:xdigit:]]', '&&', 'g')
endif endif
call s:MatchColorValue(strpart(foundcolor, 1), part) call s:MatchColorValue(strpart(foundcolor, 1), part)
elseif exp=='rgba' elseif exp ==# 'rgba'
"TODO get rid of duplicated variables "TODO get rid of duplicated variables
call s:MatchColorValue(s:HexForRGBValue(foundcolor[1], foundcolor[2], foundcolor[3]), part) call s:MatchColorValue(s:HexForRGBValue(foundcolor[1], foundcolor[2], foundcolor[3]), part)
elseif exp=='hsla' elseif exp ==# 'hsla'
call s:MatchColorValue(s:HexForHSLValue(foundcolor[1], foundcolor[2], foundcolor[3]), part) call s:MatchColorValue(s:HexForHSLValue(foundcolor[1], foundcolor[2], foundcolor[3]), part)
endif endif
endwhile endwhile
@@ -372,14 +372,14 @@ function! s:PreviewCSSColor(str)
endfunction endfunction
if has("gui_running") || &t_Co==256 if has('gui_running') || &t_Co==256
" HACK modify cssDefinition to add @cssColors to its contains " HACK modify cssDefinition to add @cssColors to its contains
redir => cssdef redir => cssdef
silent! syn list cssDefinition silent! syn list cssDefinition
redir END redir END
if len( cssdef ) if len( cssdef )
for out in split( cssdef, "\n" ) for out in split( cssdef, "\n" )
if out !~ '^cssDefinition ' | continue | endif if out !~# '^cssDefinition ' | continue | endif
let out = substitute( out, ' \+xxx \+', ' ', '' ) let out = substitute( out, ' \+xxx \+', ' ', '' )
let out = substitute( out, ' contains=\zs', '@cssColors,', '' ) let out = substitute( out, ' contains=\zs', '@cssColors,', '' )
exe 'syn region' out exe 'syn region' out
@@ -627,12 +627,12 @@ if has("gui_running") || &t_Co==256
"call s:VimCssInit(1) "call s:VimCssInit(1)
":augroup css augroup coloresque
"au! au!
autocmd CursorMovedI <buffer> silent call s:ProcessByLine('.') autocmd CursorMovedI <buffer> silent call s:ProcessByLine('.')
autocmd ColorScheme <buffer> silent call s:VimCssInit(1) autocmd ColorScheme <buffer> silent call s:VimCssInit(1)
autocmd BufEnter <buffer> silent call s:VimCssInit(1) autocmd BufEnter <buffer> silent call s:VimCssInit(1)
":augroup END augroup END
"autocmd CursorMoved <buffer> silent call s:ProcessByLine('.') "autocmd CursorMoved <buffer> silent call s:ProcessByLine('.')
endif endif