Permalink
Browse files

Finishing the initial feature set

*   Clearing the status bar

*   Adding toggle functionality (executing `<Plug>Vimroomize` a second
    time will get you back to "normal" vim mode with the color scheme
    reset, and all secondary windows closed.
  • Loading branch information...
mikewest committed Oct 31, 2010
1 parent ab9599d commit d11f90c567a64aab49dc2f65a024a964ef8f058e
Showing with 37 additions and 15 deletions.
  1. +37 −15 plugin/vimroom.vim
@@ -1,4 +1,4 @@
"============================================================================
"==============================================================================
"File: vimroom.vim
"Description: Vaguely emulates a writeroom-like environment in Vim by
" splitting the current window in such a way as to center a column
@@ -7,7 +7,11 @@
"Version: 0.1
"Last Change: 2010-10-31
"License: BSD <../LICENSE.markdown>
"============================================================================
"==============================================================================
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin Configuration
"
" The typical start to any vim plugin: If the plugin has already been loaded,
" exit as quickly as possible.
@@ -31,11 +35,20 @@ if !exists( "g:vimroom_background" )
let g:vimroom_background = "black"
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin Code
"
" Given the desired column width, and minimum sidebar width, determine
" the minimum window width necessary for splitting to make sense
let s:minwidth = g:vimroom_width + ( g:vimroom_min_sidebar_width * 2 )
" Save the current color scheme for reset later
let s:scheme = g:colors_name

This comment has been minimized.

@FND

FND Oct 31, 2010

I got the following error on startup:

line 47:
E121: Undefined variable: g:colors_name
E15: Invalid expression: g:colors_name

(Ubuntu Lucid, command-line Vim 7.2)

So I had to modify that line as follows:

if exists( "g:colors_name" )
    let s:scheme = g:colors_name
endif

This comment has been minimized.

@mikewest

mikewest Oct 31, 2010

Owner

Huh. Thanks for the bug report! I'm using vim 7.2 on OSX, and g:colors_name exists. Weird. Have you set a colour scheme, or are you just using whatever Vim sets up as default?

I'm not at all sure how I can set things up to toggle back to "normal" if I can't use that variable to determine which color scheme is currently active... :/

This comment has been minimized.

@FND

FND Nov 1, 2010

I don't use any color scheme, so Vim just uses my terminal's color scheme (green on black).

I'm afraid my Vim fu on this is too limited to be of any further help...

This comment has been minimized.

@mikewest

mikewest Nov 1, 2010

Owner

That does help, though. Should give me what I need to reproduce the bug locally... Then I can fix it. :)

" We're currently in nonvimroomized state
let s:active = 0
function! s:is_the_screen_wide_enough()
return winwidth( winnr() ) >= s:minwidth
endfunction
@@ -45,19 +58,28 @@ function! s:sidebar_size()
endfunction
function! <SID>Vimroomize()
if s:is_the_screen_wide_enough()
let s:sidebar = s:sidebar_size()
exec( "leftabove " . s:sidebar . "vsplit new" )
set noma
wincmd l
exec( "rightbelow " . s:sidebar . "vsplit new" )
set noma
wincmd h
set wrap
set linebreak
exec( "hi VertSplit ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background )
exec( "hi NonText ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background )
set fillchars+=vert:\
if s:active == 1
let s:active = 0
only
exec( "colorscheme " . s:scheme )
else
if s:is_the_screen_wide_enough()
let s:active = 1
let s:sidebar = s:sidebar_size()
exec( "silent leftabove " . s:sidebar . "vsplit new" )
set noma
wincmd l
exec( "silent rightbelow " . s:sidebar . "vsplit new" )
set noma
wincmd h
set wrap
set linebreak
exec( "hi VertSplit ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background )
exec( "hi NonText ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background )
exec( "hi StatusLine ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background )
exec( "hi StatusLineNC ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background )
set fillchars+=vert:\
endif
endif
endfunction

0 comments on commit d11f90c

Please sign in to comment.