├── .gitignore ├── LICENSE ├── README.md ├── doc └── octopress.txt ├── ftplugin └── octopress.vim ├── plugin └── octopress.vim └── syntax └── octopress.vim /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dan Lowe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [vim-octopress][] adds syntax highlighting and [Octopress][] commands to 3 | [Vim][]. Both [Markdown][] and [Textile][] modes are supported. 4 | 5 | [vim-octopress]: https://github.com/tangledhelix/vim-octopress 6 | [octopress]: http://octopress.org/ 7 | [vim]: http://www.vim.org/ 8 | [markdown]: http://daringfireball.net/projects/markdown/syntax 9 | [textile]: http://txstyle.org/ 10 | 11 | Using the `:Octopress` command, you can create new posts, regenerate your 12 | output files, and even deploy to your server. 13 | 14 | NOTE: At this time, live preview mode is not supported, due to limitations in 15 | how Vim handles background processes. It is not expected that this support 16 | will be added unless Octopress significantly redesigns the preview mode. 17 | 18 | If you use [Pathogen][] (and you really should): 19 | 20 | [pathogen]: https://github.com/tpope/vim-pathogen 21 | 22 | ``` 23 | cd ~/.vim/bundle 24 | git clone https://github.com/tangledhelix/vim-octopress.git octopress 25 | ``` 26 | 27 | Or, to install the old-fashioned way: 28 | 29 | ``` 30 | git clone https://github.com/tangledhelix/vim-octopress.git 31 | cd vim-octopress 32 | for i in doc ftplugin plugin syntax; do 33 | mkdir -p ~/.vim/$i 34 | cp $i/octopress.* ~/.vim/$i 35 | done 36 | ``` 37 | 38 | For more information, see `:help octopress` or read 39 | [octopress.txt][octopress-doc] online. 40 | 41 | [octopress-doc]: https://github.com/tangledhelix/vim-octopress/blob/master/doc/octopress.txt 42 | 43 | -------------------------------------------------------------------------------- /doc/octopress.txt: -------------------------------------------------------------------------------- 1 | *octopress.txt* *vim-octopress* *octopress* 2 | 3 | Introduction |octopress-intro| 4 | Default file format |octopress-default-format| 5 | Textile support |octopress-textile| 6 | Using Octopress syntax automatically |octopress-autocmd| 7 | The :Octopress command |:Octopress| 8 | Using a custom 'rake' executable |g:octopress_rake_executable| 9 | 10 | *octopress-intro* 11 | vim-octopress provides syntax support for Octopress posts (in Markdown or 12 | Textile formats) and provides some Octopress rake tasks to run within Vim. 13 | 14 | You can always find the latest code on GitHub: 15 | 16 | https://github.com/tangledhelix/vim-octopress 17 | 18 | *g:octopress_default_format* *octopress-default-format* 19 | By default, Octopress will assume a file's base syntax is Markdown, unless: 20 | 21 | - The filename ends in .textile, which will switch to Textile mode 22 | - The buffer is unnamed and 'g:octopress_default_format' is 'textile' 23 | 24 | Example: 25 | 26 | let g:octopress_default_format = 'textile' 27 | 28 | The default format is 'markdown' unless otherwise specified. 29 | 30 | *octopress-textile* 31 | Though the default format is Markdown, Textile is supported as well. You 32 | must install the Textile bundle yourself, since it is not included with 33 | Vim (at least not as of version 7.3). You can get the Textile bundle at 34 | either of the following locations: 35 | 36 | http://www.vim.org/scripts/script.php?script_id=2305 37 | 38 | https://github.com/timcharper/textile.vim 39 | 40 | *octopress-autocmd* 41 | To use this mode for your Octopress files, use an autocmd. 42 | 43 | autocmd BufNewFile,BufRead *.markdown,*.textile set filetype=octopress 44 | 45 | Since Octopress is a superset of Markdown and Textile, it should not interfere 46 | with non-Octopress Markdown and Textile files. It's also a superset of the 47 | Jekyll syntax, so it should work fine for any pure Jekyll files you might have. 48 | 49 | *:Octopress* 50 | The :Octopress command 51 | 52 | :Octopress 53 | 54 | is one of: 55 | 56 | new_post Add a new post 57 | generate Regenerate output files from sources 58 | deploy Default deploy task 59 | gen_deploy Generate and then deploy 60 | push Deploy to GitHub Pages 61 | rsync Deploy via rsync 62 | clean Clean caches (pygments, gist, sass) 63 | 64 | new_post is the only command that takes arguments. The rest of the line 65 | after ':Octopress new_post' is considered to be the post title. 66 | 67 | Note that due to a problem with rake's argument handling, a post title that 68 | contains a comma will be truncated at the comma. I tried to work around this 69 | using shell escapes and such, but it's a problem in rake itself, and is an 70 | issue using the raw Octopress commands outside of Vim also. 71 | 72 | imathis says this will not be a problem when they move to a CLI instead of 73 | using rake. 74 | 75 | *g:octopress_rake_executable* 76 | By default, 'rake' is taken from your path. If you want to use a different 77 | rake, specify its path in 'g:octopress_rake_executable'. 78 | 79 | let g:octopress_rake_executable = '/path/to/rake' 80 | 81 | -------------------------------------------------------------------------------- /ftplugin/octopress.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin 2 | " Language: Octopress (Markdown/Textile with Liquid) 3 | " Maintainer: Dan Lowe (dan@tangledhelix.com) 4 | " URL: https://github.com/tangledhelix/vim-octopress 5 | 6 | if exists('b:did_ftplugin') 7 | finish 8 | endif 9 | 10 | " This mostly loads HTML-related code, so it should not interfere 11 | " with Textile. 12 | runtime! ftplugin/markdown.vim 13 | unlet! b:did_ftplugin 14 | 15 | -------------------------------------------------------------------------------- /plugin/octopress.vim: -------------------------------------------------------------------------------- 1 | " octopress.vim - Wrapper for Octopress Rake commands 2 | " Language: Octopress (Markdown/Textile with Liquid) 3 | " Maintainer: Dan Lowe (dan@tangledhelix.com) 4 | " URL: https://github.com/tangledhelix/vim-octopress 5 | " 6 | " TODO: store state of swapfile, then restore it. 7 | " only change state if it was set previously. 8 | 9 | if exists('g:loaded_octopress') || &cp 10 | finish 11 | endif 12 | let g:loaded_octopress = 1 13 | 14 | if exists('g:octopress_rake_executable') 15 | " Just use the global if it's set 16 | else 17 | " Otherwise set the global to 'rake' 18 | let g:octopress_rake_executable = 'rake' 19 | endif 20 | 21 | function! s:Octopress(task, ...) 22 | redraw! 23 | if a:task ==# 'new_post' 24 | if a:0 == 0 25 | echoerr 'Missing post_title' 26 | return 27 | endif 28 | let rakefile_path = substitute(system(g:octopress_rake_executable . " -e 'puts (Rake.application.find_rakefile_location())[1]'"), "\n", '', '') 29 | let rake_output = system(g:octopress_rake_executable . ' ' . a:task . '[' . shellescape(join(a:000)) . ']') 30 | let post_path = '' 31 | for line in split(rake_output, "\n") 32 | if line =~? 'Creating new post:' 33 | let post_path = substitute(line, '^Creating new post: ', '', '') 34 | break 35 | endif 36 | endfor 37 | if post_path == '' 38 | echoerr 'Unable to find path to new post file' 39 | else 40 | execute ':edit ' . rakefile_path . '/' . post_path 41 | endif 42 | " TODO add task new_page 43 | elseif a:task ==# 'watch' || a:task ==# 'preview' 44 | echo 'Sorry, background tasks are not supported.' 45 | return 46 | elseif a:task ==# 'generate' || a:task ==# 'deploy' || a:task ==# 'gen_deploy' || a:task ==# 'push' || a:task ==# 'rsync' || a:task ==# 'clean' 47 | if a:task ==# 'deploy' || a:task ==# 'gen_deploy' || a:task ==# 'rsync' 48 | execute 'set noswapfile' 49 | endif 50 | execute '!' . g:octopress_rake_executable . ' ' . a:task 51 | else 52 | echo "I don't know about that Octopress task." 53 | endif 54 | redraw! 55 | endfunction 56 | 57 | function! s:Complete(ArgLead, CmdLine, CursorPos) 58 | return "new_post\nclean\ndeploy\ngen_deploy\ngenerate\npush\nrsync\n" 59 | endfunction 60 | 61 | command! -bang -nargs=* -complete=custom,s:Complete Octopress call s:Octopress() 62 | 63 | -------------------------------------------------------------------------------- /syntax/octopress.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Octopress (Markdown/Textile with Liquid) 3 | " Maintainer: Dan Lowe (dan@tangledhelix.com) 4 | " URL: https://github.com/tangledhelix/vim-octopress 5 | 6 | if exists('b:current_syntax') 7 | finish 8 | endif 9 | 10 | if !exists('g:octopress_default_format') 11 | let g:octopress_default_format = 'markdown' 12 | endif 13 | 14 | let b:filename = expand('%:t') 15 | if empty(b:filename) 16 | let b:octopress_filetype = g:octopress_default_format 17 | else 18 | let b:octopress_fname_result = matchlist(b:filename, '\m\.\([^.]\+\)$') 19 | let b:octopress_fname_exten = b:octopress_fname_result[1] 20 | if b:octopress_fname_exten == 'textile' 21 | let b:octopress_filetype = 'textile' 22 | else 23 | let b:octopress_filetype = 'markdown' 24 | endif 25 | endif 26 | 27 | if b:octopress_filetype == 'textile' 28 | runtime! syntax/textile.vim 29 | else 30 | runtime! syntax/markdown.vim 31 | endif 32 | unlet! b:current_syntax 33 | 34 | " YAML front matter 35 | syn region octopressYamlFrontMatter start=/\m^---\s*$/ end=/\m^---\s*$/ contains=octopressYamlFrontMatterParam,octopressYamlFrontMatterValue 36 | syn match octopressYamlFrontMatterParam /\m^[^:]\+:/ contained nextgroup=octopressYamlFrontMatterValue 37 | syn match octopressYamlFrontMatterValue /\m\s.*$/ contained 38 | 39 | " Liquid tags 40 | syn match octopressLiquidTag /\m{%\s\+\(video\|include_code\|gist\|jsfiddle\|img\|flickr_image\|render_partial\|include\)\s.*\s*%}/ oneline 41 | 42 | " Liquid blocks 43 | syn region octopressLiquidBlock matchgroup=octopressLiquidBlockDelimiter start=/\m{%\s\+\(codeblock\|blockquote\|pullquote\|raw\)\s.*\s*%}/ end=/\m{%\s\+end\(codeblock\|blockquote\|pullquote\|raw\)\s\+%}/ contains=octopressPullquote 44 | syn match octopressPullquote /\m{"\s[^{]\+\s"}/ contained oneline 45 | 46 | " Backtick block 47 | syn region octopressBacktickBlock matchgroup=octopressBacktickBlockDelimiter start=/\m^```\(\s*\|\s\+.*\)$/ end=/\m^```\s*$/ 48 | 49 | command -nargs=+ HiLink hi def link 50 | 51 | HiLink octopressYamlFrontMatter PreProc 52 | HiLink octopressYamlFrontMatterParam Identifier 53 | HiLink octopressYamlFrontMatterValue String 54 | 55 | HiLink octopressLiquidTag PreProc 56 | 57 | HiLink octopressLiquidBlockDelimiter PreProc 58 | HiLink octopressLiquidBlock Underlined 59 | HiLink octopressPullquote PreProc 60 | 61 | HiLink octopressBacktickBlockDelimiter PreProc 62 | HiLink octopressBacktickBlock Underlined 63 | 64 | delcommand HiLink 65 | 66 | let b:current_syntax = 'octopress' 67 | 68 | --------------------------------------------------------------------------------