otavioschwanck / arrow.nvim

Bookmark your files, separated by project, and quickly navigate through them.
Other
454 stars 19 forks source link

Provide action to add buffer to list without toggling/improve mapping configuration #11

Closed jemag closed 7 months ago

jemag commented 7 months ago

Currently the s key toggles between adding and removing items from the list. The issue is that I often want to quickly add a bunch of different files without checking if they are already there and I end up removing them.

I see that the save https://github.com/otavioschwanck/arrow.nvim/blob/75c892c441cbd51b3b5bc4c527455801e0a7c174/lua/arrow/persist.lua#L41 function already exists. However:

  1. is it safe to use that exposed function?
  2. it would be nice to provide an 'on_attach' function where we can set local bindings to the arrow buffer instead of global ones
otavioschwanck commented 7 months ago

Currently the s key toggles between adding and removing items from the list. The issue is that I often want to quickly add a bunch of different files without checking if they are already there and I end up removing them.

I see that the save

https://github.com/otavioschwanck/arrow.nvim/blob/75c892c441cbd51b3b5bc4c527455801e0a7c174/lua/arrow/persist.lua#L41

function already exists. However:

  1. is it safe to use that exposed function?
  2. it would be nice to provide an 'on_attach' function where we can set local bindings to the arrow buffer instead of global ones

You can use safely:

vim.keymap.set("n", "<C-s>", require("arrow.persist").toggle)
jemag commented 7 months ago

Is there a way to set the keybind only for the arrow buffer though?

Basically I am trying to do either something like:

require("arrow").setup({
  on_attach = function()
    vim.keymap.set("n", "a", require("arrow.persist").save, { buffer = true})
  end,
})

or maybe

vim.api.nvim_create_autocmd("FileType", {
  pattern = "arrow",
  callback = function()
    vim.keymap.set("n", "a", require("arrow.persist").save, { buffer = true})
  end,
})
otavioschwanck commented 7 months ago

Is there a way to set the keybind only for the arrow buffer though?

Basically I am trying to do either something like:

require("arrow").setup({
  on_attach = function()
  vim.keymap.set("n", "a", require("arrow.persist").save, { buffer = true})
  end,
})

or maybe

vim.api.nvim_create_autocmd("FileType", {
  pattern = "arrow",
  callback = function()
    vim.keymap.set("n", "a", require("arrow.persist").save, { buffer = true})
  end,
})

There is no way to just save, just toggle. I will add an option to do that later on the day

otavioschwanck commented 7 months ago

Created an option to save / remove without toggle:

https://github.com/otavioschwanck/arrow.nvim/commit/a302cebc0e52b2e7f5d2cb09066fcf839176dd06

Just add to setup:

separate_save_and_remove = true,