【发布时间】:2019-02-22 19:26:12
【问题描述】:
我是 vim 新手,我想用 vim 编写代码。我已经为 TypeScript 中的语法高亮 JSX 安装了必要的插件,一切都适用于 GUI 版本的 Vim,但不适用于基于终端的 Vim。请帮我找出问题所在。以下是我用于语法高亮的插件。
- 对于 TypeScript:https://github.com/leafgarland/typescript-vim
- 对于 TypeScript 中的 JSX:https://github.com/peitalin/vim-jsx-typescript
我正在使用 Vundle 安装插件。我尝试对上面提到的第二个插件的 README 部分中给出的颜色进行一些自定义。据我所知,当我使用hi 命令时,它对基于终端的 Vim 没有任何影响,但在基于 GUI 的 Vim 上运行良好。另外,如果可能的话,请将我指向任何文章/博客,让初学者了解有关 vim 和 vimscript 的更多信息。
编辑:
我正在尝试为 React 开发的 TypeScript 中的 JSX 设置语法高亮,我已经安装了上面的插件来实现这一点。下面是我的 .vimrc 文件的内容。
set nocompatible " choose no compatibility with legacy vi syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
set t_Co=256
filetype plugin indent on " load file type plugins + indentation
"" monkai theme
syntax enable
colorscheme monokai
set nu
set guifont=monacob\ bold\ 9
highlight ColorColumn ctermbg=gray
set colorcolumn=80
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optinal)
set backspace=indent,eol,start " backspace through everything in insert mode
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
" set the runtime path to include Vundle and initialize
set rtp +=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive.git'
Plugin 'tpope/vim-rails'
Plugin 'leafgarland/typescript-vim'
Plugin 'peitalin/vim-jsx-typescript'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" autocmd FileType typescript.tsx setlocal commentstring={/*\ %s\ */}
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx
autocmd BufNewFile,BufRead *.ts,*.js set filetype=typescript.jsx
" dark red
hi tsxTagName guifg=#E06C75
" orange
hi tsxCloseString guifg=#F99575
hi tsxCloseTag guifg=#F99575
hi tsxAttributeBraces guifg=#F99575
hi tsxEqual guifg=#F99575
" yellow
hi tsxAttrib guifg=#F8BD7F cterm=italic
正如我们在 .vimrc 和屏幕截图中看到的,在文件末尾声明的 JSX 标签颜色等在 Gvim 中可以正常工作,但对于基于终端的 vim 无效。请帮助我理解我在这里做错了什么。
【问题讨论】:
-
你看到了什么?为什么是错的?你期望看到什么?你做了什么究竟?
标签: typescript vim vi vim-plugin vim-syntax-highlighting