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 DIR fails to open file at correct path #257

Closed
3 of 6 tasks
habamax opened this issue Dec 20, 2018 · 6 comments
Closed
3 of 6 tasks

LeaderfFile DIR fails to open file at correct path #257

habamax opened this issue Dec 20, 2018 · 6 comments

Comments

@habamax
Copy link

habamax commented Dec 20, 2018

  • vim or neovim?
    • vim
    • neovim
  • Output of vim --version or nvim --version:
	VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 19 2018 23:02:37)
	MS-Windows 64-bit GUI version with OLE support
	Included patches: 1-610
	Compiled by appveyor@APPVYR-WIN
	Huge version with GUI.  Features included (+) or not (-):
	+acl                +cmdline_hist       +eval               +keymap             +multi_lang         +reltime            +terminal           +vreplace
	+arabic             +cmdline_info       +ex_extra           +lambda             +mzscheme/dyn       +rightleft          -termresponse       -vtp
	+autocmd            +comments           +extra_search       +langmap            +netbeans_intg      +ruby/dyn           +textobjects        +wildignore
	+autochdir          +conceal            +farsi              +libcall            +num64              +scrollbind         +textprop           +wildmenu
	+autoservername     +cryptv             +file_in_path       +linebreak          +ole                +signs              -tgetent            +windows
	+balloon_eval       +cscope             +find_in_path       +lispindent         +packages           +smartindent        +timers             +writebackup
	-balloon_eval_term  +cursorbind         +float              +listcmds           +path_extra         +startuptime        +title              -xfontset
	+browse             +cursorshape        +folding            +localmap           +perl/dyn           +statusline         +toolbar            -xim
	++builtin_terms     +dialog_con_gui     -footer             +lua/dyn            +persistent_undo    -sun_workshop       +user_commands      +xpm_w32
	+byte_offset        +diff               +gettext/dyn        +menu               -postscript         +syntax             +vartabs            -xterm_save
	+channel            +digraphs           -hangul_input       +mksession          +printer            +tag_binary         +vertsplit          
	+cindent            +directx            +iconv/dyn          +modify_fname       +profile            +tag_old_static     +virtualedit        
	+clientserver       -dnd                +insert_expand      +mouse              +python/dyn         -tag_any_white      +visual             
	+clipboard          -ebcdic             +job                +mouseshape         +python3/dyn        +tcl/dyn            +visualextra        
	+cmdline_compl      +emacs_tags         +jumplist           +multi_byte_ime/dyn +quickfix           -termguicolors      +viminfo            
	system vimrc file: "$VIM\vimrc"
		user vimrc file: "$HOME\_vimrc"
	2nd user vimrc file: "$HOME\vimfiles\vimrc"
	3rd user vimrc file: "$VIM\_vimrc"
		user exrc file: "$HOME\_exrc"
	2nd user exrc file: "$VIM\_exrc"
	system gvimrc file: "$VIM\gvimrc"
		user gvimrc file: "$HOME\_gvimrc"
	2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
	3rd user gvimrc file: "$VIM\_gvimrc"
		defaults file: "$VIMRUNTIME\defaults.vim"
		system menu file: "$VIMRUNTIME\menu.vim"
	Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python37.dll\" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl528.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DFEAT_HUGE /Fd.\ObjGXOULYHTRZAMD64/ /Zi
	Linking: link  /nologo /subsystem:windows,5.02 /opt:ref /LTCG:STATUS /HIGHENTROPYVA:NO oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib  /machine:AMD64  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python37.lib   "C:\Tcl\lib\tclstub86.lib" WSock32.lib xpm\x64\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug

:echo g:Lf_Debug_Cmd

  • Output of :echo has("python"): 0
  • Output of :echo has("python3"): 1
  • Output of :echo &pythondll(only vim, not neovim): python27.dll
  • Output of :echo &pythonthreedll(only vim, not neovim): python37.dll
  • Output of :py print(sys.version): error
  • Output of :py3 print(sys.version): 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]
  • Output of :echo g:Lf_Debug_Cmd: git ls-files && git ls-files --others --exclude-standard -x ".svn" -x ".hg" -x "*.sw?" -x "~$*" -x "*.bak" -x "*.exe" -x "*.o" -x "*.so" -x "*.py[co]" -x "*.tmp"
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
	let g:Lf_StlSeparator = { 'left': '', 'right': '' }
	let g:Lf_ShortcutF = '<leader>ff'
	let g:Lf_Shortcutb = '<leader>b'
	let g:Lf_WindowHeight = 0.30
	let g:Lf_ShowHidden = 1
	let g:Lf_FollowLinks = 1
	let g:Lf_CommandMap = {'<ESC>': ['<C-Space>', '<ESC>']}
	let g:Lf_NormalMap = {"File":   [["u", ':LeaderfFile ..<CR>']]}
    let g:Lf_PreviewResult = {'Colorscheme': 1}
    let g:Lf_WildIgnore = {
            \ 'dir': ['.svn','.git','.hg'],
            \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]', '*.tmp']
            \}
    let g:Lf_MruWildIgnore = copy(g:Lf_WildIgnore)
	cabbrev lf LeaderfFile
	nnoremap <leader>f/ :Leaderf rg<CR>
	nnoremap <leader>/ :LeaderfLineAll<CR>
	nnoremap <leader>fh :LeaderfHelp<CR>
	nnoremap <leader>fm :LeaderfMru<CR>
	nnoremap <leader>fs :LeaderfSelf<CR>
	nnoremap <leader>fc :LeaderfColorscheme<CR>
	nnoremap <leader>fdd :LeaderfFile ~/docs<CR>
	" open .vim or .vimfiles or nvim config directory
	nnoremap <leader>fdv :exe ':LeaderfFile '.fnamemodify($MYVIMRC, ':p:h')<CR>

Describe your question, feature request, or bug.

When you have

" Convenient to :save or :write a copy of a file to the same directory.
autocmd BufEnter * silent! lcd %:p:h

then second :LeaderfFile DIR fails to open correct file.

The same happens if you have vim-rooter plugin installed.

Steps to reproduce

with autocmd:

  1. Add autocmd to your vimrc or install vim-rooter plugin.
  2. Open file in first directory with :LeaderfFile DIR1
  3. Open file in second directory with :leaderfFile DIR2

vim-leaderf-and-lcd-auto

with vim-rooter:

The same as with autocmd but DIR1 and DIR2 should be under git -- so vim-rooter will change cwd.

vim-leaderf-and-rooter

Actual behaviour

Empty file with the chosen file name is opened at incorrect path.

Expected behaviour

Choosen file should be opened.

@Yggdroot
Copy link
Owner

autocmd BufEnter * silent! lcd %:p:h

This command is evil, please do not use it.

@habamax
Copy link
Author

habamax commented Dec 21, 2018

I know, I don't use it. The main issue is with vim-rooter which essentially does (I think :) ) the same under the hood -- changes working directory whenever you open a file.

And because I use windows and gvim -- my workflow is mostly out of cmd line -- so my starting working directory is almost always the path vim is installed in. That is very inconvenient, and to make life easier you might start using autochdir, autocmd with lcd or vim-rooter.

PS I have tried the same with CtrlP and fzf -- they don't have that problem. But even with this annoying issue, your plugin is more convenient to me

@Yggdroot
Copy link
Owner

I think you should change your workflow. I also work on Windows sometimes, I have never encountered this issue. So I don't need vim-rooter.
My workflow is:

  1. right click, a menu is popped up.
    menu
  2. select Vim Here
  3. enter vim, and the current working directory is the current directory.

How to add the Vim Here to right-click menu?

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\edit with vim8.0]
@="Edit with vim8.0"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\*\Shell\edit with vim8.0\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Shell\edit with vim8.0]
@="Edit with vim8.0"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Directory\Shell\edit with vim8.0\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\Vim8.0 Here]
@="Vim8.0 Here"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\Vim8.0 Here\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Drive\Shell\edit with vim8.0]
@="Edit with vim8.0"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Drive\Shell\edit with vim8.0\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\" %1"

Save the text above in a file named, for example, vim.reg. Run this file.
(Of course you can customize C:\\Program Files\\Vim\\vim80\\gvim.exe)

@habamax
Copy link
Author

habamax commented Dec 21, 2018

I have "Vim here", but it really is inconvenient for me.

I usually <Win>gvim<Enter> and then open files/projects needed.

Well, okay. I can see a couple ways to workaround my problem:

  1. try to fix it change the way it works in a fork of your plugin
  2. return to fzf -- try to add some parts of leaderf there (mostly your awesome LeaderfHelp)
  3. or return to CtrlP

Anyway, thanks!

Yggdroot added a commit that referenced this issue Dec 22, 2018
@Yggdroot
Copy link
Owner

Fixed in dev branch, please have a try.

@habamax
Copy link
Author

habamax commented Dec 22, 2018

YES!

It is fixed! Thank you very much, really appreciated!

Yggdroot added a commit that referenced this issue Dec 23, 2018
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