mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 01:10:05 +08:00
feat(flygrep): hide guicursor
This commit is contained in:
parent
9042571586
commit
a1ec2b9bac
@ -21,123 +21,115 @@ let s:self = {}
|
|||||||
" reverse: if reverse
|
" reverse: if reverse
|
||||||
|
|
||||||
function! s:self.group2dict(name) abort
|
function! s:self.group2dict(name) abort
|
||||||
let id = hlID(a:name)
|
let id = hlID(a:name)
|
||||||
if id == 0
|
if id == 0
|
||||||
return {
|
return {
|
||||||
\ 'name' : '',
|
\ 'name' : '',
|
||||||
\ 'ctermbg' : '',
|
\ 'ctermbg' : '',
|
||||||
\ 'ctermfg' : '',
|
\ 'ctermfg' : '',
|
||||||
\ 'bold' : '',
|
\ 'bold' : '',
|
||||||
\ 'italic' : '',
|
\ 'italic' : '',
|
||||||
\ 'reverse' : '',
|
\ 'reverse' : '',
|
||||||
\ 'underline' : '',
|
\ 'underline' : '',
|
||||||
\ 'guibg' : '',
|
\ 'guibg' : '',
|
||||||
\ 'guifg' : '',
|
\ 'guifg' : '',
|
||||||
\ }
|
\ }
|
||||||
endif
|
endif
|
||||||
let rst = {
|
let rst = {
|
||||||
\ 'name' : synIDattr(id, 'name'),
|
\ 'name' : synIDattr(id, 'name'),
|
||||||
\ 'ctermbg' : synIDattr(id, 'bg', 'cterm'),
|
\ 'ctermbg' : synIDattr(id, 'bg', 'cterm'),
|
||||||
\ 'ctermfg' : synIDattr(id, 'fg', 'cterm'),
|
\ 'ctermfg' : synIDattr(id, 'fg', 'cterm'),
|
||||||
\ 'bold' : synIDattr(id, 'bold'),
|
\ 'bold' : synIDattr(id, 'bold'),
|
||||||
\ 'italic' : synIDattr(id, 'italic'),
|
\ 'italic' : synIDattr(id, 'italic'),
|
||||||
\ 'reverse' : synIDattr(id, 'reverse'),
|
\ 'reverse' : synIDattr(id, 'reverse'),
|
||||||
\ 'underline' : synIDattr(id, 'underline'),
|
\ 'underline' : synIDattr(id, 'underline'),
|
||||||
\ 'guibg' : tolower(synIDattr(id, 'bg#', 'gui')),
|
\ 'guibg' : tolower(synIDattr(id, 'bg#', 'gui')),
|
||||||
\ 'guifg' : tolower(synIDattr(id, 'fg#', 'gui')),
|
\ 'guifg' : tolower(synIDattr(id, 'fg#', 'gui')),
|
||||||
\ }
|
\ }
|
||||||
return rst
|
return rst
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:self.unite(base, target, part) abort
|
function! s:self.unite(base, target, part) abort
|
||||||
let base = self.group2dict(a:base)
|
let base = self.group2dict(a:base)
|
||||||
let target = self.group2dict(a:target)
|
let target = self.group2dict(a:target)
|
||||||
if empty(base) || empty(target)
|
if empty(base) || empty(target)
|
||||||
return
|
return
|
||||||
elseif get(base,a:part, '') ==# get(target, a:part, '')
|
elseif get(base,a:part, '') ==# get(target, a:part, '')
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
let target[a:part] = base[a:part]
|
let target[a:part] = base[a:part]
|
||||||
call self.hi(target)
|
call self.hi(target)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:self.hi(info) abort
|
function! s:self.hi(info) abort
|
||||||
if empty(a:info) || get(a:info, 'name', '') ==# ''
|
if empty(a:info) || get(a:info, 'name', '') ==# ''
|
||||||
return
|
return
|
||||||
|
endif
|
||||||
|
exe 'hi clear ' . a:info.name
|
||||||
|
let cmd = 'hi! ' . a:info.name
|
||||||
|
if !empty(a:info.ctermbg)
|
||||||
|
let cmd .= ' ctermbg=' . a:info.ctermbg
|
||||||
|
endif
|
||||||
|
if !empty(a:info.ctermfg)
|
||||||
|
let cmd .= ' ctermfg=' . a:info.ctermfg
|
||||||
|
endif
|
||||||
|
if !empty(a:info.guibg)
|
||||||
|
let cmd .= ' guibg=' . a:info.guibg
|
||||||
|
endif
|
||||||
|
if !empty(a:info.guifg)
|
||||||
|
let cmd .= ' guifg=' . a:info.guifg
|
||||||
|
endif
|
||||||
|
let style = []
|
||||||
|
for sty in ['bold', 'italic', 'underline', 'reverse']
|
||||||
|
if get(a:info, sty, '') ==# '1'
|
||||||
|
call add(style, sty)
|
||||||
endif
|
endif
|
||||||
exe 'hi clear ' . a:info.name
|
endfor
|
||||||
let cmd = 'hi! ' . a:info.name
|
if !empty(style)
|
||||||
if !empty(a:info.ctermbg)
|
let cmd .= ' gui=' . join(style, ',') . ' cterm=' . join(style, ',')
|
||||||
let cmd .= ' ctermbg=' . a:info.ctermbg
|
endif
|
||||||
endif
|
try
|
||||||
if !empty(a:info.ctermfg)
|
silent! exe cmd
|
||||||
let cmd .= ' ctermfg=' . a:info.ctermfg
|
catch
|
||||||
endif
|
endtry
|
||||||
if !empty(a:info.guibg)
|
|
||||||
let cmd .= ' guibg=' . a:info.guibg
|
|
||||||
endif
|
|
||||||
if !empty(a:info.guifg)
|
|
||||||
let cmd .= ' guifg=' . a:info.guifg
|
|
||||||
endif
|
|
||||||
let style = []
|
|
||||||
for sty in ['bold', 'italic', 'underline', 'reverse']
|
|
||||||
if get(a:info, sty, '') ==# '1'
|
|
||||||
call add(style, sty)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if !empty(style)
|
|
||||||
let cmd .= ' gui=' . join(style, ',') . ' cterm=' . join(style, ',')
|
|
||||||
endif
|
|
||||||
try
|
|
||||||
silent! exe cmd
|
|
||||||
catch
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:self.hide_in_normal(name) abort
|
function! s:self.hide_in_normal(name) abort
|
||||||
let group = self.group2dict(a:name)
|
let group = self.group2dict(a:name)
|
||||||
if empty(group)
|
if empty(group)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if (exists('+termguicolors') && &termguicolors ) || has('gui_running')
|
let normal = self.group2dict('Normal')
|
||||||
let bg = self.group2dict('Normal').guibg
|
let guibg = get(normal, 'guibg', '')
|
||||||
if empty(bg)
|
let ctermbg = get(normal, 'ctermbg', '')
|
||||||
return
|
let group.guifg = guibg
|
||||||
endif
|
let group.guibg = guibg
|
||||||
let group.guifg = bg
|
let group.ctermfg = ctermbg
|
||||||
let group.guibg = bg
|
let group.ctermbg = ctermbg
|
||||||
else
|
call self.hi(group)
|
||||||
let bg = self.group2dict('Normal').ctermbg
|
|
||||||
if empty(bg)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let group.ctermfg = bg
|
|
||||||
let group.ctermbg = bg
|
|
||||||
endif
|
|
||||||
call self.hi(group)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:self.hi_separator(a, b) abort
|
function! s:self.hi_separator(a, b) abort
|
||||||
let hi_a = self.group2dict(a:a)
|
let hi_a = self.group2dict(a:a)
|
||||||
let hi_b = self.group2dict(a:b)
|
let hi_b = self.group2dict(a:b)
|
||||||
let hi_a_b = {
|
let hi_a_b = {
|
||||||
\ 'name' : a:a . '_' . a:b,
|
\ 'name' : a:a . '_' . a:b,
|
||||||
\ 'guibg' : hi_b.guibg,
|
\ 'guibg' : hi_b.guibg,
|
||||||
\ 'guifg' : hi_a.guibg,
|
\ 'guifg' : hi_a.guibg,
|
||||||
\ 'ctermbg' : hi_b.ctermbg,
|
\ 'ctermbg' : hi_b.ctermbg,
|
||||||
\ 'ctermfg' : hi_a.ctermbg,
|
\ 'ctermfg' : hi_a.ctermbg,
|
||||||
\ }
|
\ }
|
||||||
let hi_b_a = {
|
let hi_b_a = {
|
||||||
\ 'name' : a:b . '_' . a:a,
|
\ 'name' : a:b . '_' . a:a,
|
||||||
\ 'guibg' : hi_a.guibg,
|
\ 'guibg' : hi_a.guibg,
|
||||||
\ 'guifg' : hi_b.guibg,
|
\ 'guifg' : hi_b.guibg,
|
||||||
\ 'ctermbg' : hi_a.ctermbg,
|
\ 'ctermbg' : hi_a.ctermbg,
|
||||||
\ 'ctermfg' : hi_b.ctermbg,
|
\ 'ctermfg' : hi_b.ctermbg,
|
||||||
\ }
|
\ }
|
||||||
call self.hi(hi_a_b)
|
call self.hi(hi_a_b)
|
||||||
call self.hi(hi_b_a)
|
call self.hi(hi_b_a)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:self.syntax_at(...) abort
|
function! s:self.syntax_at(...) abort
|
||||||
@ -197,5 +189,5 @@ function! s:self.syntax_of(pattern, ...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#api#vim#highlight#get() abort
|
function! SpaceVim#api#vim#highlight#get() abort
|
||||||
return deepcopy(s:self)
|
return deepcopy(s:self)
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -874,9 +874,15 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
|||||||
let save_tve = &t_ve
|
let save_tve = &t_ve
|
||||||
setlocal t_ve=
|
setlocal t_ve=
|
||||||
let cursor_hi = {}
|
let cursor_hi = {}
|
||||||
if has('gui_running')
|
let cursor_hi = s:HI.group2dict('Cursor')
|
||||||
let cursor_hi = s:HI.group2dict('Cursor')
|
let lcursor_hi = s:HI.group2dict('lCursor')
|
||||||
call s:HI.hide_in_normal('Cursor')
|
let guicursor = &guicursor
|
||||||
|
call s:HI.hide_in_normal('Cursor')
|
||||||
|
call s:HI.hide_in_normal('lCursor')
|
||||||
|
" hi Cursor ctermbg=16 ctermfg=16 guifg=#282c34 guibg=#282c34
|
||||||
|
" hi lCursor ctermbg=16 ctermfg=16 guifg=#282c34 guibg=#282c34
|
||||||
|
if has('nvim')
|
||||||
|
set guicursor+=a:Cursor/lCursor
|
||||||
endif
|
endif
|
||||||
" setlocal nomodifiable
|
" setlocal nomodifiable
|
||||||
setf SpaceVimFlyGrep
|
setf SpaceVimFlyGrep
|
||||||
@ -926,9 +932,9 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
|||||||
endif
|
endif
|
||||||
call s:LOGGER.info('FlyGrep ending ===========================')
|
call s:LOGGER.info('FlyGrep ending ===========================')
|
||||||
let &t_ve = save_tve
|
let &t_ve = save_tve
|
||||||
if has('gui_running')
|
call s:HI.hi(cursor_hi)
|
||||||
call s:HI.hi(cursor_hi)
|
call s:HI.hi(lcursor_hi)
|
||||||
endif
|
let &guicursor = guicursor
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user