Remove old vendored classpath.vim

This commit is contained in:
Tim Pope 2013-03-12 15:37:58 -04:00
parent 1a8eab85d9
commit fa6e35bc19
4 changed files with 3 additions and 182 deletions

View File

@ -97,22 +97,10 @@ Because why not? It works in the quasi-REPL too.
> Why does it take so long for Vim to startup?
The short answer is because the JVM is slow.
See the [classpath.vim FAQ][]. You can uninstall classpath.vim if you only
care about nREPL support.
The first time you load a Clojure file from any given project, foreplay.vim
sets about trying to determine your class path, leveraging either
`lein classpath` or `mvn dependency:build-classpath`. This takes a couple of
seconds or so in the best case scenario, and potentially much longer if it
decides to hit the network. (I don't understand why "tell me the class path"
requires hitting the network, but what do I know?)
Because the class path is oh-so-expensive to retrieve, foreplay.vim caches it
in `g:CLASSPATH_CACHE`. By default, this disappears when you exit Vim, but
you can save it across sessions in `.viminfo` with this handy option:
set viminfo+=!
The cache is expired when the timestamp on `project.clj` or `pom.xml` changes.
[classpath.vim FAQ]: https://github.com/tpope/vim-classpath#FAQ
## Contributing

View File

@ -1,133 +0,0 @@
" autoload/classpath.vim
" Maintainer: Tim Pope <http://tpo.pe>
if exists("g:autoloaded_classpath")
finish
endif
let g:autoloaded_classpath = 1
function! classpath#separator() abort
return has('win32') ? ';' : ':'
endfunction
function! classpath#file_separator() abort
return exists('shellslash') && !&shellslash ? '\' : '/'
endfunction
function! classpath#split(cp) abort
return split(a:cp, classpath#separator())
endfunction
function! classpath#to_vim(cp) abort
let path = []
for elem in classpath#split(a:cp)
let path += [elem ==# '.' ? '' : elem]
endfor
if a:cp =~# '\(^\|:\)\.$'
let path += ['']
endif
return join(map(path, 'escape(v:val, ", ")'), ',')
endfunction
function! classpath#from_vim(path) abort
if a:path =~# '^,\=$'
return '.'
endif
let path = []
for elem in split(substitute(a:path, ',$', '', ''), ',')
if elem ==# ''
let path += ['.']
else
let path += split(glob(substitute(elem, '\\\ze[\\ ,]', '', 'g'), 1), "\n")
endif
endfor
return join(path, classpath#separator())
endfunction
function! classpath#detect(...) abort
let sep = classpath#file_separator()
let buffer = a:0 ? a:1 : '%'
let default = $CLASSPATH ==# '' ? ',' : classpath#to_vim($CLASSPATH)
let root = getbufvar(buffer, 'java_root')
if root ==# ''
let root = simplify(fnamemodify(bufname(buffer), ':p:s?[\/]$??'))
endif
if !isdirectory(fnamemodify(root, ':h'))
return default
endif
let previous = ""
while root !=# previous
if isdirectory(root . '/src')
if filereadable(root . '/project.clj')
let file = 'project.clj'
let cmd = 'lein classpath'
let pattern = "[^\n]*\\ze\n*$"
let default = join(map(['test', 'src', 'dev-resources', 'resources', 'target'.sep.'classes'], 'escape(root . sep . v:val, ", ")'), ',')
let base = ''
break
endif
if filereadable(root . '/pom.xml')
let file = 'pom.xml'
let cmd = 'mvn dependency:build-classpath'
let pattern = '\%(^\|\n\)\zs[^[].\{-\}\ze\n'
let base = escape(root.sep.'src'.sep.'*'.sep.'*', ', ') . ','
let default = base . default
break
endif
endif
let previous = root
let root = fnamemodify(root, ':h')
endwhile
if !exists('file')
if a:0 > 1 && a:2 ==# 'keep'
return ''
else
return default
endif
endif
if !exists('g:CLASSPATH_CACHE') || type(g:CLASSPATH_CACHE) != type({})
unlet! g:CLASSPATH_CACHE
let g:CLASSPATH_CACHE = {}
endif
let [when, last, path] = split(get(g:CLASSPATH_CACHE, root, "-1\t-1\t."), "\t")
let disk = getftime(root . sep . file)
if last ==# disk
return path
else
try
if &verbose
echomsg 'Determining class path with '.cmd.' ...'
endif
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
try
execute cd . fnameescape(root)
let out = system(cmd)
finally
execute cd . fnameescape(dir)
endtry
catch /^Vim:Interrupt/
return default
endtry
let match = matchstr(out, pattern)
if !v:shell_error && exists('out') && out !=# ''
let path = base . classpath#to_vim(match)
let g:CLASSPATH_CACHE[root] = localtime() . "\t" . disk . "\t" . path
return path
else
echohl WarningMSG
echomsg "Couldn't determine class path."
echohl NONE
echo out
return default
endif
endif
endfunction
" vim:set et sw=2:

View File

@ -7,17 +7,6 @@ This plugin is only available if 'compatible' is not set.
You need Clojure runtime files to use this plugin. Try vim-clojure-static.
CLASSPATH *foreplay-classpath*
Upon loading a Clojure buffer, the 'path' option is automatically set to your
class path. The class path is found by `lein classpath`, `mvn
dependency:build-classpath`, or failing both of those, $CLASSPATH.
This behavior is going away soon. Install classpath.vim if you'd like to keep
it.
https://github.com/tpope/vim-classpath
CONNECTING TO A REPL *foreplay-connect*
Connecting to lein repl happens automatically. If you have a different setup,

View File

@ -1,23 +0,0 @@
" classpath.vim - Set 'path' from the Java class path
" Maintainer: Tim Pope <http://tpo.pe/>
if exists('g:no_foreplay_classpath') || exists("g:loaded_classpath") || v:version < 700 || &cp
finish
endif
let g:loaded_classpath = 1
if &viminfo !~# '!'
set viminfo+=!
endif
augroup classpath
autocmd!
autocmd FileType clojure
\ if expand('%:p') =~# '^zipfile:' |
\ let &l:path = getbufvar('#', '&path') |
\ else |
\ let &l:path = classpath#detect() |
\ endif
augroup END
" vim:set et sw=2: