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

Feature request: open buffer in chosen project #153

Open
hardenedapple opened this issue Apr 17, 2024 · 0 comments
Open

Feature request: open buffer in chosen project #153

hardenedapple opened this issue Apr 17, 2024 · 0 comments

Comments

@hardenedapple
Copy link

I would like to open a buffer restricted to a given project (as the way to "jump" to that project -- once I've changed dir to that project root the builtin.buffers picker works just fine).

I copy-pasted and tweaked to get the below which appears to work, but not opening as a pull request since I have very little idea what is going on and don't have a clue what default mappings you would want.

diff --git a/lua/telescope/_extensions/project/actions.lua b/lua/telescope/_extensions/project/actions.lua
index 454e6ab..d35dd78 100644
--- a/lua/telescope/_extensions/project/actions.lua
+++ b/lua/telescope/_extensions/project/actions.lua
@@ -184,6 +184,19 @@ M.recent_project_files = function(prompt_bufnr)
   end
 end
 
+-- Choose an open buffer within the selected project using the Telescope
+-- builtin `buffers`.
+M.buffers_in_project = function(prompt_bufnr)
+  local project_path = M.get_selected_path(prompt_bufnr)
+  actions._close(prompt_bufnr, true)
+  local cd_successful = _utils.change_project_dir(project_path, cd_scope)
+  if cd_successful then
+    vim.schedule(function()
+      builtin.buffers({cwd_only = true})
+    end)
+  end
+end
+
 -- Change working directory to the selected project and close the picker.
 M.change_working_directory = function(prompt_bufnr)
   local project_path = M.get_selected_path(prompt_bufnr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant