mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:50:04 +08:00
Add some log for flygrep (#2388)
* add some debug info for flygrep * new feature: hide cursor when using gvim
This commit is contained in:
parent
df7c456e3c
commit
648f010cf3
@ -140,8 +140,8 @@ func! s:self._handle_input(...) abort
|
||||
endf
|
||||
|
||||
func! s:self._build_prompt() abort
|
||||
normal! :
|
||||
let ident = repeat(' ', self.__cmp.win_screenpos(0)[1] - 1)
|
||||
redraw
|
||||
echohl Comment | echon ident . self._prompt.mpt
|
||||
echohl None | echon self._prompt.begin
|
||||
echohl Wildmenu | echon self._prompt.cursor
|
||||
@ -149,6 +149,7 @@ func! s:self._build_prompt() abort
|
||||
if empty(self._prompt.cursor) && !has('nvim')
|
||||
echohl Comment | echon '_' | echohl None
|
||||
endif
|
||||
" FIXME: Macvim need extra redraw,
|
||||
endf
|
||||
|
||||
function! s:self._clear_prompt() abort
|
||||
|
@ -8,6 +8,18 @@
|
||||
|
||||
let s:self = {}
|
||||
|
||||
|
||||
" the key of a highlight should be:
|
||||
" name: the name of the highlight group
|
||||
" ctermbg: background color in cterm
|
||||
" ctermfg: fround color in cterm
|
||||
" bold: if bold?
|
||||
" italic: if italic?
|
||||
" underline: if underline
|
||||
" guibg: gui background color
|
||||
" guifg: found color in gui
|
||||
" reverse: if reverse
|
||||
|
||||
function! s:self.group2dict(name) abort
|
||||
let id = index(map(range(1999), "synIDattr(v:val, 'name')"), a:name)
|
||||
if id == -1
|
||||
@ -17,6 +29,7 @@ function! s:self.group2dict(name) abort
|
||||
\ 'ctermfg' : '',
|
||||
\ 'bold' : '',
|
||||
\ 'italic' : '',
|
||||
\ 'reverse' : '',
|
||||
\ 'underline' : '',
|
||||
\ 'guibg' : '',
|
||||
\ 'guifg' : '',
|
||||
@ -28,6 +41,7 @@ function! s:self.group2dict(name) abort
|
||||
\ 'ctermfg' : synIDattr(id, 'fg', 'cterm'),
|
||||
\ 'bold' : synIDattr(id, 'bold'),
|
||||
\ 'italic' : synIDattr(id, 'italic'),
|
||||
\ 'reverse' : synIDattr(id, 'reverse'),
|
||||
\ 'underline' : synIDattr(id, 'underline'),
|
||||
\ 'guibg' : synIDattr(id, 'bg#'),
|
||||
\ 'guifg' : synIDattr(id, 'fg#'),
|
||||
@ -52,6 +66,7 @@ function! s:self.hi(info) abort
|
||||
if empty(a:info) || get(a:info, 'name', '') ==# ''
|
||||
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
|
||||
@ -66,7 +81,7 @@ function! s:self.hi(info) abort
|
||||
let cmd .= ' guifg=' . a:info.guifg
|
||||
endif
|
||||
let style = []
|
||||
for sty in ['bold', 'italic', 'underline']
|
||||
for sty in ['bold', 'italic', 'underline', 'reverse']
|
||||
if get(a:info, sty, '') ==# '1'
|
||||
call add(style, sty)
|
||||
endif
|
||||
|
@ -13,6 +13,7 @@ let s:JOB = SpaceVim#api#import('job')
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
let s:BUFFER = SpaceVim#api#import('vim#buffer')
|
||||
let s:LIST = SpaceVim#api#import('data#list')
|
||||
let s:HI = SpaceVim#api#import('vim#highlight')
|
||||
"}}}
|
||||
|
||||
" Init local options: {{{
|
||||
@ -43,13 +44,15 @@ function! s:grep_timer(timer) abort
|
||||
endif
|
||||
let cmd = s:get_search_cmd(s:current_grep_pattern)
|
||||
call SpaceVim#logger#info('grep cmd: ' . string(cmd))
|
||||
call SpaceVim#logger#info('full cmd: ' . join(cmd))
|
||||
let s:grepid = s:JOB.start(cmd, {
|
||||
\ 'on_stdout' : function('s:grep_stdout'),
|
||||
\ 'on_stderr' : function('s:grep_stderr'),
|
||||
\ 'in_io' : 'null',
|
||||
\ 'on_exit' : function('s:grep_exit'),
|
||||
\ })
|
||||
" sometimes the flygrep command failed to run, so we need to log the jobid
|
||||
" of the grep command.
|
||||
call SpaceVim#logger#info('flygrep job id is: ' . string(s:grepid))
|
||||
endfunction
|
||||
|
||||
function! s:get_search_cmd(expr) abort
|
||||
@ -228,7 +231,8 @@ let s:MPT._prompt.mpt = g:spacevim_commandline_prompt . ' '
|
||||
|
||||
" API: MPT._onclose {{{
|
||||
function! s:close_buffer() abort
|
||||
if s:grepid != 0
|
||||
" NOTE: the jobid maybe -1, that is means the cmd is not executable.
|
||||
if s:grepid > 0
|
||||
call s:JOB.stop(s:grepid)
|
||||
endif
|
||||
call timer_stop(s:grep_timer_id)
|
||||
@ -240,7 +244,8 @@ let s:MPT._onclose = function('s:close_buffer')
|
||||
|
||||
" API: MPT._oninputpro {{{
|
||||
function! s:close_grep_job() abort
|
||||
if s:grepid != 0
|
||||
" NOTE: the jobid maybe -1, that is means the cmd is not executable.
|
||||
if s:grepid > 0
|
||||
call s:JOB.stop(s:grepid)
|
||||
endif
|
||||
call timer_stop(s:grep_timer_id)
|
||||
@ -534,6 +539,11 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber
|
||||
let save_tve = &t_ve
|
||||
setlocal t_ve=
|
||||
if has('gui_running')
|
||||
let cursor_hi = s:HI.group2dict('Cursor')
|
||||
let g:wsd = cursor_hi
|
||||
call s:HI.hide_in_normal('Cursor')
|
||||
endif
|
||||
" setlocal nomodifiable
|
||||
setf SpaceVimFlyGrep
|
||||
call s:matchadd('FileName', '[^:]*:\d\+:\d\+:', 3)
|
||||
@ -572,9 +582,14 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
|
||||
call SpaceVim#logger#info(' ignore_case : ' . string(s:grep_ignore_case))
|
||||
call SpaceVim#logger#info(' smart_case : ' . string(s:grep_smart_case))
|
||||
call SpaceVim#logger#info(' expr opt : ' . string(s:grep_expr_opt))
|
||||
" sometimes user can not see the flygrep windows, redraw only once.
|
||||
redraw
|
||||
call s:MPT.open()
|
||||
call SpaceVim#logger#info('FlyGrep ending ===========================')
|
||||
let &t_ve = save_tve
|
||||
if has('gui_running')
|
||||
call s:HI.hi(cursor_hi)
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
@ -590,5 +605,4 @@ endfunction
|
||||
function! SpaceVim#plugins#flygrep#mode() abort
|
||||
return s:grep_mode . (empty(s:mode) ? '' : '(' . s:mode . ')')
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
|
@ -8,10 +8,14 @@
|
||||
|
||||
### 功能改进
|
||||
|
||||
- Add debug info for flygrep ([#2388](https://github.com/SpaceVim/SpaceVim/pull/2388))
|
||||
|
||||
### 非兼容性变动
|
||||
|
||||
### 问题修复
|
||||
|
||||
- Clear rootDir cache after rooter pattern change([#2370](https://github.com/SpaceVim/SpaceVim/pull/2370))
|
||||
|
||||
### 移除的功能
|
||||
|
||||
### 文档、wiki 及官网变动
|
||||
|
@ -8,6 +8,8 @@ The next release is v1.0.1
|
||||
|
||||
### Improvement
|
||||
|
||||
- Add debug info for flygrep ([#2388](https://github.com/SpaceVim/SpaceVim/pull/2388))
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
|
Loading…
Reference in New Issue
Block a user