Neovim 中的语法高亮问题
Syntax Highlighting Issues in Neovim
我这两天一直在想为什么我的语法高亮在 Neovim 中不起作用。
我在我的 sysinit.vim 和 "filetype plugin indent on" 中包含了 "syntax on",当我 运行 nvim 时我没有得到任何错误。
当我执行 "echo $VIMRUNTIME" 时,我得到了正确的目录(我想。我使用 homebrew 安装。路径是 usr/local/Cellar/neovim/0.1.7/share/nvim/runtime)。我已验证语法文件夹确实存在于该文件夹中。
然而,当我在 neovim 中时,除了尾随白色的红色块外,我没有得到任何突出显示 space。如果我 运行 ":syntax" 它识别正确的语法(用 python 测试)。我发现的另一个奇怪现象是当我从编辑器中 运行 ":syntax on" 时,颜色变暗了。如果我把它关掉,什么都不会改变。由于在 init.vim 文件中启用了语法,我不知道为什么这会改变编辑器的外观。
我正在用头撞墙。请帮忙!我的 init.vim 在下面。这是一项正在进行的工作!
" Disables Vi compatibility. Vi compatibility mode disables some modern Vim Features.
set nocompatible
" Enables filetype detection, filetype-specific scripts (ftplugins),
" and filetype-specific indent scripts.
filetype plugin indent on
syntax on " Turns on syntax highlighting
set ruler " Show row and column ruler information
set number " Show line numbers
set spelllang=en " Enable spell-checking
set softtabstop=4 " Number of spaces per tab
set title " Set the terminal title to the current file
set visualbell " Turn on the visual bell
set cursorline " Highlight the line under the cursor
set hidden " Hide inactive buffers
set ttimeoutlen=0 " Eliminate delay when switching modes
set expandtab " Converts tabs into spaces
" Lazyredraw attempts to solve Vim lag by reducing processing required. When
" enabled, any action that is not typed will not cause the screen to redraw.
set lazyredraw
" Faster redrawing
set ttyfast
" Don't display the current mode in the status line.
" This info is already displayed in the Airline status bar.
set noshowmode
inoremap jj <esc> " Remaps the esc key to 'jj'
inoremap jk <esc> " Remaps the esc key to 'jk'
" Disabling all of the cursor keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" Changes the cursor shape. (Flashing pipe in insert mode, block in normal node.)
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
" Colors and Theme Options
set termguicolors " Enables "True Color" support
silent! colorscheme gruvbox " Sets the color scheme, if present
set background=dark " Sets the default background to dark mode
let g:gruvbox_contrast_dark="hard" " Changes dark mode contrasts. Possible values are soft, medium, and hard. Default is medium
let g:gruvbox_contrast_light="hard" " Changes light mode contrasts. Possible values are soft, medium, and hard. Default is medium
let g:gruvbox_italicize_comments=1 " Enables italics for comments
let g:gruvbox_italicize_strings=1 " Enables italics for strings
这个问题的解决方案愚蠢得可笑。显然,当对比度滑块在 iTerm2 中一直调高时。它会导致主题出现问题。现在一切正常。希望这个 post 会在将来为某些人省去很多麻烦。
我这两天一直在想为什么我的语法高亮在 Neovim 中不起作用。
我在我的 sysinit.vim 和 "filetype plugin indent on" 中包含了 "syntax on",当我 运行 nvim 时我没有得到任何错误。
当我执行 "echo $VIMRUNTIME" 时,我得到了正确的目录(我想。我使用 homebrew 安装。路径是 usr/local/Cellar/neovim/0.1.7/share/nvim/runtime)。我已验证语法文件夹确实存在于该文件夹中。
然而,当我在 neovim 中时,除了尾随白色的红色块外,我没有得到任何突出显示 space。如果我 运行 ":syntax" 它识别正确的语法(用 python 测试)。我发现的另一个奇怪现象是当我从编辑器中 运行 ":syntax on" 时,颜色变暗了。如果我把它关掉,什么都不会改变。由于在 init.vim 文件中启用了语法,我不知道为什么这会改变编辑器的外观。
我正在用头撞墙。请帮忙!我的 init.vim 在下面。这是一项正在进行的工作!
" Disables Vi compatibility. Vi compatibility mode disables some modern Vim Features.
set nocompatible
" Enables filetype detection, filetype-specific scripts (ftplugins),
" and filetype-specific indent scripts.
filetype plugin indent on
syntax on " Turns on syntax highlighting
set ruler " Show row and column ruler information
set number " Show line numbers
set spelllang=en " Enable spell-checking
set softtabstop=4 " Number of spaces per tab
set title " Set the terminal title to the current file
set visualbell " Turn on the visual bell
set cursorline " Highlight the line under the cursor
set hidden " Hide inactive buffers
set ttimeoutlen=0 " Eliminate delay when switching modes
set expandtab " Converts tabs into spaces
" Lazyredraw attempts to solve Vim lag by reducing processing required. When
" enabled, any action that is not typed will not cause the screen to redraw.
set lazyredraw
" Faster redrawing
set ttyfast
" Don't display the current mode in the status line.
" This info is already displayed in the Airline status bar.
set noshowmode
inoremap jj <esc> " Remaps the esc key to 'jj'
inoremap jk <esc> " Remaps the esc key to 'jk'
" Disabling all of the cursor keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" Changes the cursor shape. (Flashing pipe in insert mode, block in normal node.)
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
" Colors and Theme Options
set termguicolors " Enables "True Color" support
silent! colorscheme gruvbox " Sets the color scheme, if present
set background=dark " Sets the default background to dark mode
let g:gruvbox_contrast_dark="hard" " Changes dark mode contrasts. Possible values are soft, medium, and hard. Default is medium
let g:gruvbox_contrast_light="hard" " Changes light mode contrasts. Possible values are soft, medium, and hard. Default is medium
let g:gruvbox_italicize_comments=1 " Enables italics for comments
let g:gruvbox_italicize_strings=1 " Enables italics for strings
这个问题的解决方案愚蠢得可笑。显然,当对比度滑块在 iTerm2 中一直调高时。它会导致主题出现问题。现在一切正常。希望这个 post 会在将来为某些人省去很多麻烦。