Skip to content

Commit

Permalink
EDN files are unlikely to contain many lists, so check them last
Browse files Browse the repository at this point in the history
  • Loading branch information
axvr committed Apr 28, 2023
1 parent 51e6a43 commit e573da7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions indent/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,17 @@ function! s:GetClojureIndent()
call s:CheckPair('reg', '#\zs"', '"', function('<SID>NotRegexpDelimiter'))
else
let IgnoredRegionFn = function('<SID>IgnoredRegion')
call s:CheckPair('lst', '(', ')', IgnoredRegionFn)
call s:CheckPair('map', '{', '}', IgnoredRegionFn)
call s:CheckPair('vec', '\[', '\]', IgnoredRegionFn)
if bufname() ==? '\.edn$'
" If EDN file, check list pair last.
call s:CheckPair('map', '{', '}', IgnoredRegionFn)
call s:CheckPair('vec', '\[', '\]', IgnoredRegionFn)
call s:CheckPair('lst', '(', ')', IgnoredRegionFn)
else
" If CLJ file, check list pair first.
call s:CheckPair('lst', '(', ')', IgnoredRegionFn)
call s:CheckPair('map', '{', '}', IgnoredRegionFn)
call s:CheckPair('vec', '\[', '\]', IgnoredRegionFn)
endif
endif

" Find closest matching higher form.
Expand All @@ -145,10 +153,10 @@ function! s:GetClojureIndent()
elseif formtype ==# 'reg'
" Inside a regular expression.
return s:GetStringIndent(coord, 1)
else
" Keep existing indent.
return -1
endif

" Keep existing indent.
return -1
endfunction

if exists("*searchpairpos")
Expand Down

0 comments on commit e573da7

Please sign in to comment.