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
Related
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.
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 recently discovered Vim colorschemes, and in the process have discovered a rather curious bug: when I run hi Normal ctermbg in Vim, the color change carries over to the shell that I'm running Vim in, like so:
I'm using PuTTYtray (but also see the behavior in PuTTY) with 256 colors enabled , bolded text indicated by font changes, and $TERM set to "putty-256color"; my .vimrc is as follows:
set t_Co=256
colors zenburn
and zenburn.vim can be found here. I've isolated the problem specifically to specifically line 298, where it first configures ctermbg for Normal highlighting.
(As an aside: it seems that when using PuTTY tray with specific color settings, in Normal highlighting, ctermbg has to be first set simultaneously with guifg or guibg, e.g. hi Normal guifg=#dcdccc ctermbg=237, and only after that will hi Normal ctermbg=some_val work.)
Does anyone happen to have any idea why this is happening?
I've also tried to do a workaround by running hi Normal ctermbg=None on VimLeave (although I recognize that this is problematic if I run multiple Vim instances, so if anyone can suggest an alternative that would also be welcome), but with no success. Adding the following to my .vimrc does not work:
function! RESET_ctermbg()
"reset $ctermbg to None"
exec "hi Normal ctermbg=None"
endfunction
au VimLeave * call RESET_ctermbg()
I've fixed the problem by changing $TERM to xterm-256color; my best bet is that putty-256color is not well-supported enough as a shell to handle behavior like the vim colorscheme I was doing, so I don't even need to try to make the workaround work anymore.
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.