如何在NerdTree中隐藏TypeScript自动生成的文件?

6
我想在 NERDTree 中隐藏 TypeScript 转换器生成的自动文件(.js .js.map)。
3个回答

5

感谢 Hussein Nazzal,我通过以下方式解决了问题(因为我使用的是Angular2,所以需要注意一些步骤):

  • Add an outDir property to tsconfig.json this way:

    {
      "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false, 
        "outDir": "buildjs/"
      },
      "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
      ]
    }
    
  • Then in .vimrc file add the following:

    let NERDTreeIgnore=['buildjs$']
    
  • Don't forget to modify index.html and add the following line near System.import('buildjs/main'),

    System.import('app/main')`
    
  • add to System.config

    map: {
      app: 'buildjs'
    }
    

1
这是最好的答案。我使用了“dist”而不是“buildjs”,但这很好用。谢谢! - Doug Johnston
太好了。我尝试在index.html中调整System.config - 不要这样做 :) 相反,请更改systems.config.js中的映射。 - tmadsen
不是很喜欢这种方法,它并没有隐藏自动生成的文件,只是将它们生成到了另一个目录中。 - Evan Carroll

2

to hide files use the NERDTreeIgnore

let NERDTreeIgnore = ['\.js$' , '\.js.map$']

以下代码应该添加到你的vimrc文件中。

1
问题在于,我不想隐藏JavaScript文件,只想隐藏TypeScript自动生成的文件。 - Werner Echezuria
这取决于转译文件的方法... 如果您使用 --outFile,那么您可以指定输出文件为 somefile.generated.ts 并将 '.generated.ts$' 添加到忽略列表中。如果您正在使用 gulp,您也可以做类似的事情... 但是没有其他方法可以知道文件是否是生成的文件。但是,如果您将文件输出到 dist 目录中,您也可以隐藏该目录。 - Hussein Nazzal
我正在使用Angular2配置,我猜应该有一种方法可以使用tsconfig.json文件进行配置。 - Werner Echezuria
1
只需指定“outDir”并隐藏文件夹,或者使用“outFile”将文件连接起来。这里是一份ts配置选项清单:http://json.schemastore.org/tsconfig - Hussein Nazzal
我认为@WernerEchezuria想要的是,如果在同一个目录中存在一个与之同名(减去扩展名)的.ts文件,则隐藏.js文件。至少这是我希望弄清楚如何做到的事情。 - user210757

1
如果您在NERDTree中输入大写字母I,您可以切换隐藏文件的可见性。
要默认隐藏文件,请将以下行放入您的vimrc文件中:
let NERDTreeShowHidden=0

问题在于Angular没有使用“.”前缀构建它们。 - Evan Carroll

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接