From 011e282038f5ee6c41c4a3ffa3ba380fda48923a Mon Sep 17 00:00:00 2001 From: Tamas Kovacs Date: Wed, 5 Apr 2017 23:07:13 +0200 Subject: [PATCH] Indent clojure multi-arity function definitions --- ftplugin/slimv.vim | 15 ++++++++++++--- indent/clojure.vim | 10 +++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ftplugin/slimv.vim b/ftplugin/slimv.vim index 8ce9d22..4cccab3 100644 --- a/ftplugin/slimv.vim +++ b/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 " License: This file is placed in the public domain. " No warranty, express or implied. @@ -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( '.' ) @@ -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 ) diff --git a/indent/clojure.vim b/indent/clojure.vim index 3b9e4fe..dca9209 100644 --- a/indent/clojure.vim +++ b/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 " License: This file is placed in the public domain. " No warranty, express or implied. @@ -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