2013-12-29 05:37:14 -05:00
|
|
|
"==============================================================================
|
|
|
|
"File: zenroom2.vim
|
|
|
|
"Description: Emulates iA Writer environment when editing Markdown, reStructuredText
|
|
|
|
" or text files.
|
|
|
|
"Maintainer: Amir Salihefendic <amix@doist.io>
|
2013-12-29 09:15:49 -05:00
|
|
|
"Version: 0.1
|
2013-12-29 05:37:14 -05:00
|
|
|
"Last Change: 2013-12-29
|
|
|
|
"License: BSD
|
|
|
|
"==============================================================================
|
|
|
|
|
|
|
|
if exists( "g:loaded_zenroom2_plugin" )
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_zenroom2_plugin = 1
|
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Plugin Configuration
|
|
|
|
"
|
|
|
|
" Save the current `background` value for reset later
|
|
|
|
let s:save_background = ""
|
2013-12-29 09:15:49 -05:00
|
|
|
if exists( "&background" )
|
|
|
|
let s:save_background = &background
|
|
|
|
endif
|
2013-12-29 05:37:14 -05:00
|
|
|
|
|
|
|
" Save the current `textwidth'` value for reset later
|
|
|
|
let s:save_textwidth = ""
|
2013-12-29 09:15:49 -05:00
|
|
|
if exists( "&textwidth'" )
|
|
|
|
let s:save_textwidth' = &textwidth'
|
|
|
|
endif
|
2013-12-29 05:37:14 -05:00
|
|
|
|
|
|
|
function! s:markdown_room()
|
|
|
|
set background=light
|
|
|
|
set linespace=8
|
|
|
|
set textwidth=80
|
|
|
|
|
|
|
|
hi Normal guibg=gray95
|
|
|
|
hi NonText guifg=gray95
|
2013-12-29 09:15:49 -05:00
|
|
|
hi FoldColumn guibg=gray95
|
2013-12-29 05:37:14 -05:00
|
|
|
hi CursorLine guibg=gray90
|
|
|
|
hi Title gui=bold guifg=gray25
|
|
|
|
hi MarkdownHeadingDelimiter gui=bold guifg=gray25
|
|
|
|
hi htmlSpecialChar guifg=black
|
|
|
|
hi markdownError guifg=black
|
|
|
|
hi markdownBold gui=bold guifg=gray25
|
|
|
|
hi markdownItalic guifg=gray25 gui=underline
|
|
|
|
hi markdownUrl guifg=#2fb3a6
|
|
|
|
hi markdownAutomaticLink guifg=#2fb3a6
|
|
|
|
hi markdownLinkText guifg=#317849
|
|
|
|
hi markdownUrlTitle guifg=#317849
|
|
|
|
hi markdownBlockquote guifg=#317849 gui=bold
|
|
|
|
hi markdownId guifg=#2fb3a6
|
|
|
|
hi markdownIdDeclaration guifg=#317849 gui=bold
|
|
|
|
hi markdownListMarker guifg=#317849
|
|
|
|
hi Cursor guibg=#15abdd
|
|
|
|
|
|
|
|
if has('gui_running')
|
|
|
|
let l:highlightbgcolor = "guibg=#f2f2f2"
|
|
|
|
let l:highlightfgbgcolor = "guifg=#f2f2f2" . " " . l:highlightbgcolor
|
|
|
|
else
|
|
|
|
let l:highlightbgcolor = "ctermbg=bg"
|
|
|
|
let l:highlightfgbgcolor = "ctermfg=bg" . " " . l:highlightbgcolor
|
|
|
|
endif
|
|
|
|
|
|
|
|
exec( "hi Normal " . l:highlightbgcolor )
|
|
|
|
exec( "hi VertSplit " . l:highlightfgbgcolor )
|
|
|
|
exec( "hi NonText " . l:highlightfgbgcolor )
|
|
|
|
exec( "hi StatusLine " . l:highlightfgbgcolor )
|
|
|
|
exec( "hi StatusLineNC " . l:highlightfgbgcolor )
|
|
|
|
endfunction
|
|
|
|
|
2013-12-29 06:33:00 -05:00
|
|
|
function! g:zenroom_goyo_before()
|
|
|
|
if !has("gui_running")
|
|
|
|
return
|
|
|
|
endif
|
2013-12-29 09:15:49 -05:00
|
|
|
let is_mark_or_rst = &filetype == "markdown" || &filetype == "rst" || &filetype == "text"
|
2013-12-29 05:37:14 -05:00
|
|
|
|
2013-12-29 09:15:49 -05:00
|
|
|
if is_mark_or_rst
|
2013-12-29 05:37:14 -05:00
|
|
|
call s:markdown_room()
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2013-12-29 06:33:00 -05:00
|
|
|
function! g:zenroom_goyo_after()
|
|
|
|
if !has("gui_running")
|
|
|
|
return
|
|
|
|
endif
|
2013-12-29 09:15:49 -05:00
|
|
|
let is_mark_or_rst = &filetype == "markdown" || &filetype == "rst" || &filetype == "text"
|
|
|
|
if is_mark_or_rst
|
2013-12-29 05:37:14 -05:00
|
|
|
set linespace=0
|
|
|
|
|
|
|
|
if s:save_textwidth != ""
|
|
|
|
exec( "set textwidth=" . s:save_textwidth )
|
|
|
|
endif
|
|
|
|
|
|
|
|
if s:save_background != ""
|
|
|
|
exec( "set background=" . s:save_background )
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2013-12-29 06:33:00 -05:00
|
|
|
let g:goyo_callbacks = [ function('g:zenroom_goyo_before'), function('g:zenroom_goyo_after') ]
|