From 92393f02efadfb1d9f97c74c8feb853c1caea9de Mon Sep 17 00:00:00 2001 From: Steven Arcangeli <506791+stevearc@users.noreply.github.com> Date: Wed, 30 Aug 2023 18:34:13 -0700 Subject: feat: apply changes as text edits using LSP utils (#18) * feat: apply changes as text edits using LSP utils This means we can leverage all of the work that was done in the LSP client to preserve marks, cursor position, etc * log: add trace logging to debug performance * feat: use the same diff -> TextEdit technique for bad LSP servers Some LSP servers simply return a single TextEdit that replaces the whole buffer. This is bad for extmarks, cursor, and if the buffer is open in multiple windows the non-active window will jump to the top. We can detect that situation and apply the same vim.diff logic to convert it into more granular TextEdits. --- lua/conform/health.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lua/conform/health.lua') diff --git a/lua/conform/health.lua b/lua/conform/health.lua index 195a331..d36ef03 100644 --- a/lua/conform/health.lua +++ b/lua/conform/health.lua @@ -90,6 +90,9 @@ M.show_window = function() seen[formatter.name] = true end append_formatters(buf_formatters) + if vim.tbl_isempty(buf_formatters) then + table.insert(lines, "") + end table.insert(lines, "") table.insert(lines, "Other formatters:") -- cgit v1.2.3-70-g09d2