Skip to content

Commit

Permalink
Squashed '.vim/bundle/laktek-distraction-free-writing/' content from …
Browse files Browse the repository at this point in the history
…commit df624e5

git-subtree-dir: .vim/bundle/laktek-distraction-free-writing
git-subtree-split: df624e52b934c1867b790f97bf9fe20eb16f1833
  • Loading branch information
Nicola Paolucci committed Oct 24, 2013
0 parents commit fcf6fea
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Distraction Free Writing for Vim

* Copy `plugin/DistractionFree.vim` to `~/.vim/plugin`

* Copy `syntax/mkd.vim` to `~/.vim/syntax`

* Copy `ftdetect/mkd.vim` to `~/.vim/ftdetect`

* Copy `colors/iawriter.vim` to `~/.vim/colors`

* In .vimrc, specify the colorschemes and fonts to use in fullscreen mode and normal mode.

g:fullscreen_colorscheme - colorscheme to use in fullscreen mode
g:fullscreen_font font to use in fullscreen mode
g:normal_colorscheme - colorscheme to use in normal mode
g:normal_font - font to use in normal mode

example (macvim):

```vim
let g:fullscreen_colorscheme = "iawriter"
let g:fullscreen_font = "Cousine:h14"
let g:normal_colorscheme = "codeschool"
let g:normal_font="Inconsolata:h14"
```

or, for gvim:

```vim
let g:fullscreen_colorscheme = "iawriter"
let g:fullscreen_font ="Cousine 12"
let g:normal_colorscheme= g:colors_name
let g:normal_font=&guifont
```

Under linux, you must manually activate fullscreen mode (ie ALT+F11)
66 changes: 66 additions & 0 deletions colors/iawriter.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"
" Last Change: 2011/12/11
" Maintainer: Jacek Dominiak <doj (at) ptpbs (dot) com>
"
" Description: Vim color file
"

set background=light
hi clear
if exists("syntax_on")
syntax reset
endif

let g:colors_name="iawriter"

hi Cursor guifg=fg guibg=#54D4FF
hi Normal guifg=#424242 guibg=#f5f6f6 ctermfg=black ctermbg=white
hi DiffAdd guibg=#c0ffe0 ctermbg=3
hi DiffDelete guifg=#ff8097 guibg=#ffe0f7 ctermfg=4 ctermbg=5
hi DiffChange guibg=#cfefff ctermbg=9
hi DiffText guibg=#bfdfff gui=NONE ctermbg=6 cterm=NONE
hi NonText guifg=bg guibg=bg gui=NONE ctermfg=darkblue
hi SpecialKey guifg=grey50 guibg=grey86 gui=NONE ctermfg=darkblue
hi LineNr guifg=bg guibg=bg ctermfg=darkblue
hi Search guibg=#fff999
hi StatusLine guifg=bg guibg=#333333 gui=NONE ctermfg=bg ctermbg=black cterm=NONE
hi StatusLineNC guifg=bg guibg=grey40 gui=NONE ctermfg=bg ctermbg=black cterm=NONE
hi Visual guifg=fg guibg=#ccccdd gui=NONE
hi VisualNOS guifg=bg guibg=#ccccdd gui=NONE

" syntax highlighting groups
hi Comment guifg=#000099 guibg=bg ctermfg=darkblue
hi String guifg=fg guibg=#e0e4cc ctermfg=darkred
hi Constant guifg=#c033ff guibg=bg ctermfg=darkmagenta
hi Statement guifg=#737373 guibg=bg ctermfg=black cterm=NONE
hi PreProc guifg=#335588 guibg=bg gui=NONE ctermfg=blue
hi Type guifg=#338855 guibg=bg gui=NONE ctermfg=darkgreen
hi StorageClass guifg=#990000 guibg=bg ctermfg=red
hi Special guifg=#6688ff guibg=bg ctermfg=darkcyan
hi Function guifg=#117777 guibg=bg ctermfg=red
hi Title guifg=black guibg=bg ctermfg=black cterm=bold

" showpairs plugin
" for cursor on paren
hi ShowPairsHL guibg=#c4ffc4 ctermbg=lightgreen
" for cursor between parens
hi ShowPairsHLp guibg=#c4f0c4 ctermbg=lightgreen
" unmatched paren
hi ShowPairsHLe guibg=#ff5555 ctermbg=red

" settings for Vim7
if version >= 700
hi MatchParen guibg=#c4ffc4 ctermbg=lightgreen
" Spell
hi SpellBad guifg=fg gui=undercurl ctermfg=red cterm=underline
hi SpellRare guifg=magenta gui=undercurl ctermfg=magenta cterm=underline
hi SpellCap guifg=fg gui=undercurl guisp=#22cc22 cterm=underline
" Completion menu
hi Pmenu guibg=#ffffcc ctermbg=yellow
hi PmenuSel guibg=#ddddaa ctermbg=lightcyan cterm=NONE
hi PmenuSbar guibg=#999966 ctermbg=lightcyan
" Tab line
hi TabLine guibg=grey70 cterm=underline
hi TabLineSel gui=NONE cterm=NONE
hi TabLineFill guifg=black guibg=grey80 cterm=underline
endif
2 changes: 2 additions & 0 deletions ftdetect/mkd.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
" markdown filetype file
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd
127 changes: 127 additions & 0 deletions plugin/DistractionFree.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
" DistrationFree.vim -- Toggle distraction free writing mode
" Author: Lakshan Perera (lakshan AT web2media net)
" URL: https://github.com/laktek/distraction-free-writing-vim
"
" Usage:
"
" Copy this file to .vim/plugin.
"
" In .vimrc, specify the colorschemes and fonts to use
" in fullscreen mode and normal mode.
"
" g:fullscreen_colorscheme - colorscheme to use in fullscreen mode
" g:fullscreen_font font to use in fullscreen mode
" g:normal_colorscheme - colorscheme to use in normal mode
" g:normal_font - font to use in normal mode
" eg: let g:fullscreen_colorscheme = "iawriter"
"
" By default, toggling of full screen mode is bound to F4 key.
" You can change it in .vimrc as follows:
" :map <F4> :call ToggleDistractionFreeWriting()<CR>

"initVariable borrowed from NERDTree
function! s:initVariable(var, value)
if !exists(a:var)
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
return 1
endif
return 0
endfunction

"Initialize variables
call s:initVariable("g:distractionFreeFullscreen", "off")

function! DistractionFreeWriting()
exec "colorscheme ".g:fullscreen_colorscheme
" added escape function to allow for multiword font names
" (AmaruCoder)
exec "set gfn=".escape(g:fullscreen_font,' ')

set background=light
set lines=40 columns=100 " size of the editable area
set linespace=5 " spacing between lines
set guioptions-=r " remove righ scrollbar
set laststatus=0 " don't show status line
set noruler " don't show ruler
if has("gui_macvim")
set fuoptions=background:#00f5f6f6 " bakground color
set fullscreen " go to fullscreen editing mode
else
set guioptions-=m " remove menu
set guioptions-=T " remove Toolbar
endif
let g:distractionFreeFullscreen = 'on'
set linebreak " break the lines on words
endfunction

function! ToggleDistractionFreeWriting()
if g:distractionFreeFullscreen == 'on'
exec "set background=".s:prev_background
exec "set lines=".s:prev_lines
exec "set columns=".s:prev_columns
exec "set linespace=".s:prev_linespace
exec "set laststatus=".s:prev_laststatus
exec "set guioptions+=r"

set noruler!
if has("gui_macvim")
exec "set fuoptions=".s:prev_fuoptions
set fullscreen!
else
set guioptions+=m " add menu
endif
let g:distractionFreeFullscreen = 'off'
set linebreak!

exec "colorscheme ".g:normal_colorscheme
" added escape function to allow for multiword font names
" (AmaruCoder)
exec "set gfn=".escape(g:normal_font,' ')
else
let s:prev_background = &background
let s:prev_gfn = &gfn
let s:prev_lines = &lines
let s:prev_columns = &columns
let s:prev_linespace = &linespace
if has("gui_macvim")
let s:prev_fuoptions = &fuoptions
endif
let s:prev_laststatus = &laststatus
let s:prev_font = &gfn

call DistractionFreeWriting()
endif
endfunction

if !exists('g:fullscreen_colorscheme')
let g:fullscreen_colorscheme = "iawriter"
endif

if !exists('g:fullscreen_font')
if has("gui_macvim")
let g:fullscreen_font = "Cousine:h14"
else
let g:fullscreen_font = "Cousine 12"
endif
endif

if !exists('g:normal_colorscheme')
if has("gui_macvim")
let g:normal_colorscheme = "codeschool"
else
let g:normal_colorscheme = g:colors_name
end
endif

if !exists('g:normal_font')
if has("gui_macvim")
let g:normal_font="Inconsolata:h14"
else
let g:normal_font=&guifont
endif
endif

:map <F4> :call ToggleDistractionFreeWriting()<CR>
" turn-on distraction free writing mode by default for markdown files
" au BufNewFile,BufRead *.{md,mdown,mkd,mkdn,markdown,mdwn} call DistractionFreeWriting()
105 changes: 105 additions & 0 deletions syntax/mkd.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
" Vim syntax file
" Language: Markdown
" Maintainer: Ben Williams <benw@plasticboy.com>
" URL: http://plasticboy.com/markdown-vim-mode/
" Version: 9
" Last Change: 2009 May 18
" Remark: Uses HTML syntax file
" Remark: I don't do anything with angle brackets (<>) because that would too easily
" easily conflict with HTML syntax
" TODO: Handle stuff contained within stuff (e.g. headings within blockquotes)


" Read the HTML syntax to start with
if version < 600
so <sfile>:p:h/html.vim
else
runtime! syntax/html.vim
unlet b:current_syntax
endif

if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif

" don't use standard HiLink, it will not work with included syntax files
if version < 508
command! -nargs=+ HtmlHiLink hi link <args>
else
command! -nargs=+ HtmlHiLink hi def link <args>
endif

syn spell toplevel
syn case ignore
syn sync linebreaks=1

"additions to HTML groups
syn region htmlBold start=/\\\@<!\(^\|\A\)\@=\*\@<!\*\*\*\@!/ end=/\\\@<!\*\@<!\*\*\*\@!\($\|\A\)\@=/ contains=@Spell,htmlItalic
syn region htmlItalic start=/\\\@<!\(^\|\A\)\@=\*\@<!\*\*\@!/ end=/\\\@<!\*\@<!\*\*\@!\($\|\A\)\@=/ contains=htmlBold,@Spell
syn region htmlBold start=/\\\@<!\(^\|\A\)\@=_\@<!___\@!/ end=/\\\@<!_\@<!___\@!\($\|\A\)\@=/ contains=htmlItalic,@Spell
syn region htmlItalic start=/\\\@<!\(^\|\A\)\@=_\@<!__\@!/ end=/\\\@<!_\@<!__\@!\($\|\A\)\@=/ contains=htmlBold,@Spell

" [link](URL) | [link][id] | [link][]
syn region mkdLink matchgroup=mkdDelimiter start="\!\?\[" end="\]\ze\s*[[(]" contains=@Spell nextgroup=mkdURL,mkdID skipwhite oneline
syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained
syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained

" Link definitions: [id]: URL (Optional Title)
" TODO handle automatic links without colliding with htmlTag (<URL>)
syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite
syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained

"define Markdown groups
syn match mkdLineContinue ".$" contained
syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/
syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/
syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/
syn match mkdRule /^\s*-\{3,}$/
syn match mkdRule /^\s*\*\{3,5}$/
syn match mkdListItem "^\s*[-*+]\s\+"
syn match mkdListItem "^\s*\d\+\.\s\+"
syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/
syn match mkdLineBreak / \+$/
syn region mkdCode start=/\\\@<!`/ end=/\\\@<!`/
syn region mkdCode start=/\s*``[^`]*/ end=/[^`]*``\s*/
syn region mkdCode start=/\s*```[^`]*/ end=/[^`]*```\s*/
syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell
syn region mkdCode start="<pre[^>]*>" end="</pre>"
syn region mkdCode start="<code[^>]*>" end="</code>"

"HTML headings
syn region htmlH1 start="^\s*#" end="\($\|#\+\)" contains=@Spell
syn region htmlH2 start="^\s*##" end="\($\|#\+\)" contains=@Spell
syn region htmlH3 start="^\s*###" end="\($\|#\+\)" contains=@Spell
syn region htmlH4 start="^\s*####" end="\($\|#\+\)" contains=@Spell
syn region htmlH5 start="^\s*#####" end="\($\|#\+\)" contains=@Spell
syn region htmlH6 start="^\s*######" end="\($\|#\+\)" contains=@Spell
syn match htmlH1 /^.\+\n=\+$/ contains=@Spell
syn match htmlH2 /^.\+\n-\+$/ contains=@Spell

"highlighting for Markdown groups
HtmlHiLink mkdString String
HtmlHiLink mkdCode String
HtmlHiLink mkdBlockquote Comment
HtmlHiLink mkdLineContinue Comment
HtmlHiLink mkdListItem Identifier
HtmlHiLink mkdRule Identifier
HtmlHiLink mkdLineBreak Todo
HtmlHiLink mkdLink htmlLink
HtmlHiLink mkdURL htmlString
HtmlHiLink mkdID Identifier
HtmlHiLink mkdLinkDef mkdID
HtmlHiLink mkdLinkDefTarget mkdURL
HtmlHiLink mkdLinkTitle htmlString

HtmlHiLink mkdDelimiter Delimiter

let b:current_syntax = "mkd"

delcommand HtmlHiLink
" vim: ts=8

0 comments on commit fcf6fea

Please sign in to comment.