diff --git a/autoload/SpaceVim/api/vim/highlight.vim b/autoload/SpaceVim/api/vim/highlight.vim index 6daab2df0..1d234ef3d 100644 --- a/autoload/SpaceVim/api/vim/highlight.vim +++ b/autoload/SpaceVim/api/vim/highlight.vim @@ -161,6 +161,16 @@ function! s:self.syntax_at(...) abort return synIDattr(synID(l:lnum, l:col, 1), 'name') endfunction +let s:string_hi = { + \ 'c' : 'cCppString', + \ 'cpp' : 'cCppString', + \ 'python' : 'pythonString', + \ } + +function! s:self.is_string(l, c) abort + return synIDattr(synID(a:l, a:c, 1), 'name') == get(s:string_hi, &filetype, &filetype . 'String') +endfunction + function! s:self.syntax_of(pattern, ...) abort if a:0 < 1 let l:nth = 1 diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 1035458bb..30e68ac34 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -48,6 +48,7 @@ let s:FILE = SpaceVim#api#import('file') let s:MESSAGE = SpaceVim#api#import('vim#message') let s:CMP = SpaceVim#api#import('vim#compatible') let s:NOTI = SpaceVim#api#import('notify') +let s:HI = SpaceVim#api#import('vim#highlight') function! SpaceVim#layers#core#plugins() abort @@ -542,12 +543,12 @@ function! s:jump_last_change() abort endfunction function! s:split_string(newline) abort - if s:is_string(line('.'), col('.')) + if s:HI.is_string(line('.'), col('.')) let save_cursor = getcurpos() let c = col('.') let sep = '' while c > 0 - if s:is_string(line('.'), c) + if s:HI.is_string(line('.'), c) let c -= 1 else if !empty(get(get(g:string_info, &filetype, {}), 'quotes_hi', [])) @@ -579,18 +580,6 @@ function! s:split_string(newline) abort endif endfunction - -" @toto add sting highlight for other filetype -let s:string_hi = { - \ 'c' : 'cCppString', - \ 'cpp' : 'cCppString', - \ 'python' : 'pythonString', - \ } - -function! s:is_string(l, c) abort - return synIDattr(synID(a:l, a:c, 1), 'name') == get(s:string_hi, &filetype, &filetype . 'String') -endfunction - " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') function! s:_function(fstr) abort diff --git a/autoload/SpaceVim/layers/edit.vim b/autoload/SpaceVim/layers/edit.vim index 2629fc12f..06cb739c2 100644 --- a/autoload/SpaceVim/layers/edit.vim +++ b/autoload/SpaceVim/layers/edit.vim @@ -60,6 +60,7 @@ let s:LIST = SpaceVim#api#import('data#list') let s:VIM = SpaceVim#api#import('vim') let s:CMP = SpaceVim#api#import('vim#compatible') let s:BUFFER = SpaceVim#api#import('vim#buffer') +let s:HI = SpaceVim#api#import('vim#highlight') let s:autosave_timeout = 0 let s:autosave_events = [] @@ -798,13 +799,13 @@ endfunction function! s:join_string_with() abort - if s:is_string(line('.'), col('.')) + if s:HI.is_string(line('.'), col('.')) let c = col('.') let a = 0 let b = 0 let _c = c while c > 0 - if s:is_string(line('.'), c) + if s:HI.is_string(line('.'), c) let c -= 1 else let a = c @@ -813,7 +814,7 @@ function! s:join_string_with() abort endwhile let c = _c while c > 0 - if s:is_string(line('.'), c) + if s:HI.is_string(line('.'), c) let c += 1 else let b = c @@ -827,16 +828,6 @@ function! s:join_string_with() abort endif endfunction -let s:string_hi = { - \ 'c' : 'cCppString', - \ 'cpp' : 'cCppString', - \ } - -function! s:is_string(l, c) abort - return synIDattr(synID(a:l, a:c, 1), 'name') == get(s:string_hi, &filetype, &filetype . 'String') -endfunction - - " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') function! s:_function(fstr) abort