简体   繁体   English

Neovim 中的语法高亮问题

[英]Syntax Highlighting Issues in Neovim

I have been trying to figure out why my syntax highlighting won't work in Neovim for two days now.我一直在试图弄清楚为什么我的语法突出显示在 Neovim 中两天都不起作用。

I have included "syntax on" in my sysinit.vim as well as "filetype plugin indent on" and I get no errors when I run nvim.我在我的 sysinit.vim 中包含了“syntax on”以及“filetype plugin indent on”,当我运行 nvim 时我没有得到任何错误。

When I do an "echo $VIMRUNTIME" I get the proper directory (I think. I used homebrew to install. The path is usr/local/Cellar/neovim/0.1.7/share/nvim/runtime).当我执行“echo $VIMRUNTIME”时,我得到了正确的目录(我想。我使用自制软件进行安装。路径是 usr/local/Cellar/neovim/0.1.7/share/nvim/runtime)。 I have verified that the syntax folder is indeed present in that folder.我已验证语法文件夹确实存在于该文件夹中。

However, when I am in neovim I get no highlighting other than a red block for trailing white space.但是,当我在 neovim 中时,除了用于尾随空格的红色块之外,我没有突出显示。 If I run ":syntax" it identifies the proper syntax (testing with python).如果我运行“:syntax”,它会识别正确的语法(使用 python 进行测试)。 Another strange occurrence I've identified is when I run ":syntax on" from within the editor, the colors get darker.我发现的另一个奇怪现象是当我从编辑器中运行“:syntax on”时,colors 变暗了。 If I turn it back off, nothing changes.如果我把它关掉,什么都不会改变。 As syntax is enabled in the init.vim file, I have no idea why that would change the appearance of the editor.由于在 init.vim 文件中启用了语法,我不知道为什么这会改变编辑器的外观。

I'm banging my head against the wall on this.我正在用头撞墙。 Please help.请帮忙。 My init.vim is below.我的 init.vim 在下面。 It's a work in progress!这是一项正在进行的工作!

" 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

The solution to this is was ridiculously dumb. 解决方案是愚蠢的。 Apparently when the contrast slider is turned all the way up in iTerm2.. It causes issues with themes. 显然,在iTerm2中将对比度滑块完全调高时。这会导致主题出现问题。 All is working now. 现在一切正常。 Hopefully this post will save someone a lot of headache in the future. 希望这篇文章将来可以减轻别人的头痛。

for me problem was from nvim-tree对我来说问题来自 nvim-tree

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM