Skip to content

Commit

Permalink
feat: add option to disable save cursor location
Browse files Browse the repository at this point in the history
  • Loading branch information
dcai committed Mar 20, 2024
1 parent 7aa1df1 commit c1835da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ local default = {
datafile = vim.fn.stdpath("data") .. "/marlin.json", -- location of data file
open_callback = callbacks.change_buffer -- default way to open buffer
sorter = sorter.by_buffer -- sort by bufferid
save_cursor_location = true
suppress = {
missing_root = false -- don't give warning on project root not found
}
Expand Down
22 changes: 14 additions & 8 deletions lua/marlin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ local default = {
datafile = vim.fn.stdpath("data") .. "/marlin.json",
open_callback = callbacks.change_buffer,
sorter = sorter.by_buffer,
save_cursor_location = true,
suppress = {
missing_root = false,
},
Expand Down Expand Up @@ -348,14 +349,19 @@ marlin.setup = function(opts)
-- Load project specific data
marlin.load_project_files()

local augroup = vim.api.nvim_create_augroup("marlin", {})
vim.api.nvim_create_autocmd({ "CursorMoved", "BufLeave", "VimLeavePre" }, {
group = augroup,
pattern = "*",
callback = function(_)
update_location(marlin)
end,
})
if marlin.opts.save_cursor_location then
local augroup = vim.api.nvim_create_augroup("marlin", {})
vim.api.nvim_create_autocmd(
{ "CursorMoved", "BufLeave", "VimLeavePre" },
{
group = augroup,
pattern = "*",
callback = function(_)
update_location(marlin)
end,
}
)
end
end
--- Sort indexes
---
Expand Down

0 comments on commit c1835da

Please sign in to comment.