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

Why hidden directories and hidden files are displayed when I press <leader>f? #197

Closed
2 of 6 tasks
zhanglintc opened this issue Aug 13, 2018 · 5 comments
Closed
2 of 6 tasks
Labels

Comments

@zhanglintc
Copy link

zhanglintc commented Aug 13, 2018

  • vim or neovim?
    • vim
    • neovim
  • Output of vim --version or nvim --version:
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2018 15:17:01)
Included patches: 1-1813
  • Output of :echo has("python"):
    1
  • Output of :echo has("python3"):
    0
  • Output of :echo &pythondll(only vim, not neovim):
    libpython2.7.so.1.0
  • Output of :echo &pythonthreedll(only vim, not neovim):
    nothing
  • Output of :py print(sys.version):
2.7.5 (default, Jul 13 2018, 13:06:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
  • Output of :py3 print(sys.version):
    nothing
  • Output of :echo g:Lf_Debug_Cmd:
    find "." -name . -o -type f -print 2>/dev/null | sed 's#^\./##'
  • Operating system:
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Configurations related to LeaderF in vimrc:
" Leaderf settings
map <leader>r :Leaderf function<CR>

Describe your question, feature request, or bug.

  1. this is my ~ folder
[lane@vbox ~]$ ls
a.out  auto-commit  critical  lib  mssout  pms_statistics_batch  shell-conf  vs.cpp  vv.cpp
  1. jut type vim in terminal, then press <leader>f. this is the output:
   1 .bash_logout
   2 .bash_profile
   3 .cache/abrt/lastnotification
   4 .cache/go-build/README
   5 .cache/go-build/06/0698933c5ec965bf12f620cedfb65b107fe7787e112806b14216b3a0d06e1d74-a
   6 .cache/go-build/0c/0cf4a399696cc3e8c06c2e9154adfc4fd6a01c91db87c71d996b9ef94336230e-d
   7 .cache/go-build/33/339f156709622028a74b71257fcc2b8a46da6245f73d0943068cb81990cc7334-a
   8 .cache/go-build/38/383c62707d8fff8d8282a6fd2dd043729e45f361a96031964e20954e878d3a0d-a
   9 .cache/go-build/43/433c1fbd69d3d56513bae7a477fdc37198e7cdbbdf533e0b6124745de0e09b9a-a
  10 .cache/go-build/4d/4dc59a48a33fb36ab5869a41a2fddc751b5711c7e0ae66ba939d43db740faf2b-a
  11 .cache/go-build/a9/a99bee50b5c4db4031abb035aff4b6b25de93b3b8cb8cbf78acd994f15c79712-a
  12 .cache/go-build/b9/b9e0a12eff093772e9839db597e270280f6daca9135cc111b4565d2e684164ce-d
  13 .cache/go-build/b9/b9b708337ca7f03577f430c963f3c8c140a8b8a7f16bb25d9ce8e75f59c207d6-d
  14 .cache/go-build/e3/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855-d
  15 .cache/go-build/log.txt
  16 .cache/go-build/trim.txt
  17 .cache/ctrlp/mru/cache.txt
  1. type <c-p>, this is what CtrlP output:
> lib/libapl.pl
> mssout/base64.o
> mssout/mssout.o
> mssout/makefile
> mssout/mCurl.o
> mssout/cJSON.o
> mssout/mssout
> vs.cpp
> vv.cpp
> a.out

I think LeaderF's output is strange. I don't want to see something like .cache/XXXX or .git/XXXX when I press <leader>f. It seems CtrlP's output is more accetpable. Is this a bug? Or just something I haven't set up correctly?

hi, 我就是前几天在知乎评论问问题那个, 今天终于可以把问题详细的整理成issue了. 感觉每次使用<leader>f的时候出来那堆隐藏文件夹下的东西看着挺别扭的, 不知道是刻意为之还是就是有bug? 而且通常情况下, 我文件夹里都会有比如.gitignore文件, 在使用<c-p>的时候他并不会默认显示出来, 但是<leader>f的时候会显示出来. 总感觉这些隐藏文件不显示似乎更符合直觉来着.

Steps to reproduce

see Describe your question, feature request, or bug.

Actual behaviour

see Describe your question, feature request, or bug.

Expected behaviour

see Describe your question, feature request, or bug.

Yggdroot added a commit that referenced this issue Aug 14, 2018
@Yggdroot Yggdroot added the bug label Aug 14, 2018
@Yggdroot
Copy link
Owner

这也算是个bug吧,我fix了。
不过你还可以安装rg,这样就可以使用rg来建立索引,会更快。

@zhanglintc
Copy link
Author

更新了, 确认了下, 现在 .cache 这样的隐藏文件夹不会出现了, 非常感谢. .gitignore 这样的隐藏文件依然会出现, 不过这个倒不影响, 反正隐藏文件没几个, 显示出来心里还有数一些. 只有隐藏文件夹比较烦人.

rg是什么意思, 就是我按他的记载安装就可以吗, 你这个插件到时候会自动调用rg来提高检索速度呗?

@Yggdroot
Copy link
Owner

奇怪,我这边.gitignore不会显示出来。
实际上后台执行的是这个命令find "." -name "." -o -name ".*" -prune -o -type f -print 2>/dev/null | sed 's#^\./##',你确定用这条命令.gitignore还能显示出来?

rg是一个类似grep的工具,但是比较快。只要安装成功(rg这个命令可用),LeaderF就会自动调用rg。

@zhanglintc
Copy link
Author

现在我这里是这样的:

  1. 以前<leader>f后立即执行:echo g:Lf_Debug_Cmd显示如下:
find "." -name . -o -type f -print 2>/dev/null | sed 's#^\./##'

Shell中执行这句话会出现.git一类的隐藏文件夹, 也会出现.gitignore.


  1. 现在<leader>f后立即执行:echo g:Lf_Debug_Cmd显示如下:
git ls-files && git ls-files --others --exclude-standard

Shell中执行这句话不会出现.git一类的隐藏文件夹, 但是会出现.gitignore.


  1. 执行你给出的find "." -name "." -o -name ".*" -prune -o -type f -print 2>/dev/null | sed 's#^\./##'这条命令, 不会出现隐藏文件夹和文件.

看起来似乎是没有正确执行到你想要执行的那条命令. 当然我觉得这个好像问题不大来着.

@Yggdroot
Copy link
Owner

哦,原来如此。
你如果在一个git的repo下运行LeaderF,就会用git ls-files && git ls-files --others --exclude-standard
具体逻辑在这里:

def _buildCmd(self, dir):
if lfEval("g:Lf_ShowRelativePath") == '1':
dir = os.path.relpath(dir)
if lfEval("exists('g:Lf_ExternalCommand')") == '1':
cmd = lfEval("g:Lf_ExternalCommand") % dir.join('""')
self._external_cmd = cmd
return cmd
if lfEval("g:Lf_UseVersionControlTool") == '1':
if self._exists(dir, ".git"):
wildignore = lfEval("g:Lf_WildIgnore")
if ".git" in wildignore["dir"]:
wildignore["dir"].remove(".git")
if ".git" in wildignore["file"]:
wildignore["file"].remove(".git")
ignore = ""
for i in wildignore["dir"]:
ignore += ' -x "%s"' % i
for i in wildignore["file"]:
ignore += ' -x "%s"' % i
cmd = "git ls-files && git ls-files --others --exclude-standard %s" % ignore
self._external_cmd = cmd
return cmd
elif self._exists(dir, ".hg"):
wildignore = lfEval("g:Lf_WildIgnore")
if ".hg" in wildignore["dir"]:
wildignore["dir"].remove(".hg")
if ".hg" in wildignore["file"]:
wildignore["file"].remove(".hg")
ignore = ""
for i in wildignore["dir"]:
ignore += ' -X "%s"' % self._expandGlob("dir", i)
for i in wildignore["file"]:
ignore += ' -X "%s"' % self._expandGlob("file", i)
cmd = 'hg files %s "%s"' % (ignore, dir)
self._external_cmd = cmd
return cmd
if lfEval("exists('g:Lf_DefaultExternalTool')") == '1':
default_tool = {"rg": 0, "pt": 0, "ag": 0, "find": 0}
tool = lfEval("g:Lf_DefaultExternalTool")
if tool and lfEval("executable('%s')" % tool) == '0':
raise Exception("executable '%s' can not be found!" % tool)
default_tool[tool] = 1
else:
default_tool = {"rg": 1, "pt": 1, "ag": 1, "find": 1}
if default_tool["rg"] and lfEval("executable('rg')") == '1':
wildignore = lfEval("g:Lf_WildIgnore")
if os.name == 'nt': # https://github.com/BurntSushi/ripgrep/issues/500
color = ""
ignore = ""
for i in wildignore["dir"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'): # rg does not show hidden files by default
ignore += ' -g "!%s"' % i
for i in wildignore["file"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'):
ignore += ' -g "!%s"' % i
else:
color = "--color never"
ignore = ""
for i in wildignore["dir"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'):
ignore += " -g '!%s'" % i
for i in wildignore["file"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'):
ignore += " -g '!%s'" % i
if lfEval("g:Lf_FollowLinks") == '1':
followlinks = "-L"
else:
followlinks = ""
if lfEval("g:Lf_ShowHidden") == '0':
show_hidden = ""
else:
show_hidden = "--hidden"
cmd = 'rg --no-messages --files %s %s %s %s "%s"' % (color, ignore, followlinks, show_hidden, dir)
elif default_tool["pt"] and lfEval("executable('pt')") == '1' and os.name != 'nt': # there is bug on Windows
wildignore = lfEval("g:Lf_WildIgnore")
ignore = ""
for i in wildignore["dir"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'): # pt does not show hidden files by default
ignore += " --ignore=%s" % i
for i in wildignore["file"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'):
ignore += " --ignore=%s" % i
if lfEval("g:Lf_FollowLinks") == '1':
followlinks = "-f"
else:
followlinks = ""
if lfEval("g:Lf_ShowHidden") == '0':
show_hidden = ""
else:
show_hidden = "--hidden"
cmd = 'pt --nocolor %s %s %s -g="" "%s"' % (ignore, followlinks, show_hidden, dir)
elif default_tool["ag"] and lfEval("executable('ag')") == '1':
wildignore = lfEval("g:Lf_WildIgnore")
ignore = ""
for i in wildignore["dir"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'): # ag does not show hidden files by default
ignore += ' --ignore "%s"' % i
for i in wildignore["file"]:
if lfEval("g:Lf_ShowHidden") != '0' or not i.startswith('.'):
ignore += ' --ignore "%s"' % i
if lfEval("g:Lf_FollowLinks") == '1':
followlinks = "-f"
else:
followlinks = ""
if lfEval("g:Lf_ShowHidden") == '0':
show_hidden = ""
else:
show_hidden = "--hidden"
cmd = 'ag --nocolor --silent %s %s %s -g "" "%s"' % (ignore, followlinks, show_hidden, dir)
elif default_tool["find"] and lfEval("executable('find')") == '1' \
and lfEval("executable('sed')") == '1':
wildignore = lfEval("g:Lf_WildIgnore")
ignore_dir = ""
for d in wildignore["dir"]:
ignore_dir += '-type d -name "%s" -prune -o ' % d
ignore_file = ""
for f in wildignore["file"]:
ignore_file += '-type f -name "%s" -o ' % f
if lfEval("g:Lf_FollowLinks") == '1':
followlinks = "-L"
else:
followlinks = ""
if lfEval("g:Lf_ShowRelativePath") == '1':
strip = "| sed 's#^\./##'"
else:
strip = ""
if os.name == 'nt':
redir_err = ""
else:
redir_err = " 2>/dev/null"
if lfEval("g:Lf_ShowHidden") == '0':
show_hidden = '-name ".*" -prune -o'
else:
show_hidden = ""
cmd = 'find %s "%s" -name "." -o %s %s %s -type f -print %s %s' % (followlinks,
dir,
ignore_dir,
ignore_file,
show_hidden,
redir_err,
strip)
else:
cmd = None
self._external_cmd = cmd
return cmd

let g:Lf_UseVersionControlTool = 0可以不使用git。

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

No branches or pull requests

2 participants