telescope-project.nvim icon indicating copy to clipboard operation
telescope-project.nvim copied to clipboard

Feature Request: Search on current project's files

Open matheusfillipe opened this issue 4 years ago • 10 comments
trafficstars

Expose the command to search files in the current project directly so that you can bind a shortcut directly to it. As I see currently you have to invoke the menu, find the current project again and then be able to search on its files.

matheusfillipe avatar Aug 03 '21 02:08 matheusfillipe

also a option to disable the find files search instantly after the project has been selected

danielnehrig avatar Aug 05 '21 19:08 danielnehrig

@matheusfillipe How does it differ to the option "browse inside files within your project" accessible via b/C-b ?

matu3ba avatar Aug 12 '21 09:08 matu3ba

@matu3ba When you are editing a big project sometimes :Telescope find_files will only list files under your current working directory. This plugin always has the feature to fuzzy search over files of the current project regardless of the current working directory. The problem is that it only exposes one command that I can bind to (:lua require'telescope'.extensions.project.project{}<cr>) unless I am mistaken that's the only telescope command it has.

Another problem with the b\C-b thing is that you have to first type the name of the project you are on. What I want is to be able to already search for the files of the current project with a single command.

I guess this project isn't currently keeping track of the last selected project so that would be needed for this, and then expose a command to directly have the file exploring telescope from that menu.

matheusfillipe avatar Aug 12 '21 20:08 matheusfillipe

Ah, I get it. Instead of require'telescope'.extensions.project.project{}<cr> you want require'telescope'.extensions.project.project{}.all()<cr> and require'telescope'.extensions.project.project{}.current()<cr>

Yes, this would help. I am planning this for running scripts (local project) vs editing scripts (all projects). But having it upstream would make things simpler.

matu3ba avatar Aug 13 '21 12:08 matu3ba

Any news on this issue? I'm a convert from doom-emacs and Visual Studio Code. In Doom, I could just hit <Leader> p f or <Leader> <Leader> to search for a file in the current project. I used this all the time!

In VS Code this is covered by hitting Ctrl-P. The files even come up sorted according to recency.

Having this functionality work as frictionless as possible in Neovim is a hard requirement for my workflow. And it's already covered by tools like CommandT or CtrlP. However, I think that Telescope is the way to go from this point on, so having a fast "jump to project-file" is crucial from my point of view.

tim-hilt avatar Nov 22 '21 08:11 tim-hilt

Hey Tim, I am in the process of figuring out and communicating the intended direction to become maintainer.

There are 3 blockers on the refactor (#75) for this:

  1. [ ] setting up 2 different entry points/modes with 1 for editing projects and 1 for using projects and prefix relevant functions to make clear if they modify telescope-project.txt and telescopoe-workspaces.txt
  2. [ ] expose the path of current project as lua function, so users can define their own keybindings
  3. [ ] encode the behavior of :lcd,:cd and ":nocd" into the picker call functions of telescope-project
  4. [ ] (no real blocker) provide example keybindings

If you want to move things forward, open a PR for 1. so we can discuss the design and iterate further. Do you have any idea, how I could indicate a "public and user API for other plugins" and "forbidden/private functions" in lua to differentiate the first point?

matu3ba avatar Nov 22 '21 11:11 matu3ba

@matu3ba I'm not a lua-programmer at all and will have difficulties making time to implement this feature. I can't promise anything, but I'll at least take a look at the sourcecode.

tim-hilt avatar Nov 22 '21 11:11 tim-hilt

@tim-hilt Hey Tim, lua is fairly easy (you have 2 type of tables and functions). Files are also only tables. I am still using this for logging:

local fp = assert(io.open("/tmp/tmpfile", "w")) --DEBUG
for index,tables in pairs(repo_paths) do        --DEBUG
  fp:write(index)                               --DEBUG
  fp:write(", ")                                --DEBUG
  fp:write(tables)                              --DEBUG
  fp:write("\n")                                --DEBUG
end                                             --DEBUG
fp.close()                                      --DEBUG

local fp = assert(io.open("/tmp/tmpfile", "w")) --DEBUG
for index,tables in ipairs(repo_paths) do       --DEBUG
  fp:write(index)                               --DEBUG
  fp:write(", ")                                --DEBUG
  fp:write(tostring(tables))                    --DEBUG
  fp:write("\n")                                --DEBUG
end                                             --DEBUG
fp.close()                                      --DEBUG
-- deleting lines ending with DEBUG :g/.*DEBUG$/del

matu3ba avatar Nov 22 '21 11:11 matu3ba

also a option to disable the find files search instantly after the project has been selected

any news on this one?

Tej12345 avatar Jun 15 '22 21:06 Tej12345

also a option to disable the find files search instantly after the project has been selected

This bit already exists, see <C-l> when selecting a project.

As for the other issue, if you use Git for your projects you might find Telescope's builtin for git-files more useful than the regular file finder, and it is scoped to the project root.

alerque avatar Sep 14 '22 14:09 alerque