I'm using vim in zsh in wsl, playing with it's color setting.
I want to use colorscheme solarized for my vim, but it caused the background of terminal color to gray (open in vim by using :ter)
How can I avoid it?
I know that I can use :!(command) or ctrl + a and fg to use terminal while editing in vim, but I'm just curious.
The problem
Like many other (inexplicably) popular colorschemes, Solarized has been abandoned for a long time. One consequence is that features like :help hl-Terminal and :help g:terminal_ansi_colors, that were introduced in the meantime, are not supported.
Your options
Edit the colorscheme directly.
Override it with an autocommand, as per this gist.
Find an up-to-date fork.
Find another, well maintained, colorscheme.
Related
When I run, for example, ! yarn lint inside a MacVim. I have this result.
While I run the same command in Terminal's Vim. This is what I get.
Is there any way to make the former colourised as the latter?
The shell used by the MacVim GUI for :! commands is a so-called "dumb shell" that doesn't support styling at all so you can't have colors, there. If you absolutely need styled output, use the built-in :help :terminal.
That said, command-line utilities are expected to know when and when not to use styling. Since the ones you use appear to output escape sequence when they shouldn't, it might be a good idea to notify their maintainers of that flaw.
The reason why you are seeing the different color schemes is because the Terminal and MacVim editor each have their own application-specific configurations, which includes the theme. However, it is possible to unify the two applications to share the same Vim settings in a .vimrc file. The default .vimrc that MacVim looks for is located under $HOME/.vimrc, and the same goes for the Terminal’s version of Vim. If you like the dark background that is being used in the Terminal’s Vim, you can set it with:
set background=dark
I also highly recommend you read up, at least to a basic understanding, on the .vimrc settings.
There are also some good examples out there:
https://gist.github.com/simonista/8703722
https://github.com/amix/vimrc/tree/master/vimrcs
So I followed romainl's suggestion and came up with a solution.
First, :terminal ++close yarn format does colour the terminal result nicely, so I updated my mapping.
map <Leader>l :terminal ++close yarn format<CR>
Then to fix the auto-reload problem. This is what I did.
set autoread
au CursorHold,CursorHoldI * checktime
au FocusGained,BufEnter * :checktime
Thanks to resources from this thread!
https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim
I 'm working on MacOS Catalina and I am using vim 8.2
The only profile set up in my iterm2 is the Default one.
which has been set up to used a slightly customized solarized theme as depicted below
I am now opening vim (which has also been set up to use its counterpart solarized colorscheme)
My question is, why when I am opening the :terminal in vim, this opens in black background (I don't think there even exists a profile with such setting)
This will happen when you have Vim running with 'termguicolors' on. (You can confirm it and see where it's being enabled with :verb set tgc?.) Same as when running in a GUI (not the terminal), it will tell Vim to use 24-bit colors, and use the color scheme full RGB color specifications, rather than use the terminal color palette.
In that situations, Vim's colors get completely detached from those of the terminal where Vim is running, so Vim's built-in terminal no longer has access to the actual terminal colors.
You can set specific colors to use in Vim's built-in terminal with the g:terminal_ansi_colors variable (see :help g:terminal_ansi_colors for details.)
Alternatively, disabling 'termguicolors' should work as well. Assuming the Vim color scheme has been built in a way that will use the terminal color scheme to reproduce the same colors, it might not have other side effects in how Vim colors otherwise look.
Removing line
set termguicolors
from .vimrc fixed it
I have a gruvbox theme applied to Vim inside vimrc.
The problem is that when I run the :terminal command inside Vim the colorscheme is different from either the Vim theme or the Terminal theme.
I have tried this on Hyper and iTerm2 and it is the same. Somehow the neither of the colorscheme gets applied to the :terminal. I did try looking at the discussions in github but my knowledge of Vim is not sufficient to understand it. Can someone can explain the problem and the solution? I am running Vim version 8.2.900, Hyper 3.0.2, iTerm 3.3.10.
The :terminal palette is supposed to be a list named g:terminal_ansi_colors, which your colorscheme doesn't define.
You should use their issue tracker to report that oversight and get it fixed… or use a more competently written colorscheme.
I've updated vim to its latest release (8.1.39) and I'm still not able to have a color theme working. I've downloaded atom.vim to ~/.vim/colors. Note: in my Ubuntu install it's working just fine.
And my ~/.vimrc is as follows:
set t_Co=256
set background=dark
colorscheme atom
syntax on
When I run :colorscheme in vim it returns atom but still with no color/syntax highlight at all.
What could I be missing?
Thanks!
The colorscheme you are trying to use only works with GUI Vim (GVim/MacVim) or maybe with TUI Vim but only if your terminal supports true colors and if your Vim is built with that feature and if you :set termguicolors (and possibly other hacks).
See :help 'termguicolors'.
Also, the README.md is not called IGNOREME.md for a good reason:
Currently Atom is GVim only. I tend to use the default colours when (infrequently) in a terminal. If you have a strong desire for added terminal support leave me a comment, drop me an email or even better: send me a pull request!
(Emphasis mine.)
I have tried two schemes, desert and wombat and I have set the colorscheme in my .vimrc file. When I open vim from my shell I don't see the color of the scheme, but when I open with MacVim I do. In both, when I type :colorscheme I see the scheme that is set in the .vimrc file, but I fail to see why I don't see the colors.
As a note, I installed the spf13 distro and uninstalled it using the script provided.
Any thoughts of how can I troubleshoot this?
First, check how many colors are supported by your terminal:
:echo $TERM
:set t_Co?
The colorscheme must actually support terminals by providing term= and cterm= definitions; many don't. See https://stackoverflow.com/a/12949536/813602 for how to work around this with the CSApprox plugin.
Inspect the colorscheme file (found in the colors/ subdirectory), or use the :highlight command to list the current color definitions.
Terminal emulators are limited to 256 colors max and often need manual setup to go beyond 8 or 16.
The coolest Vim colorschemes are designed for GVim/MacVim which can display thousands of colors.
Because of 1 and 2 it is impossible to fully emulate a GUI colorscheme in a terminal emulator if the GUI colorscheme uses colors outside the 256 colors in the X11 palette.
However, you could:
use a colorscheme that works in GUI and CLI
use a colorscheme that works only in CLI and another that works only in GUI and switch between them in your ~/.vimrc depending on the context
use a plugin that converts your GUI colorscheme on the fly: this one, this one, this one or this one
edit your colorscheme manually to add terminal support
Terminals support 88 or 256 colors. Even if your terminal supports 256 colors, you have to specify that your terminal support it in your vimrc. (cf. Using GUI color settings in a terminal)
set t_Co=256
Concerning your background, you should maybe specify that you are using a dark or a light background if your theme doesn't already declare it.
set background=dark
set background=light