rlivings39 / vscode-fzf-quick-open

vscode extension providing quick file/folder open and searching using fzf
MIT License
77 stars 17 forks source link

Search in project root #32

Closed oren0e closed 1 year ago

oren0e commented 3 years ago

I know that there is an option to search in the project root when using with vim, where "project root" being found by the folder that has .git folder (basically the repo home upper most directory). Is there a possibility to add this here as well?

Currently if I search in a subfolder, then the search is only within that subfolder, not taking into account files in the project that are found in upper directories.

rlivings39 commented 3 years ago

Limiting the search to a sub-folder is an intended feature so you can cd in the terminal to change the scope of the search. With the current tech, you could set fzf-quick-open.initialWorkingDirectory to be the desired root directory for your project. That setting controls the initial working directory of the launched terminal. Does that accomplish what you're looking for or are you proposing some other behavior?

oren0e commented 3 years ago

Thanks for the answer. It does not accomplish what I want because this solution will require me manually setting this up for every project, that's not convenient.
In vim for example, I have this setting to search in the project folder:

command! -bang -nargs=* PFiles
  \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--info=inline'], 'dir': system('git -C '.expand('%:p:h').' rev-parse --show-toplevel 2> /dev/null')[:-2]}), <bang>0)
nnoremap <silent> <Leader><space> :PFiles<CR>

So I guess I would want that when I search, vscode will search in the base folder (and sub-folders of course) of the project. In the command above I define the root dir of the project by "a folder that has .git folder in it". However, there should be an option to search from the folder you started vscode from as well (for the case where you have multiple related git repos under one directory).

bergmul commented 2 years ago

First of all thanks a lot for the great tool you programmed!

I would also like this feature. As fuzzy matching is very powerful, I think this would increase usability a lot and would allow users to easily replace vscode's built in cmd+p file search and cmd+shift+f text search with a more powerful tool.

Optimally, it would be great if we could have commands to accomplish this, e.g.

As @oren0e suggested, identifying a project via the parent folder which contains the .git folder looks promising.

jfrerich commented 2 years ago

I would love this feature option also! I'm in the process of moving from vim to vscode and I 100% miss this feature.

And thank you so much for this great Extension!

devmor-j commented 1 year ago

Thanks for making this awesome extension but in my honest opinion without this feature mentioned here, the user experience is not good at all. Imagine you have to cd into the root project folder each time you want to search sth. also we have many project folders and there is really no one initialWorkingDirectory to set. @rlivings39

rlivings39 commented 1 year ago

Thanks @clearfeld for the changes! Released the new commands in v0.5.0 of the extension. Please reply here if those new commands do what y'all had in mind or if there are other changes desired.