Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can support 'current' scope for buffers? #1290

Open
2 tasks done
fishioon opened this issue Oct 18, 2024 · 1 comment
Open
2 tasks done

Can support 'current' scope for buffers? #1290

fishioon opened this issue Oct 18, 2024 · 1 comment
Labels
feature-request Request for a feature to existing module mini.pick

Comments

@fishioon
Copy link

fishioon commented Oct 18, 2024

Contributing guidelines

Module(s)

mini.pick

Description

In my work flow, one tab one project. So I want buffers pick can support 'current' scope which only list current dir buffers?

@fishioon fishioon added the feature-request Request for a feature to existing module label Oct 18, 2024
@echasnovski
Copy link
Owner

Thanks for the suggestion!

If I understand correctly, you'd like to be able to pick only buffers for files which are located in the current working directory? This seems like a reasonable thing add and I'll look into it.

In the meantime this can be achieved with the following custom picker:

MiniPick.registry.buffers_cwd = function()
  local cwd = vim.fs.normalize(vim.fn.getcwd()) .. '/'
  local items = {}
  for _, buf_id in ipairs(vim.api.nvim_list_bufs()) do
    local buf_name = vim.fs.normalize(vim.api.nvim_buf_get_name(buf_id))
    if vim.startswith(buf_name, cwd) then
      table.insert(items, { text = vim.fn.fnamemodify(buf_name, ':.'), buf_id = buf_id })
    end
  end

  local source = { name = 'Buffers (cwd)', items = items }
  MiniPick.start({ source = source })
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for a feature to existing module mini.pick
Projects
None yet
Development

No branches or pull requests

2 participants