Why do I have to change the color scheme multiple times to get it to work? - vim

I am trying to set up a different coloscheme for my neovim. I'm trying to use Moonfly. The problem is, when I set it up, it supposed to look like this:
Instead of this, it looks like this:
However, in some strange way that I don't understand, when I change the colorscheme to PaperColor and then to Rose Pine (it that order) before changing to Moonfly, it works. I mean, I have to do this:
colorscheme papercolor
colorscheme rose-pine
colorscheme moonfly
and the colorscheme works perfectly.
I don't know if this helps, but if I change the colorscheme to Rose-Pink without changing it first to PaperColor, Rose-Pink doesn't work correctly either.
The terminal I'm using is iTerm.
Is there a way I can use the moonfly colorscheme without changing it first to papercolor and rosepink? I suppose this two colorschemes are changing something in my config that moonfly needs and doesn't change by itself, but I don't know what is this thing.

Related

How to use bolt/italic fonts in a Vim colorscheme?

I've been making a custom colorscheme for myself, but I can't seem to figure out how to apply bold/italic font to my code syntax.
I've got a series of lines like let s:keyword=#0197F4 to define colors to variables, then more lines below like exe 'hi Keyword guifg='s:keyword' gui=bold' to assign colors and text decoration. This is from a template I found, not my original code. I've got set termguicolors in my .vimrc as well.
However, the gui=bold part doesn't actually seem to do anything. I'm using Vim in the terminal (iTerm2) and I know it's capable of bold text, because when I load up my .vimrc, I can see that it does work. For example, the phrase g:python_highlight_all is bold.
I'm using python code snippets to test my highlighting, if that matters.
gui, guibg, and guifg are attributes specific to GUI Vim,
cterm, ctermbg, and ctermfg are attributes specific to color terminals.
You say:
the gui=bold part doesn't actually seem to do anything
and then:
I'm using Vim in the terminal
Since you are running Vim in a terminal emulator, the right attribute is rather obviously cterm, not gui.

Why does vim solarized colorscheme looks weird on my mac?

I installed solarized colorscheme and configure things in vimrc
However, on my mac, it looks like:
After I added a line let g:solarized_termcolors=256 in vimrc, it looks a little better:
But it's still not the color on solarized, on a linux machine(without let g:solarized_termcolors=256 in vimrc), it's like this:
So how can I make the colors on mac vim the same as on linux?
I didn't work for me either, I didn't spend too much time on researching why it wouldn't work, and turn to this one: https://github.com/lifepillar/vim-solarized8
And it works for me, try if it's working for you :)
BTW, be aware it does fall back to an approximate palette based theme if your terminal is not supporting true colors, I'm using windows terminal and it works fine, you actually don't have to put "set termguicolors" in your .vimrc. Hope it helps

Vim Issue With Changing Color Schemes

I originally used the colorscheme Solarized Dark, which worked completely fine. I also used the correct iTerm2 theme to go along with it. Then, I made a switch to the Gruvbox colorscheme, and I switched to the GruvBox iTerm2 theme to go with that. This also worked fine.
My problem occurred when I attempted to switch back to the Solarized Dark color scheme. I would post images if I could, but here's what the relevant section of my .vimrc is:
set t_Co=256
syntax enable " enable syntax processing
"Solarized Settings
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
These are the same settings I used when I first used the Solarized color scheme, and they worked fine.
But now, it looks like maybe the syntax colors are correct, but the background is pretty much black. And even if I add the let g:solarized_transcolors=1 settings (which I never had to do before), which fixes the black background, the line number column, as well as buffer header (on top), also have black backgrounds.
Any insight into this issue would be appreciated. Note that I have also tried with a completely fresh .vimrc file and .vim folder, yet I still ran into the same problem, so I don't think this can be because of any conflicts among color schemes.
My suspicion is that the vim program is somehow storing old background colors it uses and prevents them from changing.

Mac OSX Terminal Vim displays javascript code with weird and horrid shade

I develop javascript and just recently I found that I still love to use Terminal Vim instead of MacVim. Then I was totally annoyed when I opened my usual javascript file in the Terminal Vim: the statements of the code are irregularly highlighted with a mysterious color.
Just to clarify that other file types I have opened (e.g. c, html etc.) do not have the problem. I have scoured website but I could not find an answer. This is just so unacceptable, could someone help me out. A million thanks!
My .vimrc screen shot:
You appear to be using Syntastic.
The first line with the red background seems to be marked as an error.
The Error highlight group is very often set to use a red background.
My conclusion is that what you see is exactly what you should see. It is ugly on purpose and designed to look like that: you don't want to miss errors, do you?
However, Syntastic can be set to not use the Error highlighting to mark errors but the "signs" feature instead which is a lot less ugly.
You should have read the Syntastic documentation as it is all explained in plain english:
:help syntastic-error-signs
Also, set background=dark is not very useful (it doesn't change the background color, if that's what you want) and can be removed safely from your ~/.vimrc.
I found out that it was this plugin jslint.vim that caused the text to be highlighted. The problem is that this plugin could not be disabled properly which I thought I did. Thanks to the hint of #romaini, syntactic is a better plugin to check code errors and make proper configuration.
As a side note, for those who would like to use vim solarized color scheme, please use the solarized terminal color scheme first. Otherwise the color scheme won't be displayed properly.
Thank you for all of your comments and answers! Really appreciated.
Try changing your colorscheme. Open the file in Vim, then do
:colorscheme blink
To cycle through all possible colourschemes, type :colorscheme, then a space, then press Tab. When you reach a colorscheme that sounds promising, press Enter, and see if the text looks OK. Keep doing this until you find a colorscheme that you like.
Once you have found a colorscheme that you like, copy its name, and put the following in your .vimrc:
colorscheme name
(name is the name of the colorscheme you like.)
My favourite colorscheme is blink, but there are many good ones. You can even go online and download new ones if the defaults are not good enough.
Seems the syntax are not recognized correctly. Could you try:
:set filetype=javascript
One other thing to look at to make things look better (will change colors not highlighting). Make sure that your terminal reports itself as xterm-256colors. You can check this by typing echo $TERM.
If it doesn't return xterm-256colors go to Preferences -> Settings -> Advanced (tab) on the profile you are using.
Change the drop down at the top to xterm-256colors.

How to set manualy color of params[] and redirect_to in Vim?

This is my colorscheme -> https://gist.github.com/1973544
But in example screenshot of sexy-railscasts: https://github.com/oguzbilgic/sexy-railscasts-theme
params[] and redirect_to are colored.
How to achieve this?
EDIT: Problem is with filetypes. Releated -> Ultisnips break rails syntax. How to setup correctly?
This colorscheme is, as specified in its header, "A GUI Only port of the RailsCasts TextMate theme to Vim.".
GUI colorschemes (for GVim or MacVim) can make use of thousands of colors. If you want to make Vim look like in the official screenshot you'll need to use GVim.
But you appear to be using it in a terminal emulator which can only display a maximum of 256 colors. For this "GUI Only" colorscheme to even work in your terminal, you probably have a color conversion plugin like CSApprox, do you? Such plugins will do their best to match your GUI colors to their closest equivalent in the X11 set but this task is obviously not foolproof. Some colors may be frankly off and I'm almost certain that's what's happening here.
EDIT
First, I don't do Ruby, even on Rails.
Second, the syntax group of params in params[:comment] depends on the filetype:
if I have :set ft=ruby.rails:
rubyBlock, rubyMethodBlock, rubyLocalVariableOrMethod
if I have :set ft=ruby:
rubyBlock, rubyMethodBlock, rubyRailsMethod
The problem is that rubyLocalVariableOrMethod, as defined in the default ruby syntax file appears to not being linked to Function unlike rubyRailsMethod, from the rails plugin.
So I think that it's the rubyLocalVariableOrMethod that is causing problems. I've been looking around on my machine and can't seem to find how, why and by whom it is set instead of rubyRailsMethod when ft=ruby.rails.
While waiting for a real solution, there is a global setting for using rails completion when :set ft=ruby, I think it should help: let g:rubycomplete_rails = 1.
I believe that is from the rails.vim plugin.

Resources