tomkersten-vixploder 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +105 -0
- data/PostInstall.txt +21 -0
- data/README.rdoc +131 -0
- data/Rakefile +21 -0
- data/bin/256colors2.pl +63 -0
- data/bin/colortest +365 -0
- data/bin/vixplode +10 -0
- data/lib/dotfiles/aliases +30 -0
- data/lib/dotfiles/gvimrc +20 -0
- data/lib/dotfiles/vim/.VimballRecord +2 -0
- data/lib/dotfiles/vim/after/ftplugin/actionscript_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/aspvbs_snippets.vim +17 -0
- data/lib/dotfiles/vim/after/ftplugin/c_snippets.vim +58 -0
- data/lib/dotfiles/vim/after/ftplugin/css_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/django_model_snippets.vim +61 -0
- data/lib/dotfiles/vim/after/ftplugin/django_template_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/f-script_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/haskell_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/html_snippets.vim +57 -0
- data/lib/dotfiles/vim/after/ftplugin/java_snippets.vim +52 -0
- data/lib/dotfiles/vim/after/ftplugin/javascript_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/latex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/logo_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/markdown_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/movable_type_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/objc_snippets.vim +53 -0
- data/lib/dotfiles/vim/after/ftplugin/ocaml_snippets.vim +26 -0
- data/lib/dotfiles/vim/after/ftplugin/perl_snippets.vim +23 -0
- data/lib/dotfiles/vim/after/ftplugin/php_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/phpdoc_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/propel_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/python_snippets.vim +202 -0
- data/lib/dotfiles/vim/after/ftplugin/rails_snippets.vim +54 -0
- data/lib/dotfiles/vim/after/ftplugin/ruby_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/sh_snippets.vim +12 -0
- data/lib/dotfiles/vim/after/ftplugin/slate_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/smarty_snippets.vim +35 -0
- data/lib/dotfiles/vim/after/ftplugin/symfony_snippets.vim +21 -0
- data/lib/dotfiles/vim/after/ftplugin/tcl_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/template_toolkit_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/tex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/xhtml_snippets.vim +48 -0
- data/lib/dotfiles/vim/autoload/fakeclip.vim +253 -0
- data/lib/dotfiles/vim/autoload/rails.vim +4377 -0
- data/lib/dotfiles/vim/autoload/rubycomplete.vim +802 -0
- data/lib/dotfiles/vim/colors/inkpot.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black_mod.vim +213 -0
- data/lib/dotfiles/vim/colors/railscasts.vim +100 -0
- data/lib/dotfiles/vim/colors/rubyblue.vim +74 -0
- data/lib/dotfiles/vim/colors/twilight.vim +75 -0
- data/lib/dotfiles/vim/colors/twilight2.vim +74 -0
- data/lib/dotfiles/vim/colors/wombat256.vim +302 -0
- data/lib/dotfiles/vim/compiler/eruby.vim +41 -0
- data/lib/dotfiles/vim/compiler/ruby.vim +68 -0
- data/lib/dotfiles/vim/compiler/rubyunit.vim +35 -0
- data/lib/dotfiles/vim/doc/NERD_tree.txt +1235 -0
- data/lib/dotfiles/vim/doc/fakeclip.txt +190 -0
- data/lib/dotfiles/vim/doc/matchit.txt +406 -0
- data/lib/dotfiles/vim/doc/project.txt +710 -0
- data/lib/dotfiles/vim/doc/rails.txt +1123 -0
- data/lib/dotfiles/vim/doc/snippets_emu.txt +354 -0
- data/lib/dotfiles/vim/doc/surround.txt +218 -0
- data/lib/dotfiles/vim/doc/tags +433 -0
- data/lib/dotfiles/vim/filetype.vim +13 -0
- data/lib/dotfiles/vim/ftdetect/gist.vim +3 -0
- data/lib/dotfiles/vim/ftdetect/ruby.vim +14 -0
- data/lib/dotfiles/vim/ftplugin/eruby.vim +101 -0
- data/lib/dotfiles/vim/ftplugin/ruby.vim +230 -0
- data/lib/dotfiles/vim/indent/eruby.vim +73 -0
- data/lib/dotfiles/vim/indent/ruby.vim +373 -0
- data/lib/dotfiles/vim/plugin/NERD_tree.vim +3536 -0
- data/lib/dotfiles/vim/plugin/comments.vim +321 -0
- data/lib/dotfiles/vim/plugin/fakeclip.vim +174 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder.vim +1676 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder_textmate.vim +150 -0
- data/lib/dotfiles/vim/plugin/gist.vim +241 -0
- data/lib/dotfiles/vim/plugin/gitdiff.vim +141 -0
- data/lib/dotfiles/vim/plugin/matchit.vim +812 -0
- data/lib/dotfiles/vim/plugin/mru.vim +787 -0
- data/lib/dotfiles/vim/plugin/rails.vim +310 -0
- data/lib/dotfiles/vim/plugin/rspec.vim +12 -0
- data/lib/dotfiles/vim/plugin/snippets.vim +17 -0
- data/lib/dotfiles/vim/plugin/snippetsEmu.vim +973 -0
- data/lib/dotfiles/vim/plugin/supertab.vim +531 -0
- data/lib/dotfiles/vim/plugin/surround.vim +632 -0
- data/lib/dotfiles/vim/ref_vimrc +80 -0
- data/lib/dotfiles/vim/ruby/fuzzy_file_finder.rb +353 -0
- data/lib/dotfiles/vim/syntax/eruby.vim +85 -0
- data/lib/dotfiles/vim/syntax/haml.vim +113 -0
- data/lib/dotfiles/vim/syntax/mkd.vim +86 -0
- data/lib/dotfiles/vim/syntax/ruby.vim +324 -0
- data/lib/dotfiles/vim/syntax/sass.vim +93 -0
- data/lib/dotfiles/vimrc +269 -0
- data/lib/vixplode/cli.rb +73 -0
- data/lib/vixploder.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/vixplode_cli_spec.rb +15 -0
- data/spec/vixploder_spec.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +202 -8
@@ -0,0 +1,150 @@
|
|
1
|
+
if has("ruby")
|
2
|
+
|
3
|
+
" ====================================================================================
|
4
|
+
" COPIED FROM FUZZYFINDER.VIM {{{
|
5
|
+
" since they can't be called from outside fuzzyfinder.vim
|
6
|
+
" ====================================================================================
|
7
|
+
function! s:GetCurrentTagFiles()
|
8
|
+
return sort(filter(map(tagfiles(), 'fnamemodify(v:val, '':p'')'), 'filereadable(v:val)'))
|
9
|
+
endfunction
|
10
|
+
|
11
|
+
function! s:HighlightPrompt(prompt, highlight)
|
12
|
+
syntax clear
|
13
|
+
execute printf('syntax match %s /^\V%s/', a:highlight, escape(a:prompt, '\'))
|
14
|
+
endfunction
|
15
|
+
|
16
|
+
function! s:HighlightError()
|
17
|
+
syntax clear
|
18
|
+
syntax match Error /^.*$/
|
19
|
+
endfunction
|
20
|
+
" ------------------------------------------------------------------------------------
|
21
|
+
" }}}
|
22
|
+
" ====================================================================================
|
23
|
+
|
24
|
+
command! -bang -narg=? -complete=file FuzzyFinderTextMate call FuzzyFinderTextMateLauncher(<q-args>, len(<q-bang>), bufnr('%'), s:GetCurrentTagFiles())
|
25
|
+
|
26
|
+
function! InstantiateTextMateMode() "{{{
|
27
|
+
ruby << RUBY
|
28
|
+
begin
|
29
|
+
require "#{ENV['HOME']}/.vim/ruby/fuzzy_file_finder"
|
30
|
+
rescue LoadError
|
31
|
+
begin
|
32
|
+
require 'rubygems'
|
33
|
+
begin
|
34
|
+
gem 'fuzzy_file_finder'
|
35
|
+
rescue Gem::LoadError
|
36
|
+
gem 'jamis-fuzzy_file_finder'
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'fuzzy_file_finder'
|
42
|
+
end
|
43
|
+
RUBY
|
44
|
+
|
45
|
+
" Configuration option: g:fuzzy_roots
|
46
|
+
" Specifies roots in which the FuzzyFinder will search.
|
47
|
+
if !exists('g:fuzzy_roots')
|
48
|
+
let g:fuzzy_roots = ['.']
|
49
|
+
endif
|
50
|
+
|
51
|
+
" Configuration option: g:fuzzy_ceiling
|
52
|
+
" Specifies the maximum number of files that FuzzyFinder allows to be searched
|
53
|
+
if !exists('g:fuzzy_ceiling')
|
54
|
+
let g:fuzzy_ceiling = 10000
|
55
|
+
endif
|
56
|
+
|
57
|
+
" Configuration option: g:fuzzy_ignore
|
58
|
+
" A semi-colon delimited list of file glob patterns to ignore
|
59
|
+
if !exists('g:fuzzy_ignore')
|
60
|
+
let g:fuzzy_ignore = ""
|
61
|
+
endif
|
62
|
+
|
63
|
+
" Configuration option: g:fuzzy_matching_limit
|
64
|
+
" The maximum number of matches to return at a time. Defaults to 200, via the
|
65
|
+
" g:FuzzyFinderMode.TextMate.matching_limit variable, but using a global variable
|
66
|
+
" makes it easier to set this value.
|
67
|
+
|
68
|
+
ruby << RUBY
|
69
|
+
def finder
|
70
|
+
@finder ||= begin
|
71
|
+
roots = VIM.evaluate("g:fuzzy_roots").split("\n")
|
72
|
+
ceiling = VIM.evaluate("g:fuzzy_ceiling").to_i
|
73
|
+
ignore = VIM.evaluate("g:fuzzy_ignore").split(/;/)
|
74
|
+
FuzzyFileFinder.new(roots, ceiling, ignore)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
RUBY
|
78
|
+
|
79
|
+
let g:FuzzyFinderMode.TextMate = copy(g:FuzzyFinderMode.Base)
|
80
|
+
|
81
|
+
" ================================================================================
|
82
|
+
" This function is copied almost whole-sale from fuzzyfinder.vim. Ideally, I could
|
83
|
+
" used the on_complete callback to more cleanly add the new behavior, but the
|
84
|
+
" TextMate-style completion broke a few of fuzzyfinder.vim's assumptions, and the
|
85
|
+
" only way to patch that up was to override Base.complete...which required me to
|
86
|
+
" copy-and-paste much of the original implementation.
|
87
|
+
"
|
88
|
+
" Ugly. But effective.
|
89
|
+
" ================================================================================
|
90
|
+
function! g:FuzzyFinderMode.TextMate.complete(findstart, base)
|
91
|
+
if a:findstart
|
92
|
+
return 0
|
93
|
+
elseif !self.exists_prompt(a:base) || len(self.remove_prompt(a:base)) < self.min_length
|
94
|
+
return []
|
95
|
+
endif
|
96
|
+
call s:HighlightPrompt(self.prompt, self.prompt_highlight)
|
97
|
+
|
98
|
+
let result = []
|
99
|
+
|
100
|
+
if exists('g:fuzzy_matching_limit')
|
101
|
+
let l:limit = g:fuzzy_matching_limit
|
102
|
+
else
|
103
|
+
let l:limit = self.matching_limit
|
104
|
+
endif
|
105
|
+
|
106
|
+
ruby << RUBY
|
107
|
+
text = VIM.evaluate('self.remove_prompt(a:base)')
|
108
|
+
limit = VIM.evaluate('l:limit').to_i
|
109
|
+
|
110
|
+
matches = finder.find(text, limit)
|
111
|
+
matches.sort_by { |a| [-a[:score], a[:path]] }.each_with_index do |match, index|
|
112
|
+
word = match[:path]
|
113
|
+
abbr = "%2d: %s" % [index+1, match[:abbr]]
|
114
|
+
menu = "[%5d]" % [match[:score] * 10000]
|
115
|
+
VIM.evaluate("add(result, { 'word' : #{word.inspect}, 'abbr' : #{abbr.inspect}, 'menu' : #{menu.inspect} })")
|
116
|
+
end
|
117
|
+
RUBY
|
118
|
+
|
119
|
+
if empty(result) || len(result) >= self.matching_limit
|
120
|
+
call s:HighlightError()
|
121
|
+
endif
|
122
|
+
|
123
|
+
if !empty(result)
|
124
|
+
call feedkeys("\<C-p>\<Down>", 'n')
|
125
|
+
endif
|
126
|
+
|
127
|
+
return result
|
128
|
+
endfunction
|
129
|
+
|
130
|
+
function! FuzzyFinderTextMateLauncher(initial_text, partial_matching, prev_bufnr, tag_files)
|
131
|
+
call g:FuzzyFinderMode.TextMate.launch(a:initial_text, a:partial_matching, a:prev_bufnr, a:tag_files)
|
132
|
+
endfunction
|
133
|
+
|
134
|
+
let g:FuzzyFinderOptions.TextMate = copy(g:FuzzyFinderOptions.File)
|
135
|
+
endfunction "}}}
|
136
|
+
|
137
|
+
if !exists('loaded_fuzzyfinder') "{{{
|
138
|
+
function! FuzzyFinderTextMateLauncher(initial_text, partial_matching, prev_bufnr, tag_files)
|
139
|
+
call InstantiateTextMateMode()
|
140
|
+
function! FuzzyFinderTextMateLauncher(initial_text, partial_matching, prev_bufnr, tag_files)
|
141
|
+
call g:FuzzyFinderMode.TextMate.launch(a:initial_text, a:partial_matching, a:prev_bufnr, a:tag_files)
|
142
|
+
endfunction
|
143
|
+
call g:FuzzyFinderMode.TextMate.launch(a:initial_text, a:partial_matching, a:prev_bufnr, a:tag_files)
|
144
|
+
endfunction
|
145
|
+
finish
|
146
|
+
end "}}}
|
147
|
+
|
148
|
+
call InstantiateTextMateMode()
|
149
|
+
|
150
|
+
endif
|
@@ -0,0 +1,241 @@
|
|
1
|
+
"=============================================================================
|
2
|
+
" File: gist.vim
|
3
|
+
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
4
|
+
" Last Change: 22-Dec-2008. Jan 2008
|
5
|
+
" Version: 1.5
|
6
|
+
" Usage:
|
7
|
+
"
|
8
|
+
" :Gist
|
9
|
+
" post whole text to gist.
|
10
|
+
"
|
11
|
+
" :'<,'>Gist
|
12
|
+
" post selected text to gist.
|
13
|
+
"
|
14
|
+
" :Gist -p
|
15
|
+
" post whole text to gist with private.
|
16
|
+
"
|
17
|
+
" :Gist XXXXX
|
18
|
+
" edit gist XXXXX.
|
19
|
+
"
|
20
|
+
" :Gist -l
|
21
|
+
" list gists from mine.
|
22
|
+
"
|
23
|
+
" :Gist -l mattn
|
24
|
+
" list gists from mattn.
|
25
|
+
"
|
26
|
+
" :Gist -la
|
27
|
+
" list gists from all.
|
28
|
+
"
|
29
|
+
" Tips:
|
30
|
+
" * if set g:gist_clip_command, gist.vim will copy the gist code.
|
31
|
+
"
|
32
|
+
" # mac
|
33
|
+
" let g:gist_clip_command = 'pbcopy'
|
34
|
+
"
|
35
|
+
" # linux
|
36
|
+
" let g:gist_clip_command = 'xclip -selection clipboard'
|
37
|
+
"
|
38
|
+
" # others(cygwin?)
|
39
|
+
" let g:gist_clip_command = 'putclip'
|
40
|
+
"
|
41
|
+
" * if you want to detect filetype from gist's filename...
|
42
|
+
"
|
43
|
+
" # detect filetype if vim failed auto-detection.
|
44
|
+
" let g:gist_detect_filetype = 1
|
45
|
+
"
|
46
|
+
" # detect filetype always.
|
47
|
+
" let g:gist_detect_filetype = 2
|
48
|
+
"
|
49
|
+
" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim
|
50
|
+
|
51
|
+
if &cp || (exists('g:loaded_gist_vim') && g:loaded_gist_vim)
|
52
|
+
finish
|
53
|
+
endif
|
54
|
+
let g:loaded_gist_vim = 1
|
55
|
+
|
56
|
+
if (!exists('g:github_user') || !exists('g:github_token')) && !executable('git')
|
57
|
+
echoerr "Gist: require 'git' command"
|
58
|
+
finish
|
59
|
+
endif
|
60
|
+
|
61
|
+
if !executable('curl')
|
62
|
+
echoerr "Gist: require 'curl' command"
|
63
|
+
finish
|
64
|
+
endif
|
65
|
+
|
66
|
+
if !exists('g:gist_detect_filetype')
|
67
|
+
let g:gist_detect_filetype = 0
|
68
|
+
endif
|
69
|
+
|
70
|
+
function! s:nr2hex(nr)
|
71
|
+
let n = a:nr
|
72
|
+
let r = ""
|
73
|
+
while n
|
74
|
+
let r = '0123456789ABCDEF'[n % 16] . r
|
75
|
+
let n = n / 16
|
76
|
+
endwhile
|
77
|
+
return r
|
78
|
+
endfunction
|
79
|
+
|
80
|
+
function! s:encodeURIComponent(instr)
|
81
|
+
let instr = iconv(a:instr, &enc, "utf-8")
|
82
|
+
let len = strlen(instr)
|
83
|
+
let i = 0
|
84
|
+
let outstr = ''
|
85
|
+
while i < len
|
86
|
+
let ch = instr[i]
|
87
|
+
if ch =~# '[0-9A-Za-z-._~!''()*]'
|
88
|
+
let outstr = outstr . ch
|
89
|
+
elseif ch == ' '
|
90
|
+
let outstr = outstr . '+'
|
91
|
+
else
|
92
|
+
let outstr = outstr . '%' . substitute('0' . s:nr2hex(char2nr(ch)), '^.*\(..\)$', '\1', '')
|
93
|
+
endif
|
94
|
+
let i = i + 1
|
95
|
+
endwhile
|
96
|
+
return outstr
|
97
|
+
endfunction
|
98
|
+
|
99
|
+
function! s:GistList(user, token, gistls)
|
100
|
+
if a:gistls == '-all'
|
101
|
+
let url = 'http://gist.github.com/gists'
|
102
|
+
else
|
103
|
+
let url = 'http://gist.github.com/'.a:gistls
|
104
|
+
endif
|
105
|
+
exec 'silent split gist:'.a:gistls
|
106
|
+
exec 'silent 0r! curl -s '.url
|
107
|
+
silent! %s/>/>\r/g
|
108
|
+
silent! %s/</\r</g
|
109
|
+
silent! %g/<pre/,/<\/pre/join!
|
110
|
+
silent! %v/^\(gist:\|<pre>\)/d _
|
111
|
+
silent! %s/<div[^>]*>/\r /g
|
112
|
+
silent! %s/<\/pre>/\r/g
|
113
|
+
silent! %s/<[^>]\+>//g
|
114
|
+
silent! %s/\r//g
|
115
|
+
silent! %s/ / /g
|
116
|
+
silent! %s/"/"/g
|
117
|
+
silent! %s/&/\&/g
|
118
|
+
silent! %s/>/>/g
|
119
|
+
silent! %s/</</g
|
120
|
+
silent! %s/&#\(\d\d\);/\=nr2char(submatch(1))/g
|
121
|
+
setlocal nomodified
|
122
|
+
syntax match SpecialKey /^gist: /he=e-2
|
123
|
+
exec 'nnoremap <silent> <buffer> <cr> :call <SID>GistListAction()<cr>'
|
124
|
+
normal! gg
|
125
|
+
endfunction
|
126
|
+
|
127
|
+
function! s:GistDetectFiletype(gistid)
|
128
|
+
let url = 'http://gist.github.com/'.a:gistid
|
129
|
+
let res = system('curl -s '.url)
|
130
|
+
let res = substitute(res, '^.*<div class="meta">[\r\n ]*<div class="info">[\r\n ]*<span>\([^>]\+\)</span>.*$', '\1', '')
|
131
|
+
let res = substitute(res, '.*\(\.[^\.]\+\)$', '\1', '')
|
132
|
+
if res =~ '^\.'
|
133
|
+
silent! exec "doau BufRead *".res
|
134
|
+
else
|
135
|
+
silent! exec "setlocal ft=".tolower(res)
|
136
|
+
endif
|
137
|
+
endfunction
|
138
|
+
|
139
|
+
function! s:GistGet(user, token, gistid)
|
140
|
+
let url = 'http://gist.github.com/'.a:gistid.'.txt'
|
141
|
+
exec 'silent split gist:'.a:gistid
|
142
|
+
filetype detect
|
143
|
+
exec 'silent 0r! curl -s '.url
|
144
|
+
setlocal nomodified
|
145
|
+
doau StdinReadPost <buffer>
|
146
|
+
normal! gg
|
147
|
+
if (&ft == '' && g:gist_detect_filetype == 1) || g:gist_detect_filetype == 2
|
148
|
+
call s:GistDetectFiletype(a:gistid)
|
149
|
+
endif
|
150
|
+
if exists('g:gist_clip_command')
|
151
|
+
exec 'silent w !'.g:gist_clip_command
|
152
|
+
endif
|
153
|
+
endfunction
|
154
|
+
|
155
|
+
function! s:GistListAction()
|
156
|
+
let line = getline('.')
|
157
|
+
let mx = '^gist: \(\w\+\)$'
|
158
|
+
if line =~# mx
|
159
|
+
let gistid = substitute(line, mx, '\1', '')
|
160
|
+
call s:GistGet(g:github_user, g:github_token, gistid)
|
161
|
+
endif
|
162
|
+
endfunction
|
163
|
+
|
164
|
+
function! s:GistPut(user, token, content, private)
|
165
|
+
let ext = expand('%:e')
|
166
|
+
let ext = len(ext) ? '.'.ext : ''
|
167
|
+
let name = expand('%:t')
|
168
|
+
let query = [
|
169
|
+
\ 'file_ext[gistfile1]=%s',
|
170
|
+
\ 'file_name[gistfile1]=%s',
|
171
|
+
\ 'file_contents[gistfile1]=%s',
|
172
|
+
\ 'login=%s',
|
173
|
+
\ 'token=%s',
|
174
|
+
\ ]
|
175
|
+
if len(a:private)
|
176
|
+
call add(query, 'private=on')
|
177
|
+
endif
|
178
|
+
let squery = printf(join(query, '&'),
|
179
|
+
\ s:encodeURIComponent(ext),
|
180
|
+
\ s:encodeURIComponent(name),
|
181
|
+
\ s:encodeURIComponent(a:content),
|
182
|
+
\ s:encodeURIComponent(a:user),
|
183
|
+
\ s:encodeURIComponent(a:token))
|
184
|
+
unlet query
|
185
|
+
|
186
|
+
let file = tempname()
|
187
|
+
exec 'redir! > '.file
|
188
|
+
silent echo squery
|
189
|
+
redir END
|
190
|
+
echon " Posting it to gist... "
|
191
|
+
let quote = &shellxquote == '"' ? "'" : '"'
|
192
|
+
let url = 'http://gist.github.com/gists'
|
193
|
+
let res = system('curl -i -d @'.quote.file.quote.' '.url)
|
194
|
+
call delete(file)
|
195
|
+
let res = matchstr(split(res, "\n"), '^Location: ')
|
196
|
+
let res = substitute(res, '^.*: ', '', '')
|
197
|
+
let throwaway = system('echo '.quote.res.quote.'| pbcopy')
|
198
|
+
echo 'Done!'
|
199
|
+
echo 'Gist URL: '.res
|
200
|
+
endfunction
|
201
|
+
|
202
|
+
function! Gist(line1, line2, ...)
|
203
|
+
if !exists('g:github_user')
|
204
|
+
let g:github_user = substitute(system('git config --global github.user'), "\n", '', '')
|
205
|
+
endif
|
206
|
+
if !exists('g:github_token')
|
207
|
+
let g:github_token = substitute(system('git config --global github.token'), "\n", '', '')
|
208
|
+
endif
|
209
|
+
|
210
|
+
let opt = (a:0 > 0) ? substitute(a:1, ' ', '', 'g') : ''
|
211
|
+
let private = ''
|
212
|
+
let gistid = ''
|
213
|
+
let gistls = ''
|
214
|
+
let listmx = '^\(-l\|--list\)\s*\([^\s]\+\)\?$'
|
215
|
+
if opt =~ '^\(-la\|--listall\)'
|
216
|
+
let gistls = '-all'
|
217
|
+
elseif opt =~ listmx
|
218
|
+
let gistls = substitute(opt, listmx, '\2', '')
|
219
|
+
if len(gistls) == 0
|
220
|
+
let gistls = g:github_user
|
221
|
+
endif
|
222
|
+
elseif opt =~ '-p\|--private'
|
223
|
+
let private = 'on'
|
224
|
+
elseif opt =~ '^\w\+$'
|
225
|
+
let gistid = opt
|
226
|
+
elseif len(opt) > 0
|
227
|
+
echoerr 'Invalid arguments'
|
228
|
+
return
|
229
|
+
endif
|
230
|
+
|
231
|
+
if len(gistls) > 0
|
232
|
+
call s:GistList(g:github_user, g:github_token, gistls)
|
233
|
+
elseif len(gistid) > 0
|
234
|
+
call s:GistGet(g:github_user, g:github_token, gistid)
|
235
|
+
else
|
236
|
+
let content = join(getline(a:line1, a:line2), "\n")
|
237
|
+
call s:GistPut(g:github_user, g:github_token, content, private)
|
238
|
+
endif
|
239
|
+
endfunction
|
240
|
+
|
241
|
+
command! -nargs=? -range=% Gist :call Gist(<line1>, <line2>, <f-args>)
|
@@ -0,0 +1,141 @@
|
|
1
|
+
" gitdiff.vim : git helper functions
|
2
|
+
" http://www.vim.org/scripts/script.php?script_id=1846
|
3
|
+
"
|
4
|
+
" Author: Bart Trojanowski <bart@jukie.net>
|
5
|
+
" Date: 2007/05/02
|
6
|
+
" Version: 2
|
7
|
+
"
|
8
|
+
" GetLatestVimScripts: 1846 1 :AutoInstall: gitdiff.vim
|
9
|
+
|
10
|
+
"------------------------------------------------------------------------
|
11
|
+
"
|
12
|
+
" This script currently installs two new functions:
|
13
|
+
"
|
14
|
+
" :GITDiff [rev]
|
15
|
+
"
|
16
|
+
" Vertical split with working buffer, showing vimdiff between current
|
17
|
+
" buffer and a commit.
|
18
|
+
"
|
19
|
+
" :GITChanges [rev]
|
20
|
+
"
|
21
|
+
" Highlights modified lines in current buffer.
|
22
|
+
" Disable with :syntax on
|
23
|
+
"
|
24
|
+
"------------------------------------------------------------------------
|
25
|
+
|
26
|
+
if exists("loaded_gitdiff") || &compatible
|
27
|
+
finish
|
28
|
+
endif
|
29
|
+
let loaded_gitdiff = 1
|
30
|
+
|
31
|
+
"" ------------------------------------------------------------------------
|
32
|
+
" based on svndiff from...
|
33
|
+
" http://www.axisym3.net/jdany/vim-the-editor/
|
34
|
+
"" ------------------------------------------------------------------------
|
35
|
+
|
36
|
+
command! -nargs=? GITDiff :call s:GitDiff(<f-args>)
|
37
|
+
|
38
|
+
function! s:GitDiff(...)
|
39
|
+
if a:0 == 1
|
40
|
+
let rev = a:1
|
41
|
+
else
|
42
|
+
let rev = 'HEAD'
|
43
|
+
endif
|
44
|
+
|
45
|
+
let ftype = &filetype
|
46
|
+
|
47
|
+
let prefix = system("git rev-parse --show-prefix")
|
48
|
+
let thisfile = substitute(expand("%"),getcwd(),'','')
|
49
|
+
let gitfile = substitute(prefix,'\n$','','') . thisfile
|
50
|
+
|
51
|
+
" Check out the revision to a temp file
|
52
|
+
let tmpfile = tempname()
|
53
|
+
let cmd = "git show " . rev . ":" . gitfile . " > " . tmpfile
|
54
|
+
let cmd_output = system(cmd)
|
55
|
+
if v:shell_error && cmd_output != ""
|
56
|
+
echohl WarningMsg | echon cmd_output
|
57
|
+
return
|
58
|
+
endif
|
59
|
+
|
60
|
+
" Begin diff
|
61
|
+
exe "vert diffsplit" . tmpfile
|
62
|
+
exe "set filetype=" . ftype
|
63
|
+
set foldmethod=diff
|
64
|
+
wincmd l
|
65
|
+
|
66
|
+
endfunction
|
67
|
+
|
68
|
+
"" ------------------------------------------------------------------------
|
69
|
+
"" this block is taken from svndiff.vim
|
70
|
+
"" http://www.vim.org/scripts/script.php?script_id=1881#1.0
|
71
|
+
"" by Zevv Ico
|
72
|
+
"" ------------------------------------------------------------------------
|
73
|
+
|
74
|
+
command! -nargs=? GITChanges :call s:GitChanges(<f-args>)
|
75
|
+
|
76
|
+
function! s:GitChanges(...)
|
77
|
+
|
78
|
+
if a:0 == 1
|
79
|
+
let rev = a:1
|
80
|
+
else
|
81
|
+
let rev = 'HEAD'
|
82
|
+
endif
|
83
|
+
|
84
|
+
" Check if this file is managed by git, exit otherwise
|
85
|
+
|
86
|
+
let prefix = system("git rev-parse --show-prefix")
|
87
|
+
let thisfile = substitute(expand("%"),getcwd(),'','')
|
88
|
+
let gitfile = substitute(prefix,'\n$','','') . thisfile
|
89
|
+
|
90
|
+
" Reset syntax highlighting
|
91
|
+
|
92
|
+
syntax off
|
93
|
+
|
94
|
+
" Pipe the current buffer contents to a shell command calculating the diff
|
95
|
+
" in a friendly parsable format
|
96
|
+
|
97
|
+
let contents = join(getbufline("%", 1, "$"), "\n")
|
98
|
+
let diff = system("diff -u0 <(git show " . rev . ":" . gitfile . ") <(cat;echo)", contents)
|
99
|
+
|
100
|
+
" Parse the output of the diff command and hightlight changed, added and
|
101
|
+
" removed lines
|
102
|
+
|
103
|
+
for line in split(diff, '\n')
|
104
|
+
|
105
|
+
let part = matchlist(line, '@@ -\([0-9]*\),*\([0-9]*\) +\([0-9]*\),*\([0-9]*\) @@')
|
106
|
+
|
107
|
+
if ! empty(part)
|
108
|
+
let old_from = part[1]
|
109
|
+
let old_count = part[2] == '' ? 1 : part[2]
|
110
|
+
let new_from = part[3]
|
111
|
+
let new_count = part[4] == '' ? 1 : part[4]
|
112
|
+
|
113
|
+
" Figure out if text was added, removed or changed.
|
114
|
+
|
115
|
+
if old_count == 0
|
116
|
+
let from = new_from
|
117
|
+
let to = new_from + new_count - 1
|
118
|
+
let group = 'DiffAdd'
|
119
|
+
elseif new_count == 0
|
120
|
+
let from = new_from
|
121
|
+
let to = new_from + 1
|
122
|
+
let group = 'DiffDelete'
|
123
|
+
else
|
124
|
+
let from = new_from
|
125
|
+
let to = new_from + new_count - 1
|
126
|
+
let group = 'DiffChange'
|
127
|
+
endif
|
128
|
+
|
129
|
+
" Set the actual syntax highlight
|
130
|
+
|
131
|
+
exec 'syntax region ' . group . ' start=".*\%' . from . 'l" end=".*\%' . to . 'l"'
|
132
|
+
|
133
|
+
endif
|
134
|
+
|
135
|
+
endfor
|
136
|
+
|
137
|
+
endfunction
|
138
|
+
|
139
|
+
|
140
|
+
" vi: ts=2 sw=2
|
141
|
+
|