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

LeaderfFile in project #137

Closed
2 of 6 tasks
meijieru opened this issue Apr 24, 2018 · 18 comments
Closed
2 of 6 tasks

LeaderfFile in project #137

meijieru opened this issue Apr 24, 2018 · 18 comments

Comments

@meijieru
Copy link

meijieru commented Apr 24, 2018

  • vim or neovim?
    • vim
    • neovim
  • vim --version or nvim --version:

NVIM v0.3.0-dev
Build type: RelWithDebInfo
Lua 5.1
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-xCPrEf/neovim-0.2.2ubuntu2+git201804222147-ffb8904-f2f288d/build/config -I/build/neovim-xCPrEf/neovim-0.2.2ubuntu2+git201804222147-ffb8904-f2f288d/src -I/build/neovim-xCPrEf/neovim-0.2.2ubuntu2+git201804222147-ffb8904-f2f288d/.deps/usr/include -I/usr/include -I/build/neovim-xCPrEf/neovim-0.2.2ubuntu2+git201804222147-ffb8904-f2f288d/build/src/nvim/auto -I/build/neovim-xCPrEf/neovim-0.2.2ubuntu2+git201804222147-ffb8904-f2f288d/build/include
Compiled by buildd@lcy01-amd64-007

  • 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):
  • Output of :py3 print(sys.version):
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
" LeaderF
let g:Lf_ShortcutF = '<leader>ff'
let g:Lf_ShortcutB = '<leader>fb'
nnoremap <leader>fm :LeaderfMru<cr>
nnoremap <leader>fc :LeaderfFunction<cr>
nnoremap <leader>ft :LeaderfTag<cr>

let g:Lf_RootMarkers = g:root_markers
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_WindowHeight = 0.35
let g:Lf_CacheDirectory = expand('~/.vim/cache')
let g:Lf_ShowRelativePath = 1
let g:Lf_StlColorscheme = 'default'
let g:Lf_StlSeparator = { 'left': '', 'right': '' }

let g:Lf_NormalMap = {
   \ "File":   [["<ESC>", ':exec g:Lf_py "fileExplManager.quit()"<CR>'],
   \            ["<F6>", ':exec g:Lf_py "fileExplManager.quit()"<CR>'] ],
   \ "Buffer": [["<ESC>", ':exec g:Lf_py "bufExplManager.quit()"<CR>'],
   \            ["<F6>", ':exec g:Lf_py "bufExplManager.quit()"<CR>'] ],
   \ "Mru":    [["<ESC>", ':exec g:Lf_py "mruExplManager.quit()"<CR>']],
   \ "Tag":    [["<ESC>", ':exec g:Lf_py "tagExplManager.quit()"<CR>']],
   \ "Function":    [["<ESC>", ':exec g:Lf_py "functionExplManager.quit()"<CR>']],
   \ "Colorscheme":    [["<ESC>", ':exec g:Lf_py "colorschemeExplManager.quit()"<CR>']],
   \ }

Steps to reproduce

project organization:

<project_root>
    .git
    src
        a.py
        b.py
    ...

Run vim a.py in src, then run LeaderfFile, try to find b.py

Actual behaviour

leaderf try to open src/b.py instead of b.py, which is invalid.

Expected behaviour

open b.py

@Yggdroot
Copy link
Owner

Sorry, I can not quite understand your issue, could you describe in more detail?

@meijieru
Copy link
Author

@Yggdroot updated

@Yggdroot
Copy link
Owner

This works as designed, because you have set let g:Lf_WorkingDirectoryMode = 'Ac'.

LeaderF/doc/leaderf.txt

Lines 457 to 474 in 559b80a

g:Lf_WorkingDirectoryMode *g:Lf_WorkingDirectoryMode*
This option customizes LeaderF's working directory.
e.g., >
let g:Lf_WorkingDirectoryMode = 'Ac'
<
c - the directory of the current working directory.(default)
a - the nearest ancestor of current working directory that contains one of
directories or files defined in |g:Lf_RootMarkers|. Fall back to 'c' if
no such ancestor directory found.
A - the nearest ancestor of current file that contains one of directories
or files defined in |g:Lf_RootMarkers|. Fall back to 'c' if no such
ancestor directory found.
f - the directory of the current file.
F - if the current working directory is not the direct ancestor of current
file, use the directory of the current file as LeaderF's working
directory, otherwise, same as 'c'.
Note: if "f", "F" is included with "a" or "A", use the behavior of "f" or
"F"(as a fallback) when a root can't be found.

@meijieru
Copy link
Author

So what does A mode design for?
It seems to be meaningful only when vim work in top of the project.

@meijieru
Copy link
Author

The desired workflow for me is below:

  1. May work in sub-dir of the project
  2. Switch between the files, which may be not a sub-dir of cur-dir

Anyway to implement it?

@Yggdroot
Copy link
Owner

let g:Lf_WorkingDirectoryMode = 'Ac' meets your request.

@meijieru
Copy link
Author

It does not.

project organize as follow

.
├── .git
└── src
    ├── a.py
    └── b.py

start from the root of the project

  1. cd src
  2. vim a.py
  3. LeaderfFile, enter b.py<cr>
  4. it will open src/src/b.py instead of src/b.py

@Yggdroot
Copy link
Owner

I think this is the bug of neovim(neovim/neovim#3636), does vim has the same behavior?

@meijieru
Copy link
Author

Tested on vim, it works well.

@Yggdroot
Copy link
Owner

The patch for neovim/neovim#3636 has been merged, you can update neovim and have a try.

@meijieru
Copy link
Author

I remove the neovim from pip and clone and install it by pip install ., still broken.

@Yggdroot
Copy link
Owner

I think the neovim you installed this way does not have the patch, you can install through compiling the source code.

@meijieru
Copy link
Author

python-neovim 0.2.5 is used, where the patch has been applied.
The issue still occurs.

@Yggdroot
Copy link
Owner

Perhaps this is a new bug of neovim, I'll try to find out what it is exactly and open an issue for neovim.

@Yggdroot
Copy link
Owner

Yggdroot commented May 1, 2018

I have opened an issue for neovim: neovim/neovim#8336.

@meijieru
Copy link
Author

I see from the doc vim.chdir may work. But it seems not recommended.

Yggdroot added a commit that referenced this issue May 12, 2018
using `vim.chdir` as workaround
@Yggdroot
Copy link
Owner

Fixed, please have a check.

@meijieru
Copy link
Author

It is already fixed, 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

2 participants