Commits

Steve Losh committed a678503 Merge

Merge.

  • Participants
  • Parent commits 94c0fd3, 5690aca
  • Branches sjl-custom

Comments (0)

Files changed (2)

File ftplugin/slimv.vim

 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
 " Version:      0.9.8
-" Last Change:  14 Jul 2012
+" Last Change:  18 Jul 2012
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 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
 
 " 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
 
             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) ) )
     normal! %
 endfunction
 
+" Handle insert mode 'Enter' keypress
+function! SlimvHandleEnter()
+    call SlimvArglist()
+    if g:paredit_mode && g:paredit_electric_return
+        call feedkeys(PareditEnter(), 'n')
+    else
+        call feedkeys("\<CR>", 'n')
+    endif
+endfunction
+
 " Handle insert mode 'Tab' keypress by doing completion or indentation
 function! SlimvHandleTab()
     if pumvisible()
     let end = s:CloseForm( cmd )
     if end != 'ERROR' && end != ''
         " Command part before cursor is unbalanced, insert newline
-        if g:paredit_mode && exists( 'g:paredit_electric_return' ) && g:paredit_electric_return && lastline > 0 && line( "." ) >= lastline
+        call SlimvArglist()
+        if g:paredit_mode && g:paredit_electric_return && lastline > 0 && line( "." ) >= lastline
             " Apply electric return
             call feedkeys(PareditEnter(), 'n')
         else
             " No electric return handling, just enter a newline
             call feedkeys("\<CR>", 'n')
         endif
-        return
     else
         " Send current command line for evaluation
         call cursor( 0, 99999 )
 endfunction
 
 " Display function argument list
-function! SlimvArglist()
+" Optional argument is the number of characters typed after the keyword
+function! SlimvArglist( ... )
     let l = line('.')
-    let c = col('.') - 1
+    let c = col('.') - 1 - (a:0 ? a:1 : 0)
     let line = getline('.')
     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
         " Display only if entering the first space after a keyword
         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()
         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
 " 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
 
 " 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(1)<CR>
+    inoremap <silent> <buffer> <CR>       <C-R>=pumvisible() ?  "\<lt>CR>" : "\<lt>C-O>:call SlimvHandleEnter()\<lt>CR>"<CR>
     "noremap  <silent> <buffer> <C-C>      :call SlimvInterrupt()<CR>
     if !exists( 'b:au_insertleave_set' )
         let b:au_insertleave_set = 1

File plugin/paredit.vim

 " paredit.vim:
 "               Paredit mode for Slimv
 " Version:      0.9.8
-" Last Change:  14 Jun 2012
+" Last Change:  16 Jun 2012
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
             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
     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] != '\')
         endif
         let c = c - 1
     endwhile
+    let &virtualedit = ve_save
     call setline( '.', line )
     let @" = reg
 endfunction