├── VERSION ├── Rakefile ├── LICENSE.txt ├── autoload └── xmpfilter.vim ├── README.md ├── plugin └── xmpfilter.vim └── doc └── xmpfilter.txt /VERSION: -------------------------------------------------------------------------------- 1 | 1.1 2 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | desc "zip" 2 | task :zip do 3 | version = File.read("VERSION").chomp 4 | dirname = File.basename( File.dirname(File.expand_path(__FILE__))) 5 | zipname = "#{dirname}-#{version}.zip" 6 | sh "zip -r #{zipname} README.md autoload doc plugin -x doc/tags" 7 | end 8 | 9 | desc "versub" 10 | task :versub do 11 | version = File.read("VERSION").chomp 12 | files = Dir.glob('{doc,autoload,plugin}/**').select do |f| 13 | File.file? f 14 | end 15 | files.delete('doc/tags') 16 | files.each do |fname| 17 | lines = File.readlines(fname) 18 | lines.map! { |l| l.sub(/Version: (.*)/, "Version: #{version}") } 19 | File.open(fname,'w') {|f| f.puts lines } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 t9md 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /autoload/xmpfilter.vim: -------------------------------------------------------------------------------- 1 | " Object: 2 | "========================= 3 | let s:mark = " # =>" 4 | let s:xmpfilter = {} 5 | 6 | function! s:xmpfilter.init(mode) "{{{ 7 | let self._mode = a:mode 8 | let self._winview = winsaveview() 9 | let self._lazyredraw = &lazyredraw 10 | set lazyredraw 11 | endfunction "}}} 12 | 13 | function! s:xmpfilter.finish() "{{{ 14 | call winrestview(self._winview) 15 | if self._mode == 'v' 16 | normal! gv 17 | endif 18 | let &lazyredraw = self._lazyredraw 19 | redraw 20 | endfunction "}}} 21 | 22 | function! s:xmpfilter.run(mode, option,first_line, last_line) "{{{ 23 | call self.init(a:mode) 24 | let range = (self._mode == 'v') 25 | \ ? join([a:first_line, a:last_line], ",") 26 | \ : '%' 27 | let cmd = range . "!" . g:xmpfilter_cmd . " " . a:option 28 | execute cmd 29 | call self.finish() 30 | endfunction "}}} 31 | 32 | function! s:xmpfilter.mark(mode, first_line, last_line) "{{{ 33 | call self.init(a:mode) 34 | for line in range(a:first_line,a:last_line) 35 | let line_org = getline(line) 36 | let marked = strridx(line_org, s:mark) 37 | let line_new = (marked ==# -1) 38 | \ ? line_org . s:mark 39 | \ : strpart(line_org, 0, marked) 40 | call setline(line, line_new) 41 | endfor 42 | call self.finish() 43 | endfunction "}}} 44 | 45 | " PublicInterface: 46 | "========================= 47 | function! xmpfilter#run(mode, option ) range "{{{ 48 | call s:xmpfilter.run(a:mode, a:option, a:firstline, a:lastline) 49 | endfun "}}} 50 | 51 | function! xmpfilter#mark(mode) range "{{{ 52 | call s:xmpfilter.mark(a:mode, a:firstline, a:lastline) 53 | endfun "}}} 54 | " vim: foldmethod=marker 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Support 2 | * [rcodetools](http://rubygems.org/gems/rcodetools). 3 | * [seeing_is_believing](https://github.com/JoshCheek/seeing_is_believing) 4 | 5 | ![Example](https://github.com/t9md/t9md/blob/master/img/vim-ruby-xmpfilter_anime.gif?raw=true) 6 | 7 | 8 | ### [help](https://github.com/t9md/vim-ruby-xmpfilter/blob/master/doc/xmpfilter.txt) 9 | 10 | # .vimrc sample 11 | ================================== 12 | vim-ruby-xmpfilter doesn't provide any default keymap. 13 | See sample configuration below. 14 | 15 | 'xmpfilter' user 16 | 17 | autocmd FileType ruby nmap (xmpfilter-mark) 18 | autocmd FileType ruby xmap (xmpfilter-mark) 19 | autocmd FileType ruby imap (xmpfilter-mark) 20 | 21 | autocmd FileType ruby nmap (xmpfilter-run) 22 | autocmd FileType ruby xmap (xmpfilter-run) 23 | autocmd FileType ruby imap (xmpfilter-run) 24 | 25 | 'seeing_is_believing' user 26 | 27 | let g:xmpfilter_cmd = "seeing_is_believing" 28 | 29 | autocmd FileType ruby nmap (seeing_is_believing-mark) 30 | autocmd FileType ruby xmap (seeing_is_believing-mark) 31 | autocmd FileType ruby imap (seeing_is_believing-mark) 32 | 33 | autocmd FileType ruby nmap (seeing_is_believing-clean) 34 | autocmd FileType ruby xmap (seeing_is_believing-clean) 35 | autocmd FileType ruby imap (seeing_is_believing-clean) 36 | 37 | " xmpfilter compatible 38 | autocmd FileType ruby nmap (seeing_is_believing-run_-x) 39 | autocmd FileType ruby xmap (seeing_is_believing-run_-x) 40 | autocmd FileType ruby imap (seeing_is_believing-run_-x) 41 | 42 | " auto insert mark at appropriate spot. 43 | autocmd FileType ruby nmap (seeing_is_believing-run) 44 | autocmd FileType ruby xmap (seeing_is_believing-run) 45 | autocmd FileType ruby imap (seeing_is_believing-run) 46 | -------------------------------------------------------------------------------- /plugin/xmpfilter.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: xmpfilter.vim 3 | " Author: t9md 4 | " WebPage: http://github.com/t9md/vim-ruby-xmpfilter 5 | "============================================================================= 6 | 7 | " GUARD: {{{ 8 | "============================================================ 9 | " for dev 10 | " unlet g:loaded_xmpfilter 11 | 12 | if exists('g:loaded_xmpfilter') 13 | finish 14 | endif 15 | let g:loaded_xmpfilter = 1 16 | 17 | let s:old_cpo = &cpo 18 | set cpo&vim 19 | "}}} 20 | 21 | " VARIABLES: {{{ 22 | "================================================================= 23 | if !exists('g:xmpfilter_cmd') 24 | let g:xmpfilter_cmd = "xmpfilter -a" 25 | endif 26 | "}}} 27 | 28 | " KEYMAP: {{{ 29 | "================================================================= 30 | " xmpfilter 31 | nnoremap (xmpfilter-mark) :call xmpfilter#mark('n') 32 | vnoremap (xmpfilter-mark) :call xmpfilter#mark('v') 33 | inoremap (xmpfilter-mark) :call xmpfilter#mark('i')a 34 | 35 | nnoremap (xmpfilter-run) :call xmpfilter#run('n', '') 36 | vnoremap (xmpfilter-run) :call xmpfilter#run('v', '') 37 | inoremap (xmpfilter-run) :call xmpfilter#run('i', '')a 38 | 39 | " seeing_is_believing 40 | nmap (seeing_is_believing-mark) (xmpfilter-mark) 41 | vmap (seeing_is_believing-mark) (xmpfilter-mark) 42 | imap (seeing_is_believing-mark) (xmpfilter-mark) 43 | 44 | nnoremap (seeing_is_believing-run_-x) :call xmpfilter#run('n', '-x') 45 | vnoremap (seeing_is_believing-run_-x) :call xmpfilter#run('v', '-x') 46 | inoremap (seeing_is_believing-run_-x) :call xmpfilter#run('i', '-x')a 47 | 48 | nnoremap (seeing_is_believing-clean) :call xmpfilter#run('n', '-Ku --clean') 49 | vnoremap (seeing_is_believing-clean) :call xmpfilter#run('v', '-Ku --clean') 50 | inoremap (seeing_is_believing-clean) :call xmpfilter#run('i', '-Ku --clean')a 51 | 52 | " Only for seeing_is_believing 53 | nnoremap (seeing_is_believing-run) :call xmpfilter#run('n', '') 54 | vnoremap (seeing_is_believing-run) :call xmpfilter#run('v', '') 55 | inoremap (seeing_is_believing-run) :call xmpfilter#run('i', '')a 56 | 57 | "}}} 58 | 59 | let &cpo = s:old_cpo 60 | " vim: foldmethod=marker 61 | -------------------------------------------------------------------------------- /doc/xmpfilter.txt: -------------------------------------------------------------------------------- 1 | xmpfilter.txt Helper for ruby's xmpfilter or seeing_is_believing 2 | 3 | Version: 1.1 4 | Author : t9md 5 | GitHub : https://github.com/t9md/vim-ruby-xmpfilter 6 | ============================================================================== 7 | CONTENTS *xmpfilter-contents* 8 | 9 | Introduction |xmpfilter-introduction| 10 | Mapping |xmpfilter-mapping| 11 | Variables |xmpfilter-variables| 12 | Configuration Examples |xmpfilter-examples| 13 | Bug |xmpfilter-bug| 14 | Changelog |xmpfilter-changelog| 15 | 16 | ============================================================================== 17 | INTRODUCTION *xmpfilter-introduction* 18 | 19 | vim-ruby-xmpfilter provide keymap that helps you use 'xmpfilter' or 20 | 'seeing_is_believing' from Vim. 21 | 22 | * insert/delete annotation mark " # =>". 23 | * virtual keymap for marking and executing 'xmpfilter' or 'seeing_is_believing' 24 | against current bufffer. 25 | 26 | xmpfilter is provided as part of rcodetools. 27 | http://rubygems.org/gems/rcodetools 28 | 29 | seeing_is_believing 30 | https://github.com/JoshCheek/seeing_is_believing 31 | 32 | ============================================================================== 33 | MAPPINGS *xmpfilter-mappings* 34 | 35 | Insert " # =>" into end of line or delete " # =>" if it already exist. 36 | 37 | normal (xmpfilter-mark) 38 | visual (xmpfilter-mark) 39 | insert (xmpfilter-mark) 40 | 41 | normal (seeing_is_believing-mark) 42 | visual (seeing_is_believing-mark) 43 | insert (seeing_is_believing-mark) 44 | 45 | Insert evaluated result at the mark. 46 | 47 | normal (xmpfilter-run) 48 | visual (xmpfilter-run) 49 | insert (xmpfilter-run) 50 | 51 | normal (seeing_is_believing-run_-x) 52 | visual (seeing_is_believing-run_-x) 53 | insert (seeing_is_believing-run_-x) 54 | 55 | Insert evaluated result with mark. 56 | Only for "seeing_is_believing" 57 | 58 | normal (seeing_is_believing-run) 59 | visual (seeing_is_believing-run) 60 | insert (seeing_is_believing-run) 61 | 62 | Clean all marks in the buffer 63 | Only for "seeing_is_believing" 64 | 65 | normal (seeing_is_believing-clean) 66 | visual (seeing_is_believing-clean) 67 | insert (seeing_is_believing-clean) 68 | 69 | ============================================================================== 70 | COMMANDS *xmpfilter-commands* 71 | ============================================================================== 72 | VARIABLES *xmpfilter-variables* 73 | 74 | *g:xmpfilter_cmd* 75 | g:xmpfilter_cmd 76 | set filter cmd to insert eval result on mark(" # =>"). 77 | Default: "xmpfilter -a" 78 | 79 | ============================================================================== 80 | CONFIGURATION EXAMPLE *xmpfilter-examples* 81 | 82 | 83 | set configuration like bellow in your .vimrc. 84 | 85 | * 'xmpfilter' user 86 | > 87 | " Gvim 88 | autocmd FileType ruby nmap (xmpfilter-mark) 89 | autocmd FileType ruby xmap (xmpfilter-mark) 90 | autocmd FileType ruby imap (xmpfilter-mark) 91 | 92 | autocmd FileType ruby nmap (xmpfilter-run) 93 | autocmd FileType ruby xmap (xmpfilter-run) 94 | autocmd FileType ruby imap (xmpfilter-run) 95 | 96 | < 97 | * 'seeing_is_believing' user 98 | > 99 | let g:xmpfilter_cmd = "seeing_is_believing" 100 | 101 | autocmd FileType ruby nmap (seeing_is_believing-mark) 102 | autocmd FileType ruby xmap (seeing_is_believing-mark) 103 | autocmd FileType ruby imap (seeing_is_believing-mark) 104 | 105 | autocmd FileType ruby nmap (seeing_is_believing-clean) 106 | autocmd FileType ruby xmap (seeing_is_believing-clean) 107 | autocmd FileType ruby imap (seeing_is_believing-clean) 108 | 109 | " xmpfilter compatible 110 | autocmd FileType ruby nmap (seeing_is_believing-run_-x) 111 | autocmd FileType ruby xmap (seeing_is_believing-run_-x) 112 | autocmd FileType ruby imap (seeing_is_believing-run_-x) 113 | 114 | " auto insert mark at appropriate spot. 115 | autocmd FileType ruby nmap (seeing_is_believing-run) 116 | autocmd FileType ruby xmap (seeing_is_believing-run) 117 | autocmd FileType ruby imap (seeing_is_believing-run) 118 | < 119 | ============================================================================== 120 | CHANGELOG *xmpfilter-changelog* 121 | 2013-10-22: v1.1 122 | - cleanup 123 | - [fix] When (xmpfilter-mark) is executed from insert mode 124 | cursor pos change if original cursor was at EOL. 125 | 2013-09-20: v1.0 126 | - add keymap for seeing_is_believing 127 | - add |g:xmpfilter_cmd| to support seeing_is_believing 128 | - create help doc 129 | ============================================================================== 130 | vim:tw=78:ts=8:ft=help:norl: 131 | --------------------------------------------------------------------------------