-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: put the filename back into the real buffer text
- Loading branch information
Showing
26 changed files
with
259 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local M = {} | ||
|
||
local function constrain_cursor() | ||
local display = require("quicker.display") | ||
local cur = vim.api.nvim_win_get_cursor(0) | ||
local line = vim.api.nvim_buf_get_lines(0, cur[1] - 1, cur[1], true)[1] | ||
local idx = line:find(display.EM_QUAD, 1, true) | ||
if not idx then | ||
return | ||
end | ||
local min_col = idx + display.EM_QUAD_LEN - 1 | ||
if cur[2] < min_col then | ||
vim.api.nvim_win_set_cursor(0, { cur[1], min_col }) | ||
end | ||
end | ||
|
||
---@param bufnr number | ||
function M.constrain_cursor(bufnr) | ||
-- HACK: we have to defer this call because sometimes the autocmds don't take effect. | ||
vim.schedule(function() | ||
if not vim.api.nvim_buf_is_valid(bufnr) then | ||
return | ||
end | ||
local aug = vim.api.nvim_create_augroup("quicker", { clear = false }) | ||
vim.api.nvim_create_autocmd("InsertEnter", { | ||
desc = "Constrain quickfix cursor position", | ||
group = aug, | ||
nested = true, | ||
buffer = bufnr, | ||
-- For some reason the cursor bounces back to its original position, | ||
-- so we have to defer the call | ||
callback = vim.schedule_wrap(constrain_cursor), | ||
}) | ||
vim.api.nvim_create_autocmd({ "CursorMoved", "ModeChanged" }, { | ||
desc = "Constrain quickfix cursor position", | ||
nested = true, | ||
group = aug, | ||
buffer = bufnr, | ||
callback = constrain_cursor, | ||
}) | ||
end) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.