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 ignore Lf_WildIgnore #180

Closed
2 of 6 tasks
sillybun opened this issue Jul 4, 2018 · 13 comments
Closed
2 of 6 tasks

Leaderf ignore Lf_WildIgnore #180

sillybun opened this issue Jul 4, 2018 · 13 comments

Comments

@sillybun
Copy link

sillybun commented Jul 4, 2018

  • vim or neovim?
    • vim
    • neovim
  • Output of vim --version or nvim --version:
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 24 2018 08:30:22)
macOS version
Included patches: 1-1633
Compiled by travis@Traviss-Mac-913.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_netterm     +tag_binary
+arabic            +file_in_path      +mouse_sgr         +tag_old_static
+autocmd           +find_in_path      -mouse_sysmouse    -tag_any_white
-autoservername    +float             +mouse_urxvt       -tcl
+balloon_eval      +folding           +mouse_xterm       +termguicolors
+balloon_eval_term -footer            +multi_byte        +terminal
+browse            +fork()            +multi_lang        +terminfo
++builtin_terms    +fullscreen        -mzscheme          +termresponse
+byte_offset       -gettext           +netbeans_intg     +textobjects
+channel           -hangul_input      +num64             +timers
+cindent           +iconv             +odbeditor         +title
+clientserver      +insert_expand     +packages          +toolbar
+clipboard         +job               +path_extra        +transparency
+cmdline_compl     +jumplist          +perl/dyn          +user_commands
+cmdline_hist      +keymap            +persistent_undo   +vertsplit
+cmdline_info      +lambda            +postscript        +virtualedit
+comments          +langmap           +printer           +visual
+conceal           +libcall           +profile           +visualextra
+cryptv            +linebreak         +python/dyn        +viminfo
+cscope            +lispindent        +python3/dyn       +vreplace
+cursorbind        +listcmds          +quickfix          +wildignore
+cursorshape       +localmap          +reltime           +wildmenu
+dialog_con_gui    +lua/dyn           +rightleft         +windows
+diff              +menu              +ruby/dyn          +writebackup
+digraphs          +mksession         +scrollbind        -X11
+dnd               +modify_fname      +signs             -xfontset
-ebcdic            +mouse             +smartindent       +xim
+emacs_tags        +mouseshape        +startuptime       -xpm
+eval              +mouse_dec         +statusline        -xsmp
+ex_extra          -mouse_gpm         -sun_workshop      -xterm_clipboard
+extra_search      -mouse_jsbterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE
  • 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):
  • Output of :echo g:Lf_Debug_Cmd:
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
let g:Lf_WildIgnore = {
        \ 'dir': ['.svn','.git','.hg', '.mypy_cache'],
        \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]']
        \}
let g:Lf_WorkingDirectoryMode='a'
let g:Lf_RootMarkers = ['.git', '.hg', '.svn']
let g:Lf_UseCache = 0
let g:Lf_UseMemoryCache = 0

Describe your question, feature request, or bug.

我希望在找文件的时候忽略.mypy_cache中的文件,但是发现设置这个并不起效果,所以我就深入调试了一下,发现在fileExpl.py文件中getContent函数下,

            if cmd:
                executor = AsyncExecutor()
                self._executor.append(executor)
                if cmd.split(None, 1)[0] == "dir":
                    content = executor.execute(cmd)
                else:
                    content = executor.execute(cmd, encoding=lfEval("&encoding"))
                self._cmd_start_time = time.time()
                return content
            else:
                self._content = self._getFileList(dir)

这一步我发现cmd是:

git ls-files && git ls-files --others --exclude-standard

因此它没有运行self._getFileList函数,所以没有用到Lf_WildIgnore
git ls-files && git ls-files --others --exclude-standard的返回结果仅仅忽略了.git等文件。

@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2018

.mypy_cache加入到git管理了吗,如果加入的话,没法忽略的。因为git只能skip untracked 文件

-x <pattern>
--exclude=<pattern>
Skip untracked files matching pattern. Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS below for more information.

如果没有,我可以再改点代码。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

之所以有.mypy_cache是因为我vim,ale插件使用了.mypy_cache,所以从网上下载来的代码里的.gitignore里面是没有的,我觉得一个个改太麻烦,现在的解决方式是:

let g:Lf_UseVersionControlTool = 0

当然如果能加入两者都筛选的方式就更好了,我觉得最好还是能够尊重一下WildIgnore定义的忽略项。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

这个问题跟插件无关:
我想请问您是怎么在插件里实现文件跳转的,我自己想写一个插件需要文件跳转功能,但是一跳转就会面临函数被重新定义的报错,原来的函数也不继续执行了,我想问问你是用vim里面哪个函数实现的文件跳转呀?

Yggdroot added a commit that referenced this issue Jul 4, 2018
let git abide by g:Lf_WildIgnore
@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2018

改好了,你不用设置let g:Lf_UseVersionControlTool = 0来试一下。

文件跳转直接使用的:edit 文件名
如果有什么地方不清楚,最好贴上代码,因为只看

但是一跳转就会面临函数被重新定义的报错,原来的函数也不继续执行了

这么一句,没法理解什么原因。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

能否将子目录下面的文件夹也给过滤掉?
比如:

- .mypy_cache
----a.txt
- plugin
----.mypy_cache
----leaderf.vim

现在只有根目录下的.mypy_cache文件夹被剔除掉了,但是plugin/.mypy_cache下面的文件依然存在。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

这个问题跟插件无关:
我的插件vim-repl中有这样一个函数:

function! s:REPLDebugMoveCursor() abort
    for i in range(repl#GetCurrentLineNumber(), 1, -1)
        let l:t = term_getline('ZYTREPL', i)
        if stridx(l:t, '>') == 0
            let l:t = l:t[2:]
            let l:i = stridx(l:t, '(')
            let l:filefullpath = l:t[0:(l:i - 1)]
            let l:linenumber = str2nr(l:t[(l:i+1):])
            if l:filefullpath !=# expand('%:p') && l:filefullpath[0] ==# '/'
                silent exe 'edit ' . l:filefullpath
            endif
            if l:linenumber != line('.')
                call cursor(l:linenumber, 1)
            endif
            break
        endif
    endfor
endfunction

我希望完成的功能是:能够在termianl中运行一个ipdb进行python程序的调试:
image
然后当发现进入其他文件的时候能够跳转到其他文件继续调试。
现在的问题是:
使用edit filename的时候,会有这样的报错:

Error detected while processing /Users/zhangyiteng/.vim/plugged/vim-repl/ftplugin/python/python-repl.vim:
line   51:
E127: Cannot redefine function <SNR>123_REPLDebugMoveCursor: It is in use
line   96:
E127: Cannot redefine function <SNR>123_REPLDebugS: It is in use

所以想问问你会不会遇到这样的问题呢。

@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2018

子目录下本来就可以过滤掉呀。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

我也发现了,我这里呈现了一个诡异的情况:

➜  vim-repl git:(master) ✗ git ls-files && git ls-files --others --exclude-standard  -x ".svn" -x ".hg" -x '.mypy_cache' -x "*.sw?" -x "~$*" -x "*.bak" -x "*.exe" -x "*.o" -x "*.so" -x "*.py[co]"
.gitattributes
.gitignore
README.md
autoload/repl.vim
doc/autoformatpythonstatement.txt
doc/tags
ftplugin/python/python-repl.vim
plugin/.mypy_cache/3.6/_importlib_modulespec.data.json
plugin/.mypy_cache/3.6/_importlib_modulespec.meta.json
plugin/.mypy_cache/3.6/abc.data.json
plugin/.mypy_cache/3.6/abc.meta.json
plugin/.mypy_cache/3.6/builtins.data.json
plugin/.mypy_cache/3.6/builtins.meta.json
plugin/.mypy_cache/3.6/collections/__init__.data.json
plugin/.mypy_cache/3.6/collections/__init__.meta.json
plugin/.mypy_cache/3.6/collections/abc.data.json
plugin/.mypy_cache/3.6/collections/abc.meta.json
plugin/.mypy_cache/3.6/sys.data.json
plugin/.mypy_cache/3.6/sys.meta.json
plugin/.mypy_cache/3.6/time.data.json
plugin/.mypy_cache/3.6/time.meta.json
plugin/.mypy_cache/3.6/types.data.json
plugin/.mypy_cache/3.6/types.meta.json
plugin/.mypy_cache/3.6/typing.data.json
plugin/.mypy_cache/3.6/typing.meta.json
plugin/default.vim
plugin/test.py
plugin/vim-repl.vim
repl-pdb.png
repl.gif
test/.mypy_cache/3.6/_importlib_modulespec.data.json
test/.mypy_cache/3.6/_importlib_modulespec.meta.json
test/.mypy_cache/3.6/abc.data.json
test/.mypy_cache/3.6/abc.meta.json
test/.mypy_cache/3.6/builtins.data.json
test/.mypy_cache/3.6/builtins.meta.json
test/.mypy_cache/3.6/collections/__init__.data.json
test/.mypy_cache/3.6/collections/__init__.meta.json
test/.mypy_cache/3.6/collections/abc.data.json
test/.mypy_cache/3.6/collections/abc.meta.json
test/.mypy_cache/3.6/pythonpdb.data.json
test/.mypy_cache/3.6/pythonpdb.meta.json
test/.mypy_cache/3.6/sys.data.json
...

我在想怎么回事

@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2018

是不是加到git repo里了?
直接使用git ls-files是不是能列出来?

看了下你的repo,答案是肯定的。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

明白了,谢谢指教!

@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2018

对于你前面的那个问题,我说一下我的看法。
我没写过filetype的插件,所以:h ftplugin了一下。

FUNCTIONS

When defining a function, this only needs to be done once.  But the filetype
plugin will be sourced every time a file with this filetype will be opened.
This construct makes sure the function is only defined once: >

	:if !exists("*s:Func")
	:  function s:Func(arg)
	:    ...
	:  endfunction
	:endif

filetype 插件只对当前buffer有效,如果切换一个buffer,它会重新被load,所以当你执行到silent exe 'edit ' . l:filefullpath这句话时,跳到另一个buffer,插件会被重新source,function! s:REPLDebugMoveCursor() abort也就会被重新定义,虽然加了!,但此时这个function还没有执行结束,所以就出现那个错误(我猜的)。解决方法也就是让函数只load一次,可以像帮助里说的对每一个函数都加上:if !exists("*s:Func"), 或者在文件最开头加个判断:

if exists('g:xxx_loaded')
    finish
else
    let g:xxx_loaded = 1
endif

不知道这样能不能解决问题。

@sillybun
Copy link
Author

sillybun commented Jul 4, 2018

可以,没有问题!
谢谢你的帮助!
这个问题终于解决了!
万分感谢。

@Yggdroot
Copy link
Owner

Yggdroot commented Jul 4, 2018

不客气。

@Yggdroot Yggdroot closed this as completed Jul 4, 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