Setting a color theme on Vim - vim

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.)

Related

Color encoding when using `:! <command>`

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

Vim opening terminal with different profile than the default

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

:terminal colorscheme inside Vim is different from either Vim or Host Terminal

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.

Trouble Getting Colorschemes in Vim with Iterm2

I can't get the vimbrant colorscheme (or any) to work in Vim with Iterm2. This is my .vimrc file:
syntax on
syntax enable
colorscheme vimbrant
set background=dark
I have Iterm set up to use xterm-256 like it says in the FAQ as well. Whenever I echo in Vim it says 256.
The terminal also doesn't use the color settings I have in Iterm2 but I don't care about that as much.
EDIT: The file is in ~/.vim/colors/vimbrant.vim. Also, I forgot to mention that my cursor seems to have the right colors for variables and structs and whatnot, but the text itself is all white still. The background seems to be the correct color. And the only thing in my .gvimrc file is colorscheme vimbrant.
Really dumb mistake, I had minimum contrast maxed out without realizing.
I've been having the same issue and this is what seems to have solved it:
In your .bash_profile set CLICOLOR before setting TERM:
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
save bash file and source:
source ~/.bash_profile
Then, in your iTerm2 Preferences > Terminal > Report Terminal Type, set to either xterm-256color or xterm
Close iTerm2, restart it and type ls. That did the trick for me.
Good luck.
I have my iterm2 colors highly customized, and build a specific theme for vim/janus. My iterm2 colors are fine, but after the 20161204 nightly build, colors would be all messed up in vim.
I noticed the colors that were off in vim were my iterm2 profile "bright" colors. I tried set background=dark in my .vimrc, but that didn't fix it. However using set background=light, my colors are exactly how I used to have them again!
I clearly did something backwards when configuring vim, but I've fine tuned it the way I like it. I hope this helps for anyone else having an issue with vim colors after December 4th 2016.
syntax enable is useless after syntax on.
set background=dark is also generally useless outside of a colorscheme.
Does your colorscheme work when you do :colorscheme vimbrant? Where did you install it?
After trying all other suggestions made here and elsewhere, the final thing that worked for me was:
set termguicolors

Vim doesn't show colors that macvim does

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

Resources