Skip to content

Feature request: open buffer in chosen project #153

@hardenedapple

Description

@hardenedapple

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions