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/log.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/conform/log.lua') diff --git a/lua/conform/log.lua b/lua/conform/log.lua index b42d1f8..753a3c6 100644 --- a/lua/conform/log.lua +++ b/lua/conform/log.lua @@ -35,7 +35,7 @@ local function format(level, msg, ...) local ok, text = pcall(string.format, msg, vim.F.unpack_len(args)) if ok then local str_level = levels[level] - return string.format("[%s] %s", str_level, text) + return string.format("%s[%s] %s", vim.fn.strftime("%H:%M:%S"), str_level, text) else return string.format("[ERROR] error formatting log line: '%s' args %s", msg, vim.inspect(args)) end -- cgit v1.2.3-70-g09d2