|
Revision 12662, 0.8 kB
(checked in by nanki, 5 years ago)
|
|
lang/vim/misc/gosh.vim: partial S-exp evaluation.
|
| Line | |
|---|
| 1 | " gosh.vim -- UJIHISA, Tatsuhiro |
|---|
| 2 | " * type ,go then gosh runs |
|---|
| 3 | " * you have to set mapleader on your .vimrc |
|---|
| 4 | " for example: let mapleader="," |
|---|
| 5 | command! Gosh :call <SID>Gosh() |
|---|
| 6 | command! GoshPartial :call <SID>GoshPartial() |
|---|
| 7 | |
|---|
| 8 | nmap <leader>go :Gosh<cr> |
|---|
| 9 | nmap <leader>gp :GoshPartial<cr> |
|---|
| 10 | |
|---|
| 11 | func! s:Gosh() |
|---|
| 12 | call s:GoshReal(join(getline(1, line("$")), "\n")) |
|---|
| 13 | endfunc |
|---|
| 14 | |
|---|
| 15 | func! s:GoshReal(cmd) |
|---|
| 16 | exe 'bo 5sp [gosh]' |
|---|
| 17 | call eval("append(0, split(system('echo \"'.a:cmd.'\" | gosh'), '\n'))") |
|---|
| 18 | |
|---|
| 19 | setlocal nomodifiable |
|---|
| 20 | setlocal nobuflisted |
|---|
| 21 | setlocal nonumber |
|---|
| 22 | setlocal noswapfile |
|---|
| 23 | setlocal buftype=nofile |
|---|
| 24 | setlocal bufhidden=delete |
|---|
| 25 | setlocal noshowcmd |
|---|
| 26 | setlocal nowrap |
|---|
| 27 | noremap <buffer> <silent> q :close<cr> |
|---|
| 28 | noremap <buffer> <silent> <Enter> :close<cr> |
|---|
| 29 | endfunc |
|---|
| 30 | |
|---|
| 31 | func! s:GoshPartial() |
|---|
| 32 | normal "ay% |
|---|
| 33 | call s:GoshReal('(print '.getreg('a').')') |
|---|
| 34 | endfunc |
|---|