From 6e665ab8774faaf44e854e5da69727c4261821ee Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sun, 22 Sep 2024 19:59:24 -0700 Subject: [PATCH] In insert and replace modes, use internal formatting --- autoload/lsp/lsp.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index adbd60c0..83f1f4d3 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -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