Skip to content
This repository was archived by the owner on Dec 28, 2019. It is now read-only.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7787e23
Change some settings to fit my requirement
vayn Oct 8, 2011
3597d68
Change mapping
vayn Oct 8, 2011
d6ae7df
Replace V with v in mapping
vayn Oct 8, 2011
1651408
Split background color in different env
vayn Oct 8, 2011
e11829f
Merge branch 'master' of git://github.com/mikewest/vimroom
vayn Oct 9, 2011
c243ce9
Tweak the code
vayn Oct 9, 2011
fe88aa0
Merge branch 'master' of git://github.com/mikewest/vimroom
vayn Oct 9, 2011
c4878e4
Delete diff file
vayn Oct 9, 2011
4d3b858
Use "setlocal" instead of "set" when setting modifiable
vayn Oct 9, 2011
cddd22a
Delete colorcolumn settings
vayn Oct 9, 2011
4a07f5e
Fix "windows close" problem
vayn Oct 9, 2011
656ed95
Set numberwidth
vayn Oct 9, 2011
120e587
Fix local variable
vayn Oct 9, 2011
3cc161f
Add snapshot in readme
vayn Oct 9, 2011
89f0967
"Disable" line number not "close" it
vayn Oct 9, 2011
af8cf42
Disable line number in height padding windows
vayn Oct 9, 2011
e4f55c6
Revert default column width to 80
vayn Oct 9, 2011
cafbc80
Change default width to 82
vayn Oct 9, 2011
37a64ec
Merge branch 'master' of git://github.com/mikewest/vimroom
vayn Oct 9, 2011
e05ad46
Revert README
vayn Oct 9, 2011
e6bcb93
Change numberwidth when Vim is in VimRoom
vayn Oct 9, 2011
6c37c56
Move modified vimroom to correct directory
vayn Oct 9, 2011
fc01956
Close padding buffers if we quit current buffer
vayn Oct 9, 2011
559a4a0
Merge branch 'master' of git://github.com/mikewest/vimroom
vayn Oct 10, 2011
650bf97
Sometimes user would change colorscheme when they are in room
vayn Oct 11, 2011
f9bbbc5
Enhanced solution for closing padding buffers when we quit current bu…
vayn Oct 11, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 68 additions & 13 deletions plugin/vimroom.vim
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,59 @@ function! s:sidebar_size()
return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2
endfunction

" Save current buffer name
let b:vimroom_bufname = expand("%:t")
" Close padding buffer if we quit current buffer
autocmd BufHidden <buffer> call s:close_padding()

function! s:close_padding()
" Try to close current buffer and related padding buffers
try
" Unload current buffer
bdelete
" Save buffer list
redir => buflist
silent ls
redir END

let has_other_buf = 0

" Is there other buffer open?
for buf in split(buflist, "\n")
if match(buf, '_RoomPadding') == -1
let has_other_buf = 1
break
endif
endfor

if has_other_buf
" If there is other buffer existing,
" we close padding buffer first.
bwipeout _RoomPadding
" Initialize environment for other buffer
let b:vimroom_bufname = expand("%:t")
let s:active = 0
autocmd BufHidden <buffer> call s:close_padding()
else
" Otherwise, we just quit vim
qa
endif
catch
" XXX It is not the best solution, but I have no other better solutions.
" If the current buffer has been changed, and we didn't save it before
" we quit, we would be in here.

" Close padding buffers
bwipeout _RoomPadding

" Show errors and warnings
let exc = substitute(v:exception, 'Vim([a-z]*):', '', '')
echohl ErrorMsg | echo exc | echohl None
echohl WarningMsg | echo "You are in a weird dimension." | echohl None
echohl WarningMsg | echo "The best thing you should do now is save and quit." | echohl None
endtry
endfunction

function! <SID>VimroomToggle()
if s:active == 1
let s:active = 0
Expand All @@ -142,28 +195,28 @@ function! <SID>VimroomToggle()
endif
" Reset color scheme (or clear new colors, if no scheme is set)
if s:scheme != ""
exec( "colorscheme " . s:scheme )
exec( "colorscheme " . s:scheme )
else
hi clear
hi clear
endif
if s:save_t_mr != ""
exec( "set t_mr=" .s:save_t_mr )
exec( "set t_mr=" .s:save_t_mr )
endif
" Reset `scrolloff` and `laststatus`
if s:save_scrolloff != ""
exec( "set scrolloff=" . s:save_scrolloff )
exec( "set scrolloff=" . s:save_scrolloff )
endif
if s:save_laststatus != ""
exec( "set laststatus=" . s:save_laststatus )
exec( "set laststatus=" . s:save_laststatus )
endif
if s:save_textwidth != ""
exec( "set textwidth=" . s:save_textwidth )
exec( "set textwidth=" . s:save_textwidth )
endif
if s:save_number != 0
set number
set number
endif
if s:save_relativenumber != 0
set relativenumber
set relativenumber
endif
" Remove wrapping and linebreaks
set nowrap
Expand All @@ -178,14 +231,14 @@ function! <SID>VimroomToggle()
endif
if g:vimroom_min_sidebar_width
" Create the left sidebar
exec( "silent leftabove " . s:sidebar . "vsplit new" )
exec( "silent leftabove " . s:sidebar . "vsplit _RoomPadding" )
setlocal noma
setlocal nocursorline
setlocal nonumber
setlocal norelativenumber
wincmd l
" Create the right sidebar
exec( "silent rightbelow " . s:sidebar . "vsplit new" )
exec( "silent rightbelow " . s:sidebar . "vsplit _RoomPadding" )
setlocal noma
setlocal nocursorline
setlocal nonumber
Expand All @@ -194,14 +247,14 @@ function! <SID>VimroomToggle()
endif
if g:vimroom_sidebar_height
" Create the top sidebar
exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" )
exec( "silent leftabove " . g:vimroom_sidebar_height . "split _RoomPadding" )
setlocal noma
setlocal nocursorline
setlocal nonumber
setlocal norelativenumber
wincmd j
" Create the bottom sidebar
exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" )
exec( "silent rightbelow " . g:vimroom_sidebar_height . "split _RoomPadding" )
setlocal noma
setlocal nocursorline
setlocal nonumber
Expand Down Expand Up @@ -242,7 +295,7 @@ function! <SID>VimroomToggle()
let l:highlightbgcolor = "guibg=" . g:vimroom_guibackground
let l:highlightfgbgcolor = "guifg=" . g:vimroom_guibackground . " " . l:highlightbgcolor
else
let l:highlightbgcolor = "ctermbg=" . g:vimroom_guibackground
let l:highlightbgcolor = "ctermbg=" . g:vimroom_ctermbackground
let l:highlightfgbgcolor = "ctermfg=" . g:vimroom_ctermbackground . " " . l:highlightbgcolor
endif
exec( "hi Normal " . l:highlightbgcolor )
Expand All @@ -252,6 +305,8 @@ function! <SID>VimroomToggle()
exec( "hi StatusLineNC " . l:highlightfgbgcolor )
set t_mr=""
set fillchars+=vert:\
" Sometimes user would change colorscheme when they are in room
autocmd ColorScheme <buffer> let s:scheme = g:colors_name
endif
endif
endfunction
Expand Down