首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使望远镜忽略node_modules中的文件?

如何使望远镜忽略node_modules中的文件?
EN

Stack Overflow用户
提问于 2021-07-28 15:17:04
回答 3查看 6.5K关注 0票数 7

我是VIM / NEOVIM世界的新手,所以我可能做了其他错误的事情,但从文档中可以看出,望远镜将忽略在.gitignore文件中注册的所有文件,该文件确实在那里,但它仍然在node_modules中搜索。

所以我就是这么做的:

进入我的项目文件夹nvim

  • hit <leader>ff

  • Telescope的
  1. I cd打开
  2. 并开始键入,但是搜索速度非常慢,因为它们包含了node_modules

这些是我安装望远镜的插件。

代码语言:javascript
复制
" Telescope
Plug 'nvim:solua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'

然后我的地图就从文档里出来:

代码语言:javascript
复制
" 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终端中。我遗漏了什么?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-11-11 06:12:23

只需加上

require('telescope').setup{ defaults = { file_ignore_patterns = { "node_modules" }} }

给你的init.lua

票数 16
EN

Stack Overflow用户

发布于 2021-07-29 06:32:42

您需要对rg进行一些定制:

代码语言:javascript
复制
--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的配置:

代码语言:javascript
复制
require('telescope').setup{
  defaults = {
    vimgrep_arguments = {
      'rg',
      '--color=never',
      '--no-heading',
      '--with-filename',
      '--line-number',
      '--column',
      '--smart-case',
      '--ignore-file',
      '.gitignore'
    },
票数 1
EN

Stack Overflow用户

发布于 2022-06-30 06:10:01

安装BurntSushi/ripgrep,请参阅建议的依赖项下的望远镜自述,然后将node_modules放入您的.gitignore中,然后将您的好东西放进去。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68563040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档