如何解决如何让 Telescope 忽略 node_modules 中的文件?
我是 VIM / NEOVIM 世界的新手,所以我可能做错了其他事情,但是从文档中它说 Telescope 将忽略所有注册的文件在 .gitignore
文件中,该文件明确存在但仍会在 node_modules
所以这就是我所做的:
- 我
cd
进入我的项目文件夹 - 点击
nvim
- 点击
<leader>ff
- Telescope 打开,我开始输入,但搜索速度真的很慢,因为它们包括
node_modules
这些是我用来设置望远镜的插件
" Telescope
Plug 'nvim:solua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
然后我直接从文档中重新映射:
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
所有这些都在带有 Ubuntu 的 WSL 终端中运行。我错过了什么?
解决方法
您需要对 rg 进行一些自定义:
--ignore-file <PATH>...
Specifies a path to one or more .gitignore format rules files. These patterns
are applied after the patterns found in .gitignore and .ignore are applied
and are matched relative to the current working directory. Multiple additional
ignore files can be specified by using the --ignore-file flag several times.
When specifying multiple ignore files,earlier files have lower precedence
than later files.
添加到 nvim 的配置:
require('telescope').setup{
defaults = {
vimgrep_arguments = {
'rg','--color=never','--no-heading','--with-filename','--line-number','--column','--smart-case','--ignore-file','.gitignore'
},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。