Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 0.9.8

Added autodetection for 'ccl'. Delete empty lines when re-gathering Electric Returns. Inspector: put multiple items in one line (like in Slime), highlight selectable parts and actions, hide item id-s, display "path" of inspected object. Don't extend s-expression with prefix when macroexpanding. Don't evaluate or compile the REPL buffer. Added device to the path when loading pretty printer patches for SBCL (thanks to Andrew Lyon). Added option g:slimv_repl_simple_eval and Electric Return for REPL buffer. Print arglist when pressing Space after closing parens or double quotes, also when pressing Enter. Added "Clear REPL" entry to the REPL menu (mapped to <Leader>-). Paredit: special handling of cw, cb, ciw, caw supporting repeat ('.'). Do not describe empty symbol. Prefer selecting symbol to the left when cursor is on whitespace. Added "." character to iskeyword for Lisp. Removed "." when selecting symbol for completion for Clojure. Increased fuzzy completion limit. Bugfixes: Find package/namespace when current form is in a fold. PareditToggle ckecks if buffer was registered for Paredit. Electric Return re-gathering at end of line with no virtualedit. Extra character at the end of selection using 'v('. Garbage upon pressing ')' or Enter in completion popup. Paredit 'x' at end of line when 'whichwrap' includes h,l. Arglist sometimes not displayed. Paredit Wrap when line ends in a multibyte character (thanks to Sung Pae).
  • Loading branch information...
commit 3eb08d456b002948766f437299c3a3e3a2c11ce2 1 parent e64fe43
@kovisoft kovisoft authored committed
View
9 doc/paredit.txt
@@ -1,7 +1,7 @@
-*paredit.txt* Paredit Last Change: 22 May 2012
+*paredit.txt* Paredit Last Change: 06 Jul 2012
Paredit Mode for Vim *paredit* *slimv-paredit*
- Version 0.9.7
+ Version 0.9.8
The paredit.vim plugin performs structured editing of s-expressions used in
the Lisp, Clojure, Scheme programming languages. It may come as part of Slimv
@@ -391,8 +391,9 @@ pressing the next closing paren. This feature allows linewise editing of the
subform entered in the next (empty) line.
In other words <Enter> "opens" parenthetical expressions while editing, ')'
"closes" them.
-Please note that electric return is disabled for the REPL buffer where
-<Enter> is used to send the command line to the swank server for evaluation.
+Please note that electric return is disabled for the REPL buffer if Slimv
+option |g:slimv_repl_simple_eval| is nonzero. In this case <Enter> is used
+to send the command line to the swank server for evaluation.
Please find a video demonstration of the electric return feature here:
http://img8.imageshack.us/img8/9479/openparen.gif
View
62 doc/slimv.txt
@@ -1,7 +1,7 @@
-*slimv.txt* Slimv Last Change: 29 May 2012
+*slimv.txt* Slimv Last Change: 18 Aug 2012
Slimv *slimv*
- Version 0.9.7
+ Version 0.9.8
The Superior Lisp Interaction Mode for Vim.
This plugin is aimed to help Lisp development by interfacing between Vim and
@@ -188,6 +188,8 @@ For the Swank options plese visit |swank-configuration|.
|g:slimv_repl_name| Name of the REPL buffer.
+|g:slimv_repl_simple_eval| <CR> evaluates form in the REPL buffer.
+
|g:slimv_repl_split| Open the Lisp REPL buffer in a split window
or in a separate buffer.
@@ -489,6 +491,24 @@ parens and/or double quotes may remain in order to maintain their balanced
state. The default value for this option is 0, meaning that the number of lines
is unlimited, i.e. no line is ever erased.
+ *g:slimv_repl_simple_eval*
+This option controls the behaviour of insert mode <CR>, <Up>, <Down> in the
+REPL buffer.
+
+If nonzero then:
+ <CR> Evaluates the form entered in the command line
+ <Up> Brings up the previous command from the command line history
+ <Down> Brings up the next command from the command line history
+ <C-CR> Closes and evaluates the form entered in the command line
+
+If the option is zero then:
+ <C-CR> Closes and evaluates the form entered in the command line
+ <C-Up> Brings up the previous command from the command line history
+ <C-Down> Brings up the next command from the command line history
+ <CR> Inserts a newline
+ <Up> Moves the cursor up
+ <Down> Moves the cursor down
+
*g:slimv_repl_syntax*
Enables syntax highlighting for the REPL buffer. It is enabled by default but
one may want to switch it off for these reasons:
@@ -689,7 +709,7 @@ sequence, then you may want to fine tune these Vim options:
<C-C> <C-C> Interrupt Lisp Process
,<Up> ,rp Previous Input
,<Down> ,rn Next Input
- ,z ,rr Refresh REPL Buffer
+ ,- ,rc Clear REPL
Note:
Some mappings accept an optional "x prefix (where x is a register name)
@@ -1083,6 +1103,9 @@ Insert Mode:
<Down> Brings up the next command typed and sent to the Lisp REPL
when in the command line.
+Please note that the behaviour of <CR>, <Up>, <Down> is affected by the value
+of option |g:slimv_repl_simple_eval|.
+
===============================================================================
CLOJURE SUPPORT *slimv-clojure*
@@ -1410,6 +1433,35 @@ FAQ *slimv-faq*
===============================================================================
CHANGE LOG *slimv-changelog*
+0.9.8 - Added autodetection for 'ccl'.
+ - Delete empty lines when re-gathering Electric Returns.
+ - Inspector: put multiple items in one line (like in Slime).
+ - Inspector: highlight selectable parts and actions, hide item id-s.
+ - Inspector: display "path" of inspected object.
+ - Don't extend s-expression with prefix when macroexpanding.
+ - Don't evaluate or compile the REPL buffer.
+ - Added device to the path when loading pretty printer patches for SBCL
+ (thanks to Andrew Lyon).
+ - Added option g:slimv_repl_simple_eval and Electric Return for REPL buffer.
+ - Print arglist when pressing Space after closing parens or double quotes,
+ also when pressing Enter.
+ - Added "Clear REPL" entry to the REPL menu (mapped to <Leader>-).
+ - Paredit: special handling of cw, cb, ciw, caw supporting repeat ('.').
+ - Do not describe empty symbol.
+ - Prefer selecting symbol to the left when cursor is on whitespace.
+ - Added "." character to iskeyword for Lisp.
+ - Removed "." when selecting symbol for completion for Clojure.
+ - Increased fuzzy completion limit.
+ - Bugfix: find package/namespace when current form is in a fold.
+ - Bugfix: PareditToggle ckecks if buffer was registered for Paredit.
+ - Bugfix: Electric Return re-gathering at end of line with no virtualedit.
+ - Bugfix: extra character at the end of selection using 'v('
+ - Bugfix: garbage upon pressing ')' or Enter in completion popup.
+ - Bugfix: Paredit 'x' at end of line when 'whichwrap' includes h,l.
+ - Bugfix: arglist sometimes not displayed.
+ - Bugfix: Paredit Wrap when line ends in a multibyte character
+ (thanks to Sung Pae).
+
0.9.7 - Keep cursor position on expanding [--more--] in the Inspector.
- Added [--all---] to Inspector for fetching all parts.
- Don't explicitly check for pythonXX.dll, rely on has('python').
@@ -1914,8 +1966,8 @@ Also thanks to Vlad Hanciuta, Marcin Fatyga, Dmitry Petukhov,
Daniel Solano G�mez, Brian Kropf, Len Weincier, Andreas Salwasser,
Jon Thacker, Andrew Hills, Jerome Baum, John Obbele, Andreas Fredriksson,
�mer Sinan Agacan, Tobias Pflug, Chris Cahoon, Mats Rauhala, Oleg Terenchuk,
-Andrew Lyon, Andrew Smirnoff, Brett Kosinski, David Greenberg for additional
-notes and contributions.
+Andrew Lyon, Andrew Smirnoff, Brett Kosinski, David Greenberg, Sung Pae
+for additional notes and contributions.
I would also like to say a big thank you to everyone donating to support
development. This is a one-element list at the moment: :)
View
5 ftplugin/lisp/slimv-lisp.vim
@@ -1,7 +1,7 @@
" slimv-lisp.vim:
" Lisp filetype plugin for Slimv
-" Version: 0.9.4
-" Last Change: 07 Jan 2012
+" Version: 0.9.8
+" Last Change: 01 Jun 2012
" Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
" License: This file is placed in the public domain.
" No warranty, express or implied.
@@ -47,6 +47,7 @@ let s:lisp_desc = [
\ [ 'alisp', 'allegro', '', '' ],
\ [ 'alisp8', 'allegro', '', '' ],
\ [ 'lwl', 'lispworks', '', '' ],
+\ [ 'ccl', 'clozure', '', '' ],
\ [ 'wx86cl', 'clozure', 'w', '' ],
\ [ 'lx86cl', 'clozure', 'l', '' ],
\ [ '*lisp.exe', 'clisp', 'w',
View
242 ftplugin/slimv.vim
@@ -1,6 +1,6 @@
" slimv.vim: The Superior Lisp Interaction Mode for VIM
-" Version: 0.9.7
-" Last Change: 15 May 2012
+" Version: 0.9.8
+" Last Change: 30 Jul 2012
" Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
" License: This file is placed in the public domain.
" No warranty, express or implied.
@@ -189,6 +189,14 @@ if !exists( 'g:slimv_repl_syntax' )
let g:slimv_repl_syntax = 1
endif
+" Specifies the behaviour of insert mode <CR>, <Up>, <Down> in the REPL buffer:
+" 1: <CR> evaluates, <Up>/<Down> brings up command history
+" 0: <C-CR> evaluates, <C-Up>/<C-Down> brings up command history,
+" <CR> opens new line, <Up>/<Down> moves cursor up/down
+if !exists( 'g:slimv_repl_simple_eval' )
+ let g:slimv_repl_simple_eval = 1
+endif
+
" Alternative value (in msec) for 'updatetime' while the REPL buffer is changing
if !exists( 'g:slimv_updatetime' )
let g:slimv_updatetime = 500
@@ -288,6 +296,9 @@ let s:sldb_level = -1 " Are we in the SWANK
let s:compiled_file = '' " Name of the compiled file
let s:current_buf = -1 " Swank action was requested from this buffer
let s:current_win = -1 " Swank action was requested from this window
+let s:arglist_line = 0 " Arglist was requested in this line ...
+let s:arglist_col = 0 " ... and column
+let s:inspect_path = [] " Inspection path of the current object
let s:skip_sc = 'synIDattr(synID(line("."), col("."), 0), "name") =~ "[Ss]tring\\|[Cc]omment"'
" Skip matches inside string or comment
let s:skip_q = 'getline(".")[col(".")-2] == "\\"' " Skip escaped double quote characters in matches
@@ -326,7 +337,7 @@ endfunction
function! SlimvShortEcho( msg )
let saved=&shortmess
set shortmess+=T
- exe "normal :echomsg a:msg\n"
+ exe "normal :echomsg a:msg\n"
let &shortmess=saved
endfunction
@@ -710,12 +721,19 @@ function! SlimvOpenReplBuffer()
endif
" Add keybindings valid only for the REPL buffer
- inoremap <buffer> <silent> <CR> <C-R>=pumvisible() ? "\<lt>CR>" : "\<lt>End>\<lt>C-O>:call SlimvSendCommand(0)\<lt>CR>"<CR>
inoremap <buffer> <silent> <C-CR> <End><C-O>:call SlimvSendCommand(1)<CR>
- inoremap <buffer> <silent> <Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>:call SlimvHandleUp()\<lt>CR>"<CR>
- inoremap <buffer> <silent> <Down> <C-R>=pumvisible() ? "\<lt>Down>" : "\<lt>C-O>:call SlimvHandleDown()\<lt>CR>"<CR>
inoremap <buffer> <silent> <C-C> <C-O>:call SlimvInterrupt()<CR>
+ if g:slimv_repl_simple_eval
+ inoremap <buffer> <silent> <CR> <C-R>=pumvisible() ? "\<lt>CR>" : "\<lt>End>\<lt>C-O>:call SlimvSendCommand(0)\<lt>CR>"<CR>
+ inoremap <buffer> <silent> <Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>:call SlimvHandleUp()\<lt>CR>"<CR>
+ inoremap <buffer> <silent> <Down> <C-R>=pumvisible() ? "\<lt>Down>" : "\<lt>C-O>:call SlimvHandleDown()\<lt>CR>"<CR>
+ else
+ inoremap <buffer> <silent> <CR> <C-R>=pumvisible() ? "\<lt>CR>" : SlimvHandleEnterRepl()<CR><C-O>:call SlimvArglistOnEnter()<CR>
+ inoremap <buffer> <silent> <C-Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>:call SlimvHandleUp()\<lt>CR>"<CR>
+ inoremap <buffer> <silent> <C-Down> <C-R>=pumvisible() ? "\<lt>Down>" : "\<lt>C-O>:call SlimvHandleDown()\<lt>CR>"<CR>
+ endif
+
if exists( 'g:paredit_loaded' )
inoremap <buffer> <silent> <expr> <BS> PareditBackspace(1)
else
@@ -727,11 +745,13 @@ function! SlimvOpenReplBuffer()
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'/ :call SlimvSendCommand(1)<CR>'
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'<Up> :call SlimvPreviousCommand()<CR>'
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'<Down> :call SlimvNextCommand()<CR>'
+ execute 'noremap <buffer> <silent> ' . g:slimv_leader.'- :call SlimvClearReplBuffer()<CR>'
elseif g:slimv_keybindings == 2
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'rs :call SlimvSendCommand(0)<CR>'
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'ro :call SlimvSendCommand(1)<CR>'
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'rp :call SlimvPreviousCommand()<CR>'
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'rn :call SlimvNextCommand()<CR>'
+ execute 'noremap <buffer> <silent> ' . g:slimv_leader.'rc :call SlimvClearReplBuffer()<CR>'
endif
if g:slimv_repl_wrap
@@ -763,6 +783,14 @@ function! SlimvOpenReplBuffer()
call SlimvRefreshReplBuffer()
endfunction
+" Clear the contents of the REPL buffer, keeping the last prompt only
+function! SlimvClearReplBuffer()
+ if b:repl_prompt_line > 1
+ execute "normal! gg0d" . (b:repl_prompt_line-1) . "GG$"
+ let b:repl_prompt_line = 1
+ endif
+endfunction
+
" Open a new Inspect buffer
function SlimvOpenInspectBuffer()
call SlimvOpenBuffer( g:slimv_inspect_name )
@@ -776,9 +804,21 @@ function SlimvOpenInspectBuffer()
noremap <buffer> <silent> <Backspace> :call SlimvSendSilent(['[-1]'])<CR>
execute 'noremap <buffer> <silent> ' . g:slimv_leader.'q :call SlimvQuitInspect()<CR>'
- syn match Type /^\[\d\+\]/
- syn match Type /^\[<<\]/
- syn match Type /^\[--....--\]$/
+ if version < 703
+ " conceal mechanism is defined since Vim 7.3
+ syn region inspectItem matchgroup=Ignore start="{\[\d\+\]\s*" end="\[]}"
+ syn region inspectAction matchgroup=Ignore start="{<\d\+>\s*" end="<>}"
+ else
+ syn region inspectItem matchgroup=Ignore start="{\[\d\+\]\s*" end="\[]}" concealends
+ syn region inspectAction matchgroup=Ignore start="{<\d\+>\s*" end="<>}" concealends
+ setlocal conceallevel=3 concealcursor=nc
+ endif
+
+ hi def link inspectItem Special
+ hi def link inspectAction String
+
+ syn match Special /^\[<<\].*$/
+ syn match Special /^\[--....--\]$/
endfunction
" Open a new Threads buffer
@@ -816,7 +856,7 @@ function SlimvOpenSldbBuffer()
setlocal foldmethod=marker
setlocal foldmarker={{{,}}}
setlocal foldtext=substitute(getline(v:foldstart),'{{{','','')
- setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&,{,},[,]
+ setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&,{,},[,],.
if g:slimv_sldb_wrap
setlocal wrap
endif
@@ -938,14 +978,19 @@ function! s:SetKeyword()
if SlimvGetFiletype() == 'clojure'
setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&
else
- setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&,{,},[,]
+ setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&,.,{,},[,]
endif
endfunction
" Select symbol under cursor and return it
function! SlimvSelectSymbol()
call s:SetKeyword()
+ let oldpos = winsaveview()
+ if col('.') > 1 && getline('.')[col('.')-1] =~ '\s'
+ normal! h
+ endif
let symbol = expand('<cword>')
+ call winrestview( oldpos )
return symbol
endfunction
@@ -960,7 +1005,7 @@ function! SlimvSelectSymbolExt()
endfunction
" Select bottom level form the cursor is inside and copy it to register 's'
-function! SlimvSelectForm()
+function! SlimvSelectForm( extended )
" Search the opening '(' if we are standing on a special form prefix character
let c = col( '.' ) - 1
let firstchar = getline( '.' )[c]
@@ -975,7 +1020,7 @@ function! SlimvSelectForm()
if firstchar != '(' && p1[1] == p2[1] && (p1[2] == p2[2] || p1[2] == p2[2]+1)
" Empty selection and no paren found, select current word instead
normal! aw
- else
+ elseif a:extended || firstchar != '('
" Handle '() or #'() etc. type special syntax forms (but stop at prompt)
let c = col( '.' ) - 2
while c >= 0 && match( ' \t()>', getline( '.' )[c] ) < 0
@@ -1007,7 +1052,7 @@ endfunction
" Select top level form the cursor is inside and copy it to register 's'
function! SlimvSelectDefun()
call SlimvFindDefunStart()
- return SlimvSelectForm()
+ return SlimvSelectForm( 1 )
endfunction
" Return the contents of register 's'
@@ -1039,8 +1084,11 @@ function! SlimvFindPackage()
let searching = search( '(\s*' . string . '\s', 'bW' )
endwhile
if found
+ " Find the package name with all folds open
+ normal! zn
silent normal! ww
let l:packagename_tokens = split(expand('<cWORD>'),')\|\s')
+ normal! zN
if l:packagename_tokens != []
" Remove quote character from package name
let s:swank_package = substitute( l:packagename_tokens[0], "'", '', '' )
@@ -1608,6 +1656,7 @@ function! SlimvSendCommand( close )
else
" Expression is not finished yet, indent properly and wait for completion
" Indentation works only if lisp indentation is switched on
+ call SlimvArglist()
let l = line('.') + 1
call append( '.', '' )
call setline( l, repeat( ' ', SlimvIndent(l) ) )
@@ -1647,6 +1696,32 @@ function! SlimvCloseForm()
normal! %
endfunction
+" Handle insert mode 'Enter' keypress
+function! SlimvHandleEnter()
+ let s:arglist_line = line('.')
+ let s:arglist_col = col('.')
+ if g:paredit_mode && g:paredit_electric_return
+ return PareditEnter()
+ else
+ return "\<CR>"
+ endif
+endfunction
+
+" Display arglist after pressing Enter
+function! SlimvArglistOnEnter()
+ if s:arglist_line > 0
+ let l = line('.')
+ if getline(l) == ''
+ " Add spaces to make the correct indentation
+ call setline( l, repeat( ' ', SlimvIndent(l) ) )
+ normal! $
+ endif
+ call SlimvArglist( s:arglist_line, s:arglist_col )
+ endif
+ let s:arglist_line = 0
+ let s:arglist_col = 0
+endfunction
+
" Handle insert mode 'Tab' keypress by doing completion or indentation
function! SlimvHandleTab()
if pumvisible()
@@ -1724,6 +1799,57 @@ function SlimvMakeFold()
setlocal readonly
endfunction
+" Handle insert mode 'Enter' keypress in the REPL buffer
+function! SlimvHandleEnterRepl()
+ " Trim the prompt from the beginning of the command line
+ " The user might have overwritten some parts of the prompt
+ let lastline = b:repl_prompt_line
+ let lastcol = b:repl_prompt_col
+ let cmdline = getline( lastline )
+ let c = 0
+ while c < lastcol - 1 && cmdline[c] == b:repl_prompt[c]
+ let c = c + 1
+ endwhile
+
+ " Copy command line up to the cursor position
+ if line(".") == lastline
+ let cmd = [ strpart( cmdline, c, col(".") - c - 1 ) ]
+ else
+ let cmd = [ strpart( cmdline, c ) ]
+ endif
+
+ " Build a possible multi-line command up to the cursor line/position
+ let l = lastline + 1
+ while l <= line(".")
+ if line(".") == l
+ call add( cmd, strpart( getline( l ), 0, col(".") - 1) )
+ else
+ call add( cmd, strpart( getline( l ), 0) )
+ endif
+ let l = l + 1
+ endwhile
+
+ " Count the number of opening and closing braces in the command before the cursor
+ let end = s:CloseForm( cmd )
+ if end != 'ERROR' && end != ''
+ " Command part before cursor is unbalanced, insert newline
+ let s:arglist_line = line('.')
+ let s:arglist_col = col('.')
+ if g:paredit_mode && g:paredit_electric_return && lastline > 0 && line( "." ) >= lastline
+ " Apply electric return
+ return PareditEnter()
+ else
+ " No electric return handling, just enter a newline
+ return "\<CR>"
+ endif
+ else
+ " Send current command line for evaluation
+ call cursor( 0, 99999 )
+ call SlimvSendCommand(0)
+ endif
+ return ''
+endfunction
+
" Handle normal mode 'Enter' keypress in the SLDB buffer
function! SlimvHandleEnterSldb()
let line = getline('.')
@@ -1788,6 +1914,29 @@ function! SlimvHandleEnterInspect()
return
endif
+ " Find the closest [dd] or <dd> token to the left of the cursor
+ let [l, c] = searchpos( '{\[\d\+\]', 'bncW' )
+ let [l2, c2] = searchpos( '{<\d\+>', 'bncW' )
+ if l < line('.') || (l2 == line('.') && c2 > c)
+ let l = l2
+ let c = c2
+ endif
+
+ if l < line('.')
+ " No preceding token found, find the closest [dd] or <dd> to the right
+ let [l, c] = searchpos( '{\[\d\+\]', 'ncW' )
+ let [l2, c2] = searchpos( '{<\d\+>', 'ncW' )
+ if l == 0 || l > line('.') || (l2 == line('.') && c2 < c)
+ let l = l2
+ let c = c2
+ endif
+ endif
+
+ if l == line( '.' )
+ " Keep the relevant part of the line
+ let line = strpart( line, c )
+ endif
+
if line[0] == '['
if line =~ '^\[--more--\]$'
" More data follows, fetch next part
@@ -1828,6 +1977,11 @@ function! SlimvHandleEnterInspect()
else
" Inspect n-th part
let item = matchstr( line, '\d\+' )
+ if item != ''
+ " Add item name to the object path
+ let entry = matchstr(line, '\[\d\+\]\s*\zs.\{-}\ze\s*\[\]}')
+ let s:inspect_path = s:inspect_path + [entry]
+ endif
endif
if item != ''
call SlimvSendSilent( ['[' . item . ']'] )
@@ -1958,20 +2112,28 @@ function! SlimvDebugThread()
endfunction
" Display function argument list
-function! SlimvArglist()
- let l = line('.')
- let c = col('.') - 1
- let line = getline('.')
+" Optional argument is the number of characters typed after the keyword
+function! SlimvArglist( ... )
+ if a:0
+ " Symbol position supplied
+ let l = a:1
+ let c = a:2 - 1
+ else
+ " Check symbol at cursor position
+ let l = line('.')
+ let c = col('.') - 1
+ endif
+ let line = getline(l)
call s:SetKeyword()
- if s:swank_connected && c > 1 && line[c-2] =~ '\k'
+ if s:swank_connected && c > 0 && line[c-1] =~ '\k\|)\|\]\|}\|"'
let save_ve = &virtualedit
- set virtualedit=onemore
+ set virtualedit=all
" Display only if entering the first space after a keyword
let matchb = max( [l-200, 1] )
let [l0, c0] = searchpairpos( '(', '', ')', 'nbW', s:skip_sc, matchb )
if l0 > 0
" Found opening paren, let's find out the function name
- let arg = matchstr( line, '\<\k*\>', c0 )
+ let arg = matchstr( getline(l0), '\<\k*\>', c0 )
if arg != ''
" Ask function argument list from SWANK
call SlimvFindPackage()
@@ -1995,9 +2157,6 @@ function! SlimvArglist()
endif
let &virtualedit=save_ve
endif
-
- " Return empty string because this function is called from an insert mode mapping
- return ''
endfunction
" Start and connect swank server
@@ -2145,6 +2304,10 @@ endfunction
" Evaluate the whole buffer
function! SlimvEvalBuffer()
+ if bufnr( "%" ) == bufnr( g:slimv_repl_name )
+ call SlimvError( "Cannot evaluate the REPL buffer." )
+ return
+ endif
let lines = getline( 1, '$' )
if SlimvGetFiletype() == 'scheme'
" Swank-scheme requires us to pass a single s-expression
@@ -2181,7 +2344,7 @@ endfunction
function! SlimvEvalTestExp( testform )
let outreg = v:register
let oldpos = winsaveview()
- if !SlimvSelectForm()
+ if !SlimvSelectForm( 1 )
return
endif
call SlimvFindPackage()
@@ -2229,7 +2392,7 @@ endfunction
function! SlimvMacroexpand()
call SlimvBeginUpdate()
if SlimvConnectSwank()
- if !SlimvSelectForm()
+ if !SlimvSelectForm( 0 )
return
endif
let s:swank_form = SlimvGetSelection()
@@ -2245,7 +2408,7 @@ endfunction
function! SlimvMacroexpandAll()
call SlimvBeginUpdate()
if SlimvConnectSwank()
- if !SlimvSelectForm()
+ if !SlimvSelectForm( 0 )
return
endif
let s:swank_form = SlimvGetSelection()
@@ -2312,6 +2475,7 @@ function! SlimvInspect()
if !SlimvConnectSwank()
return
endif
+ let s:inspect_path = []
let frame = s:DebugFrame()
if frame != ''
" Inspect selected for a frame in the debugger's Backtrace section
@@ -2333,6 +2497,7 @@ function! SlimvInspect()
endif
let s = input( 'Inspect in frame ' . frame . ' (evaluated): ', sym )
if s != ''
+ let s:inspect_path = [s]
call SlimvBeginUpdate()
call SlimvCommand( 'python swank_inspect_in_frame("' . s . '", ' . frame . ')' )
call SlimvRefreshReplBuffer()
@@ -2340,6 +2505,7 @@ function! SlimvInspect()
else
let s = input( 'Inspect: ', SlimvSelectSymbolExt() )
if s != ''
+ let s:inspect_path = [s]
call SlimvBeginUpdate()
call SlimvCommandUsePackage( 'python swank_inspect("' . s . '")' )
endif
@@ -2466,6 +2632,10 @@ endfunction
" Compile and load whole file
function! SlimvCompileLoadFile()
+ if bufnr( "%" ) == bufnr( g:slimv_repl_name )
+ call SlimvError( "Cannot compile the REPL buffer." )
+ return
+ endif
let filename = fnamemodify( bufname(''), ':p' )
let filename = substitute( filename, '\\', '/', 'g' )
if &modified
@@ -2490,6 +2660,10 @@ endfunction
" Compile whole file
function! SlimvCompileFile()
+ if bufnr( "%" ) == bufnr( g:slimv_repl_name )
+ call SlimvError( "Cannot compile the REPL buffer." )
+ return
+ endif
let filename = fnamemodify( bufname(''), ':p' )
let filename = substitute( filename, '\\', '/', 'g' )
if &modified
@@ -2532,7 +2706,12 @@ endfunction
" Describe the selected symbol
function! SlimvDescribeSymbol()
if SlimvConnectSwank()
- call SlimvCommandUsePackage( 'python swank_describe_symbol("' . SlimvSelectSymbol() . '")' )
+ let symbol = SlimvSelectSymbol()
+ if symbol == ''
+ call SlimvError( "No symbol under cursor." )
+ return
+ endif
+ call SlimvCommandUsePackage( 'python swank_describe_symbol("' . symbol . '")' )
endif
endfunction
@@ -2734,8 +2913,7 @@ function! SlimvOmniComplete( findstart, base )
" Locate the start of the symbol name
call s:SetKeyword()
let upto = strpart( getline( '.' ), 0, col( '.' ) - 1)
- let p = match(upto, '\(\k\|\.\)\+$')
- return p
+ return match(upto, '\k\+$')
else
return SlimvComplete( a:base )
endif
@@ -2811,7 +2989,8 @@ endfunction
" Initialize buffer by adding buffer specific mappings
function! SlimvInitBuffer()
" Map space to display function argument list in status line
- inoremap <silent> <buffer> <Space> <Space><C-R>=SlimvArglist()<CR>
+ inoremap <silent> <buffer> <Space> <Space><C-O>:call SlimvArglist(line('.'),col('.')-1)<CR>

Hey, Tamas. I couldn't find the "Issues" tab so I figured I'd comment here. This change breaks visual insert block mode for me. Sometimes when I add a (let), i want to move everything under it two spaces to the right, so I C-v, go to the bottom, C-i. After hitting the first though, it prints :call SlimvArglist(line('.'),col('.')-1) and exits the block edit. This never seemed to happen before this change, and looking at the actual commit I can't figure out why the old version worked and the new one doesn't, otherwise I'd fix & issue a pull request (I'm not that great with Vimscript). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ inoremap <silent> <buffer> <CR> <C-R>=pumvisible() ? "\<lt>CR>" : SlimvHandleEnter()<CR><C-O>:call SlimvArglistOnEnter()<CR>
"noremap <silent> <buffer> <C-C> :call SlimvInterrupt()<CR>
if !exists( 'b:au_insertleave_set' )
let b:au_insertleave_set = 1
@@ -2925,6 +3104,7 @@ function! SlimvAddReplMenu()
amenu &REPL.-REPLSep- :
amenu &REPL.&Previous-Input :call SlimvPreviousCommand()<CR>
amenu &REPL.&Next-Input :call SlimvNextCommand()<CR>
+ amenu &REPL.Clear-&REPL :call SlimvClearReplBuffer()<CR>
endfunction
" =====================================================================
View
32 ftplugin/swank.py
@@ -4,8 +4,8 @@
#
# SWANK client for Slimv
# swank.py: SWANK client code for slimv.vim plugin
-# Version: 0.9.7
-# Last Change: 20 Apr 2012
+# Version: 0.9.8
+# Last Change: 30 Jun 2012
# Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
# License: This file is placed in the public domain.
# No warranty, express or implied.
@@ -378,20 +378,15 @@ def swank_parse_inspect_content(pcont):
logprint(str(el))
if type(el) == list:
if el[0] == ':action':
- item = '<' + unquote(el[2]) + '> '
+ item = '{<' + unquote(el[2]) + '>'
+ tail = '<>}'
else:
- item = '[' + unquote(el[2]) + '] '
- if linestart < 0:
- lst.append("\n")
- linestart = len(lst)
- lst.insert(linestart, item)
+ item = '{[' + unquote(el[2]) + ']'
+ tail = '[]}'
+ lst.insert(len(lst), item)
linestart = -1
text = unquote(el[1])
- if text[-len(item):] == ' ' * len(item):
- # If possible, remove spaces from the end in the length of item info
- lst.append(text[:-len(item)])
- else:
- lst.append(text)
+ lst.append(text + tail)
else:
text = unquote(el)
lst.append(text)
@@ -407,7 +402,12 @@ def swank_parse_inspect_content(pcont):
buf = vim.current.buffer
buf.append([''])
buf.append("".join(lst).split("\n"))
- buf.append(['', '[<<]'])
+ inspect_path = vim.eval('s:inspect_path')
+ if len(inspect_path) > 1:
+ ret = '[<<] Return to ' + ' -> '.join(inspect_path[:-1])
+ else:
+ ret = '[<<] Exit Inspector'
+ buf.append(['', ret])
vim.command('normal! 3G0')
vim.command('call SlimvHelp(2)')
vim.command('call winrestview(oldpos)')
@@ -968,7 +968,7 @@ def swank_completions(symbol):
swank_rex(':simple-completions', cmd, 'nil', 't')
def swank_fuzzy_completions(symbol):
- cmd = '(swank:fuzzy-completions "' + symbol + '" ' + get_swank_package() + ' :limit 200 :time-limit-in-msec 2000)'
+ cmd = '(swank:fuzzy-completions "' + symbol + '" ' + get_swank_package() + ' :limit 2000 :time-limit-in-msec 2000)'
swank_rex(':fuzzy-completions', cmd, 'nil', 't')
def swank_undefine_function(fn):
@@ -993,6 +993,8 @@ def swank_inspector_nth_action(n):
swank_rex(':inspector-call-nth-action', cmd, 'nil', 't', str(n))
def swank_inspector_pop():
+ # Remove the last two entries from the inspect path
+ vim.command('let s:inspect_path = s:inspect_path[:-2]')
swank_rex(':inspector-pop', '(swank:inspector-pop)', 'nil', 't')
def swank_inspect_in_frame(symbol, n):
View
127 plugin/paredit.vim
@@ -1,7 +1,7 @@
" paredit.vim:
" Paredit mode for Slimv
-" Version: 0.9.7
-" Last Change: 22 May 2012
+" Version: 0.9.8
+" Last Change: 18 Aug 2012
" Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
" License: This file is placed in the public domain.
" No warranty, express or implied.
@@ -75,6 +75,7 @@ let s:yank_pos = []
" Buffer specific initialization
function! PareditInitBuffer()
+ let b:paredit_init = 1
" Make sure to include special characters in 'iskeyword'
" in case they are accidentally removed
" Also define regular expressions to identify special characters used by paredit
@@ -101,7 +102,7 @@ function! PareditInitBuffer()
if g:paredit_mode
" Paredit mode is on: add buffer specific keybindings
inoremap <buffer> <expr> ( PareditInsertOpening('(',')')
- inoremap <buffer> <silent> ) <C-O>:<C-U>call PareditInsertClosing('(',')')<CR>
+ inoremap <buffer> <silent> ) <C-R>=(pumvisible() ? "\<lt>C-Y>" : "")<CR><C-O>:let save_ve=&ve<CR><C-O>:set ve=onemore<CR><C-O>:<C-U>call PareditInsertClosing('(',')')<CR><C-O>:let &ve=save_ve<CR>
inoremap <buffer> <expr> " PareditInsertQuotes()
inoremap <buffer> <expr> <BS> PareditBackspace(0)
inoremap <buffer> <expr> <Del> PareditDel()
@@ -125,6 +126,10 @@ function! PareditInitBuffer()
vnoremap <buffer> <silent> c :<C-U>call PareditChange(visualmode(),1)<CR>
nnoremap <buffer> <silent> dd :<C-U>call PareditDeleteLines()<CR>
nnoremap <buffer> <silent> cc :<C-U>call PareditChangeLines()<CR>
+ nnoremap <buffer> <silent> cw :<C-U>call PareditChangeSpec('cw',1)<CR>
+ nnoremap <buffer> <silent> cb :<C-U>call PareditChangeSpec('cb',0)<CR>
+ nnoremap <buffer> <silent> ciw :<C-U>call PareditChangeSpec('ciw',1)<CR>
+ nnoremap <buffer> <silent> caw :<C-U>call PareditChangeSpec('caw',1)<CR>
nnoremap <buffer> <silent> p :<C-U>call PareditPut('p')<CR>
nnoremap <buffer> <silent> P :<C-U>call PareditPut('P')<CR>
execute 'nnoremap <buffer> <silent> ' . g:paredit_leader.'w( :<C-U>call PareditWrap("(",")")<CR>'
@@ -137,9 +142,9 @@ function! PareditInitBuffer()
execute 'nmap <buffer> <silent> ' . g:paredit_leader.'I :<C-U>call PareditRaise()<CR>'
if &ft == 'clojure'
inoremap <buffer> <expr> [ PareditInsertOpening('[',']')
- inoremap <buffer> <silent> ] <C-O>:<C-U>call PareditInsertClosing('[',']')<CR>
+ inoremap <buffer> <silent> ] <C-R>=(pumvisible() ? "\<lt>C-Y>" : "")<CR><C-O>:let save_ve=&ve<CR><C-O>:set ve=onemore<CR><C-O>:<C-U>call PareditInsertClosing('[',']')<CR><C-O>:let &ve=save_ve<CR>
inoremap <buffer> <expr> { PareditInsertOpening('{','}')
- inoremap <buffer> <silent> } <C-O>:<C-U>call PareditInsertClosing('{','}')<CR>
+ inoremap <buffer> <silent> } <C-R>=(pumvisible() ? "\<lt>C-Y>" : "")<CR><C-O>:let save_ve=&ve<CR><C-O>:set ve=onemore<CR><C-O>:<C-U>call PareditInsertClosing('{','}')<CR><C-O>:let &ve=save_ve<CR>
execute 'nnoremap <buffer> <silent> ' . g:paredit_leader.'w[ :<C-U>call PareditWrap("[","]")<CR>'
execute 'vnoremap <buffer> <silent> ' . g:paredit_leader.'w[ :<C-U>call PareditWrapSelection("[","]")<CR>'
execute 'nnoremap <buffer> <silent> ' . g:paredit_leader.'w{ :<C-U>call PareditWrap("{","}")<CR>'
@@ -174,8 +179,8 @@ function! PareditInitBuffer()
execute 'nnoremap <buffer> <silent> ' . g:paredit_leader.'S :<C-U>call PareditSplice()<CR>'
endif
- if g:paredit_electric_return && !s:IsReplBuffer()
- " No electric return in the REPL buffer
+ if g:paredit_electric_return && mapcheck( "<CR>", "i" ) == ""
+ " Do not override any possible mapping for <Enter>
inoremap <buffer> <expr> <CR> PareditEnter()
endif
else
@@ -199,6 +204,10 @@ function! PareditInitBuffer()
silent! unmap <buffer> c
silent! unmap <buffer> dd
silent! unmap <buffer> cc
+ silent! unmap <buffer> cw
+ silent! unmap <buffer> cb
+ silent! unmap <buffer> ciw
+ silent! unmap <buffer> caw
if &ft == 'clojure'
silent! iunmap <buffer> [
silent! iunmap <buffer> ]
@@ -324,6 +333,43 @@ function! PareditChangeLines()
call PareditChange(visualmode(),1)
endfunction
+" Handle special change command, e.g. cw
+" Check if we may revert to its original Vim function
+" This way '.' can be used to repeat the command
+function! PareditChangeSpec( cmd, dir )
+ let line = getline( '.' )
+ if a:dir == 0
+ " Changing backwards
+ let c = col( '.' ) - 2
+ while c >= 0 && line[c] =~ b:any_matched_char
+ " Shouldn't delete a matched character, just move left
+ call feedkeys( 'h', 'n')
+ let c = c - 1
+ endwhile
+ if c < 0 && line[0] =~ b:any_matched_char
+ " Can't help, still on matched character, insert instead
+ call feedkeys( 'i', 'n')
+ return
+ endif
+ else
+ " Changing forward
+ let c = col( '.' ) - 1
+ while c < len(line) && line[c] =~ b:any_matched_char
+ " Shouldn't delete a matched character, just move right
+ call feedkeys( 'l', 'n')
+ let c = c + 1
+ endwhile
+ if c == len(line)
+ " Can't help, still on matched character, append instead
+ call feedkeys( 'a', 'n')
+ return
+ endif
+ endif
+
+ " Safe to use Vim's built-in change function
+ call feedkeys( a:cmd, 'n')
+endfunction
+
" Paste text from put register in a balanced way
function! PareditPut( cmd )
let regname = v:register
@@ -357,7 +403,10 @@ endfunction
" Toggle paredit mode
function! PareditToggle()
- let g:paredit_mode = 1 - g:paredit_mode
+ " Don't disable paredit if it was not initialized yet for the current buffer
+ if exists( 'b:paredit_init') || g:paredit_mode == 0
+ let g:paredit_mode = 1 - g:paredit_mode
+ endif
echo g:paredit_mode ? 'Paredit mode on' : 'Paredit mode off'
call PareditInitBuffer()
endfunction
@@ -547,6 +596,10 @@ function! PareditFindOpening( open, close, select )
normal! lvh
let &ve = save_ve
call searchpair( open, '', close, 'bW', s:skip_sc )
+ if &selection == 'inclusive'
+ " Trim last character from the selection, it will be included anyway
+ normal! oho
+ endif
endif
endfunction
@@ -635,6 +688,30 @@ function! PareditInsertOpening( open, close )
return retval
endfunction
+" Re-gather electric returns up
+function! s:ReGatherUp()
+ if g:paredit_electric_return && getline('.') =~ '^\s*)'
+ " Re-gather electric returns in the current line for ')'
+ normal! k
+ while getline( line('.') ) =~ '^\s*$'
+ " Delete all empty lines
+ normal! ddk
+ endwhile
+ normal! Jl
+ elseif g:paredit_electric_return && getline('.') =~ '^\s*\(\]\|}\)' && &ft == 'clojure'
+ " Re-gather electric returns in the current line for ']' and '}'
+ normal! k
+ while getline( line('.') ) =~ '^\s*$'
+ " Delete all empty lines
+ normal! ddk
+ endwhile
+ call setline( line('.'), substitute( line, '\s*$', '', 'g' ) )
+ normal! Jxl
+ endif
+ " Already have the desired character, move right
+ call feedkeys( "\<Right>", 'n' )
+endfunction
+
" Insert closing type of a paired character, like ) or ].
function! PareditInsertClosing( open, close )
if !g:paredit_mode || s:InsideComment() || s:InsideString() || !s:IsBalanced()
@@ -648,12 +725,7 @@ function! PareditInsertClosing( open, close )
call feedkeys( a:close, 'n' )
return
elseif line[pos] == a:close
- if g:paredit_electric_return && line =~ '^\s*)'
- " Re-gather electric returns in the current line
- normal! kJl
- endif
- " Already have the desired character, move right
- call feedkeys( "\<Right>", 'n' )
+ call s:ReGatherUp()
return
endif
let open = escape( a:open , '[]' )
@@ -661,11 +733,21 @@ function! PareditInsertClosing( open, close )
let newpos = searchpairpos( open, '', close, 'nW', s:skip_sc )
if g:paredit_electric_return && newpos[0] > line('.')
" Closing paren is in a line below, check if there are electric returns to re-gather
- let nextline = getline( line('.') + 1 )
- let nextline = substitute( nextline, '\s', '', 'g' )
+ while getline('.') =~ '^\s*$'
+ " Delete all empty lines above the cursor
+ normal! ddk
+ endwhile
+ let oldpos = getpos( '.' )
+ normal! j
+ while getline('.') =~ '^\s*$'
+ " Delete all empty lines below the cursor
+ normal! dd
+ endwhile
+ let nextline = substitute( getline('.'), '\s', '', 'g' )
+ call setpos( '.', oldpos )
if len(nextline) > 0 && nextline[0] == ')'
" Re-gather electric returns in the line of the closing ')'
- call setline( line('.'), substitute( line, '\s*$', '', 'g' ) )
+ call setline( line('.'), substitute( getline('.'), '\s*$', '', 'g' ) )
normal! Jl
call feedkeys( "\<Right>", 'n' )
return
@@ -679,12 +761,10 @@ function! PareditInsertClosing( open, close )
endif
elseif g:paredit_electric_return && line =~ '^\s*)'
" Re-gather electric returns in the current line
- normal! kJl
- call feedkeys( "\<Right>", 'n' )
+ call s:ReGatherUp()
return
endif
- if newpos[0] > 0
- call setpos( '.', [0, newpos[0], newpos[1], 0] )
+ if searchpair( open, '', close, 'W', s:skip_sc ) > 0
call feedkeys( "\<Right>", 'n' )
endif
"TODO: indent after going to closing character
@@ -834,6 +914,8 @@ function! s:EraseFwd( count, startcol )
let line = getline( '.' )
let pos = col( '.' ) - 1
let reg = @"
+ let ve_save = &virtualedit
+ set virtualedit=all
let c = a:count
while c > 0
if line[pos] == '\' && line[pos+1] =~ b:any_matched_char && (pos < 1 || line[pos-1] != '\')
@@ -874,6 +956,7 @@ function! s:EraseFwd( count, startcol )
endif
let c = c - 1
endwhile
+ let &virtualedit = ve_save
call setline( '.', line )
let @" = reg
endfunction
@@ -1396,7 +1479,7 @@ function! s:WrapSelection( open, close )
let c0 = col( "'<" )
let c1 = col( "'>" )
if &selection == 'inclusive'
- let c1 = c1 + 1
+ let c1 = c1 + strlen(matchstr(getline(l1)[c1-1 :], '.'))
endif
if [l0, c0] == [0, 0] || [l1, c1] == [0, 0]
" No selection
View
1  slime/contrib/swank-presentation-streams.lisp
@@ -74,6 +74,7 @@ be sensitive and remember what object it is in the repl if predicate is true"
(sb-ext:without-package-locks
(swank-backend::with-debootstrapping
(load (make-pathname
+ :device (pathname-device swank-loader:*source-directory*)
:name "sbcl-pprint-patch"
:type "lisp"
:directory (pathname-directory swank-loader:*source-directory*)))))))
Please sign in to comment.
Something went wrong with that request. Please try again.