Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

vim bundle, get rid of pathogen

  • Loading branch information...
commit 7ccad7def445cb6beb8083084e9be9ea6f3a1e24 1 parent ab6eaec
Ralph von der Heyden authored
245 autoload/pathogen.vim
... ... @@ -1,245 +0,0 @@
1   -" pathogen.vim - path option manipulation
2   -" Maintainer: Tim Pope <http://tpo.pe/>
3   -" Version: 2.0
4   -
5   -" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
6   -"
7   -" For management of individually installed plugins in ~/.vim/bundle (or
8   -" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
9   -" prior to `filetype plugin indent on` is the only other setup necessary.
10   -"
11   -" The API is documented inline below. For maximum ease of reading,
12   -" :set foldmethod=marker
13   -
14   -if exists("g:loaded_pathogen") || &cp
15   - finish
16   -endif
17   -let g:loaded_pathogen = 1
18   -
19   -" Point of entry for basic default usage. Give a directory name to invoke
20   -" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
21   -" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
22   -" pathogen#cycle_filetype() is invoked.
23   -function! pathogen#infect(...) abort " {{{1
24   - let source_path = a:0 ? a:1 : 'bundle'
25   - if source_path =~# '[\\/]'
26   - call pathogen#runtime_prepend_subdirectories(source_path)
27   - else
28   - call pathogen#runtime_append_all_bundles(source_path)
29   - endif
30   - call pathogen#cycle_filetype()
31   -endfunction " }}}1
32   -
33   -" Split a path into a list.
34   -function! pathogen#split(path) abort " {{{1
35   - if type(a:path) == type([]) | return a:path | endif
36   - let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
37   - return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
38   -endfunction " }}}1
39   -
40   -" Convert a list to a path.
41   -function! pathogen#join(...) abort " {{{1
42   - if type(a:1) == type(1) && a:1
43   - let i = 1
44   - let space = ' '
45   - else
46   - let i = 0
47   - let space = ''
48   - endif
49   - let path = ""
50   - while i < a:0
51   - if type(a:000[i]) == type([])
52   - let list = a:000[i]
53   - let j = 0
54   - while j < len(list)
55   - let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
56   - let path .= ',' . escaped
57   - let j += 1
58   - endwhile
59   - else
60   - let path .= "," . a:000[i]
61   - endif
62   - let i += 1
63   - endwhile
64   - return substitute(path,'^,','','')
65   -endfunction " }}}1
66   -
67   -" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
68   -function! pathogen#legacyjoin(...) abort " {{{1
69   - return call('pathogen#join',[1] + a:000)
70   -endfunction " }}}1
71   -
72   -" Remove duplicates from a list.
73   -function! pathogen#uniq(list) abort " {{{1
74   - let i = 0
75   - let seen = {}
76   - while i < len(a:list)
77   - if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
78   - call remove(a:list,i)
79   - elseif a:list[i] ==# ''
80   - let i += 1
81   - let empty = 1
82   - else
83   - let seen[a:list[i]] = 1
84   - let i += 1
85   - endif
86   - endwhile
87   - return a:list
88   -endfunction " }}}1
89   -
90   -" \ on Windows unless shellslash is set, / everywhere else.
91   -function! pathogen#separator() abort " {{{1
92   - return !exists("+shellslash") || &shellslash ? '/' : '\'
93   -endfunction " }}}1
94   -
95   -" Convenience wrapper around glob() which returns a list.
96   -function! pathogen#glob(pattern) abort " {{{1
97   - let files = split(glob(a:pattern),"\n")
98   - return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
99   -endfunction "}}}1
100   -
101   -" Like pathogen#glob(), only limit the results to directories.
102   -function! pathogen#glob_directories(pattern) abort " {{{1
103   - return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
104   -endfunction "}}}1
105   -
106   -" Turn filetype detection off and back on again if it was already enabled.
107   -function! pathogen#cycle_filetype() " {{{1
108   - if exists('g:did_load_filetypes')
109   - filetype off
110   - filetype on
111   - endif
112   -endfunction " }}}1
113   -
114   -" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
115   -" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
116   -function! pathogen#is_disabled(path) " {{{1
117   - if a:path =~# '\~$'
118   - return 1
119   - elseif !exists("g:pathogen_disabled")
120   - return 0
121   - endif
122   - let sep = pathogen#separator()
123   - return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
124   -endfunction "}}}1
125   -
126   -" Prepend all subdirectories of path to the rtp, and append all 'after'
127   -" directories in those subdirectories.
128   -function! pathogen#runtime_prepend_subdirectories(path) " {{{1
129   - let sep = pathogen#separator()
130   - let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
131   - let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
132   - let rtp = pathogen#split(&rtp)
133   - let path = expand(a:path)
134   - call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
135   - let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
136   - return &rtp
137   -endfunction " }}}1
138   -
139   -" For each directory in rtp, check for a subdirectory named dir. If it
140   -" exists, add all subdirectories of that subdirectory to the rtp, immediately
141   -" after the original directory. If no argument is given, 'bundle' is used.
142   -" Repeated calls with the same arguments are ignored.
143   -function! pathogen#runtime_append_all_bundles(...) " {{{1
144   - let sep = pathogen#separator()
145   - let name = a:0 ? a:1 : 'bundle'
146   - if "\n".s:done_bundles =~# "\\M\n".name."\n"
147   - return ""
148   - endif
149   - let s:done_bundles .= name . "\n"
150   - let list = []
151   - for dir in pathogen#split(&rtp)
152   - if dir =~# '\<after$'
153   - let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
154   - else
155   - let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
156   - endif
157   - endfor
158   - let &rtp = pathogen#join(pathogen#uniq(list))
159   - return 1
160   -endfunction
161   -
162   -let s:done_bundles = ''
163   -" }}}1
164   -
165   -" Invoke :helptags on all non-$VIM doc directories in runtimepath.
166   -function! pathogen#helptags() " {{{1
167   - let sep = pathogen#separator()
168   - for dir in pathogen#split(&rtp)
169   - if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(glob(dir.sep.'doc'.sep.'*')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
170   - helptags `=dir.'/doc'`
171   - endif
172   - endfor
173   -endfunction " }}}1
174   -
175   -command! -bar Helptags :call pathogen#helptags()
176   -
177   -" Like findfile(), but hardcoded to use the runtimepath.
178   -function! pathogen#runtime_findfile(file,count) "{{{1
179   - let rtp = pathogen#join(1,pathogen#split(&rtp))
180   - return fnamemodify(findfile(a:file,rtp,a:count),':p')
181   -endfunction " }}}1
182   -
183   -" Backport of fnameescape().
184   -function! pathogen#fnameescape(string) " {{{1
185   - if exists('*fnameescape')
186   - return fnameescape(a:string)
187   - elseif a:string ==# '-'
188   - return '\-'
189   - else
190   - return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
191   - endif
192   -endfunction " }}}1
193   -
194   -function! s:find(count,cmd,file,lcd) " {{{1
195   - let rtp = pathogen#join(1,pathogen#split(&runtimepath))
196   - let file = pathogen#runtime_findfile(a:file,a:count)
197   - if file ==# ''
198   - return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
199   - elseif a:lcd
200   - let path = file[0:-strlen(a:file)-2]
201   - execute 'lcd `=path`'
202   - return a:cmd.' '.pathogen#fnameescape(a:file)
203   - else
204   - return a:cmd.' '.pathogen#fnameescape(file)
205   - endif
206   -endfunction " }}}1
207   -
208   -function! s:Findcomplete(A,L,P) " {{{1
209   - let sep = pathogen#separator()
210   - let cheats = {
211   - \'a': 'autoload',
212   - \'d': 'doc',
213   - \'f': 'ftplugin',
214   - \'i': 'indent',
215   - \'p': 'plugin',
216   - \'s': 'syntax'}
217   - if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
218   - let request = cheats[a:A[0]].a:A[1:-1]
219   - else
220   - let request = a:A
221   - endif
222   - let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
223   - let found = {}
224   - for path in pathogen#split(&runtimepath)
225   - let path = expand(path, ':p')
226   - let matches = split(glob(path.sep.pattern),"\n")
227   - call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
228   - call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
229   - for match in matches
230   - let found[match] = 1
231   - endfor
232   - endfor
233   - return sort(keys(found))
234   -endfunction " }}}1
235   -
236   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
237   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
238   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
239   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
240   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
241   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
242   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
243   -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
244   -
245   -" vim:set ft=vim ts=8 sw=2 sts=2:
49 bundle/go.vim/autoload/go/complete.vim
... ... @@ -0,0 +1,49 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" This file provides a utility function that performs auto-completion of
  6 +" package names, for use by other commands.
  7 +
  8 +let s:goos = $GOOS
  9 +let s:goarch = $GOARCH
  10 +
  11 +if len(s:goos) == 0
  12 + if exists('g:golang_goos')
  13 + let s:goos = g:golang_goos
  14 + elseif has('win32') || has('win64')
  15 + let s:goos = 'windows'
  16 + elseif has('macunix')
  17 + let s:goos = 'darwin'
  18 + else
  19 + let s:goos = '*'
  20 + endif
  21 +endif
  22 +
  23 +if len(s:goarch) == 0
  24 + if exists('g:golang_goarch')
  25 + let s:goarch = g:golang_goarch
  26 + else
  27 + let s:goarch = '*'
  28 + endif
  29 +endif
  30 +
  31 +function! go#complete#Package(ArgLead, CmdLine, CursorPos)
  32 + let goroot = $GOROOT
  33 + if len(goroot) == 0
  34 + " should not occur.
  35 + return []
  36 + endif
  37 + let ret = {}
  38 + let root = expand(goroot.'/pkg/'.s:goos.'_'.s:goarch)
  39 + for i in split(globpath(root, a:ArgLead.'*'), "\n")
  40 + if isdirectory(i)
  41 + let i .= '/'
  42 + elseif i !~ '\.a$'
  43 + continue
  44 + endif
  45 + let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
  46 + let ret[i] = i
  47 + endfor
  48 + return sort(keys(ret))
  49 +endfunction
23 bundle/go.vim/ftdetect/gofiletype.vim
... ... @@ -0,0 +1,23 @@
  1 +" We take care to preserve the user's fileencodings and fileformats,
  2 +" because those settings are global (not buffer local), yet we want
  3 +" to override them for loading Go files, which are defined to be UTF-8.
  4 +let s:current_fileformats = ''
  5 +let s:current_fileencodings = ''
  6 +
  7 +" define fileencodings to open as utf-8 encoding even if it's ascii.
  8 +function! s:gofiletype_pre()
  9 + let s:current_fileformats = &g:fileformats
  10 + let s:current_fileencodings = &g:fileencodings
  11 + set fileencodings=utf-8 fileformats=unix
  12 + setlocal filetype=go
  13 +endfunction
  14 +
  15 +" restore fileencodings as others
  16 +function! s:gofiletype_post()
  17 + let &g:fileformats = s:current_fileformats
  18 + let &g:fileencodings = s:current_fileencodings
  19 +endfunction
  20 +
  21 +au BufNewFile *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
  22 +au BufRead *.go call s:gofiletype_pre()
  23 +au BufReadPost *.go call s:gofiletype_post()
44 bundle/go.vim/ftplugin/go/fmt.vim
... ... @@ -0,0 +1,44 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" fmt.vim: Vim command to format Go files with gofmt.
  6 +"
  7 +" This filetype plugin add a new commands for go buffers:
  8 +"
  9 +" :Fmt
  10 +"
  11 +" Filter the current Go buffer through gofmt.
  12 +" It tries to preserve cursor position and avoids
  13 +" replacing the buffer with stderr output.
  14 +"
  15 +
  16 +command! -buffer Fmt call s:GoFormat()
  17 +
  18 +function! s:GoFormat()
  19 + let view = winsaveview()
  20 + silent %!gofmt
  21 + if v:shell_error
  22 + let errors = []
  23 + for line in getline(1, line('$'))
  24 + let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
  25 + if !empty(tokens)
  26 + call add(errors, {"filename": @%,
  27 + \"lnum": tokens[2],
  28 + \"col": tokens[3],
  29 + \"text": tokens[4]})
  30 + endif
  31 + endfor
  32 + if empty(errors)
  33 + % | " Couldn't detect gofmt error format, output errors
  34 + endif
  35 + undo
  36 + if !empty(errors)
  37 + call setloclist(0, errors, 'r')
  38 + endif
  39 + echohl Error | echomsg "Gofmt returned error" | echohl None
  40 + endif
  41 + call winrestview(view)
  42 +endfunction
  43 +
  44 +" vim:ts=4:sw=4:et
13 bundle/go.vim/ftplugin/go/godoc.vim
... ... @@ -0,0 +1,13 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" godoc.vim: Vim command to see godoc.
  6 +
  7 +if exists("b:did_ftplugin")
  8 + finish
  9 +endif
  10 +
  11 +silent! nmap <buffer> <silent> K <Plug>(godoc-keyword)
  12 +
  13 +" vim:ts=4:sw=4:et
201 bundle/go.vim/ftplugin/go/import.vim
... ... @@ -0,0 +1,201 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" import.vim: Vim commands to import/drop Go packages.
  6 +"
  7 +" This filetype plugin adds three new commands for go buffers:
  8 +"
  9 +" :Import {path}
  10 +"
  11 +" Import ensures that the provided package {path} is imported
  12 +" in the current Go buffer, using proper style and ordering.
  13 +" If {path} is already being imported, an error will be
  14 +" displayed and the buffer will be untouched.
  15 +"
  16 +" :ImportAs {localname} {path}
  17 +"
  18 +" Same as Import, but uses a custom local name for the package.
  19 +"
  20 +" :Drop {path}
  21 +"
  22 +" Remove the import line for the provided package {path}, if
  23 +" present in the current Go buffer. If {path} is not being
  24 +" imported, an error will be displayed and the buffer will be
  25 +" untouched.
  26 +"
  27 +" In addition to these commands, there are also two shortcuts mapped:
  28 +"
  29 +" \f - Runs :Import fmt
  30 +" \F - Runs :Drop fmt
  31 +"
  32 +" The backslash is the default maplocalleader, so it is possible that
  33 +" your vim is set to use a different character (:help maplocalleader).
  34 +"
  35 +if exists("b:did_ftplugin")
  36 + finish
  37 +endif
  38 +
  39 +command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', <f-args>)
  40 +command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
  41 +command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
  42 +map <buffer> <LocalLeader>f :Import fmt<CR>
  43 +map <buffer> <LocalLeader>F :Drop fmt<CR>
  44 +
  45 +function! s:SwitchImport(enabled, localname, path)
  46 + let view = winsaveview()
  47 + let path = a:path
  48 +
  49 + " Quotes are not necessary, so remove them if provided.
  50 + if path[0] == '"'
  51 + let path = strpart(path, 1)
  52 + endif
  53 + if path[len(path)-1] == '"'
  54 + let path = strpart(path, 0, len(path) - 1)
  55 + endif
  56 + if path == ''
  57 + call s:Error('Import path not provided')
  58 + return
  59 + endif
  60 +
  61 + let qpath = '"' . path . '"'
  62 + if a:localname != ''
  63 + let qlocalpath = a:localname . ' ' . qpath
  64 + else
  65 + let qlocalpath = qpath
  66 + endif
  67 + let indentstr = 0
  68 + let packageline = -1 " Position of package name statement
  69 + let appendline = -1 " Position to introduce new import
  70 + let deleteline = -1 " Position of line with existing import
  71 + let linesdelta = 0 " Lines added/removed
  72 +
  73 + " Find proper place to add/remove import.
  74 + let line = 0
  75 + while line <= line('$')
  76 + let linestr = getline(line)
  77 +
  78 + if linestr =~# '^package\s'
  79 + let packageline = line
  80 + let appendline = line
  81 +
  82 + elseif linestr =~# '^import\s\+('
  83 + let appendstr = qlocalpath
  84 + let indentstr = 1
  85 + let appendline = line
  86 + while line <= line("$")
  87 + let line = line + 1
  88 + let linestr = getline(line)
  89 + let m = matchlist(getline(line), '^\()\|\(\s\+\)\(\S*\s*\)"\(.\+\)"\)')
  90 + if empty(m)
  91 + continue
  92 + endif
  93 + if m[1] == ')'
  94 + break
  95 + endif
  96 + if a:localname != '' && m[3] != ''
  97 + let qlocalpath = printf('%-' . (len(m[3])-1) . 's %s', a:localname, qpath)
  98 + endif
  99 + let appendstr = m[2] . qlocalpath
  100 + let indentstr = 0
  101 + if m[4] == path
  102 + let appendline = -1
  103 + let deleteline = line
  104 + break
  105 + elseif m[4] < path
  106 + let appendline = line
  107 + endif
  108 + endwhile
  109 + break
  110 +
  111 + elseif linestr =~# '^import '
  112 + if appendline == packageline
  113 + let appendstr = 'import ' . qlocalpath
  114 + let appendline = line - 1
  115 + endif
  116 + let m = matchlist(linestr, '^import\(\s\+\)\(\S*\s*\)"\(.\+\)"')
  117 + if !empty(m)
  118 + if m[3] == path
  119 + let appendline = -1
  120 + let deleteline = line
  121 + break
  122 + endif
  123 + if m[3] < path
  124 + let appendline = line
  125 + endif
  126 + if a:localname != '' && m[2] != ''
  127 + let qlocalpath = printf("%s %" . len(m[2])-1 . "s", a:localname, qpath)
  128 + endif
  129 + let appendstr = 'import' . m[1] . qlocalpath
  130 + endif
  131 +
  132 + elseif linestr =~# '^\(var\|const\|type\|func\)\>'
  133 + break
  134 +
  135 + endif
  136 + let line = line + 1
  137 + endwhile
  138 +
  139 + " Append or remove the package import, as requested.
  140 + if a:enabled
  141 + if deleteline != -1
  142 + call s:Error(qpath . ' already being imported')
  143 + elseif appendline == -1
  144 + call s:Error('No package line found')
  145 + else
  146 + if appendline == packageline
  147 + call append(appendline + 0, '')
  148 + call append(appendline + 1, 'import (')
  149 + call append(appendline + 2, ')')
  150 + let appendline += 2
  151 + let linesdelta += 3
  152 + let appendstr = qlocalpath
  153 + let indentstr = 1
  154 + endif
  155 + call append(appendline, appendstr)
  156 + execute appendline + 1
  157 + if indentstr
  158 + execute 'normal >>'
  159 + endif
  160 + let linesdelta += 1
  161 + endif
  162 + else
  163 + if deleteline == -1
  164 + call s:Error(qpath . ' not being imported')
  165 + else
  166 + execute deleteline . 'd'
  167 + let linesdelta -= 1
  168 +
  169 + if getline(deleteline-1) =~# '^import\s\+(' && getline(deleteline) =~# '^)'
  170 + " Delete empty import block
  171 + let deleteline -= 1
  172 + execute deleteline . "d"
  173 + execute deleteline . "d"
  174 + let linesdelta -= 2
  175 + endif
  176 +
  177 + if getline(deleteline) == '' && getline(deleteline - 1) == ''
  178 + " Delete spacing for removed line too.
  179 + execute deleteline . "d"
  180 + let linesdelta -= 1
  181 + endif
  182 + endif
  183 + endif
  184 +
  185 + " Adjust view for any changes.
  186 + let view.lnum += linesdelta
  187 + let view.topline += linesdelta
  188 + if view.topline < 0
  189 + let view.topline = 0
  190 + endif
  191 +
  192 + " Put buffer back where it was.
  193 + call winrestview(view)
  194 +
  195 +endfunction
  196 +
  197 +function! s:Error(s)
  198 + echohl Error | echo a:s | echohl None
  199 +endfunction
  200 +
  201 +" vim:ts=4:sw=4:et
65 bundle/go.vim/indent/go.vim
... ... @@ -0,0 +1,65 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" indent/go.vim: Vim indent file for Go.
  6 +"
  7 +" TODO:
  8 +" - function invocations split across lines
  9 +" - general line splits (line ends in an operator)
  10 +
  11 +if exists("b:did_indent")
  12 + finish
  13 +endif
  14 +let b:did_indent = 1
  15 +
  16 +" C indentation is too far off useful, mainly due to Go's := operator.
  17 +" Let's just define our own.
  18 +setlocal nolisp
  19 +setlocal autoindent
  20 +setlocal indentexpr=GoIndent(v:lnum)
  21 +setlocal indentkeys+=<:>,0=},0=)
  22 +
  23 +if exists("*GoIndent")
  24 + finish
  25 +endif
  26 +
  27 +function! GoIndent(lnum)
  28 + let prevlnum = prevnonblank(a:lnum-1)
  29 + if prevlnum == 0
  30 + " top of file
  31 + return 0
  32 + endif
  33 +
  34 + " grab the previous and current line, stripping comments.
  35 + let prevl = substitute(getline(prevlnum), '//.*$', '', '')
  36 + let thisl = substitute(getline(a:lnum), '//.*$', '', '')
  37 + let previ = indent(prevlnum)
  38 +
  39 + let ind = previ
  40 +
  41 + if prevl =~ '[({]\s*$'
  42 + " previous line opened a block
  43 + let ind += &sw
  44 + endif
  45 + if prevl =~# '^\s*\(case .*\|default\):$'
  46 + " previous line is part of a switch statement
  47 + let ind += &sw
  48 + endif
  49 + " TODO: handle if the previous line is a label.
  50 +
  51 + if thisl =~ '^\s*[)}]'
  52 + " this line closed a block
  53 + let ind -= &sw
  54 + endif
  55 +
  56 + " Colons are tricky.
  57 + " We want to outdent if it's part of a switch ("case foo:" or "default:").
  58 + " We ignore trying to deal with jump labels because (a) they're rare, and
  59 + " (b) they're hard to disambiguate from a composite literal key.
  60 + if thisl =~# '^\s*\(case .*\|default\):$'
  61 + let ind -= &sw
  62 + endif
  63 +
  64 + return ind
  65 +endfunction
85 bundle/go.vim/plugin/godoc.vim
... ... @@ -0,0 +1,85 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" godoc.vim: Vim command to see godoc.
  6 +
  7 +if exists("g:loaded_godoc")
  8 + finish
  9 +endif
  10 +let g:loaded_godoc = 1
  11 +
  12 +let s:buf_nr = -1
  13 +let s:last_word = ''
  14 +
  15 +function! s:GodocView()
  16 + if !bufexists(s:buf_nr)
  17 + leftabove new
  18 + file `="[Godoc]"`
  19 + let s:buf_nr = bufnr('%')
  20 + elseif bufwinnr(s:buf_nr) == -1
  21 + leftabove split
  22 + execute s:buf_nr . 'buffer'
  23 + delete _
  24 + elseif bufwinnr(s:buf_nr) != bufwinnr('%')
  25 + execute bufwinnr(s:buf_nr) . 'wincmd w'
  26 + endif
  27 +
  28 + setlocal filetype=godoc
  29 + setlocal bufhidden=delete
  30 + setlocal buftype=nofile
  31 + setlocal noswapfile
  32 + setlocal nobuflisted
  33 + setlocal modifiable
  34 + setlocal nocursorline
  35 + setlocal nocursorcolumn
  36 + setlocal iskeyword+=:
  37 + setlocal iskeyword-=-
  38 +
  39 + nnoremap <buffer> <silent> K :Godoc<cr>
  40 +
  41 + au BufHidden <buffer> call let <SID>buf_nr = -1
  42 +endfunction
  43 +
  44 +function! s:GodocWord(word)
  45 + let word = a:word
  46 + silent! let content = system('godoc ' . word)
  47 + if v:shell_error || !len(content)
  48 + if len(s:last_word)
  49 + silent! let content = system('godoc ' . s:last_word.'/'.word)
  50 + if v:shell_error || !len(content)
  51 + echo 'No documentation found for "' . word . '".'
  52 + return
  53 + endif
  54 + let word = s:last_word.'/'.word
  55 + else
  56 + echo 'No documentation found for "' . word . '".'
  57 + return
  58 + endif
  59 + endif
  60 + let s:last_word = word
  61 + silent! call s:GodocView()
  62 + setlocal modifiable
  63 + silent! %d _
  64 + silent! put! =content
  65 + silent! normal gg
  66 + setlocal nomodifiable
  67 + setfiletype godoc
  68 +endfunction
  69 +
  70 +function! s:Godoc(...)
  71 + let word = join(a:000, ' ')
  72 + if !len(word)
  73 + let word = expand('<cword>')
  74 + endif
  75 + let word = substitute(word, '[^a-zA-Z0-9\/]', '', 'g')
  76 + if !len(word)
  77 + return
  78 + endif
  79 + call s:GodocWord(word)
  80 +endfunction
  81 +
  82 +command! -nargs=* -range -complete=customlist,go#complete#Package Godoc :call s:Godoc(<q-args>)
  83 +nnoremap <silent> <Plug>(godoc-keyword) :<C-u>call <SID>Godoc('')<CR>
  84 +
  85 +" vim:ts=4:sw=4:et
76 bundle/go.vim/readme.txt
... ... @@ -0,0 +1,76 @@
  1 +Vim plugins for Go (http://golang.org)
  2 +======================================
  3 +
  4 +To use all the Vim plugins, add these lines to your vimrc.
  5 +
  6 + set rtp+=$GOROOT/misc/vim
  7 + filetype plugin indent on
  8 + syntax on
  9 +
  10 +If you want to select fewer plugins, use the instructions in the rest of
  11 +this file.
  12 +
  13 +Vim syntax highlighting
  14 +-----------------------
  15 +
  16 +To install automatic syntax highlighting for GO programs:
  17 +
  18 + 1. Copy or link the filetype detection script to the ftdetect directory
  19 + underneath your vim runtime directory (normally $HOME/.vim/ftdetect)
  20 + 2. Copy or link syntax/go.vim to the syntax directory underneath your vim
  21 + runtime directory (normally $HOME/.vim/syntax). Linking this file rather
  22 + than just copying it will ensure any changes are automatically reflected
  23 + in your syntax highlighting.
  24 + 3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
  25 +
  26 + syntax on
  27 +
  28 +In a typical unix environment you might accomplish this using the following
  29 +commands:
  30 +
  31 + mkdir -p $HOME/.vim/ftdetect
  32 + mkdir -p $HOME/.vim/syntax
  33 + mkdir -p $HOME/.vim/autoload/go
  34 + ln -s $GOROOT/misc/vim/ftdetect/gofiletype.vim $HOME/.vim/ftdetect/
  35 + ln -s $GOROOT/misc/vim/syntax/go.vim $HOME/.vim/syntax
  36 + ln -s $GOROOT/misc/vim/autoload/go/complete.vim $HOME/.vim/autoload/go
  37 + echo "syntax on" >> $HOME/.vimrc
  38 +
  39 +
  40 +Vim filetype plugins
  41 +--------------------
  42 +
  43 +To install one of the available filetype plugins:
  44 +
  45 + 1. Same as 1 above.
  46 + 2. Copy or link one or more plugins from ftplugin/go/*.vim to the
  47 + Go-specific ftplugin directory underneath your vim runtime directory
  48 + (normally $HOME/.vim/ftplugin/go/*.vim).
  49 + 3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
  50 +
  51 + filetype plugin on
  52 +
  53 +
  54 +Vim indentation plugin
  55 +----------------------
  56 +
  57 +To install automatic indentation:
  58 +
  59 + 1. Same as 1 above.
  60 + 2. Copy or link indent/go.vim to the indent directory underneath your vim
  61 + runtime directory (normally $HOME/.vim/indent).
  62 + 3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
  63 +
  64 + filetype indent on
  65 +
  66 +
  67 +Godoc plugin
  68 +------------
  69 +
  70 +To install godoc plugin:
  71 +
  72 + 1. Same as 1 above.
  73 + 2. Copy or link plugin/godoc.vim to $HOME/.vim/plugin/godoc,
  74 + syntax/godoc.vim to $HOME/.vim/syntax/godoc.vim,
  75 + ftplugin/go/godoc.vim to $HOME/.vim/ftplugin/go/godoc.vim.
  76 + and autoload/go/complete.vim to $HOME/.vim/autoload/go/complete.vim.
207 bundle/go.vim/syntax/go.vim
... ... @@ -0,0 +1,207 @@
  1 +" Copyright 2009 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +"
  5 +" go.vim: Vim syntax file for Go.
  6 +"
  7 +" Options:
  8 +" There are some options for customizing the highlighting; the recommended
  9 +" settings are the default values, but you can write:
  10 +" let OPTION_NAME = 0
  11 +" in your ~/.vimrc file to disable particular options. You can also write:
  12 +" let OPTION_NAME = 1
  13 +" to enable particular options. At present, all options default to on.
  14 +"
  15 +" - go_highlight_array_whitespace_error
  16 +" Highlights white space after "[]".
  17 +" - go_highlight_chan_whitespace_error
  18 +" Highlights white space around the communications operator that don't follow
  19 +" the standard style.
  20 +" - go_highlight_extra_types
  21 +" Highlights commonly used library types (io.Reader, etc.).
  22 +" - go_highlight_space_tab_error
  23 +" Highlights instances of tabs following spaces.
  24 +" - go_highlight_trailing_whitespace_error
  25 +" Highlights trailing white space.
  26 +
  27 +" Quit when a (custom) syntax file was already loaded
  28 +if exists("b:current_syntax")
  29 + finish
  30 +endif
  31 +
  32 +if !exists("go_highlight_array_whitespace_error")
  33 + let go_highlight_array_whitespace_error = 1
  34 +endif
  35 +if !exists("go_highlight_chan_whitespace_error")
  36 + let go_highlight_chan_whitespace_error = 1
  37 +endif
  38 +if !exists("go_highlight_extra_types")
  39 + let go_highlight_extra_types = 1
  40 +endif
  41 +if !exists("go_highlight_space_tab_error")
  42 + let go_highlight_space_tab_error = 1
  43 +endif
  44 +if !exists("go_highlight_trailing_whitespace_error")
  45 + let go_highlight_trailing_whitespace_error = 1
  46 +endif
  47 +
  48 +syn case match
  49 +
  50 +syn keyword goDirective package import
  51 +syn keyword goDeclaration var const type
  52 +syn keyword goDeclType struct interface
  53 +
  54 +hi def link goDirective Statement
  55 +hi def link goDeclaration Keyword
  56 +hi def link goDeclType Keyword
  57 +
  58 +" Keywords within functions
  59 +syn keyword goStatement defer go goto return break continue fallthrough
  60 +syn keyword goConditional if else switch select
  61 +syn keyword goLabel case default
  62 +syn keyword goRepeat for range
  63 +
  64 +hi def link goStatement Statement
  65 +hi def link goConditional Conditional
  66 +hi def link goLabel Label
  67 +hi def link goRepeat Repeat
  68 +
  69 +" Predefined types
  70 +syn keyword goType chan map bool string error
  71 +syn keyword goSignedInts int int8 int16 int32 int64 rune
  72 +syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr
  73 +syn keyword goFloats float32 float64
  74 +syn keyword goComplexes complex64 complex128
  75 +
  76 +hi def link goType Type
  77 +hi def link goSignedInts Type
  78 +hi def link goUnsignedInts Type
  79 +hi def link goFloats Type
  80 +hi def link goComplexes Type
  81 +
  82 +" Treat func specially: it's a declaration at the start of a line, but a type
  83 +" elsewhere. Order matters here.
  84 +syn match goType /\<func\>/
  85 +syn match goDeclaration /^func\>/
  86 +
  87 +" Predefined functions and values
  88 +syn keyword goBuiltins append cap close complex copy delete imag len
  89 +syn keyword goBuiltins make new panic print println real recover
  90 +syn keyword goConstants iota true false nil
  91 +
  92 +hi def link goBuiltins Keyword
  93 +hi def link goConstants Keyword
  94 +
  95 +" Comments; their contents
  96 +syn keyword goTodo contained TODO FIXME XXX BUG
  97 +syn cluster goCommentGroup contains=goTodo
  98 +syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
  99 +syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell
  100 +
  101 +hi def link goComment Comment
  102 +hi def link goTodo Todo
  103 +
  104 +" Go escapes
  105 +syn match goEscapeOctal display contained "\\[0-7]\{3}"
  106 +syn match goEscapeC display contained +\\[abfnrtv\\'"]+
  107 +syn match goEscapeX display contained "\\x\x\{2}"
  108 +syn match goEscapeU display contained "\\u\x\{4}"
  109 +syn match goEscapeBigU display contained "\\U\x\{8}"
  110 +syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
  111 +
  112 +hi def link goEscapeOctal goSpecialString
  113 +hi def link goEscapeC goSpecialString
  114 +hi def link goEscapeX goSpecialString
  115 +hi def link goEscapeU goSpecialString
  116 +hi def link goEscapeBigU goSpecialString
  117 +hi def link goSpecialString Special
  118 +hi def link goEscapeError Error
  119 +
  120 +" Strings and their contents
  121 +syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError
  122 +syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
  123 +syn region goRawString start=+`+ end=+`+
  124 +
  125 +hi def link goString String
  126 +hi def link goRawString String
  127 +
  128 +" Characters; their contents
  129 +syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU
  130 +syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup
  131 +
  132 +hi def link goCharacter Character
  133 +
  134 +" Regions
  135 +syn region goBlock start="{" end="}" transparent fold
  136 +syn region goParen start='(' end=')' transparent
  137 +
  138 +" Integers
  139 +syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
  140 +syn match goHexadecimalInt "\<0x\x\+\>"
  141 +syn match goOctalInt "\<0\o\+\>"
  142 +syn match goOctalError "\<0\o*[89]\d*\>"
  143 +
  144 +hi def link goDecimalInt Integer
  145 +hi def link goHexadecimalInt Integer
  146 +hi def link goOctalInt Integer
  147 +hi def link Integer Number
  148 +
  149 +" Floating point
  150 +syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
  151 +syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
  152 +syn match goFloat "\<\d\+[Ee][-+]\d\+\>"
  153 +
  154 +hi def link goFloat Float
  155 +
  156 +" Imaginary literals
  157 +syn match goImaginary "\<\d\+i\>"
  158 +syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
  159 +syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
  160 +syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>"
  161 +
  162 +hi def link goImaginary Number
  163 +
  164 +" Spaces after "[]"
  165 +if go_highlight_array_whitespace_error != 0
  166 + syn match goSpaceError display "\(\[\]\)\@<=\s\+"
  167 +endif
  168 +
  169 +" Spacing errors around the 'chan' keyword
  170 +if go_highlight_chan_whitespace_error != 0
  171 + " receive-only annotation on chan type
  172 + syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@="
  173 + " send-only annotation on chan type
  174 + syn match goSpaceError display "\(\<chan\)\@<=\s\+\(<-\)\@="
  175 + " value-ignoring receives in a few contexts
  176 + syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
  177 +endif
  178 +
  179 +" Extra types commonly seen
  180 +if go_highlight_extra_types != 0
  181 + syn match goExtraType /\<bytes\.\(Buffer\)\>/
  182 + syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
  183 + syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
  184 + syn match goExtraType /\<unsafe\.Pointer\>/
  185 +endif
  186 +
  187 +" Space-tab error
  188 +if go_highlight_space_tab_error != 0
  189 + syn match goSpaceError display " \+\t"me=e-1
  190 +endif
  191 +
  192 +" Trailing white space error
  193 +if go_highlight_trailing_whitespace_error != 0
  194 + syn match goSpaceError display excludenl "\s\+$"
  195 +endif
  196 +
  197 +hi def link goExtraType Type
  198 +hi def link goSpaceError Error
  199 +
  200 +" Search backwards for a global declaration to start processing the syntax.
  201 +"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/
  202 +
  203 +" There's a bug in the implementation of grouphere. For now, use the
  204 +" following as a more expensive/less precise workaround.
  205 +syn sync minlines=500
  206 +
  207 +let b:current_syntax = "go"
20 bundle/go.vim/syntax/godoc.vim
... ... @@ -0,0 +1,20 @@
  1 +" Copyright 2011 The Go Authors. All rights reserved.
  2 +" Use of this source code is governed by a BSD-style
  3 +" license that can be found in the LICENSE file.
  4 +
  5 +if exists("b:current_syntax")
  6 + finish
  7 +endif
  8 +
  9 +syn case match
  10 +syn match godocTitle "^\([A-Z]*\)$"
  11 +
  12 +command -nargs=+ HiLink hi def link <args>
  13 +
  14 +HiLink godocTitle Title
  15 +
  16 +delcommand HiLink
  17 +
  18 +let b:current_syntax = "godoc"
  19 +
  20 +" vim:ts=4 sts=2 sw=2:
65 vimrc
... ... @@ -1,3 +1,37 @@
  1 +""" Vundle config start
  2 +set nocompatible " choose no compatibility with legacy vi
  3 +filetype off " required!
  4 +set rtp+=~/.vim/bundle/vundle/
  5 +call vundle#rc()
  6 +Bundle 'gmarik/vundle'
  7 +
  8 +" My Bundles here:
  9 +"
  10 +" original repos on github
  11 +Bundle 'Lokaltog/vim-powerline'
  12 +Bundle 'altercation/vim-colors-solarized'
  13 +Bundle 'aniero/vim-copy-as-rtf'
  14 +Bundle 'kana/vim-fakeclip'
  15 +Bundle 'kana/vim-textobj-user'
  16 +Bundle 'kien/ctrlp.vim'
  17 +Bundle 'mileszs/ack.vim'
  18 +Bundle 'nelstrom/vim-textobj-rubyblock'
  19 +Bundle 'ralph/go.vim'
  20 +Bundle 'scrooloose/nerdtree'
  21 +Bundle 'tomtom/tcomment_vim'
  22 +Bundle 'tpope/vim-fugitive'
  23 +Bundle 'tpope/vim-ragtag'
  24 +Bundle 'tpope/vim-rails'
  25 +Bundle 'tpope/vim-surround'
  26 +Bundle 'vim-ruby/vim-ruby'
  27 +Bundle 'vim-scripts/YankRing.vim'
  28 +filetype plugin indent on " required!
  29 +""" Vundle config end
  30 +
  31 +
  32 +
  33 +
  34 +
1 35 "" General settings
2 36 set nocompatible " choose no compatibility with legacy vi
3 37 syntax enable
@@ -19,9 +53,6 @@ set incsearch " incremental searching
19 53 set ignorecase " searches are case insensitive...
20 54 set smartcase " ... unless they contain at least one capital letter
21 55
22   -"" Pathogen
23   -call pathogen#infect()
24   -
25 56 "" Color scheme
26 57 set background=light
27 58 colorscheme solarized
@@ -72,31 +103,3 @@ nnoremap <leader><space> :nohl<cr> " un-highlight search results
72 103 map <F5> :call system('pbcopy', @%)<cr> " Copy file path to clipboard
73 104 map <leader>p :CtrlP<cr>
74 105 map <leader>b :CtrlPBuffer<cr>
75   -
76   -
77   -
78   -filetype off " required!
79   -set rtp+=~/.vim/bundle/vundle/
80   -call vundle#rc()
81   -Bundle 'gmarik/vundle'
82   -
83   -" My Bundles here:
84   -"
85   -" original repos on github
86   -Bundle 'Lokaltog/vim-powerline'
87   -Bundle 'altercation/vim-colors-solarized'
88   -Bundle 'aniero/vim-copy-as-rtf'
89   -Bundle 'kana/vim-fakeclip'
90   -Bundle 'kana/vim-textobj-user'
91   -Bundle 'kien/ctrlp.vim'
92   -Bundle 'mileszs/ack.vim'
93   -Bundle 'nelstrom/vim-textobj-rubyblock'
94   -Bundle 'scrooloose/nerdtree'
95   -Bundle 'tomtom/tcomment_vim'
96   -Bundle 'tpope/vim-fugitive'
97   -Bundle 'tpope/vim-ragtag'
98   -Bundle 'tpope/vim-rails'
99   -Bundle 'tpope/vim-surround'
100   -Bundle 'vim-ruby/vim-ruby'
101   -Bundle 'vim-scripts/YankRing.vim'
102   -filetype plugin indent on " required!

0 comments on commit 7ccad7d

Please sign in to comment.
Something went wrong with that request. Please try again.