Skip to content

Commit

Permalink
adding g:parinfer_mode - adding airline support for mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Case Nelson committed Dec 19, 2015
1 parent ab1f02c commit 14463f6
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions plugin/parinfer.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
let g:parinfer_mode = "indent"

function! s:indent()
if has('nvim') && g:parinfer_mode != "off"
try
silent undojoin
catch
endtry
let l:lines = ParinferIndent("changed")
if !empty(lines)
call setline(1,lines)
endif
endif
endfunction

augroup ClojureParinfer
autocmd FileType clojure
\ :autocmd! ClojureParinfer BufEnter <buffer>
\ :let lines = ParinferIndent("enter") | if !empty(lines) | call setline(1,lines) | endif | unlet lines
\ :autocmd! ClojureParinfer BufEnter <buffer>
\ :call <SID>indent()

autocmd FileType clojure
\ :autocmd! TextChanged,TextChangedI <buffer>
\ :try | silent undojoin | catch | endtry | let lines = ParinferIndent("changed") | if !empty(lines) | call setline(1,lines) | endif | unlet lines
\ :autocmd! ClojureParinfer TextChanged,TextChangedI <buffer>
\ :call <SID>indent()
augroup END

if (exists('g:loaded_airline') && g:loaded_airline)
function! ParinferAirline(...)
if &filetype == "clojure"
let w:airline_section_a = g:airline_section_a . ' %{g:parinfer_mode}'
endif
endfunction

call airline#add_statusline_func('ParinferAirline')
endif

0 comments on commit 14463f6

Please sign in to comment.