- Timestamp:
- 02/02/08 18:24:37 (5 years ago)
- Location:
- dotfiles/vim/kana
- Files:
-
- 4 modified
-
dot.vim/autoload/ku.vim (modified) (18 diffs)
-
dot.vim/autoload/vcsi.vim (modified) (3 diffs)
-
dot.vim/doc/ku.txt (modified) (6 diffs)
-
dot.vimrc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dotfiles/vim/kana/dot.vim/autoload/ku.vim
r5824 r6039 4 4 " License: MIT license (see <http://www.opensource.org/licenses/mit-license>) 5 5 " $Id$ "{{{1 6 " FIXME: Translate the following FIXMEs in English. 7 " 8 " FIXME: ドキュメント更新。 9 " 10 " FIXME: s:do(): どのitemにもマッチしない入力であってもactionに渡す。 11 " 例えば今の状況ではtype fileで新規ファイルを開けないので、 12 " このような処理は必要である。 13 " 14 " ただし、これをするならばどのtypeのactionを使うかが問題。 15 " s:preferred_typeが定義されている場合に限定か。 16 " 17 " FIXME: より「賢い」ソーティング (優先順位: 低) 18 " - パスっぽいものは最後のコンポーネントを重視するのはどうか? 19 " - type buffer: フルパスと相対パスのどちらを使うべきか? 20 " - パスっぽいものは相対パス優先の方がいい? 21 " '/'の値は若い以上、今のままでは自動的に相対パスが軽視されることになる。 22 " 23 " FIXME: strtrans()の代替作成。<Left>等を正しく変換するように。 24 " 25 " FIXME: type file - stub. 26 " FIXME: type directory - NIY. 27 " 28 " FIXME: 各種比較でのcase sensitivityの統一・見直し。 29 " 30 " FIXME: 実装方法の選択 31 " (A) ins-completion-menuを利用(Omni completion) 32 " + Insert modeの基本的な操作体系を利用可能。 33 " - 一部キーをmappingできないため、細かい情報を取れない。 34 " * 特に問題な点は 35 " 「どの項目が選択されているか」と 36 " 「選択状況が変化したか」を 37 " 知ることができないこと。 38 " * このために 39 " 「actionを<Tab>で選んで実行」というI/Fや、 40 " 「利用可能なactionを適宜表示」ということができない。 41 " - CursorMovedIのフックを利用しての検出のため、カオス過ぎる。 42 " 特にs:PROMPTはひどい発明。 43 " 44 " (B) getchar()で自力管理 45 " + キー入力を全て把握できるため、ins-completion-menuの問題はない。 46 " - キー入力を自力で管理する以上、 47 " 基本的な操作体系も含めて実装しなければならない。 48 " * itemsの一覧表示はins-completion-menu以外の方法が取れる。 49 " 例えばtype毎に並べたitemsのうち、 50 " preferred以外はfoldする等。 51 " 52 " buffuzzy/zapitの経験から(A)を利用していたが、 53 " itemsの表示はバッファを使ってどうとでもできるので、 54 " (B)も一考の価値はある。 55 " 56 " ただ、(A)でもある程度の問題は解決してしまったため、一先ずは(A)で行く。 57 " (B)には(B)で魅力的なメリットがあるので、落ち着いたらそちらも考える。 6 " FIXME: auto-complete 1 component for each typing '/' (like bluewind). 7 " FIXME: s:do(): Force action on unmatched pattern. 8 " FIXME: more smart sorting: 9 " - considering last component. 10 " - type buffer: full path vs. relative path. 11 " FIXME: review on case sensitivity. 12 " FIXME: alternative implementation (getchar()), if necessary. 58 13 " 59 14 " Variables and Constants "{{{1 … … 61 16 let s:FALSE = 0 62 17 let s:TRUE = !s:FALSE 18 19 let s:TYPE_NUMBER = type(0) 20 let s:TYPE_STRING = type('') 21 let s:TYPE_FUNCTION = type(function('function')) 22 let s:TYPE_LIST = type([]) 23 let s:TYPE_DICTONARY = type({}) 24 63 25 64 26 " Flag which indicates whether the ku window is opened with bang (:Ku!). … … 143 105 2 wincmd _ 144 106 107 " Do some initialization for each type. 108 for type_name in keys(s:types) 109 call s:types[type_name].initialize() 110 endfor 111 145 112 " Start Insert mode. 146 113 % delete _ … … 168 135 if !s:valid_type_definition_p(a:args) 169 136 echohl ErrorMsg 170 echomsg 'Invalid type definition:' str trans(a:args)137 echomsg 'Invalid type definition:' string(a:args) 171 138 echohl None 172 139 return s:FALSE … … 289 256 290 257 " Do the specified aciton. 291 if type(item) != type('')258 if type(item) == s:TYPE_DICTONARY 292 259 let ActionFunction = (a:choose_p 293 \ ? s:choose_action (item._ku_type.actions)260 \ ? s:choose_action_for_item(item) 294 261 \ : item._ku_type.actions[0].function) 295 call ActionFunction(item)262 call s:apply(ActionFunction, [item]) 296 263 endif 297 264 endfunction … … 365 332 function! s:nop(...) "{{{2 366 333 return 334 endfunction 335 336 337 338 339 function! s:string(s) "{{{2 340 " like strtrans(), but convert into more human-readable notation on special 341 " keys such as <Left>. 342 return strtrans(a:s) " FIXME: NIY. 367 343 endfunction 368 344 … … 477 453 function! s:make_asis_regexp(s) "{{{2 478 454 " FIXME: case sensitivity 479 return '\c\V' . substitute( a:s, '\', '\\', 'g')455 return '\c\V' . substitute(substitute(a:s, '\s\+', ' ', 'g'), '\', '\\', 'g') 480 456 endfunction 481 457 … … 485 461 function! s:make_skip_regexp(s) "{{{2 486 462 " FIXME: case sensitivity 487 return substitute(s:make_asis_regexp(a:s), '\s', '\\.\\*', 'g') 463 " FIXME: path separator assumption 464 let p_asis = s:make_asis_regexp(substitute(a:s, '/', ' / ', 'g')) 465 return substitute(p_asis, '\s', '\\.\\*', 'g') 488 466 endfunction 489 467 … … 543 521 544 522 545 function! s:choose_action(actions) "{{{2 546 " FIXME: style of the menu message. 547 echo 'Available actions are:' 548 for action in a:actions 549 echo printf('%s :: %s', strtrans(action.key), action.name) 550 endfor 551 echo '' 523 function! s:choose_action_for_item(item) "{{{2 524 let actions = a:item._ku_type.actions 525 call s:show_available_actions_message(a:item) 552 526 553 527 let c = nr2char(getchar()) 554 528 redraw " clear the menu message lines to avoid hit-enter prompt. 555 529 556 for action in a :actions530 for action in actions 557 531 if c ==# action.key 558 532 return action.function … … 560 534 endfor 561 535 562 echo 'The key' s trtrans(c) 'is not associated with any action'536 echo 'The key' s:string(c) 'is not associated with any action' 563 537 \ '-- nothing happened.' 564 538 return function('s:nop') 539 endfunction 540 541 542 543 544 function! s:show_available_actions_message(item) "{{{2 545 " FIXME: like ls(1). 546 let actions = a:item._ku_type.actions 547 let max_key_length = max(map(copy(actions), 'len(s:string(v:val.key))')) 548 let max_name_length = max(map(copy(actions), 'len(v:val.name)')) 549 let padding = 3 550 let max_cell_length = max_key_length + 3 + max_name_length + padding 551 let format = '%*s%*s - %-*s' 552 553 let max_column = max([1, (&columns + padding - 1) / max_cell_length]) 554 let max_column = min([max_column, 4]) 555 let n = len(actions) 556 let max_row = n / max_column + (n % max_column != 0) 557 558 echo printf('Available actions for %s (type %s) are:', 559 \ a:item.word, a:item._ku_type.name) 560 for r in range(max_row) 561 let i = r 562 echo '' 563 while i < n 564 echon printf(format, 565 \ (i == r ? 0 : padding), '', 566 \ max_key_length, s:string(actions[i].key), 567 \ max_name_length, actions[i].name) 568 let i += max_row 569 endwhile 570 endfor 571 echo '' 565 572 endfunction 566 573 … … 581 588 582 589 function! s:valid_type_definition_p(args) "{{{2 583 let T_NUM = type(0) 584 let T_STR = type('') 585 let T_FUNC = type(function('function')) 586 let T_LIST = type([]) 587 let T_DICT = type({}) 588 589 if type(a:args) != T_DICT 590 if type(a:args) != s:TYPE_DICTONARY 590 591 return s:FALSE 591 592 endif 592 593 593 594 " -- The name of this type. 594 if !s:has_valid_entry(a:args, 'name', T_STR) | return s:FALSE | endif595 if !s:has_valid_entry(a:args, 'name', s:TYPE_STRING) | return s:FALSE | endif 595 596 if !(a:args.name =~# '^[a-z]\+$') | return s:FALSE | endif 596 597 … … 604 605 " 'name' The name of the action. 605 606 " 'function' The function of the action. It is called with one parameter, 606 " the selected item (as described in :help complete-items).607 if !s:has_valid_entry(a:args, 'actions', T_LIST) | return s:FALSE | endif607 " the selected item (as described in |complete-items|). 608 if !s:has_valid_entry(a:args,'actions',s:TYPE_LIST) | return s:FALSE | endif 608 609 if !(1 <= len(a:args.actions)) | return s:FALSE | endif 609 610 for v in a:args.actions 610 if !s:has_valid_entry(v, 'key', T_STR) | return s:FALSE | endif 611 if !s:has_valid_entry(v, 'name', T_STR) | return s:FALSE | endif 612 if !s:has_valid_entry(v, 'function', T_FUNC) | return s:FALSE | endif 611 if !s:has_valid_entry(v, 'key', s:TYPE_STRING) | return s:FALSE | endif 612 if !s:has_valid_entry(v, 'name', s:TYPE_STRING) | return s:FALSE | endif 613 if !(has_key(v, 'function') && s:callable_p(v.function)) 614 return s:FALSE 615 endif 613 616 endfor 614 617 615 618 " -- Function to gather items which match to the given pattern. 616 619 " It takes 1 argument (user input pattern). 617 " It returns a list of items. Each item is a string. 618 if !s:has_valid_entry(a:args, 'gather', T_FUNC) | return s:FALSE | endif 619 620 " FIXME: other entries. 620 " It returns a list of items. Each item is a |complete-items|. 621 if !s:has_valid_entry(a:args,'gather',s:TYPE_FUNCTION) |return s:FALSE |endif 622 623 " -- Function to initialize some information of 'gather'. 624 " It will be called with no argument. 625 " Its returning value will be discarded. 626 " This entry may be missing, if so, nothing will be happened on 627 " initialization. 628 if has_key(a:args, 'initialize') 629 if !(type(a:args.initialize) == s:TYPE_FUNCTION) | return s:FALSE | endif 630 else 631 let a:args.initialize = function('s:nop') 632 endif 633 634 " -- other entries -- 635 621 636 return s:TRUE 622 637 endfunction … … 632 647 633 648 649 function! s:callable_p(obj) "{{{2 650 return (type(a:obj) == s:TYPE_FUNCTION) 651 \ || ((type(a:obj) == s:TYPE_DICTONARY) && has_key(a:obj, '__call__')) 652 endfunction 653 654 655 656 657 function! s:apply(obj, args) "{{{2 658 if type(a:obj) == s:TYPE_FUNCTION 659 return call(a:obj, a:args) 660 elseif type(a:obj) == s:TYPE_DICTONARY && has_key(a:obj, '__call__') 661 return call(a:obj.__call__, a:args, a:obj) 662 else 663 throw 'This object is not callable:' string(a:obj) 664 endif 665 endfunction 666 667 668 669 670 function! s:pa(f, ...) "{{{2 671 " pa = Partial Apply 672 " Returns a callable object g, 673 " where g(b, ...) is equivalent to f(a, ..., b, ...). 674 let g = {} 675 let g.f = a:f 676 let g.args = copy(a:000) " a:000 will be lost after this execution. 677 function! g.__call__(...) 678 return call(self.f, self.args + a:000) 679 endfunction 680 return g 681 endfunction 682 683 684 685 634 686 635 687 … … 638 690 " Built-in Types "{{{1 639 691 " buffer "{{{2 692 " FIXME: how about unlisted buffers? 640 693 let s:_type_buffer_cached_items = [] 641 694 let s:_type_buffer_last_bufnr = s:INVALID_BUFNR 642 695 function! s:_type_buffer_gather(pattern) 643 if s:_type_buffer_last_bufnr != bufnr('$') 696 if s:_type_buffer_last_bufnr == bufnr('$') 697 call filter(s:_type_buffer_cached_items, 'bufexists(v:val._buffer_number)') 698 else 644 699 let s:_type_buffer_cached_items = [] 645 700 let format = 'buffer %' . len(bufnr('$')) . 'd' … … 664 719 execute a:item._buffer_number 'buffer'.ku#bang() 665 720 endfunction 666 function! s:_type_buffer_action_split_open(item) 667 execute a:item._buffer_number 'sbuffer' 668 endfunction 669 function! s:_type_buffer_action_vsplit_open(item) 670 execute 'vertical' a:item._buffer_number 'sbuffer' 671 endfunction 672 673 674 " FIXME: other variants: hjkl HJKL. 721 function! s:_type_buffer_action_xsplit(modifier, item) 722 execute a:modifier a:item._buffer_number 'sbuffer' 723 endfunction 724 function! s:_type_buffer_action_xdelete(command, item) 725 execute a:item._buffer_number a:command.ku#bang() 726 endfunction 727 728 675 729 call ku#register_type({ 676 730 \ 'name': 'buffer', 731 \ 'gather': function('s:_type_buffer_gather'), 677 732 \ 'actions': [ 678 733 \ {'key': 'o', 679 734 \ 'name': 'open', 680 735 \ 'function': function('s:_type_buffer_action_open')}, 736 \ {'key': 'n', 737 \ 'name': 'split', 738 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), '')}, 681 739 \ {'key': 's', 682 \ 'name': 'split open',683 \ 'function': function('s:_type_buffer_action_split_open')},740 \ 'name': 'split', 741 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), '')}, 684 742 \ {'key': 'v', 685 \ 'name': 'vsplit open', 686 \ 'function': function('s:_type_buffer_action_vsplit_open')}, 743 \ 'name': 'vsplit', 744 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 745 \ 'vertical')}, 746 \ {'key': 'h', 747 \ 'name': 'split left', 748 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 749 \ 'vertical leftabove')}, 750 \ {'key': 'j', 751 \ 'name': 'split down', 752 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 753 \ 'rightbelow')}, 754 \ {'key': 'k', 755 \ 'name': 'split up', 756 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 757 \ 'leftabove')}, 758 \ {'key': 'l', 759 \ 'name': 'split right', 760 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 761 \ 'vertical rightbelow')}, 762 \ {'key': "\<C-h>", 763 \ 'name': 'split left', 764 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 765 \ 'vertical leftabove')}, 766 \ {'key': "\<C-j>", 767 \ 'name': 'split down', 768 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 769 \ 'rightbelow')}, 770 \ {'key': "\<C-k>", 771 \ 'name': 'split up', 772 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 773 \ 'leftabove')}, 774 \ {'key': "\<C-l>", 775 \ 'name': 'split right', 776 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 777 \ 'vertical rightbelow')}, 778 \ {'key': 'H', 779 \ 'name': 'split far left', 780 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 781 \ 'vertical topleft')}, 782 \ {'key': 'J', 783 \ 'name': 'split bottom', 784 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 785 \ 'botright')}, 786 \ {'key': 'K', 787 \ 'name': 'split top', 788 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 789 \ 'topleft')}, 790 \ {'key': 'L', 791 \ 'name': 'split far right', 792 \ 'function': s:pa(function('s:_type_buffer_action_xsplit'), 793 \ 'vertical botright')}, 794 \ {'key': 'U', 795 \ 'name': 'unload', 796 \ 'function': s:pa(function('s:_type_buffer_action_xdelete'), 797 \ 'bunload')}, 798 \ {'key': 'D', 799 \ 'name': 'delete', 800 \ 'function': s:pa(function('s:_type_buffer_action_xdelete'), 801 \ 'bdelete')}, 802 \ {'key': 'W', 803 \ 'name': 'wipeout', 804 \ 'function': s:pa(function('s:_type_buffer_action_xdelete'), 805 \ 'bwipeout')}, 687 806 \ ], 688 \ 'gather': function('s:_type_buffer_gather'),689 807 \ }) 690 808 … … 693 811 694 812 " file "{{{2 695 " FIXME: stub. 696 let s:_type_file_cached_items = [] 697 let s:_type_file_last_bufnr = s:INVALID_BUFNR 813 " FIXME: action idea: source 814 " FIXME: action idea: ':' - set up ":<cursor> <item>" for any Ex command. 815 " FIXME: unexpected propmt on some environments when glob() is called. 816 " it happens when the pattern contains '{foo,bar}'. 817 " FIXME: smart caching. 818 " FIXME: can't list the root directory. 819 function! s:_type_file_initialize() 820 let s:_type_file_cache = {} 821 let s:_type_file_frags_count = -1 822 endfunction 823 698 824 function! s:_type_file_gather(pattern) 699 if s:_type_file_last_bufnr != bufnr('$') 700 let s:_type_file_cached_items = [] 701 for i in range(1, bufnr('$')) 702 if bufexists(i) && buflisted(i) && getbufvar(i, '&buftype') == '' 703 call add(s:_type_file_cached_items, 704 \ { 705 \ 'word': bufname(i), 706 \ 'menu': 'file', 707 \ 'dup': s:TRUE, 708 \ }) 709 endif 710 endfor 711 let s:_type_file_last_bufnr = bufnr('$') 712 endif 713 return s:_type_file_cached_items 714 endfunction 715 716 825 let c = len(split(a:pattern, '/', s:TRUE)) - 1 826 if s:_type_file_frags_count != c 827 let s:_type_file_frags_count = c 828 let s:_type_file_cache[c] 829 \ = map(split(glob(s:make_glob_pattern(a:pattern)), '\n'), 830 \ "{'word': v:val, 'menu': 'file', 'dup': s:TRUE}") 831 endif 832 return s:_type_file_cache[c] 833 endfunction 834 835 function! s:make_glob_pattern(s) 836 " FIXME: path separetor assumption. 837 let frags = split(substitute(a:s, '\s\+', '*', 'g'), '/', 1) 838 call map(frags, '"{,.??,.[^.]}*" . v:val . "*"') 839 call map(frags, 'substitute(v:val, "\\*\\+", "*", "g")') 840 return join(frags, '/') 841 endfunction 842 843 844 " FIXME: filename with special characters -- should escape? 717 845 function! s:_type_file_action_open(item) 718 846 execute 'edit'.ku#bang() a:item.word 719 847 endfunction 720 function! s:_type_file_action_split_open(item) 721 execute 'split' a:item.word 722 endfunction 723 function! s:_type_file_action_vsplit_open(item) 724 execute 'vsplit' a:item.word 848 function! s:_type_file_action_xsplit(modifier, item) 849 execute a:modifier 'split' a:item.word 725 850 endfunction 726 851 … … 728 853 call ku#register_type({ 729 854 \ 'name': 'file', 855 \ 'initialize': function('s:_type_file_initialize'), 856 \ 'gather': function('s:_type_file_gather'), 730 857 \ 'actions': [ 731 858 \ {'key': 'o', 732 859 \ 'name': 'open', 733 860 \ 'function': function('s:_type_file_action_open')}, 861 \ {'key': 'n', 862 \ 'name': 'split', 863 \ 'function': s:pa(function('s:_type_file_action_xsplit'), '')}, 734 864 \ {'key': 's', 735 \ 'name': 'split open',736 \ 'function': function('s:_type_file_action_split_open')},865 \ 'name': 'split', 866 \ 'function': s:pa(function('s:_type_file_action_xsplit'), '')}, 737 867 \ {'key': 'v', 738 \ 'name': 'vsplit open', 739 \ 'function': function('s:_type_file_action_vsplit_open')}, 868 \ 'name': 'vsplit', 869 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 870 \ 'vertical')}, 871 \ {'key': 'h', 872 \ 'name': 'split left', 873 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 874 \ 'vertical leftabove')}, 875 \ {'key': 'j', 876 \ 'name': 'split down', 877 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 878 \ 'rightbelow')}, 879 \ {'key': 'k', 880 \ 'name': 'split up', 881 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 882 \ 'leftabove')}, 883 \ {'key': 'l', 884 \ 'name': 'split right', 885 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 886 \ 'vertical rightbelow')}, 887 \ {'key': "\<C-h>", 888 \ 'name': 'split left', 889 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 890 \ 'vertical leftabove')}, 891 \ {'key': "\<C-j>", 892 \ 'name': 'split down', 893 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 894 \ 'rightbelow')}, 895 \ {'key': "\<C-k>", 896 \ 'name': 'split up', 897 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 898 \ 'leftabove')}, 899 \ {'key': "\<C-l>", 900 \ 'name': 'split right', 901 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 902 \ 'vertical rightbelow')}, 903 \ {'key': 'H', 904 \ 'name': 'split far left', 905 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 906 \ 'vertical topleft')}, 907 \ {'key': 'J', 908 \ 'name': 'split bottom', 909 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 910 \ 'botright')}, 911 \ {'key': 'K', 912 \ 'name': 'split top', 913 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 914 \ 'topleft')}, 915 \ {'key': 'L', 916 \ 'name': 'split far right', 917 \ 'function': s:pa(function('s:_type_file_action_xsplit'), 918 \ 'vertical botright')}, 740 919 \ ], 741 \ 'gather': function('s:_type_file_gather'),742 920 \ }) 743 921 … … 750 928 751 929 " directory "{{{2 752 " FIXME: not written yet .930 " FIXME: not written yet -- integrate into type file? 753 931 754 932 -
dotfiles/vim/kana/dot.vim/autoload/vcsi.vim
r5824 r6039 100 100 return s:execute_vcs_command({ 101 101 \ 'command': 'revert', 102 \ 'items': s:normalize_items(a:000 )102 \ 'items': s:normalize_items(a:000, 'no-new-window') 103 103 \ }) 104 104 endfunction … … 246 246 247 247 248 function! s:normalize_items(unnormalized_items) "{{{2 248 function! s:normalize_items(unnormalized_items, ...) "{{{2 249 let no_new_window_p = a:0 && a:1 ==# 'no-new-window' 249 250 let items = [] 250 251 for item in (len(a:unnormalized_items) ? a:unnormalized_items : ['-']) … … 255 256 call extend(items, b:vcsi_target_items) 256 257 else 257 call add(items, bufname( '#'))258 call add(items, bufname(no_new_window_p ? '' : '#')) 258 259 endif 259 260 else -
dotfiles/vim/kana/dot.vim/doc/ku.txt
r5824 r6039 29 29 proper candidates for the input pattern. 30 30 31 *ku-window* 31 *ku-window* *ku-buffer* 32 32 ku window The window which is opened by |ku-commands|. 33 33 This window will be automatically closed when: … … 45 45 Start selecting by ku. 46 46 [bang] modifier will be used by an action. 47 {preferred-type} means what type of items to be 48 appeared at fisrt in the completion list. 47 {preferred-type} specifies what type of items to be 48 appeared in the completion list. If it is omitted, 49 all type of items will be appeared. 49 50 50 51 … … 71 72 Return whether [bang] modifier is given for the last 72 73 executed |:Ku| or |ku#start()|. String "!" will be 73 returned if [bang] modifier is give , otherwise an74 returned if [bang] modifier is given, otherwise an 74 75 empty string will be returned. 75 76 76 ku#register_type({ args}) *ku#register_type()*77 Register new type which is defined by { args}.78 { args} is a dictionary. See the comment in the source79 for the detail of { args}.77 ku#register_type({typedef}) *ku#register_type()* 78 Register new type which is defined by {typedef}. 79 {typedef} is a dictionary. See |ku-write-new-type| 80 for the detail of {typedef}. 80 81 81 82 Note that any built-in type can be overridden. … … 94 95 In the ku window, the following key mappings are defined: 95 96 96 <Plug>(ku-cancel) Cancel selecting (and close the ku window). 97 <Plug>(ku-do-default) Do the default action for the current item. 98 <Plug>(ku-choose-action) Choose an action, then do it for the item. 99 <Plug>(ku-next-type) Change the preferred type (ascending). 100 <Plug>(ku-previous-type) Change the preferred type (descending). 97 <Plug>(ku-cancel) *<Plug>(ku-cancel)* 98 Cancel selecting (and close the ku window). 99 100 <Plug>(ku-do-default) *<Plug>(ku-do-default)* 101 Do the default action for the current item. 102 103 <Plug>(ku-choose-action) *<Plug>(ku-choose-action)* 104 Show the mesasge on available actions, take a single 105 key input, then do the appropriate action. 106 107 <Plug>(ku-next-type) *<Plug>(ku-next-type)* 108 <Plug>(ku-previous-type) *<Plug>(ku-previous-type)* 109 Change the preferred type (ascending / descending). 101 110 102 111 The default key mappings are defined by |ku#default_key_mappings()|. … … 106 115 107 116 ============================================================================== 108 ITEM TYPES*ku-types*109 110 Ku supports the following types of items to be selected.117 TYPES *ku-types* 118 119 Types are kinds of items. The following types are built-in. 111 120 112 121 Name Actions ~ 113 "buffer" |:buffer|, |:sbuffer|, ... 114 "directory" |:edit|, |:new|, ..., |:cd| 115 "file" |:edit|, |:new|, ... 122 buffer Open the specified buffer with |:buffer| or |:sbuffer|. 123 file Open the specified file with |:edit| or |:new|. 116 124 117 125 … … 121 129 CUSTOMIZING *ku-customizing* 122 130 123 - FIXME: not written yet. 124 - key mappings. 125 - add your own type of items. 131 Initialization *ku-initialization* 132 *KuBufferInitialize* 133 Ku has its own buffer to do its work. Whenever the buffer is created, 134 "User KuBufferInitialize" event will be published. Use this event to 135 do user's initialization for the buffer, for example: > 136 137 autocmd User KuBufferInitialize call MyOwnInitialization() 138 < 139 If there is no autocommand for |KuBufferInitialize|, Ku will call 140 |ku#default_key_mappings()|. 141 142 Write New Type *ku-write-new-type* 143 To use new type, call |ku#register_type()| with its {typedef}. 144 {typedef} is a dictionary and it contains the following entries: 145 146 'name' string 147 The name of this type. It consits of only lowercase 148 alphabets. 149 150 'actions' list 151 The available actions for items of this type. 152 Each value is a dictionary with the following entries: 153 154 'key' string 155 The key to choose this action. 156 It will be used by |<Plug>(ku-choose-action)|. 157 158 'name' string 159 The name of this action. Use short and brief one. 160 161 'function' funcref 162 The function of this action. It will be called with 163 one parameter, the selected item (as described in 164 |complete-items|). 165 166 Note that the first entry is treated as the default action for 167 items of this type. So it will be used by 168 |<Plug>(ku-do-default)|. 169 170 'gather' funcref 171 The function to gather items matching to the given pattern. 172 It is called with one parameter, the user input pattern. 173 It must return the list of |complete-items|. 174 175 'initialize' funcref (optional) 176 The function which will be called with no argument whenever 177 the ku window is opened. The main purpose of this function is 178 to do some initialization for 'gather'. 126 179 127 180 -
dotfiles/vim/kana/dot.vimrc
r5824 r6039 323 323 324 324 " CMapABC: support input for Alternate Built-in Commands "{{{2 325 " Memo: It's possible to implement this feature by using :cabbrev with <expr>. 326 " But it seems to be hard to reset the current definitions. 325 327 326 328 let s:CMapABC_Entries = [] … … 1247 1249 endif 1248 1250 endfunction 1251 1252 1253 " Show the lines which match to the last search pattern. 1254 nnoremap g/ :g/<Return> 1255 vnoremap g/ :g/<Return> 1249 1256 1250 1257
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)