Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lua/line-number-change-mode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function M.setup(opts)
vim.cmd.redraw()
end
end

-- Keep track of mode because we don't get a ModeChanged event when
-- opening a file from Telescope. See:
-- https://github.com/sethen/line-number-change-mode.nvim/issues/7
M.mode = mode
end

set_hl_for_mode(va.nvim_get_mode().mode)
Expand All @@ -33,6 +38,24 @@ function M.setup(opts)
set_hl_for_mode(new_mode)
end,
})

vim.api.nvim_create_autocmd({ "WinLeave" }, {
group = group,
callback = function(_)
-- If we're leaving a window and we're still in insert mode, schedule
-- a callback for the next run of the event loop to make sure the
-- correct mode highlight is displayed. See:
-- https://github.com/sethen/line-number-change-mode.nvim/issues/7
if M.mode == 'i' then
vim.schedule(function()
if opts.debug then
vim.notify('in insert mode, will schedule mode set')
end
set_hl_for_mode(vim.api.nvim_get_mode().mode)
end)
end
end,
})
end

return M