vim 中的 TypeScript 语法高亮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35087549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:14:36  来源:igfitidea点击:

TypeScript syntax highlighting in vim

vimtypescriptvim-syntax-highlighting

提问by Nico Schl?mer

I installed the typescript pluginvia

我通过以下方式安装了打字稿插件

git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/bundle/typescript-vim

and inserted

并插入

au BufRead,BufNewFile *.ts   setfiletype typescript

into by ~/.vim.rc. Linting via Syntasticand tsc/tslint works well, and

进入~/.vim.rc. 通过Syntastic和 tsc/tslint 进行 Linting 效果很好,并且

:set syntax

shows syntax=typescript. However,

显示syntax=typescript。然而,

:syntax

shows No Syntax items defined for this bufferand highlighting doesn't work.

显示No Syntax items defined for this buffer和突出显示不起作用。

Any idea what's going wrong?

知道出了什么问题吗?

采纳答案by Nico Schl?mer

What was missing from ~/.vimrcis a specification of where to find the plugin, i.e.,

缺少的~/.vimrc是在哪里找到插件的规范,即,

Plugin 'leafgarland/typescript-vim'

Highlighting works now.

突出显示现在有效。

回答by dino

Vim 8 has native package loading. Leave .vimrcalone and just do this:

Vim 8 具有本地包加载。.vimrc不用管,就这样做:

$ mkdir -p ~/.vim/pack/typescript/start
$ cd ~/.vim/pack/typescript/start
$ git clone https://github.com/leafgarland/typescript-vim.git

回答by Kemin Zhou

There are not so many postings when I searched on line for solving this problem. I installed Vundel, according to the instruction, and add the Plugin line to my ~/.vimrc file. Also added one line

我在网上搜索解决这个问题的帖子并没有那么多。我按照说明安装了 Vundel,并将插件行添加到我的 ~/.vimrc 文件中。还加了一行

autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript

to vimrc. Still not working. Then I manually copied the typescript.vim file in each of the directories cloned from git: [email protected]:leafgarland/typescript-vim.git

到 vimrc。还是行不通。然后我手动复制了从 git 克隆的每个目录中的 typescript.vim 文件: [email protected]:leafgarland/typescript-vim.git

compiler ftdetect ftplugin indent syntax

to their corresponding directories, respectively, to the /usr/share/vim/vim74/. If you use vim8.0 the directory basename will be vim80.

到它们对应的目录,分别到/usr/share/vim/vim74/。如果您使用 vim8.0,则目录基名将是 vim80。

It started to work. This may not be a good solution, but at least it get me started.

它开始工作了。这可能不是一个好的解决方案,但至少它让我开始了。