Skip to content

Commit

Permalink
Add message decay
Browse files Browse the repository at this point in the history
  • Loading branch information
deathbeam committed Feb 21, 2024
1 parent 68d4ec0 commit 7dc1b21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ call setup with no arguments for default.
```lua
require("lspecho").setup {
echo = true, -- Echo progress messages, if set to false you can use .message() to get the current message
decay = 1000, -- Message decay time in milliseconds
}

```
Expand Down
17 changes: 17 additions & 0 deletions lua/lspecho/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ local M = {}

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

local function clear()
timer:stop()
timer:start(
1000,
0,
vim.schedule_wrap(function()
last_message = ''
if M.config.echo then
vim.api.nvim_command('redraw | echo ""')
end
end)
)
end

local function log(msg)
local client = msg.client or ''
Expand Down Expand Up @@ -88,11 +103,13 @@ local function lsp_progress(err, progress, ctx)
message = (value.message or (cur and cur.message)) .. ' - Done',
})
series[token] = nil
clear()
end
end

M.config = {
echo = true, -- Echo progress messages, if set to false you can use .message() to get the current message
decay = 1000, -- Message decay time in milliseconds
}

function M.message()
Expand Down

0 comments on commit 7dc1b21

Please sign in to comment.