mirror of
https://github.com/raimon49/requirements.txt.vim.git
synced 2026-02-01 21:05:24 +08:00
Merge branch 'support-ci'
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
## Environment normalisation:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
.vim-flavor
|
||||
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 2.2.3
|
||||
script:
|
||||
rake ci
|
||||
3
Gemfile
Normal file
3
Gemfile
Normal file
@@ -0,0 +1,3 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'vim-flavor', '~> 1.1'
|
||||
19
Gemfile.lock
Normal file
19
Gemfile.lock
Normal file
@@ -0,0 +1,19 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
blankslate (3.1.3)
|
||||
parslet (1.7.1)
|
||||
blankslate (>= 2.0, <= 4.0)
|
||||
thor (0.19.1)
|
||||
vim-flavor (1.1.5)
|
||||
parslet (~> 1.0)
|
||||
thor (~> 0.14)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
vim-flavor (~> 1.1)
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
||||
11
Rakefile
Normal file
11
Rakefile
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env rake
|
||||
|
||||
task :ci => [:dump, :test]
|
||||
|
||||
task :dump do
|
||||
sh 'vim --version'
|
||||
end
|
||||
|
||||
task :test do
|
||||
sh 'bundle exec vim-flavor test'
|
||||
end
|
||||
4
VimFlavor
Normal file
4
VimFlavor
Normal file
@@ -0,0 +1,4 @@
|
||||
# Since flavorfile is parsed as a Ruby script,
|
||||
# you can comment out arbitrary lines like this.
|
||||
|
||||
# flavor '$foo_uri', '~> 1.0'
|
||||
1
VimFlavor.lock
Normal file
1
VimFlavor.lock
Normal file
@@ -0,0 +1 @@
|
||||
kana/vim-vspec (1.6.1)
|
||||
33
autoload/requirements.vim
Normal file
33
autoload/requirements.vim
Normal file
@@ -0,0 +1,33 @@
|
||||
" the Requirements File Format syntax support for Vim
|
||||
" Version: 0.1
|
||||
" Author: raimon <raimon49@hotmail.com>
|
||||
" License: MIT LICENSE
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:requirements#detect_filename_pattern')
|
||||
let g:requirements#detect_filename_pattern = ''
|
||||
endif
|
||||
|
||||
|
||||
function! requirements#matched_filename(filename)
|
||||
if a:filename =~# '\v.*require(ment)?s\.(txt|in)$'
|
||||
return 1
|
||||
endif
|
||||
|
||||
if a:filename =~# '\vrequire(ment)?s/.*\.(txt|in)$'
|
||||
return 1
|
||||
endif
|
||||
|
||||
if len(g:requirements#detect_filename_pattern)
|
||||
\ && a:filename =~# g:requirements#detect_filename_pattern
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: et sw=4 ts=4 sts=4:
|
||||
@@ -6,15 +6,7 @@
|
||||
function! s:isRequirementsFile()
|
||||
let l:filename = expand("%:p")
|
||||
|
||||
if l:filename =~# '\v.*require(ment)?s\.(txt|in)'
|
||||
return 1
|
||||
endif
|
||||
|
||||
if l:filename =~# '\v.require(ment)?s/.*\.(txt|in)'
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
return requirements#matched_filename(l:filename)
|
||||
endfunction
|
||||
|
||||
au BufNewFile,BufRead *.{txt,in} if s:isRequirementsFile() | set ft=requirements
|
||||
|
||||
16
plugin/requirements.vim
Normal file
16
plugin/requirements.vim
Normal file
@@ -0,0 +1,16 @@
|
||||
" the Requirements File Format syntax support for Vim
|
||||
" Version: 0.1
|
||||
" Author: raimon <raimon49@hotmail.com>
|
||||
" License: MIT LICENSE
|
||||
|
||||
if exists('g:loaded_requirements')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_requirements = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: et sw=4 ts=4 sts=4:
|
||||
43
t/test_ftdetect.vim
Normal file
43
t/test_ftdetect.vim
Normal file
@@ -0,0 +1,43 @@
|
||||
filetype plugin on
|
||||
runtime! plugin/requirements.vim
|
||||
|
||||
describe 'enable: requirements#matched_filename()'
|
||||
it 'to enable file type detection: basic filename'
|
||||
Expect requirements#matched_filename('requirements.txt') to_be_true
|
||||
Expect requirements#matched_filename('requires.txt') to_be_true
|
||||
end
|
||||
|
||||
it 'to enable file type detection: pip-tools filename'
|
||||
Expect requirements#matched_filename('requirements.in') to_be_true
|
||||
Expect requirements#matched_filename('requires.in') to_be_true
|
||||
end
|
||||
|
||||
it 'to enable file type detection: directory structure'
|
||||
Expect requirements#matched_filename('requirements/dev.txt') to_be_true
|
||||
Expect requirements#matched_filename('requires/tests.in') to_be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'disable: requirements#matched_filename()'
|
||||
it 'to enable file type detection: basic filename'
|
||||
Expect requirements#matched_filename('requirements.text') to_be_false
|
||||
end
|
||||
|
||||
it 'to enable file type detection: pip-tools filename'
|
||||
Expect requirements#matched_filename('requirements.ini') to_be_false
|
||||
end
|
||||
|
||||
it 'to enable file type detection: directory structure'
|
||||
Expect requirements#matched_filename('require/dev.txt') to_be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'g:requirements#detect_filename_pattern'
|
||||
it 'use g:requirements#detect_filename_pattern'
|
||||
Expect requirements#matched_filename('freeze.txt') to_be_false
|
||||
let g:requirements#detect_filename_pattern = 'freeze'
|
||||
Expect requirements#matched_filename('freeze.txt') to_be_true
|
||||
end
|
||||
end
|
||||
|
||||
" vim: et sw=4 ts=4 sts=4:
|
||||
Reference in New Issue
Block a user