Monday, September 24, 2012

Re: Colorschemes and split window

On Saturday, September 22, 2012 1:18:23 AM UTC-5, ramgorur wrote:
> H
>
> On Monday, April 30, 2012 9:15:26 AM UTC-4, rameo wrote:
> > It seems that I have found the solution (after many many hours of trying :-( )
> >
> > I created the function below.
> > The function must do this (and seems to do it):
> >
> > a) when there is only 1 window:
> > check if filetype is "vim" --> Dark_ColorScheme
> > if filetype is not "vim" --> Light_ColorScheme
> > b) when there is a split window:
> > check if exist split window colorscheme variable (g:splitcolor)
> > if yes, colorscheme of splitwindow = g:splitcolor
> >
> > when leaving split window:
> > keep the value of the current color in g:splitcolor
> >
> > Can anyone tell me if I made a mistake and if the function can be simplified?
> >
> > function SetColors()
> > if winnr('$') > 1
> > if exists('g:splitcolor')
> > exe 'colors '.g:splitcolor
> > else
> > exe 'colors Light_ColorScheme'
> > endif
> > elseif winnr('$') == 1 && &ft == 'vim'
> > exe 'colors Dark_ColorScheme'
> > elseif winnr('$') == 1 && &ft != 'vim'
> > exe 'colors Light_ColorScheme'
> > endif
> > endfunction
> > function KeepColors()
> > if winnr('$') > 1
> > let g:splitcolor = g:colors_name
> > endif
> > endfunction
> > augroup filetype_colorscheme
> > au BufEnter * call SetColors()
> > au BufLeave * call KeepColors()
> > augroup END
>
> Hi,
>
> I am trying to achieve similar goal, I want to have different color schemes for different file types, but I use omnicppcomplete, which opens a floating window for auto-completion. So, when I try to do the autocompletion, the whole color scheme reverts back to the default. Have you found any work around?

What do you mean by "floating window"? The best workaround would probably be to detect this type of window in your function and take no action if detected. Is it just the "preview window"? If so, testing for &previewwindow should do it. Does it have a special &buftype value? Or a special &filetype value? These could be tested as well.

I suspect you're talking about the preview window, since you're using completion. If you have "preview" in your 'completeopts' option, you will automatically see the preview window pop up for completion methods which supply the required information.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: