mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-16 07:23:48 -05:00
Run a build and commit the results
This commit is contained in:
@@ -3,46 +3,31 @@ if polyglot#init#is_disabled(expand('<sfile>:p'), 'requirements', 'autoload/requ
|
||||
endif
|
||||
|
||||
""
|
||||
" @section Introduction, intro
|
||||
" @library
|
||||
" <doc/@plugin(name).txt> is generated by <https://github.com/google/vimdoc>.
|
||||
" See <README.md> for more information about installation and screenshots.
|
||||
" Refer https://github.com/vim/vim/blob/75e27d78f5370e7d2e0898326d9b080937e7b090/runtime/scripts.vim#L33-L71
|
||||
"
|
||||
" When a file's shebang is "pip install -r" or "pip-compile",
|
||||
" set its filetype to |requirements|.
|
||||
function! requirements#shebang() abort
|
||||
let s:line1 = getline(1)
|
||||
|
||||
""
|
||||
" Update cache.
|
||||
function! requirements#update_cache() abort
|
||||
let s:items = []
|
||||
let l:pip_items = split(system('COMP_WORDS="pip install -" COMP_CWORD=2 PIP_AUTO_COMPLETE=1 pip'))
|
||||
let l:pypi_items = split(system('pip-cache pkgnames'))
|
||||
for l:item in l:pip_items
|
||||
let s:items += [{'word': l:item, 'menu': 'pip'}]
|
||||
endfor
|
||||
for l:item in l:pypi_items
|
||||
let s:items += [{'word': l:item, 'menu': 'pypi'}]
|
||||
endfor
|
||||
call writefile([json_encode(s:items)], s:cache)
|
||||
if s:line1 =~# "^#!"
|
||||
if s:line1 =~# '^#!\s*\S*\<env\s'
|
||||
let s:line1 = substitute(s:line1, '\S\+=\S\+', '', 'g')
|
||||
let s:line1 = substitute(s:line1, '\(-[iS]\|--ignore-environment\|--split-string\)', '', '')
|
||||
let s:line1 = substitute(s:line1, '\<env\s\+', '', '')
|
||||
endif
|
||||
if s:line1 =~# '^#!\s*\a:[/\\]'
|
||||
let s:name = substitute(s:line1, '^#!.*[/\\]\(\i\+\).*', '\1', '')
|
||||
elseif s:line1 =~# '^#!.*\<env\>'
|
||||
let s:name = substitute(s:line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '')
|
||||
elseif s:line1 =~# '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)'
|
||||
let s:name = substitute(s:line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '')
|
||||
else
|
||||
let s:name = substitute(s:line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '')
|
||||
endif
|
||||
if s:name =~# '^pip'
|
||||
set ft=requirements
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if exists('*stdpath')
|
||||
let s:cache_dir_home = stdpath('cache')
|
||||
else
|
||||
let s:cache_dir_home = $HOME . '/.cache/nvim'
|
||||
endif
|
||||
let s:cache_dir = s:cache_dir_home . '/requirements.vim'
|
||||
call mkdir(s:cache_dir, 'p')
|
||||
""
|
||||
" Completion cache path.
|
||||
call g:requirements#utils#plugin.Flag('g:requirements#cache',
|
||||
\ s:cache_dir . '/requirements.json'
|
||||
\ )
|
||||
let s:cache = g:requirements#cache
|
||||
try
|
||||
let s:items = json_decode(readfile(s:cache)[0])
|
||||
catch /\v^Vim%(\(\a+\))?:E(684|484|491):/
|
||||
call requirements#update_cache()
|
||||
let s:items = json_decode(readfile(s:cache)[0])
|
||||
endtry
|
||||
""
|
||||
" Completion cache contents. For program.
|
||||
call g:requirements#utils#plugin.Flag('g:requirements#items', s:items)
|
||||
" vim: et sw=4 ts=4 sts=4:
|
||||
|
||||
Reference in New Issue
Block a user