mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
refactor(vim#highlight): add is_string()
function
This commit is contained in:
parent
a8d183fdd9
commit
95e1f0e199
@ -161,6 +161,16 @@ function! s:self.syntax_at(...) abort
|
|||||||
return synIDattr(synID(l:lnum, l:col, 1), 'name')
|
return synIDattr(synID(l:lnum, l:col, 1), 'name')
|
||||||
endfunction
|
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
|
function! s:self.syntax_of(pattern, ...) abort
|
||||||
if a:0 < 1
|
if a:0 < 1
|
||||||
let l:nth = 1
|
let l:nth = 1
|
||||||
|
@ -48,6 +48,7 @@ let s:FILE = SpaceVim#api#import('file')
|
|||||||
let s:MESSAGE = SpaceVim#api#import('vim#message')
|
let s:MESSAGE = SpaceVim#api#import('vim#message')
|
||||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||||
let s:NOTI = SpaceVim#api#import('notify')
|
let s:NOTI = SpaceVim#api#import('notify')
|
||||||
|
let s:HI = SpaceVim#api#import('vim#highlight')
|
||||||
|
|
||||||
|
|
||||||
function! SpaceVim#layers#core#plugins() abort
|
function! SpaceVim#layers#core#plugins() abort
|
||||||
@ -542,12 +543,12 @@ function! s:jump_last_change() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:split_string(newline) abort
|
function! s:split_string(newline) abort
|
||||||
if s:is_string(line('.'), col('.'))
|
if s:HI.is_string(line('.'), col('.'))
|
||||||
let save_cursor = getcurpos()
|
let save_cursor = getcurpos()
|
||||||
let c = col('.')
|
let c = col('.')
|
||||||
let sep = ''
|
let sep = ''
|
||||||
while c > 0
|
while c > 0
|
||||||
if s:is_string(line('.'), c)
|
if s:HI.is_string(line('.'), c)
|
||||||
let c -= 1
|
let c -= 1
|
||||||
else
|
else
|
||||||
if !empty(get(get(g:string_info, &filetype, {}), 'quotes_hi', []))
|
if !empty(get(get(g:string_info, &filetype, {}), 'quotes_hi', []))
|
||||||
@ -579,18 +580,6 @@ function! s:split_string(newline) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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
|
" function() wrapper
|
||||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||||
function! s:_function(fstr) abort
|
function! s:_function(fstr) abort
|
||||||
|
@ -60,6 +60,7 @@ let s:LIST = SpaceVim#api#import('data#list')
|
|||||||
let s:VIM = SpaceVim#api#import('vim')
|
let s:VIM = SpaceVim#api#import('vim')
|
||||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||||
let s:BUFFER = SpaceVim#api#import('vim#buffer')
|
let s:BUFFER = SpaceVim#api#import('vim#buffer')
|
||||||
|
let s:HI = SpaceVim#api#import('vim#highlight')
|
||||||
|
|
||||||
let s:autosave_timeout = 0
|
let s:autosave_timeout = 0
|
||||||
let s:autosave_events = []
|
let s:autosave_events = []
|
||||||
@ -798,13 +799,13 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:join_string_with() abort
|
function! s:join_string_with() abort
|
||||||
if s:is_string(line('.'), col('.'))
|
if s:HI.is_string(line('.'), col('.'))
|
||||||
let c = col('.')
|
let c = col('.')
|
||||||
let a = 0
|
let a = 0
|
||||||
let b = 0
|
let b = 0
|
||||||
let _c = c
|
let _c = c
|
||||||
while c > 0
|
while c > 0
|
||||||
if s:is_string(line('.'), c)
|
if s:HI.is_string(line('.'), c)
|
||||||
let c -= 1
|
let c -= 1
|
||||||
else
|
else
|
||||||
let a = c
|
let a = c
|
||||||
@ -813,7 +814,7 @@ function! s:join_string_with() abort
|
|||||||
endwhile
|
endwhile
|
||||||
let c = _c
|
let c = _c
|
||||||
while c > 0
|
while c > 0
|
||||||
if s:is_string(line('.'), c)
|
if s:HI.is_string(line('.'), c)
|
||||||
let c += 1
|
let c += 1
|
||||||
else
|
else
|
||||||
let b = c
|
let b = c
|
||||||
@ -827,16 +828,6 @@ function! s:join_string_with() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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
|
" function() wrapper
|
||||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||||
function! s:_function(fstr) abort
|
function! s:_function(fstr) abort
|
||||||
|
Loading…
x
Reference in New Issue
Block a user