mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 20:30:05 +08:00
feat(bookmarks): add leaderf support for vim-bookmarks
This commit is contained in:
parent
88eb4db751
commit
72814fb13f
@ -195,6 +195,21 @@ function! SpaceVim#layers#leaderf#config() abort
|
||||
\ 'after_enter' : string(s:_function('s:init_leaderf_win', 1))[10:-3]
|
||||
\ }
|
||||
|
||||
let g:Lf_Extensions.bookmarks =
|
||||
\ {
|
||||
\ 'source': string(s:_function('s:bookmarks', 1))[10:-3],
|
||||
\ 'accept': string(s:_function('s:bookmarks_acp', 1))[10:-3],
|
||||
\ 'highlights_def': {
|
||||
\ 'Lf_register_name': '^".',
|
||||
\ 'Lf_register_content': '\s\+.*',
|
||||
\ },
|
||||
\ 'highlights_cmd': [
|
||||
\ 'hi def link Lf_register_name ModeMsg',
|
||||
\ 'hi def link Lf_register_content Normal',
|
||||
\ ],
|
||||
\ 'after_enter' : string(s:_function('s:init_leaderf_win', 1))[10:-3]
|
||||
\ }
|
||||
|
||||
let g:Lf_Extensions.locationlist =
|
||||
\ {
|
||||
\ 'source': string(s:_function('s:locationlist', 1))[10:-3],
|
||||
@ -462,6 +477,33 @@ function! s:manpage_acp(line, args) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:bookmarks(...) abort
|
||||
let bookmarks = []
|
||||
let files = sort(bm#all_files())
|
||||
for file in files
|
||||
let line_nrs = sort(bm#all_lines(file), "bm#compare_lines")
|
||||
for line_nr in line_nrs
|
||||
let bookmark = bm#get_bookmark_by_line(file, line_nr)
|
||||
call add(bookmarks, printf("%s:%d:1:%s", file, line_nr,
|
||||
\ bookmark.annotation !=# ''
|
||||
\ ? "Annotation: " . bookmark.annotation
|
||||
\ : (bookmark.content !=# "" ? bookmark.content
|
||||
\ : "empty line")
|
||||
\ ))
|
||||
endfor
|
||||
endfor
|
||||
return bookmarks
|
||||
endfunction
|
||||
|
||||
function! s:bookmarks_acp(line, argvs) abort
|
||||
let line = a:line
|
||||
let filename = fnameescape(split(line, ':\d\+:')[0])
|
||||
let linenr = matchstr(line, ':\d\+:')[1:-2]
|
||||
let colum = matchstr(line, '\(:\d\+\)\@<=:\d\+:')[1:-2]
|
||||
exe 'e ' . filename
|
||||
call cursor(linenr, colum)
|
||||
endfunction
|
||||
|
||||
func! s:neoyank(...) abort
|
||||
let yank = []
|
||||
for text in neoyank#_get_yank_histories()['"']
|
||||
|
@ -177,6 +177,8 @@ function! BookmarkShowAll()
|
||||
exec ":Unite vim_bookmarks"
|
||||
elseif exists(':CtrlP') == 2 && g:bookmark_disable_ctrlp == 0
|
||||
exec ":CtrlPBookmark"
|
||||
elseif exists(':Leaderf')
|
||||
exe ':Leaderf bookmarks'
|
||||
else
|
||||
let oldformat = &errorformat " backup original format
|
||||
let &errorformat = "%f:%l:%m" " custom format for bookmarks
|
||||
|
Loading…
Reference in New Issue
Block a user