mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:30: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)
|
||||
call jobstop(a:id)
|
||||
call remove(self.jobs, a:id)
|
||||
else
|
||||
call self.warn('[job API] Failed to stop job :' . a:id)
|
||||
endif
|
||||
elseif self.vim_job
|
||||
if has_key(self.jobs, a:id)
|
||||
|
@ -7,6 +7,7 @@
|
||||
"=============================================================================
|
||||
|
||||
let s:self = {}
|
||||
let s:self.__floating = SpaceVim#api#import('neovim#floating')
|
||||
|
||||
|
||||
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]
|
||||
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
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
@ -16,6 +16,12 @@ let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
let s:STR = SpaceVim#api#import('data#string')
|
||||
let s:KEY = SpaceVim#api#import('vim#key')
|
||||
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 "{{{
|
||||
return exists('s:desc_lookup')
|
||||
@ -394,7 +400,7 @@ function! s:start_buffer() abort " {{{
|
||||
|
||||
setlocal modifiable
|
||||
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',
|
||||
\ 'width' : &columns,
|
||||
@ -506,16 +512,13 @@ function! s:build_mpt(mpt) abort
|
||||
endfunction
|
||||
|
||||
function! s:winopen() abort " {{{
|
||||
if !exists('s:bufnr')
|
||||
let s:bufnr = -1
|
||||
endif
|
||||
call s:highlight_cursor()
|
||||
let pos = g:leaderGuide_position ==? 'topleft' ? 'topleft' : 'botright'
|
||||
if exists('*nvim_open_win')
|
||||
if !bufexists(s:bufnr)
|
||||
let s:bufnr = nvim_create_buf(v:false,v:false)
|
||||
endif
|
||||
call s:FLOATING.open_win(s:bufnr, v:true,
|
||||
let s:winid = s:FLOATING.open_win(s:bufnr, v:true,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
\ 'width' : &columns,
|
||||
@ -543,8 +546,8 @@ function! s:winopen() abort " {{{
|
||||
autocmd WinLeave <buffer> call s:winclose()
|
||||
augroup END
|
||||
endif
|
||||
let s:winid = winnr()
|
||||
endif
|
||||
let s:gwin = winnr()
|
||||
let s:guide_help_mode = 0
|
||||
setlocal filetype=leaderGuide
|
||||
if exists('&winhighlight')
|
||||
@ -560,31 +563,60 @@ function! s:winopen() abort " {{{
|
||||
call s:toggle_hide_cursor()
|
||||
endfunction " }}}
|
||||
|
||||
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()
|
||||
if exists('*nvim_open_win')
|
||||
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')
|
||||
call s:SL.open_float([
|
||||
\ ['Guide: ', 'LeaderGuiderPrompt'],
|
||||
\ [' ', 'LeaderGuiderSep1'],
|
||||
\ [SpaceVim#mapping#leader#getName(s:prefix_key)
|
||||
\ . keys . gname, 'LeaderGuiderName'],
|
||||
\ [' ', '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
|
||||
|
||||
function! s:guide_help_msg() abort
|
||||
function! s:guide_help_msg(escape) abort
|
||||
if s:guide_help_mode == 1
|
||||
let msg = ' n -> next-page, p -> previous-page, u -> undo-key'
|
||||
else
|
||||
let msg = ' [C-h paging/help]'
|
||||
endif
|
||||
return substitute(msg,' ', '\\ ', 'g')
|
||||
return a:escape ? substitute(msg,' ', '\\ ', 'g') : msg
|
||||
endfunction
|
||||
|
||||
let s:t_ve = ''
|
||||
@ -597,16 +629,21 @@ endfunction
|
||||
|
||||
function! s:winclose() abort " {{{
|
||||
call s:toggle_hide_cursor()
|
||||
noautocmd execute s:gwin.'wincmd w'
|
||||
if s:gwin == winnr()
|
||||
noautocmd close
|
||||
redraw!
|
||||
exe s:winres
|
||||
let s:gwin = -1
|
||||
noautocmd execute s:winnr.'wincmd w'
|
||||
call winrestview(s:winv)
|
||||
if exists('*nvim_open_win')
|
||||
doautocmd WinEnter
|
||||
if exists('*nvim_win_close')
|
||||
call nvim_win_close(s:winid, 1)
|
||||
call s:close_float_statusline()
|
||||
else
|
||||
noautocmd execute s:winid.'wincmd w'
|
||||
if s:winid == winnr()
|
||||
noautocmd close
|
||||
redraw!
|
||||
exe s:winres
|
||||
let s:winid = -1
|
||||
noautocmd execute s:winnr.'wincmd w'
|
||||
call winrestview(s:winv)
|
||||
if exists('*nvim_open_win')
|
||||
doautocmd WinEnter
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
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:FLOATING = SpaceVim#api#import('neovim#floating')
|
||||
let s:JSON = SpaceVim#api#import('data#json')
|
||||
let s:SL = SpaceVim#api#import('vim#statusline')
|
||||
" }}}
|
||||
|
||||
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:preview_timer_id)
|
||||
noautocmd normal! "_ggdG
|
||||
call s:update_statusline()
|
||||
let s:complete_input_history_num = [0,0]
|
||||
endfunction
|
||||
|
||||
@ -383,6 +385,7 @@ function! s:grep_stderr(id, data, event) abort
|
||||
endfunction
|
||||
|
||||
function! s:grep_exit(id, data, event) abort
|
||||
call s:update_statusline()
|
||||
redraw
|
||||
call s:MPT._build_prompt()
|
||||
redrawstatus
|
||||
@ -404,6 +407,7 @@ function! s:next_item() abort
|
||||
if s:preview_able == 1
|
||||
call s:preview()
|
||||
endif
|
||||
call s:update_statusline()
|
||||
redraw
|
||||
call s:MPT._build_prompt()
|
||||
redrawstatus
|
||||
@ -458,6 +462,7 @@ function! s:previous_item() abort
|
||||
if s:preview_able == 1
|
||||
call s:preview()
|
||||
endif
|
||||
call s:update_statusline()
|
||||
redraw
|
||||
call s:MPT._build_prompt()
|
||||
redrawstatus
|
||||
@ -753,6 +758,7 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
||||
endif
|
||||
" setlocal nomodifiable
|
||||
setf SpaceVimFlyGrep
|
||||
call s:update_statusline()
|
||||
call s:matchadd('FileName', '[^:]*:\d\+:\d\+:', 3)
|
||||
let s:MPT._prompt.begin = get(a:argv, 'input', '')
|
||||
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.
|
||||
redraw
|
||||
call s:MPT.open()
|
||||
call s:close_statusline()
|
||||
call SpaceVim#logger#info('FlyGrep ending ===========================')
|
||||
let &t_ve = save_tve
|
||||
if has('gui_running')
|
||||
@ -800,40 +807,22 @@ function! SpaceVim#plugins#flygrep#open(argv) abort
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
let s:statusline_win_id = -1
|
||||
let s:statusline_buf_id = -1
|
||||
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,
|
||||
\ [
|
||||
function! s:update_statusline() abort
|
||||
call s:SL.open_float([
|
||||
\ ['FlyGrep ', 'SpaceVim_statusline_a_bold'],
|
||||
\ ['', 'SpaceVim_statusline_a_SpaceVim_statusline_b'],
|
||||
\ [SpaceVim#plugins#flygrep#mode(), 'SpaceVim_statusline_b'],
|
||||
\ ['', 'SpaceVim_statusline_b_SpaceVim_statusline_c'],
|
||||
\ [getcwd(), 'SpaceVim_statusline_c'],
|
||||
\ ['', 'SpaceVim_statusline_c_SpaceVim_statusline_b'],
|
||||
\ [SpaceVim#plugins#flygrep#lineNr(), 'SpaceVim_statusline_b'],
|
||||
\ ['', 'SpaceVim_statusline_b_SpaceVim_statusline_z'],
|
||||
\ ],
|
||||
\ {})
|
||||
\ [' ', 'SpaceVim_statusline_a_SpaceVim_statusline_b'],
|
||||
\ [SpaceVim#plugins#flygrep#mode() . ' ', 'SpaceVim_statusline_b'],
|
||||
\ [' ', 'SpaceVim_statusline_b_SpaceVim_statusline_c'],
|
||||
\ [getcwd() . ' ', 'SpaceVim_statusline_c'],
|
||||
\ [' ', 'SpaceVim_statusline_c_SpaceVim_statusline_b'],
|
||||
\ [SpaceVim#plugins#flygrep#lineNr() . ' ', 'SpaceVim_statusline_b'],
|
||||
\ [' ', 'SpaceVim_statusline_b_SpaceVim_statusline_z'],
|
||||
\ [repeat(' ', &columns - 11), 'SpaceVim_statusline_z'],
|
||||
\ ])
|
||||
endfunction
|
||||
|
||||
function! Test_st() abort
|
||||
call s:create_statusline()
|
||||
function! s:close_statusline() abort
|
||||
call s:SL.close_float()
|
||||
endfunction
|
||||
|
||||
" 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