Skip to content
This repository was archived by the owner on Feb 23, 2025. It is now read-only.

Commit a0ee072

Browse files
committed
Update to set indentexpr in ftplugin when formatter is native-image's
1 parent fbd5ff8 commit a0ee072

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

autoload/iced/format.vim

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ function! iced#format#calculate_indent(lnum) abort
1919
return iced#system#get(s:formatter).calculate_indent(a:lnum)
2020
endfunction
2121

22+
function! s:set_indentexpr() abort
23+
setlocal indentexpr=GetIcedIndent()
24+
endfunction
25+
2226
function! iced#format#set_indentexpr() abort
2327
if get(g:, 'iced_enable_auto_indent', v:true)
24-
setlocal indentexpr=GetIcedIndent()
28+
" Delay `setlocal` if called by ftplugin, because `GetIcedIndent` is not yet loaded
29+
call iced#system#get('future').do({-> s:set_indentexpr()})
2530
endif
2631
endfunction
2732

ftplugin/clojure.vim

+5
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@ for key in ['error', 'trace']
454454
endfor
455455
"" }}}
456456

457+
" Set `indentexpr` without waiting for a REPL connection when native-image formatter is used
458+
if g:iced_formatter !=# 'default'
459+
call iced#format#set_indentexpr()
460+
endif
461+
457462
let &cpoptions = s:save_cpo
458463
unlet s:save_cpo
459464

indent/clojure.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let s:save_cpo = &cpo
22
set cpo&vim
33

4-
" NOTE: setting indentexpr is executed at nREPL connection
4+
" NOTE: setting indentexpr is executed at nREPL connection or ftplugin/clojure.vim
55
function! GetIcedIndent()
66
return iced#format#calculate_indent(v:lnum)
77
endfunction

0 commit comments

Comments
 (0)