└── autoload └── unite └── sources └── history.vim /autoload/unite/sources/history.vim: -------------------------------------------------------------------------------- 1 | " unite source: history 2 | " Version: 0.2.0 3 | " Author : thinca 4 | " License: zlib License 5 | 6 | let s:save_cpo = &cpo 7 | set cpo&vim 8 | 9 | let s:source = { 10 | \ 'action_table': {}, 11 | \ } 12 | 13 | function! s:source.gather_candidates(args, context) 14 | return map(filter(map(reverse(range(1, histnr(self.type))), 15 | \ '[v:val, histget(self.type, v:val)]'), 16 | \ 'v:val[1] != ""'), '{ 17 | \ "word": v:val[1], 18 | \ "abbr": self.type . v:val[1], 19 | \ "kind": "command", 20 | \ "action__command": v:val[1], 21 | \ "action__histadd": 1, 22 | \ "action__type": self.type, 23 | \ "action__index": v:val[0], 24 | \ }') 25 | endfunction 26 | 27 | 28 | let s:action_table = { 29 | \ 'delete': { 30 | \ 'description': 'delete from history', 31 | \ 'is_selectable': 1, 32 | \ 'is_invalidate_cache': 1, 33 | \ 'is_quit': 0, 34 | \ }, 35 | \ } 36 | 37 | function! s:action_table.delete.func(candidates) 38 | call map(a:candidates, 'histdel(v:val.action__type, v:val.action__index)') 39 | endfunction 40 | 41 | let s:source.action_table.command = s:action_table 42 | 43 | 44 | 45 | function! unite#sources#history#define() 46 | return map([{'name': 'command', 'type': ':'}, 47 | \ {'name': 'search', 'type': '/'}], 48 | \ 'extend(copy(s:source), 49 | \ extend(v:val, {"name": "history/" . v:val.name, 50 | \ "description": "candidates from history of " . v:val.name}))') 51 | endfunction 52 | 53 | let &cpo = s:save_cpo 54 | unlet s:save_cpo 55 | --------------------------------------------------------------------------------