Skip to content

Commit

Permalink
In insert and replace modes, use internal formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yegappan committed Sep 23, 2024
1 parent c1ec74d commit 6e665ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autoload/lsp/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,12 @@ export def FormatExpr(): number
return 1
endif

if ['i', 'R', 'ic', 'ix']->index(mode()) != -1
# When 'formatexpr' is called in insert mode to format a line exceeding
# 'textwidth', use internal formatting.
return 1
endif

lspserver.textDocFormat(@%, true, v:lnum, v:lnum + v:count - 1)
return 0
enddef
Expand Down

0 comments on commit 6e665ab

Please sign in to comment.