Neovimでカラースキームを正しく表示できません。

Neovimでカラースキームを正しく表示できません。

私はしばらくneovimカラースキームで遊んだが、プレビューと同じように見えるようにすることはできません。

私はosxでTerminal.appを使用していますが、私は256色の制限の問題だと思ってTrue Colorをサポートするiterm2に移動しました。状況は少し改善されましたが、カラースキームはスクリーンショットで見たものとまったく異なりました!

ここに画像の説明を入力してください。

iterm2 + neovimのSolarizedテーマは次のとおりです。

ここに画像の説明を入力してください。

これは以下に関連しています。https://github.com/altercation/vim-colors-solarizedスクリーンショット!

私は成功せずにgoogle fooを使用しました。確かに色を正確に得る方法があります。どんなアイデアがありますか?

  "*****************************************************************************
"" Plug install packages
"*****************************************************************************

" Specify a directory for plugins
call plug#begin('~/.config/nvim/plugged')

Plug 'tomasr/molokai'
Plug 'dracula/vim'
Plug 'justb3a/vim-smarties'
Plug 'tyrannicaltoucan/vim-quantum' " let g:quantum_black = 1
Plug 'mhartington/oceanic-next'
Plug 'altercation/vim-colors-solarized'
" Plug 'vim-scripts/CSApprox'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'airblade/vim-gitgutter'
Plug 'bronson/vim-trailing-whitespace'
Plug 'editorconfig/editorconfig-vim'
Plug 'Raimondi/delimitMate'
Plug 'scrooloose/syntastic'
Plug 'Yggdroot/indentLine'
Plug 'tpope/vim-commentary'
Plug 'sheerun/vim-polyglot'
Plug 'valloric/matchtagalways'

" Initialize plugin system
call plug#end()

"*****************************************************************************
"" Visual Settings
"*****************************************************************************
set number
set ruler
set nowrap

let $NVIM_TUI_ENABLE_TRUE_COLOR=1 
set termguicolors " unfortunately doesn't work in terminal.app - needs true color support, like iterm2 but it lags and diff in visuals is not that much so sticking to terminal.app for now

set background=dark
colorscheme solarized

"*****************************************************************************
"" NERDTree config
"*****************************************************************************

" open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif

" keep focus on NERDTree when opening a directory
autocmd VimEnter * wincmd p

" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

"*****************************************************************************
"" Optimizations
"*****************************************************************************

set lazyredraw

let g:python_host_skip_check = 1
let g:python3_host_skip_check = 1

"*****************************************************************************
"" syntastic
"*****************************************************************************

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

"*****************************************************************************
"" yank and cut to osx clipboard
"*****************************************************************************

noremap YY "+y<CR>
noremap XX "+x<CR>

"*****************************************************************************
"" indent
"*****************************************************************************

" tabs
set listchars=tab:˗\ ,eol:¬
set list

" spaces
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '·'
let g:indentLine_faster = 1

set tabstop=2

"*****************************************************************************
"" matchtagalways
"*****************************************************************************

let g:mta_filetypes = { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1, 'php': 1 }

"*****************************************************************************
"" ctrlp
"*****************************************************************************

set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|tox|ico|git|hg|svn))$'

ベストアンサー1

各カラースキームは、GUIの色に関係なく端末の色を定義します。伝統的に、ターミナルは最大256色をサポートし、ほとんどの場合16色パレットを使用していました。 GUIは通常24ビットカラーをサポートしているため、Vim(およびNeovim)はカラースキーム作成者に別々のハイライト設定を提供します。

今日、多くの最新端末も24ビットカラーをサポートしています。ただし、これらの端末で実行しても、ネオビームは通常、端末のカラースキームと256色のレンダリング方法を使用します。この設定

set termguicolors

NeovimがGUIのカラースキーム設定を使用して24ビットカラーをレンダリングするようにします。しかし、確かにNeovimが実際にGUIで実行されているかのように偽装します。つまり、has('gui_running')正しいことはまだ間違っています。

残念ながら、GUIモードと24ビットカラーモードの統合により、一部のプラグインがtermguicolors正しく処理できないことがあります。あなたの状況はそのようなシナリオです。 vim-solarized-colorsの現在の実装は、24ビットカラーモードの正しい色を設定するために使用されるため、has('gui_running')Neovimは24ビットカラーを使用しますが、GUIで実行されない場合は、誤った値が奇妙に混在して設定されます。

幸いなことに、修正方法は非常に簡単です。 vim-solarized-colorsを&termguicolors適切な場所にパッチします。パッチは以下にあります。今回提出してください私のプラグインポイントに。ちなみに、この四半期には役に立つと考えられる他のパッチが含まれています。 Vim設定で自由に指定するか、必要に応じて自分のバージョンにパッチを適用してください。

おすすめ記事