| 1 | "============================================================================= |
|---|
| 2 | " FILE: vimshell.vim |
|---|
| 3 | " AUTHOR: Janakiraman .S <prince@india.ti.com>(Original) |
|---|
| 4 | " Shougo Matsushita <Shougo.Matsu@gmail.com>(Modified) |
|---|
| 5 | " Last Modified: 23 May 2009 |
|---|
| 6 | " Usage: Just source this file. |
|---|
| 7 | " License: MIT license {{{ |
|---|
| 8 | " Permission is hereby granted, free of charge, to any person obtaining |
|---|
| 9 | " a copy of this software and associated documentation files (the |
|---|
| 10 | " "Software"), to deal in the Software without restriction, including |
|---|
| 11 | " without limitation the rights to use, copy, modify, merge, publish, |
|---|
| 12 | " distribute, sublicense, and/or sell copies of the Software, and to |
|---|
| 13 | " permit persons to whom the Software is furnished to do so, subject to |
|---|
| 14 | " the following conditions: |
|---|
| 15 | " |
|---|
| 16 | " The above copyright notice and this permission notice shall be included |
|---|
| 17 | " in all copies or substantial portions of the Software. |
|---|
| 18 | " |
|---|
| 19 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|---|
| 20 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|---|
| 21 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|---|
| 22 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|---|
| 23 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|---|
| 24 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|---|
| 25 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 26 | " }}} |
|---|
| 27 | " Version: 5.11, for Vim 7.0 |
|---|
| 28 | "----------------------------------------------------------------------------- |
|---|
| 29 | " ChangeLog: "{{{ |
|---|
| 30 | " 5.11: |
|---|
| 31 | " - Added VimShellExecute and VimShellInteractive commands. |
|---|
| 32 | " 5.10: |
|---|
| 33 | " - Implemented iexe. |
|---|
| 34 | " - Improved bg. |
|---|
| 35 | " - Improved print_prompt(). |
|---|
| 36 | " - Use neocomplcache#manual_filename_complete(). |
|---|
| 37 | " 5.9: |
|---|
| 38 | " - Fixed background execution. |
|---|
| 39 | " - Fixed auto_cd bug. |
|---|
| 40 | " - Fixed error in screen command. |
|---|
| 41 | " 5.8: |
|---|
| 42 | " - Fixed !! error. |
|---|
| 43 | " - Implemented filename completion. |
|---|
| 44 | " - Implemented exchange ~ into $HOME. |
|---|
| 45 | " 5.7: |
|---|
| 46 | " - Implemented g:VimShell_ExecuteFileList. |
|---|
| 47 | " - Refactoring. |
|---|
| 48 | " - Added screen, bg internal command. |
|---|
| 49 | " 5.6: |
|---|
| 50 | " - Escape prompt when prompt search. |
|---|
| 51 | " - Fixed auto cd error. |
|---|
| 52 | " 5.5: |
|---|
| 53 | " - Created ftplugin/vimshell.vim |
|---|
| 54 | " - Added command vimshell_previous_prompt and vimshell_next_prompt. |
|---|
| 55 | " 5.4: |
|---|
| 56 | " - Fixed alias, cd, histdel bug. |
|---|
| 57 | " 5.3: |
|---|
| 58 | " - Improved autocmds. |
|---|
| 59 | " - Refactoring plugin call. |
|---|
| 60 | " 5.2: |
|---|
| 61 | " - Plugin interface changed. |
|---|
| 62 | " - Converted special commands into internal commands. |
|---|
| 63 | " - Deleted quick match. |
|---|
| 64 | " 5.1: |
|---|
| 65 | " - Improved key-mappings and autocmd. |
|---|
| 66 | " - Implemented command line stack. |
|---|
| 67 | " 5.0: |
|---|
| 68 | " - Return previous buffer when call vimshell#switch_shell on vimshell. |
|---|
| 69 | " - Implemented vimshell#error_line. |
|---|
| 70 | " - Error when iexe execute without python interface. |
|---|
| 71 | " 4.9: |
|---|
| 72 | " - Implemented exit command. |
|---|
| 73 | " - Implemented hide command. |
|---|
| 74 | " - Added g:VimShell_SmartCase option. |
|---|
| 75 | " 4.8: |
|---|
| 76 | " - Implemented comment. |
|---|
| 77 | " - Not escape when cd command. |
|---|
| 78 | " - Eval environment variables. |
|---|
| 79 | " 4.7: |
|---|
| 80 | " - Improved vimshell#switch_shell. |
|---|
| 81 | " - Implemented one command. |
|---|
| 82 | " - Implemented ev command. |
|---|
| 83 | " 4.6: |
|---|
| 84 | " - Implemented h command. |
|---|
| 85 | " - Implemented VimShell buffer current directory. |
|---|
| 86 | " - History execution was implemented with h command. |
|---|
| 87 | " - Change VimShell current directory when vimshell#switch_shell. |
|---|
| 88 | " 4.5: |
|---|
| 89 | " - Fixed popd and history bugs. |
|---|
| 90 | " - Implemented history arguments. |
|---|
| 91 | " - Implemented internal command. |
|---|
| 92 | " - Improved syntax color. |
|---|
| 93 | " 4.4: |
|---|
| 94 | " - Changed s:alias_table into b:vimshell_alias_table. |
|---|
| 95 | " - Interpret cd of no argument as cd $HOME |
|---|
| 96 | " - Added pwd command. |
|---|
| 97 | " - Improved ls on Windows. |
|---|
| 98 | " - Load ~/.vimshrc on init. |
|---|
| 99 | " - Improved escape. |
|---|
| 100 | " 4.3: |
|---|
| 101 | " - Implemented zsh like cd. |
|---|
| 102 | " - Make built-in command autoload. |
|---|
| 103 | " - Optimized special commands. |
|---|
| 104 | " - Implemented popd, dirs command. |
|---|
| 105 | " 4.2: |
|---|
| 106 | " - Implemented alias command. |
|---|
| 107 | " - Implemented VimShell script. |
|---|
| 108 | " - Optimized vimshell#process_enter. |
|---|
| 109 | " 4.1: |
|---|
| 110 | " - Implemented history command. |
|---|
| 111 | " - Implemented histdel command. |
|---|
| 112 | " - Implemented nop command. |
|---|
| 113 | " - Ignore empty command line. |
|---|
| 114 | " 4.0: |
|---|
| 115 | " - Implemented shell background execution. |
|---|
| 116 | " - Added g:VimShell_UseCkw option. |
|---|
| 117 | " Ver.3.9 ~ 1.0"{{{ |
|---|
| 118 | " 3.9: |
|---|
| 119 | " - Implemented background execution on Linux. |
|---|
| 120 | " - Improved print prompt. |
|---|
| 121 | " - Fixed cd bug. |
|---|
| 122 | " - Fixed background execution bug. |
|---|
| 123 | " 3.8: |
|---|
| 124 | " - Implemented background execution on Windows. |
|---|
| 125 | " - Implemented shell execution. |
|---|
| 126 | " - Implemented shell command. |
|---|
| 127 | " - Implemented exit command. |
|---|
| 128 | " 3.7: |
|---|
| 129 | " - Not escape quotation. |
|---|
| 130 | " - Implemented command completion. |
|---|
| 131 | " 3.6: |
|---|
| 132 | " - Improved command execute. |
|---|
| 133 | " - Fixed execute program bug. |
|---|
| 134 | " 3.5: |
|---|
| 135 | " - Implemented by autoload. |
|---|
| 136 | " - Fixed non-Windows platform error. |
|---|
| 137 | " - Improved history executed. |
|---|
| 138 | " - Fixed many bugs. |
|---|
| 139 | " 3.4: |
|---|
| 140 | " - Fixed filename escape bug. |
|---|
| 141 | " - Fixed vimshell buffer clear when hide. |
|---|
| 142 | " - No setlocal lazyredraw. |
|---|
| 143 | " - Filename escape when cd. |
|---|
| 144 | " - Implemented pseudo shell variables. |
|---|
| 145 | " 3.3: |
|---|
| 146 | " - Changed escape sequence into "\<ESC>". |
|---|
| 147 | " - Changed autocmd timing. |
|---|
| 148 | " - Added filename escape. |
|---|
| 149 | " - Added vimshell_split_switch, vimshell_switch, vimshell_split_create, vimshell_create. |
|---|
| 150 | " - Can have multiple Vimshell instance. |
|---|
| 151 | " 3.2: |
|---|
| 152 | " - Fixed space name command bug. |
|---|
| 153 | " - Fixed quick match bug. |
|---|
| 154 | " - Implemented vim and view command. |
|---|
| 155 | " 3.1: |
|---|
| 156 | " - Fixed ATOK X3 is ON when startinsert. |
|---|
| 157 | " - Silent message if exit code isn't 0. |
|---|
| 158 | " 3.0: |
|---|
| 159 | " - Do startinsert! after command executed. |
|---|
| 160 | " - Added g:VimShell_QuickMatchMaxLists option. |
|---|
| 161 | " - Added g:VimShell_QuickMatchEnable option. |
|---|
| 162 | " - Implemented two digits quick match. |
|---|
| 163 | " 2.9: |
|---|
| 164 | " - Trial implemented highlight escape sequence. |
|---|
| 165 | " - Fixed history bug. |
|---|
| 166 | " - Convert cd to lcd. |
|---|
| 167 | " 2.8: |
|---|
| 168 | " - Dup check when quick match. |
|---|
| 169 | " - Due to optimize, filtering len(cur_keyword_str) >. |
|---|
| 170 | " - Ignore head spaces when completion. |
|---|
| 171 | " 2.7: |
|---|
| 172 | " - Implemented shell history completion by omnifunc. |
|---|
| 173 | " - Mapping omnifunc <C-j>. |
|---|
| 174 | " - Implemented quick match. |
|---|
| 175 | " - Improved escape. |
|---|
| 176 | " 2.6: |
|---|
| 177 | " - Implemented shell history. |
|---|
| 178 | " 2.5: |
|---|
| 179 | " - Set lazyredraw in vimshell buffer. |
|---|
| 180 | " - Refactoring. |
|---|
| 181 | " 2.3: |
|---|
| 182 | " - Code cleanup. |
|---|
| 183 | " 2.2: |
|---|
| 184 | " - Fix syntax highlight at pipe command. |
|---|
| 185 | " - Fix quotation highlight. |
|---|
| 186 | " 2.1: |
|---|
| 187 | " - Fix syntax highlights. |
|---|
| 188 | " 2.0: |
|---|
| 189 | " - Implemented syntax highlight. |
|---|
| 190 | " 1.0: |
|---|
| 191 | " - Initial version."}}} |
|---|
| 192 | ""}}} |
|---|
| 193 | "----------------------------------------------------------------------------- |
|---|
| 194 | " TODO: "{{{ |
|---|
| 195 | " - |
|---|
| 196 | ""}}} |
|---|
| 197 | " Bugs"{{{ |
|---|
| 198 | " - |
|---|
| 199 | ""}}} |
|---|
| 200 | "============================================================================= |
|---|
| 201 | |
|---|
| 202 | if exists('g:loaded_vimshell') || v:version < 700 |
|---|
| 203 | finish |
|---|
| 204 | endif |
|---|
| 205 | |
|---|
| 206 | " Plugin keymapping"{{{ |
|---|
| 207 | nnoremap <silent> <Plug>(vimshell_split_switch) :<C-u>call vimshell#switch_shell(1)<CR> |
|---|
| 208 | nnoremap <silent> <Plug>(vimshell_split_create) :<C-u>call vimshell#create_shell(1)<CR> |
|---|
| 209 | nnoremap <silent> <Plug>(vimshell_switch) :<C-u>call vimshell#switch_shell(0)<CR> |
|---|
| 210 | nnoremap <silent> <Plug>(vimshell_create) :<C-u>call vimshell#create_shell(0)<CR> |
|---|
| 211 | nnoremap <silent> <Plug>(vimshell_enter) :<C-u>call vimshell#process_enter()<CR> |
|---|
| 212 | nnoremap <silent> <Plug>(vimshell_insert_command_completion) :<C-u>call vimshell#insert_command_completion()<CR> |
|---|
| 213 | nnoremap <silent> <Plug>(vimshell_push_current_line) :<C-u>call vimshell#push_current_line()<CR> |
|---|
| 214 | nnoremap <silent> <Plug>(vimshell_previous_prompt) :<C-u>call vimshell#previous_prompt()<CR> |
|---|
| 215 | nnoremap <silent> <Plug>(vimshell_next_prompt) :<C-u>call vimshell#next_prompt()<CR> |
|---|
| 216 | nmap <silent> <Leader>sp <Plug>(vimshell_split_switch) |
|---|
| 217 | nmap <silent> <Leader>sn <Plug>(vimshell_split_create) |
|---|
| 218 | nmap <silent> <Leader>sh <Plug>(vimshell_switch) |
|---|
| 219 | nmap <silent> <Leader>sc <Plug>(vimshell_create) |
|---|
| 220 | "}}} |
|---|
| 221 | |
|---|
| 222 | " Global options definition."{{{ |
|---|
| 223 | if !exists('g:VimShell_Prompt') |
|---|
| 224 | let g:VimShell_Prompt = 'VimShell% ' |
|---|
| 225 | endif |
|---|
| 226 | if !exists('g:VimShell_HistoryPath') |
|---|
| 227 | let g:VimShell_HistoryPath = $HOME.'/.vimshell_hist' |
|---|
| 228 | endif |
|---|
| 229 | if !exists('g:VimShell_HistoryMaxSize') |
|---|
| 230 | let g:VimShell_HistoryMaxSize = 1000 |
|---|
| 231 | endif |
|---|
| 232 | if !exists('g:VimShell_VimshrcPath') |
|---|
| 233 | let g:VimShell_VimshrcPath = $HOME.'/.vimshrc' |
|---|
| 234 | endif |
|---|
| 235 | if !exists('g:VimShell_IgnoreCase') |
|---|
| 236 | let g:VimShell_IgnoreCase = 1 |
|---|
| 237 | endif |
|---|
| 238 | if !exists('g:VimShell_SmartCase') |
|---|
| 239 | let g:VimShell_SmartCase = 0 |
|---|
| 240 | endif |
|---|
| 241 | if !exists('g:VimShell_MaxHistoryWidth') |
|---|
| 242 | let g:VimShell_MaxHistoryWidth = 40 |
|---|
| 243 | endif |
|---|
| 244 | if !exists('g:VimShell_UseCkw') |
|---|
| 245 | let g:VimShell_UseCkw = 0 |
|---|
| 246 | endif |
|---|
| 247 | if !exists('g:VimShell_ExecuteFileList') |
|---|
| 248 | let g:VimShell_ExecuteFileList = {} |
|---|
| 249 | endif |
|---|
| 250 | "}}} |
|---|
| 251 | |
|---|
| 252 | command! -nargs=0 VimShell call vimshell#switch_shell(0) |
|---|
| 253 | command! -nargs=+ -complete=shellcmd VimShellExecute call vimshell#internal#bg#vimshell_bg(split(<q-args>)) |
|---|
| 254 | command! -nargs=+ -complete=shellcmd VimShellInteractive call vimshell#internal#iexe#vimshell_iexe(split(<q-args>)) |
|---|
| 255 | |
|---|
| 256 | let g:loaded_vimshell = 1 |
|---|
| 257 | |
|---|
| 258 | " vim: foldmethod=marker |
|---|