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

Leaderf rg does not search in working directory? #277

Closed
3 of 6 tasks
xaljer opened this issue Feb 7, 2019 · 7 comments
Closed
3 of 6 tasks

Leaderf rg does not search in working directory? #277

xaljer opened this issue Feb 7, 2019 · 7 comments

Comments

@xaljer
Copy link

xaljer commented Feb 7, 2019

  • vim or neovim?
    • vim
    • neovim
  • Output of vim --version or nvim --version:
NVIM v0.3.4
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe /DWIN32 /D_WINDOWS /W3 /MD /Zi /O2 /Ob1 /DNDEBUG -DMIN_LOG_LEVEL=3 /W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -D_WIN32_WINNT=0x0600 -DINCLUDE_GENERATED_DECLARATIONS -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -IC:/projects/neovim/build/config -IC:/projects/neovim/src -IC:/projects/neovim/.deps/usr/include -IC:/projects/neovim/build/src/nvim/auto -IC:/projects/neovim/build/include
Compiled by appveyor@APPVYR-WIN

Features: -acl +iconv -jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files/nvim/share/nvim"
  • Output of :echo has("python"):
    0
  • Output of :echo has("python3"):
    1
  • Output of :echo &pythondll(only vim, not neovim):
  • Output of :echo &pythonthreedll(only vim, not neovim):
  • Output of :py print(sys.version):
    E319 No "python" provider found.
  • Output of :py3 print(sys.version):
    3.7.2
  • Output of :echo g:Lf_Debug_Cmd:
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_WindowHeight = 0.36
"nnoremap <A-p> :LeaderfFunction!<CR>
nnoremap <C-p> :Leaderf file<CR>
" search word under cursor, the pattern is treated as regex, and enter normal mode directly
noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>
" search word under cursor, the pattern is treated as regex,
" append the result to previous search results.
noremap <C-G> :<C-U><C-R>=printf("Leaderf! rg --append -e %s ", expand("<cword>"))<CR>
" search visually selected text literally, don't quit LeaderF after accepting an entry
xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F --stayOpen -e %s ", leaderf#Rg#visual())<CR>
" recall last search. If the result window is closed, reopen it.
noremap go :<C-U>Leaderf! rg --stayOpen --recall<CR>

Describe your question, feature request, or bug.

I found that Leaderf! rg search string under directory same with :pwd, but Leaderf file search files under working directory which indicated by g:Lf_RootMarkers. Why they have different behaves?
I already set this in my init.vim:

let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'

Can I get the root working directory and set it to rg path?

Steps to reproduce

directory structure:

my-project (root working directory)
  - .git
  - sub-folder
    - test.c

open test.c using neovim, use Leaderf rg -e to search something.

Actual behaviour

searching under my-project path.

Expected behaviour

searching under sub-folder path.

@Yggdroot
Copy link
Owner

Yggdroot commented Feb 7, 2019

Yes, Leaderf rg always starts from cwd, g:Lf_RootMarkers and g:Lf_WorkingDirectoryMode are only for Leaderf file, so you want that Leaderf rg has the same behavior as Leaderf file when using g:Lf_RootMarkers and g:Lf_WorkingDirectoryMode?

@xaljer
Copy link
Author

xaljer commented Feb 7, 2019

@Yggdroot ,
Yes, I think project-wide searching is useful. Is there/Could you provide an option or a method to do this?

@Yggdroot
Copy link
Owner

Actual behaviour

searching under my-project path.

Expected behaviour

searching under sub-folder path.

I don't understand your expectation, I think the current behavior is the expected behavior.

@xaljer
Copy link
Author

xaljer commented Feb 25, 2019

sorry, my mistake. The actual behaviour is searching under sub-folder path, and my expected behaviour is searching under project path, always, just like LeaderfFile. As your explained, this is not bug, but a feature request. That is provide an option to make:

Leaderf rg has the same behavior as Leaderf file when using g:Lf_RootMarkers and g:Lf_WorkingDirectoryMode

Yggdroot added a commit that referenced this issue Feb 26, 2019
@Yggdroot
Copy link
Owner

Now you can use Leaderf rg like this:

Leaderf rg --wd-mode=ac -e xxx

--wd-mode <MODE>      Specify the working directory mode, value has the same
                        meaning as g:Lf_WorkingDirectoryMode.

@skywind3000
Copy link
Contributor

@xaljer
Copy link
Author

xaljer commented Mar 2, 2019

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants