Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions autoload/bm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ function! bm#all_lines(file)
return keys(g:line_map[a:file])
endfunction

function! bm#coc_location_list()
let files = sort(bm#all_files())
let locations = []
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)
let content = bookmark['annotation'] !=# ''
\ ? "Annotation: ". bookmark['annotation']
\ : (bookmark['content'] !=# ""
\ ? bookmark['content']
\ : "empty line")
let item = {
\ 'lnum': line_nr,
\ 'filename': file,
\ 'col': 1,
\ 'text': content
\ }
call add(locations, item)
endfor
endfor
return locations
endfunction

function! bm#location_list()
let files = sort(bm#all_files())
let locations = []
Expand Down
48 changes: 27 additions & 21 deletions plugin/bookmark.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ call s:set('g:bookmark_center', 0 )
call s:set('g:bookmark_location_list', 0 )
call s:set('g:bookmark_disable_ctrlp', 0 )
call s:set('g:bookmark_display_annotation', 0 )
call s:set('g:bookmark_show_all_by_coclist', 0 )

function! s:init(file)
if g:bookmark_auto_save ==# 1 || g:bookmark_manage_per_buffer ==# 1
Expand Down Expand Up @@ -177,30 +178,35 @@ command! BookmarkPrev call BookmarkPrev()
command! CtrlPBookmark call ctrlp#init(ctrlp#bookmarks#id())

function! BookmarkShowAll()
if s:is_quickfix_win()
q
if g:bookmark_show_all_by_coclist ==# 1
let g:coc_jump_locations=bm#coc_location_list()
CocList --normal --auto-preview location
else
call s:refresh_line_numbers()
if exists(':Unite')
exec ":Unite vim_bookmarks"
elseif exists(':CtrlP') == 2 && g:bookmark_disable_ctrlp == 0
exec ":CtrlPBookmark"
else
let oldformat = &errorformat " backup original format
let &errorformat = "%f:%l:%m" " custom format for bookmarks
if g:bookmark_location_list
lgetexpr bm#location_list()
belowright lopen
if s:is_quickfix_win()
q
else
cgetexpr bm#location_list()
belowright copen
call s:refresh_line_numbers()
if exists(':Unite')
exec ":Unite vim_bookmarks"
elseif exists(':CtrlP') == 2 && g:bookmark_disable_ctrlp == 0
exec ":CtrlPBookmark"
else
let oldformat = &errorformat " backup original format
let &errorformat = "%f:%l:%m" " custom format for bookmarks
if g:bookmark_location_list
lgetexpr bm#location_list()
belowright lopen
else
cgetexpr bm#location_list()
belowright copen
endif
augroup BM_AutoCloseCommand
autocmd!
autocmd WinLeave * call s:auto_close()
augroup END
let &errorformat = oldformat " re-apply original format
endif
endif
augroup BM_AutoCloseCommand
autocmd!
autocmd WinLeave * call s:auto_close()
augroup END
let &errorformat = oldformat " re-apply original format
endif
endif
endfunction
command! ShowAllBookmarks call CallDeprecatedCommand('BookmarkShowAll')
Expand Down