Skip to content

Commit

Permalink
Indent clojure multi-arity function definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
kovisoft committed Apr 5, 2017
1 parent 7e988bd commit 011e282
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 12 additions & 3 deletions ftplugin/slimv.vim
@@ -1,6 +1,6 @@
" slimv.vim: The Superior Lisp Interaction Mode for VIM
" Version: 0.9.13
" Last Change: 18 Mar 2017
" Version: 0.9.14
" Last Change: 05 Apr 2017
" Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
" License: This file is placed in the public domain.
" No warranty, express or implied.
Expand Down Expand Up @@ -1575,7 +1575,11 @@ endfunction
" TODO: implement custom indent procedure and omit lispindent()
function SlimvLispindent( lnum )
set lisp
let li = lispindent( a:lnum )
if SlimvGetFiletype() =~ '.*clojure.*' && exists( '*GetClojureIndent' ) && line('.') == a:lnum
let li = GetClojureIndent()
else
let li = lispindent( a:lnum )
endif
set nolisp
let backline = max([a:lnum-g:slimv_indent_maxlines, 1])
let oldpos = getpos( '.' )
Expand Down Expand Up @@ -1715,6 +1719,11 @@ function! SlimvIndentUnsafe( lnum )
if lb >= l && (lb > l || cb > c)
return cb
endif
" Is this a multi-arity function definition?
let line = strpart( getline(l), c-1 )
if match( line, '(\s*\[' ) >= 0
return c + 1
endif
endif
" Is this a form with special indentation?
let line = strpart( getline(l), c-1 )
Expand Down
10 changes: 7 additions & 3 deletions indent/clojure.vim
@@ -1,7 +1,7 @@
" clojure.vim:
" Clojure indent plugin for Slimv
" Version: 0.9.5
" Last Change: 21 Feb 2012
" Version: 0.9.14
" Last Change: 05 Apr 2017
" Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
" License: This file is placed in the public domain.
" No warranty, express or implied.
Expand All @@ -10,10 +10,14 @@
" =====================================================================
"
" Load Once:
if exists("b:did_indent") || exists("g:slimv_disable_clojure")
if exists("b:did_indent") || exists("b:slimv_did_indent") || exists("g:slimv_disable_clojure")
finish
endif

" Prevent recursive call but allow loading other clojure plugins
let b:slimv_did_indent = 1

runtime! indent/**/clojure.vim
runtime indent/**/lisp.vim

setlocal nolisp
Expand Down

0 comments on commit 011e282

Please sign in to comment.