Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ Configure via `require("peekstack").setup({ ... })`.
file = { enable = true },
marks = {
enable = false,
scope = "all", -- "buffer" | "global" | "all"
include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
include_special = false,
},
Expand Down
1 change: 0 additions & 1 deletion doc/peekstack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ With options:
file = { enable = true },
marks = {
enable = false,
scope = "all", -- "buffer" | "global" | "all"
include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
include_special = false,
},
Expand Down
5 changes: 0 additions & 5 deletions lua/peekstack/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ local KNOWN_BUFFER_MODES = { "copy", "source" }
---@type string[]
local KNOWN_RESTORE_POSITIONS = { "top", "original" }

---@type string[]
local KNOWN_MARK_SCOPES = { "buffer", "global", "all" }

---@type string[]
local KNOWN_PATH_BASES = { "repo", "cwd", "absolute" }

Expand Down Expand Up @@ -171,7 +168,6 @@ M.defaults = {
file = { enable = true },
marks = {
enable = false,
scope = "all",
include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
include_special = false,
},
Expand Down Expand Up @@ -443,7 +439,6 @@ local LAYOUT_OFFSET_RULES = {

---@type PeekstackConfigFieldRule[]
local MARKS_RULES = {
{ key = "scope", validate = field_enum(KNOWN_MARK_SCOPES), require_truthy = true },
{ key = "include", validate = field_type("string") },
{ key = "include_special", validate = field_type("boolean") },
}
Expand Down
13 changes: 12 additions & 1 deletion lua/peekstack/core/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function M.setup()
reset_reflow_timer()
popup_cursor_buffers = {}
local group = vim.api.nvim_create_augroup("PeekstackEvents", { clear = true })
local keymaps = require("peekstack.ui.keymaps")

vim.api.nvim_create_autocmd("WinClosed", {
group = group,
Expand Down Expand Up @@ -105,6 +106,7 @@ function M.setup()
local bufnr = vim.api.nvim_win_get_buf(winid)
ensure_popup_cursor_tracking(group, bufnr)
end
keymaps.activate_source_popup(winid)
if is_floating_window(winid) then
stack.touch(winid)
local layout = require("peekstack.core.layout")
Expand All @@ -116,9 +118,17 @@ function M.setup()
end,
})

vim.api.nvim_create_autocmd("WinLeave", {
group = group,
callback = function()
keymaps.deactivate_source_popup(vim.api.nvim_get_current_win())
end,
})

local current_winid = vim.api.nvim_get_current_win()
if vim.w[current_winid].peekstack_popup_id ~= nil then
ensure_popup_cursor_tracking(group, vim.api.nvim_win_get_buf(current_winid))
keymaps.activate_source_popup(current_winid)
end

local cfg = config.get()
Expand All @@ -139,8 +149,9 @@ function M.setup()
end,
})

local cleanup = require("peekstack.core.cleanup")
cleanup.stop()
if cfg.ui.popup.auto_close and cfg.ui.popup.auto_close.enabled then
local cleanup = require("peekstack.core.cleanup")
cleanup.start()
end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/peekstack/core/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function M.reflow(stack)
height = lo.height,
zindex = z,
})
vim.api.nvim_win_set_config(popup.winid, win_opts)
pcall(vim.api.nvim_win_set_config, popup.winid, win_opts)
if is_zoomed then
set_popup_zoom_winhighlight(popup.winid, true)
else
Expand Down
3 changes: 3 additions & 0 deletions lua/peekstack/core/popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ end

---@param popup PeekstackPopupModel
function M.close(popup)
-- Remove source-mode keymaps before closing the window so they do not
-- leak into normal editing of the shared buffer.
require("peekstack.ui.keymaps").remove_popup(popup)
diagnostics_ui.clear(popup.diagnostics)
if popup.winid and vim.api.nvim_win_is_valid(popup.winid) then
vim.api.nvim_win_close(popup.winid, true)
Expand Down
2 changes: 2 additions & 0 deletions lua/peekstack/persist/store.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function M.read(scope, opts)
vim.schedule(function()
local ok, decoded = pcall(vim.json.decode, data)
if not ok or type(decoded) ~= "table" then
notify.warn("Failed to decode session data: " .. path)
on_done(empty_data())
return
end
Expand Down Expand Up @@ -104,6 +105,7 @@ function M.read_sync(scope)

local ok, decoded = pcall(vim.json.decode, data)
if not ok or type(decoded) ~= "table" then
notify.warn("Failed to decode session data: " .. path)
return empty_data()
end
return decoded
Expand Down
6 changes: 6 additions & 0 deletions lua/peekstack/providers/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ function M.under_cursor(ctx, cb)
local source_name = vim.api.nvim_buf_get_name(ctx.bufnr)
local base = vim.fn.fnamemodify(source_name, ":p:h")
target = vim.fn.fnamemodify(base .. "/" .. target, ":p")

local stat = vim.uv.fs_stat(target)
if not stat or stat.type ~= "file" then
cb({})
return
end
end
local uri = fs.fname_to_uri(target)
local loc = location.normalize(
Expand Down
2 changes: 1 addition & 1 deletion lua/peekstack/providers/grep.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function M.search(_, cb)
return
end

vim.system({ "rg", "--vimgrep", query }, { text = true }, function(result)
vim.system({ "rg", "--vimgrep", "--max-count=1000", "--", query }, { text = true }, function(result)
vim.schedule(function()
if result.code ~= 0 and result.code ~= 1 then
notify.warn("rg failed: " .. (result.stderr or "unknown error"))
Expand Down
1 change: 0 additions & 1 deletion lua/peekstack/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@

---@class PeekstackConfigProviderMarks
---@field enable boolean
---@field scope "buffer"|"global"|"all"
---@field include string
---@field include_special boolean

Expand Down
Loading