Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc93af75

Browse files
committed
Fix <Plug>HaskellIndentN/-P on Neovim
In Neovim ^F causes indent to happen *twice*. Therefore on the secondround the indentation did just get reset to the default.This commit works around that by skipping the second indent when weexpect it.A more robust solution could be something like <C-\><C-O>:set indentexpr=<indent><CR><C-F>which would work regardless of Neovim behavior. == can not be used forblank lines, and :left would have to be followed by ^F anyway to set the`did_ai` flag, which is needed in order to act similarly to <C-T>/<C-D>(that leave `did_ai` as is) where indent on blank lines is deleted uponleaving Insert mode.Seeneovim/neovim#12894
1 parenta00ad1c commitc93af75

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎indent/haskell.vim‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ function s:CycleIndentExpr(dir) abort
3131
returnmode()==#'i' ?"\<C-F>" :'=='
3232
endfunction
3333

34+
lets:skip_ai=0
35+
3436
functionGetHaskellIndent()abort
37+
" Neovim indents twice on ^F...
38+
ifs:skip_ai
39+
lets:skip_ai=0
40+
return-1
41+
endif
42+
ifs:indent_dir&&has('nvim') |lets:skip_ai=1 |endif
43+
3544
let prevIndent=indent(s:indent_dir ?v:lnum :prevnonblank(v:lnum))
3645
let indentations=haskell#Parse()
3746

‎test/test_indent.vim‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,15 @@ function Test_EmptyPair() abort
143143
END
144144
calls:Test(text, [{'lnum':2,'points': [0,2]}])
145145
endfunction
146+
147+
functionTest_InsertMode()abort
148+
setfiletype=haskell
149+
callsetline(1, ['foo = let x = 0'])
150+
151+
execute"normal o\<C-T>y = 1"
152+
callassert_equal(' y = 1',getline(2))
153+
154+
" Assert that indent on blank line is deleted upon leaving Insert mode
155+
execute"normal S\<C-T>"
156+
callassert_equal('',getline(2))
157+
endfunction

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp