Skip to content

Commit

Permalink
refactor(echo): migrate to vim.uv and nvim_echo APIs
Browse files Browse the repository at this point in the history
Replace deprecated vim.loop with vim.uv and switch from nvim_command echo to
the more modern vim.api.nvim_echo API. This change removes the need for
string escaping when displaying messages.
  • Loading branch information
deathbeam committed Nov 30, 2024
1 parent 6b00e2e commit cea7082
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lua/lspecho/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ local M = {}

local series = {}
local last_message = ''
local timer = vim.loop.new_timer()

local function escape_string(str)
return str:gsub('([\\"])', '\\%1')
end
local timer = vim.uv.new_timer()

local function clear()
timer:stop()
Expand All @@ -16,7 +12,7 @@ local function clear()
vim.schedule_wrap(function()
last_message = ''
if M.config.echo then
vim.api.nvim_command('redraw | echo ""')
vim.api.nvim_echo({ { '' } }, false, {})
end
end)
)
Expand Down Expand Up @@ -60,9 +56,7 @@ local function log(msg)

last_message = out
if M.config.echo then
vim.api.nvim_command(
string.format('redraw | echo "%s"', escape_string(string.sub(out, 1, vim.v.echospace)))
)
vim.api.nvim_echo({ { string.sub(out, 1, vim.v.echospace) } }, false, {})
end
end

Expand Down

0 comments on commit cea7082

Please sign in to comment.