└── autoload └── completer.vim /autoload/completer.vim: -------------------------------------------------------------------------------- 1 | " TODO 2 | "tag 3 | "tag_listfiles 4 | "user 5 | "custom, 6 | "customlist, 7 | 8 | function! completer#augroup() 9 | redir => result 10 | silent augroup 11 | redir END 12 | return split(join(split(result, '\n'), ' '), '\s\+') 13 | endfunction 14 | 15 | function! completer#buffer() 16 | return map(range(1, bufnr('$')), 'bufname(v:val)') 17 | endfunction 18 | 19 | function! completer#behave() 20 | return ['mswin', 'xterm'] 21 | endfunction 22 | 23 | function! completer#color() 24 | return map(split(globpath(&rtp, 'colors/*.vim'), "\n"), 'fnamemodify(v:val, ":t:r")') 25 | endfunction 26 | 27 | function! completer#command() 28 | redir => result 29 | silent command 30 | redir END 31 | return map(split(result, '\n'), 'matchstr(v:val, "^\\s\\+\\zs\\S\\+\\ze")') 32 | endfunction 33 | 34 | function! completer#compiler() 35 | return map(split(globpath(&rtp, 'compiler/*.vim'), "\n"), 'fnamemodify(v:val, ":t:r")') 36 | endfunction 37 | 38 | function! completer#cscope() 39 | redir => result 40 | silent cscope 41 | redir END 42 | return filter(map(split(result, '\n'), 'matchstr(v:val, "^\\S\\+\\ze :")'), '!empty(v:val)') 43 | endfunction 44 | 45 | function! completer#dir() 46 | return filter(split(glob('*'), "\n"), 'isdirectory(v:val)') 47 | endfunction 48 | 49 | function! completer#environment() 50 | return map(split(system(has('win32') ? 'set' : 'env'), "\n"), 'matchstr(v:val, "^[^=]\\+")') 51 | endfunction 52 | 53 | function! completer#event() 54 | return ['BufNewFile', 'BufReadPre', 'BufRead', 'BufReadPost', 'BufReadCmd', 'FileReadPre', 'FileReadPost', 'FileReadCmd', 'FilterReadPre', 'FilterReadPost', 'StdinReadPre', 'StdinReadPost', 'BufWrite', 'BufWritePre', 'BufWritePost', 'BufWriteCmd', 'FileWritePre', 'FileWritePost', 'FileWriteCmd', 'FileAppendPre', 'FileAppendPost', 'FileAppendCmd', 'FilterWritePre', 'FilterWritePost', 'BufAdd', 'BufCreate', 'BufDelete', 'BufWipeout', 'BufFilePre', 'BufFilePost', 'BufEnter', 'BufLeave', 'BufWinEnter', 'BufWinLeave', 'BufUnload', 'BufHidden', 'BufNew', 'SwapExists', 'FileType', 'Syntax', 'EncodingChanged', 'TermChanged', 'OptionSet', 'VimEnter', 'GUIEnter', 'GUIFailed', 'TermResponse', 'QuitPre', 'VimLeavePre', 'VimLeave', 'FileChangedShell', 'FileChangedShellPost', 'FileChangedRO', 'ShellCmdPost', 'ShellFilterPost', 'CmdUndefined', 'FuncUndefined', 'SpellFileMissing', 'SourcePre', 'SourceCmd', 'VimResized', 'FocusGained', 'FocusLost', 'CursorHold', 'CursorHoldI', 'CursorMoved', 'CursorMovedI', 'WinEnter', 'WinLeave', 'TabEnter', 'TabLeave', 'CmdwinEnter', 'CmdwinLeave', 'InsertEnter', 'InsertChange', 'InsertLeave', 'InsertCharPre', 'TextChanged', 'TextChangedI', 'ColorScheme', 'RemoteReply', 'QuickFixCmdPre', 'QuickFixCmdPost', 'SessionLoadPost', 'MenuPopup', 'CompleteDone', 'User'] 55 | endfunction 56 | 57 | function! completer#expression() 58 | " TODO 59 | return completer#var() + completer#function() 60 | endfunction 61 | 62 | function! completer#file() 63 | return filter(split(glob('*'), "\n"), 'isfilereadable(v:val)') 64 | endfunction 65 | 66 | function! completer#file_in_path() 67 | " TODO 68 | return globpath(&path, '*', 0, 1) 69 | endfunction 70 | 71 | function! completer#filetype() 72 | " TODO 73 | return map(split(globpath(&rtp, 'ftplugin/*.vim'), "\n"), 'fnamemodify(v:val, ":t:r")') + filter(split(globpath(&rtp, 'ftplugin/*'), "\n"), 'isdirectory(v:val)') 74 | endfunction 75 | 76 | function! completer#function() 77 | redir => result 78 | silent function 79 | redir END 80 | return filter(map(split(result, '\n'), 'matchstr(v:val, "^function \\zs[^(]\\+")'), '!empty(v:val)') 81 | endfunction 82 | 83 | function! completer#help() 84 | " TODO 85 | return [] 86 | endfunction 87 | 88 | function! completer#highlight() 89 | redir => result 90 | silent highlight 91 | redir END 92 | return filter(map(split(result, '\n'), 'matchstr(v:val, "^\\S\\+\\ze\s")'), '!empty(v:val)') 93 | endfunction 94 | 95 | function! completer#history() 96 | return ['/', ':', '=', '>', '?', '@', 'all', 'cmd', 'debug', 'expr', 'input', 'search'] 97 | endfunction 98 | 99 | function! completer#var() 100 | " TODO 101 | redir => result 102 | silent let 103 | redir END 104 | return filter(map(split(result, '\n'), 'matchstr(v:val, "^\\S\\+\\ze\s")'), '!empty(v:val)') 105 | endfunction 106 | 107 | function! completer#mapping() 108 | " TODO 109 | redir => result 110 | silent map 111 | redir END 112 | return map(split(result, '\n'), 'matchstr(v:val[3:], "^\\S\\+\\ze\s")') 113 | endfunction 114 | 115 | function! completer#locale() 116 | return map(split(globpath(&rtp, 'lang/menu_*.vim'), "\n"), 'fnamemodify(v:val, ":t:r")[5:]') 117 | endfunction 118 | 119 | function! completer#menu() 120 | redir => result 121 | silent menu 122 | redir END 123 | return filter(map(split(result, '\n'), 'escape(substitute(matchstr(v:val, "^\\s*[0-9]\\+\\s\\+\\zs.*"), "&", "", "g"), " ")'), '!empty(v:val)') 124 | endfunction 125 | 126 | function! completer#option() 127 | redir => result 128 | silent version 129 | redir END 130 | return map(split(join(filter(split(result, '\n'), 'v:val=~"^[+-]"'), " "), '\s\+'), 'v:val[1:]') 131 | endfunction 132 | 133 | function! completer#shellcmd() 134 | return map(globpath(tr($PATH, ';\', ',/'), '*', 0, 1), 'fnamemodify(v:val, ":t")') 135 | endfunction 136 | 137 | function! completer#sign() 138 | return ['define', 'jump', 'list', 'place', 'undefine', 'unplace'] 139 | endfunction 140 | --------------------------------------------------------------------------------