mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:50:05 +08:00
Add: floating statusline for guide and flygrep (#3605)
This commit is contained in:
parent
7ff167ed42
commit
0598b86e4a
@ -250,8 +250,6 @@ function! s:self.stop(id) abort
|
|||||||
if has_key(self.jobs, a:id)
|
if has_key(self.jobs, a:id)
|
||||||
call jobstop(a:id)
|
call jobstop(a:id)
|
||||||
call remove(self.jobs, a:id)
|
call remove(self.jobs, a:id)
|
||||||
else
|
|
||||||
call self.warn('[job API] Failed to stop job :' . a:id)
|
|
||||||
endif
|
endif
|
||||||
elseif self.vim_job
|
elseif self.vim_job
|
||||||
if has_key(self.jobs, a:id)
|
if has_key(self.jobs, a:id)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
|
|
||||||
let s:self = {}
|
let s:self = {}
|
||||||
|
let s:self.__floating = SpaceVim#api#import('neovim#floating')
|
||||||
|
|
||||||
|
|
||||||
function! s:self.check_width(len, sec, winwidth) abort
|
function! s:self.check_width(len, sec, winwidth) abort
|
||||||
@ -87,6 +88,53 @@ function! s:self.build(left_sections, right_sections, lsep, rsep, fname, tag, hi
|
|||||||
return l[:-4]
|
return l[:-4]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:self.open_float(st) abort
|
||||||
|
if !has_key(self, '__bufnr') || !bufexists(self.__bufnr)
|
||||||
|
let self.__bufnr = nvim_create_buf(0,0)
|
||||||
|
endif
|
||||||
|
if has_key(self, '__winid') && win_id2tabwin(self.__winid)[0] == tabpagenr()
|
||||||
|
else
|
||||||
|
let self.__winid = self.__floating.open_win(self.__bufnr,
|
||||||
|
\ v:false,
|
||||||
|
\ {
|
||||||
|
\ 'relative': 'editor',
|
||||||
|
\ 'width' : &columns,
|
||||||
|
\ 'height' : 1,
|
||||||
|
\ 'row': &lines ,
|
||||||
|
\ 'col': 10
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
|
call setbufvar(self.__bufnr, '&relativenumber', 0)
|
||||||
|
call setbufvar(self.__bufnr, '&number', 0)
|
||||||
|
call setbufvar(self.__bufnr, '&cursorline', 0)
|
||||||
|
call setwinvar(win_id2win(self.__winid), '&winhighlight', 'Normal:SpaceVim_statusline_a_bold')
|
||||||
|
call setwinvar(win_id2win(self.__winid), '&cursorline', 0)
|
||||||
|
call nvim_buf_set_virtual_text(
|
||||||
|
\ self.__bufnr,
|
||||||
|
\ -1,
|
||||||
|
\ 0,
|
||||||
|
\ a:st,
|
||||||
|
\ {})
|
||||||
|
redraw!
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
if exists('*nvim_win_close')
|
||||||
|
function! s:self.close_float() abort
|
||||||
|
" @fixme: nvim_win_close only support one argv in old version
|
||||||
|
try
|
||||||
|
call nvim_win_close(self.__winid, 1)
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E118/
|
||||||
|
call nvim_win_close(self.__winid)
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:self.close_float() abort
|
||||||
|
if has_key(self, '__winid') && win_id2tabwin(self.__winid)[0] == tabpagenr()
|
||||||
|
noautocmd execute win_id2win(self.__winid).'wincmd w'
|
||||||
|
noautocmd close
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
function! SpaceVim#api#vim#statusline#get() abort
|
function! SpaceVim#api#vim#statusline#get() abort
|
||||||
return deepcopy(s:self)
|
return deepcopy(s:self)
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -16,6 +16,12 @@ let s:CMP = SpaceVim#api#import('vim#compatible')
|
|||||||
let s:STR = SpaceVim#api#import('data#string')
|
let s:STR = SpaceVim#api#import('data#string')
|
||||||
let s:KEY = SpaceVim#api#import('vim#key')
|
let s:KEY = SpaceVim#api#import('vim#key')
|
||||||
let s:FLOATING = SpaceVim#api#import('neovim#floating')
|
let s:FLOATING = SpaceVim#api#import('neovim#floating')
|
||||||
|
let s:SL = SpaceVim#api#import('vim#statusline')
|
||||||
|
|
||||||
|
" guide specific var
|
||||||
|
|
||||||
|
let s:winid = -1
|
||||||
|
let s:bufnr = -1
|
||||||
|
|
||||||
function! SpaceVim#mapping#guide#has_configuration() abort "{{{
|
function! SpaceVim#mapping#guide#has_configuration() abort "{{{
|
||||||
return exists('s:desc_lookup')
|
return exists('s:desc_lookup')
|
||||||
@ -394,7 +400,7 @@ function! s:start_buffer() abort " {{{
|
|||||||
|
|
||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
if exists('*nvim_open_win')
|
if exists('*nvim_open_win')
|
||||||
call s:FLOATING.win_config(win_getid(s:gwin),
|
call s:FLOATING.win_config(win_getid(s:winid),
|
||||||
\ {
|
\ {
|
||||||
\ 'relative': 'editor',
|
\ 'relative': 'editor',
|
||||||
\ 'width' : &columns,
|
\ 'width' : &columns,
|
||||||
@ -506,16 +512,13 @@ function! s:build_mpt(mpt) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:winopen() abort " {{{
|
function! s:winopen() abort " {{{
|
||||||
if !exists('s:bufnr')
|
|
||||||
let s:bufnr = -1
|
|
||||||
endif
|
|
||||||
call s:highlight_cursor()
|
call s:highlight_cursor()
|
||||||
let pos = g:leaderGuide_position ==? 'topleft' ? 'topleft' : 'botright'
|
let pos = g:leaderGuide_position ==? 'topleft' ? 'topleft' : 'botright'
|
||||||
if exists('*nvim_open_win')
|
if exists('*nvim_open_win')
|
||||||
if !bufexists(s:bufnr)
|
if !bufexists(s:bufnr)
|
||||||
let s:bufnr = nvim_create_buf(v:false,v:false)
|
let s:bufnr = nvim_create_buf(v:false,v:false)
|
||||||
endif
|
endif
|
||||||
call s:FLOATING.open_win(s:bufnr, v:true,
|
let s:winid = s:FLOATING.open_win(s:bufnr, v:true,
|
||||||
\ {
|
\ {
|
||||||
\ 'relative': 'editor',
|
\ 'relative': 'editor',
|
||||||
\ 'width' : &columns,
|
\ 'width' : &columns,
|
||||||
@ -543,8 +546,8 @@ function! s:winopen() abort " {{{
|
|||||||
autocmd WinLeave <buffer> call s:winclose()
|
autocmd WinLeave <buffer> call s:winclose()
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
let s:winid = winnr()
|
||||||
endif
|
endif
|
||||||
let s:gwin = winnr()
|
|
||||||
let s:guide_help_mode = 0
|
let s:guide_help_mode = 0
|
||||||
setlocal filetype=leaderGuide
|
setlocal filetype=leaderGuide
|
||||||
if exists('&winhighlight')
|
if exists('&winhighlight')
|
||||||
@ -560,31 +563,60 @@ function! s:winopen() abort " {{{
|
|||||||
call s:toggle_hide_cursor()
|
call s:toggle_hide_cursor()
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:updateStatusline() abort
|
if exists('*nvim_open_win')
|
||||||
call SpaceVim#mapping#guide#theme#hi()
|
function! s:updateStatusline() abort
|
||||||
let gname = get(s:guide_group, 'name', '')
|
call SpaceVim#mapping#guide#theme#hi()
|
||||||
if !empty(gname)
|
let gname = get(s:guide_group, 'name', '')
|
||||||
let gname = ' - ' . gname[1:]
|
if !empty(gname)
|
||||||
let gname = substitute(gname,' ', '\\ ', 'g')
|
let gname = ' - ' . gname[1:]
|
||||||
endif
|
" let gname = substitute(gname,' ', '\\ ', 'g')
|
||||||
let keys = get(s:, 'prefix_key_inp', '')
|
endif
|
||||||
let keys = substitute(keys, '\', '\\\', 'g')
|
let keys = get(s:, 'prefix_key_inp', '')
|
||||||
exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Guide:\ ' .
|
" let keys = substitute(keys, '\', '\\\', 'g')
|
||||||
\ '%#LeaderGuiderSep1#' . s:lsep .
|
call s:SL.open_float([
|
||||||
\ '%#LeaderGuiderName#\ ' .
|
\ ['Guide: ', 'LeaderGuiderPrompt'],
|
||||||
\ SpaceVim#mapping#leader#getName(s:prefix_key)
|
\ [' ', 'LeaderGuiderSep1'],
|
||||||
\ . keys . gname
|
\ [SpaceVim#mapping#leader#getName(s:prefix_key)
|
||||||
\ . '\ %#LeaderGuiderSep2#' . s:lsep . '%#LeaderGuiderFill#'
|
\ . keys . gname, 'LeaderGuiderName'],
|
||||||
\ . s:guide_help_msg()
|
\ [' ', 'LeaderGuiderSep2'],
|
||||||
|
\ [s:guide_help_msg(0), 'LeaderGuiderFill'],
|
||||||
|
\ [repeat(' ', 999), 'LeaderGuiderFill'],
|
||||||
|
\ ])
|
||||||
|
endfunction
|
||||||
|
function! s:close_float_statusline() abort
|
||||||
|
call s:SL.close_float()
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:updateStatusline() abort
|
||||||
|
call SpaceVim#mapping#guide#theme#hi()
|
||||||
|
let gname = get(s:guide_group, 'name', '')
|
||||||
|
if !empty(gname)
|
||||||
|
let gname = ' - ' . gname[1:]
|
||||||
|
let gname = substitute(gname,' ', '\\ ', 'g')
|
||||||
|
endif
|
||||||
|
let keys = get(s:, 'prefix_key_inp', '')
|
||||||
|
let keys = substitute(keys, '\', '\\\', 'g')
|
||||||
|
exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Guide:\ ' .
|
||||||
|
\ '%#LeaderGuiderSep1#' . s:lsep .
|
||||||
|
\ '%#LeaderGuiderName#\ ' .
|
||||||
|
\ SpaceVim#mapping#leader#getName(s:prefix_key)
|
||||||
|
\ . keys . gname
|
||||||
|
\ . '\ %#LeaderGuiderSep2#' . s:lsep . '%#LeaderGuiderFill#'
|
||||||
|
\ . s:guide_help_msg(1)
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! Test_st() abort
|
||||||
|
call s:updateStatusline()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:guide_help_msg() abort
|
function! s:guide_help_msg(escape) abort
|
||||||
if s:guide_help_mode == 1
|
if s:guide_help_mode == 1
|
||||||
let msg = ' n -> next-page, p -> previous-page, u -> undo-key'
|
let msg = ' n -> next-page, p -> previous-page, u -> undo-key'
|
||||||
else
|
else
|
||||||
let msg = ' [C-h paging/help]'
|
let msg = ' [C-h paging/help]'
|
||||||
endif
|
endif
|
||||||
return substitute(msg,' ', '\\ ', 'g')
|
return a:escape ? substitute(msg,' ', '\\ ', 'g') : msg
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:t_ve = ''
|
let s:t_ve = ''
|
||||||
@ -597,16 +629,21 @@ endfunction
|
|||||||
|
|
||||||
function! s:winclose() abort " {{{
|
function! s:winclose() abort " {{{
|
||||||
call s:toggle_hide_cursor()
|
call s:toggle_hide_cursor()
|
||||||
noautocmd execute s:gwin.'wincmd w'
|
if exists('*nvim_win_close')
|
||||||
if s:gwin == winnr()
|
call nvim_win_close(s:winid, 1)
|
||||||
noautocmd close
|
call s:close_float_statusline()
|
||||||
redraw!
|
else
|
||||||
exe s:winres
|
noautocmd execute s:winid.'wincmd w'
|
||||||
let s:gwin = -1
|
if s:winid == winnr()
|
||||||
noautocmd execute s:winnr.'wincmd w'
|
noautocmd close
|
||||||
call winrestview(s:winv)
|
redraw!
|
||||||
if exists('*nvim_open_win')
|
exe s:winres
|
||||||
doautocmd WinEnter
|
let s:winid = -1
|
||||||
|
noautocmd execute s:winnr.'wincmd w'
|
||||||
|
call winrestview(s:winv)
|
||||||
|
if exists('*nvim_open_win')
|
||||||
|
doautocmd WinEnter
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call s:remove_cursor_highlight()
|
call s:remove_cursor_highlight()
|
||||||
|
@ -16,6 +16,7 @@ let s:LIST = SpaceVim#api#import('data#list')
|
|||||||
let s:HI = SpaceVim#api#import('vim#highlight')
|
let s:HI = SpaceVim#api#import('vim#highlight')
|
||||||
let s:FLOATING = SpaceVim#api#import('neovim#floating')
|
let s:FLOATING = SpaceVim#api#import('neovim#floating')
|
||||||
let s:JSON = SpaceVim#api#import('data#json')
|
let s:JSON = SpaceVim#api#import('data#json')
|
||||||
|
let s:SL = SpaceVim#api#import('vim#statusline')
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
let s:grepid = 0
|
let s:grepid = 0
|
||||||
@ -339,6 +340,7 @@ function! s:close_grep_job() abort
|
|||||||
call timer_stop(s:grep_timer_id)
|
call timer_stop(s:grep_timer_id)
|
||||||
call timer_stop(s:preview_timer_id)
|
call timer_stop(s:preview_timer_id)
|
||||||
noautocmd normal! "_ggdG
|
noautocmd normal! "_ggdG
|
||||||
|
call s:update_statusline()
|
||||||
let s:complete_input_history_num = [0,0]
|
let s:complete_input_history_num = [0,0]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -383,6 +385,7 @@ function! s:grep_stderr(id, data, event) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:grep_exit(id, data, event) abort
|
function! s:grep_exit(id, data, event) abort
|
||||||
|
call s:update_statusline()
|
||||||
redraw
|
redraw
|
||||||
call s:MPT._build_prompt()
|
call s:MPT._build_prompt()
|
||||||
redrawstatus
|
redrawstatus
|
||||||
@ -404,6 +407,7 @@ function! s:next_item() abort
|
|||||||
if s:preview_able == 1
|
if s:preview_able == 1
|
||||||
call s:preview()
|
call s:preview()
|
||||||
endif
|
endif
|
||||||
|
call s:update_statusline()
|
||||||
redraw
|
redraw
|
||||||
call s:MPT._build_prompt()
|
call s:MPT._build_prompt()
|
||||||
redrawstatus
|
redrawstatus
|
||||||
@ -458,6 +462,7 @@ function! s:previous_item() abort
|
|||||||
if s:preview_able == 1
|
if s:preview_able == 1
|
||||||
call s:preview()
|
call s:preview()
|
||||||
endif
|
endif
|
||||||
|
call s:update_statusline()
|
||||||
redraw
|
redraw
|
||||||
call s:MPT._build_prompt()
|
call s:MPT._build_prompt()
|
||||||
redrawstatus
|
redrawstatus
|
||||||
@ -753,6 +758,7 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
|||||||
endif
|
endif
|
||||||
" setlocal nomodifiable
|
" setlocal nomodifiable
|
||||||
setf SpaceVimFlyGrep
|
setf SpaceVimFlyGrep
|
||||||
|
call s:update_statusline()
|
||||||
call s:matchadd('FileName', '[^:]*:\d\+:\d\+:', 3)
|
call s:matchadd('FileName', '[^:]*:\d\+:\d\+:', 3)
|
||||||
let s:MPT._prompt.begin = get(a:argv, 'input', '')
|
let s:MPT._prompt.begin = get(a:argv, 'input', '')
|
||||||
let fs = get(a:argv, 'files', '')
|
let fs = get(a:argv, 'files', '')
|
||||||
@ -792,6 +798,7 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
|||||||
" sometimes user can not see the flygrep windows, redraw only once.
|
" sometimes user can not see the flygrep windows, redraw only once.
|
||||||
redraw
|
redraw
|
||||||
call s:MPT.open()
|
call s:MPT.open()
|
||||||
|
call s:close_statusline()
|
||||||
call SpaceVim#logger#info('FlyGrep ending ===========================')
|
call SpaceVim#logger#info('FlyGrep ending ===========================')
|
||||||
let &t_ve = save_tve
|
let &t_ve = save_tve
|
||||||
if has('gui_running')
|
if has('gui_running')
|
||||||
@ -800,40 +807,22 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
let s:statusline_win_id = -1
|
function! s:update_statusline() abort
|
||||||
let s:statusline_buf_id = -1
|
call s:SL.open_float([
|
||||||
function! s:create_statusline() abort
|
|
||||||
let s:statusline_buf_id = nvim_create_buf(0,0)
|
|
||||||
let s:statusline_win_id = nvim_open_win(s:statusline_buf_id,
|
|
||||||
\ v:true,
|
|
||||||
\ {
|
|
||||||
\ 'relative': 'editor',
|
|
||||||
\ 'width' : &columns ,
|
|
||||||
\ 'height' : 1,
|
|
||||||
\ 'row' : &lines ,
|
|
||||||
\ 'col' : 10
|
|
||||||
\ })
|
|
||||||
call setbufvar(s:statusline_buf_id, '&relativenumber', 0)
|
|
||||||
call setbufvar(s:statusline_buf_id, '&number', 0)
|
|
||||||
call nvim_buf_set_virtual_text(
|
|
||||||
\ s:statusline_buf_id,
|
|
||||||
\ -1,
|
|
||||||
\ 0,
|
|
||||||
\ [
|
|
||||||
\ ['FlyGrep ', 'SpaceVim_statusline_a_bold'],
|
\ ['FlyGrep ', 'SpaceVim_statusline_a_bold'],
|
||||||
\ ['', 'SpaceVim_statusline_a_SpaceVim_statusline_b'],
|
\ [' ', 'SpaceVim_statusline_a_SpaceVim_statusline_b'],
|
||||||
\ [SpaceVim#plugins#flygrep#mode(), 'SpaceVim_statusline_b'],
|
\ [SpaceVim#plugins#flygrep#mode() . ' ', 'SpaceVim_statusline_b'],
|
||||||
\ ['', 'SpaceVim_statusline_b_SpaceVim_statusline_c'],
|
\ [' ', 'SpaceVim_statusline_b_SpaceVim_statusline_c'],
|
||||||
\ [getcwd(), 'SpaceVim_statusline_c'],
|
\ [getcwd() . ' ', 'SpaceVim_statusline_c'],
|
||||||
\ ['', 'SpaceVim_statusline_c_SpaceVim_statusline_b'],
|
\ [' ', 'SpaceVim_statusline_c_SpaceVim_statusline_b'],
|
||||||
\ [SpaceVim#plugins#flygrep#lineNr(), 'SpaceVim_statusline_b'],
|
\ [SpaceVim#plugins#flygrep#lineNr() . ' ', 'SpaceVim_statusline_b'],
|
||||||
\ ['', 'SpaceVim_statusline_b_SpaceVim_statusline_z'],
|
\ [' ', 'SpaceVim_statusline_b_SpaceVim_statusline_z'],
|
||||||
\ ],
|
\ [repeat(' ', &columns - 11), 'SpaceVim_statusline_z'],
|
||||||
\ {})
|
\ ])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! Test_st() abort
|
function! s:close_statusline() abort
|
||||||
call s:create_statusline()
|
call s:SL.close_float()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Plugin API: SpaceVim#plugins#flygrep#lineNr() {{{
|
" Plugin API: SpaceVim#plugins#flygrep#lineNr() {{{
|
||||||
|
20
bundle/context_filetype.vim/doc/tags-ja
Normal file
20
bundle/context_filetype.vim/doc/tags-ja
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
!_TAG_FILE_ENCODING utf-8 //
|
||||||
|
b:context_filetype_filetypes context_filetype.jax /*b:context_filetype_filetypes*
|
||||||
|
context_filetype context_filetype.jax /*context_filetype*
|
||||||
|
context_filetype#default_filetypes() context_filetype.jax /*context_filetype#default_filetypes()*
|
||||||
|
context_filetype#get() context_filetype.jax /*context_filetype#get()*
|
||||||
|
context_filetype#get_filetype() context_filetype.jax /*context_filetype#get_filetype()*
|
||||||
|
context_filetype#get_filetypes() context_filetype.jax /*context_filetype#get_filetypes()*
|
||||||
|
context_filetype#get_range() context_filetype.jax /*context_filetype#get_range()*
|
||||||
|
context_filetype#version() context_filetype.jax /*context_filetype#version()*
|
||||||
|
context_filetype-contents context_filetype.jax /*context_filetype-contents*
|
||||||
|
context_filetype-functions context_filetype.jax /*context_filetype-functions*
|
||||||
|
context_filetype-interface context_filetype.jax /*context_filetype-interface*
|
||||||
|
context_filetype-introduction context_filetype.jax /*context_filetype-introduction*
|
||||||
|
context_filetype-support context_filetype.jax /*context_filetype-support*
|
||||||
|
context_filetype-variables context_filetype.jax /*context_filetype-variables*
|
||||||
|
context_filetype.txt context_filetype.jax /*context_filetype.txt*
|
||||||
|
g:context_filetype#filetypes context_filetype.jax /*g:context_filetype#filetypes*
|
||||||
|
g:context_filetype#ignore_composite_filetypes context_filetype.jax /*g:context_filetype#ignore_composite_filetypes*
|
||||||
|
g:context_filetype#same_filetypes context_filetype.jax /*g:context_filetype#same_filetypes*
|
||||||
|
g:context_filetype#search_offset context_filetype.jax /*g:context_filetype#search_offset*
|
Loading…
Reference in New Issue
Block a user