Commits

Tamas Kovacs committed e106e11

Do not permanently set iskeyword in paredit.vim

Comments (0)

Files changed (1)

plugin/paredit.vim

 " 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
     if &ft =~ '.*\(clojure\|scheme\).*'
-        setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&
         let b:any_matched_char   = '(\|)\|\[\|\]\|{\|}\|\"'
         let b:any_matched_pair   = '()\|\[\]\|{}\|\"\"'
         let b:any_opening_char   = '(\|\[\|{'
         let b:any_wsopen_char    = '\s\|(\|\[\|{'
         let b:any_wsclose_char   = '\s\|)\|\]\|}'
     else
-        setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&,{,},[,]
         let b:any_matched_char   = '(\|)\|\"'
         let b:any_matched_pair   = '()\|\"\"'
         let b:any_opening_char   = '('
     endif
 endfunction
 
+" Include all prefix and special characters in 'iskeyword'
+function! s:SetKeyword()
+    let old_value = &iskeyword
+    if SlimvGetFiletype() =~ '.*\(clojure\|scheme\).*'
+        setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&
+    else
+        setlocal iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,@-@,94,~,#,\|,&,.,{,},[,]
+    endif
+    return old_value
+endfunction
+
 " General Paredit operator function
 function! PareditOpfunc( func, type, visualmode )
     let sel_save = &selection
 " If standing on a paren then wrap the whole s-expression
 " Stand on the opening paren (if not wrapping in "")
 function! PareditWrap( open, close )
+    let isk_save = s:SetKeyword()
     if a:open != '"' && getline('.')[col('.') - 1] =~ b:any_openclose_char
         execute "normal! " . "v%\<Esc>"
     else
     if a:open != '"'
         normal! %
     endif
+    let &iskeyword = isk_save
 endfunction
 
 " Splice current list into the containing list
 
 " Raise: replace containing form with the current symbol or sub-form
 function! PareditRaise()
+    let isk_save = s:SetKeyword()
     if getline('.')[col('.')-1] =~ b:any_openclose_char
         " Raise sub-form and re-indent
         normal! y%d%dab
         normal! yiwdab
         normal! "0Pb
     endif
+    let &iskeyword = isk_save
 endfunction
 
 " =====================================================================