From f68431980473f34e47ce7feb6e91337d72385e94 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 18 Dec 2019 20:00:33 +0900 Subject: [PATCH 1/3] Use setlocal --- after/syntax/css/vim-coloresque.vim | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/after/syntax/css/vim-coloresque.vim b/after/syntax/css/vim-coloresque.vim index e02d60d..2dd4ab2 100644 --- a/after/syntax/css/vim-coloresque.vim +++ b/after/syntax/css/vim-coloresque.vim @@ -63,7 +63,7 @@ function! s:MatchColorValue(color, part) if !exists('b:color_pattern[a:part]') exe s:fg_color_calc exe 'syn cluster cssColors add='.group - exe 'hi' group s:color_prefix.'bg='.color s:color_prefix.'fg='.s:FGForBG(a:color) + exe 'hi' group s:color_prefix.'bg='.a:color s:color_prefix.'fg='.s:FGForBG(a:color) let b:color_pattern[a:part] = a:color endif @@ -122,11 +122,11 @@ function! s:VimCssInit(update) if a:update==1 call s:ClearMatches() endif - :set isk+=- - :set isk+=# - :set isk+=. + setlocal isk+=- + setlocal isk+=# + setlocal isk+=. - if !exists("b:color_pattern") + if !exists('b:color_pattern') let b:color_pattern = {} return endif @@ -333,12 +333,12 @@ function! s:PreviewCSSColor(str) for exp in keys(colorexps) let place=0 - if exists("foundcolor") + if exists('foundcolor') unlet foundcolor endif while 1 - if exp=='rgba'||exp=='hsla' + if exp ==# 'rgba' || exp ==# 'hsla' let foundcolor = matchlist(a:str, colorexps[exp], place) else let foundcolor = matchstr(a:str, colorexps[exp], place) @@ -350,21 +350,21 @@ function! s:PreviewCSSColor(str) break endif - if exp=='hex' + if exp ==# 'hex' let part = foundcolor.'\>' else let part = foundcolor[0] endif - if exp=='hex' + if exp ==# 'hex' if len(foundcolor) == 4 let foundcolor = substitute(foundcolor, '[[:xdigit:]]', '&&', 'g') endif call s:MatchColorValue(strpart(foundcolor, 1), part) - elseif exp=='rgba' + elseif exp ==# 'rgba' "TODO get rid of duplicated variables 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) endif endwhile @@ -372,14 +372,14 @@ function! s:PreviewCSSColor(str) endfunction -if has("gui_running") || &t_Co==256 +if has('gui_running') || &t_Co==256 " HACK modify cssDefinition to add @cssColors to its contains redir => cssdef silent! syn list cssDefinition redir END if len( cssdef ) 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, ' contains=\zs', '@cssColors,', '' ) exe 'syn region' out @@ -627,12 +627,12 @@ if has("gui_running") || &t_Co==256 "call s:VimCssInit(1) - ":augroup css - "au! + augroup css + au! autocmd CursorMovedI silent call s:ProcessByLine('.') autocmd ColorScheme silent call s:VimCssInit(1) autocmd BufEnter silent call s:VimCssInit(1) - ":augroup END + augroup END "autocmd CursorMoved silent call s:ProcessByLine('.') endif From 1b0ac60272067ffbe2e298bffc4dc6fc9a201203 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 18 Dec 2019 20:04:10 +0900 Subject: [PATCH 2/3] Fix augroup name --- after/syntax/css/vim-coloresque.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/after/syntax/css/vim-coloresque.vim b/after/syntax/css/vim-coloresque.vim index 2dd4ab2..9126212 100644 --- a/after/syntax/css/vim-coloresque.vim +++ b/after/syntax/css/vim-coloresque.vim @@ -627,7 +627,7 @@ if has('gui_running') || &t_Co==256 "call s:VimCssInit(1) - augroup css + augroup coloresque au! autocmd CursorMovedI silent call s:ProcessByLine('.') autocmd ColorScheme silent call s:VimCssInit(1) From 2ae04bf55d6bff6d07038835cd03d11e709dc79d Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 18 Dec 2019 20:11:22 +0900 Subject: [PATCH 3/3] a:color should be color --- after/syntax/css/vim-coloresque.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/after/syntax/css/vim-coloresque.vim b/after/syntax/css/vim-coloresque.vim index 9126212..e8dce8d 100644 --- a/after/syntax/css/vim-coloresque.vim +++ b/after/syntax/css/vim-coloresque.vim @@ -63,7 +63,7 @@ function! s:MatchColorValue(color, part) if !exists('b:color_pattern[a:part]') exe s:fg_color_calc exe 'syn cluster cssColors add='.group - exe 'hi' group s:color_prefix.'bg='.a:color s:color_prefix.'fg='.s:FGForBG(a:color) + exe 'hi' group s:color_prefix.'bg='.color s:color_prefix.'fg='.s:FGForBG(a:color) let b:color_pattern[a:part] = a:color endif