root/lang/vim/misc/gosh.vim @ 12662

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=","
5command! Gosh :call <SID>Gosh()
6command! GoshPartial :call <SID>GoshPartial()
7
8nmap <leader>go :Gosh<cr>
9nmap <leader>gp :GoshPartial<cr>
10
11func! s:Gosh()
12  call s:GoshReal(join(getline(1, line("$")), "\n"))
13endfunc
14
15func! 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>
29endfunc
30
31func! s:GoshPartial()
32  normal "ay%
33  call s:GoshReal('(print '.getreg('a').')')
34endfunc
Note: See TracBrowser for help on using the browser.