]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
In insert and replace modes, use internal formatting
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 23 Sep 2024 02:59:24 +0000 (19:59 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 23 Sep 2024 02:59:24 +0000 (19:59 -0700)
autoload/lsp/lsp.vim

index adbd60c0e74d845d05157fcaeaa39ce1915e922a..83f1f4d351dd9f91f212656c85c4e40e665ebb9b 100644 (file)
@@ -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