Add requirements.txt support, closes #507

This commit is contained in:
Adam Stankiewicz
2020-08-18 23:31:31 +02:00
parent f7302d9262
commit 0df1bfa0c5
6 changed files with 104 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->156<!--/Package Count--> packages it consists of.
- It **installs and updates 120+ times faster** than the <!--Package Count-->157<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -156,6 +156,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin)
- [razor](https://github.com/adamclerk/vim-razor) (syntax, indent, ftplugin)
- [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent)
- [requirements](https://github.com/raimon49/requirements.txt.vim) (syntax, autoload)
- [rspec](https://github.com/keith/rspec.vim) (syntax)
- [rst](https://github.com/marshallward/vim-restructuredtext) (syntax, indent, autoload, ftplugin)
- [ruby](https://github.com/vim-ruby/vim-ruby) (syntax, indent, compiler, autoload, ftplugin)

36
autoload/requirements.vim Normal file
View File

@@ -0,0 +1,36 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'requirements') == -1
" the Requirements File Format syntax support for Vim
" Version: 1.5.3
" Author: raimon <raimon49@hotmail.com>
" License: MIT LICENSE
" The MIT License (MIT)
"
" Copyright (c) 2015 raimon
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to deal
" in the Software without restriction, including without limitation the rights
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
" copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in all
" copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
" SOFTWARE.
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:
endif

1
build
View File

@@ -250,6 +250,7 @@ PACKS="
raml:IN3D/vim-raml
razor:adamclerk/vim-razor
reason:reasonml-editor/vim-reason-plus
requirements:raimon49/requirements.txt.vim
rspec:keith/rspec.vim
rst:marshallward/vim-restructuredtext
ruby:vim-ruby/vim-ruby

View File

@@ -257,6 +257,7 @@ language("Jsonnet")
language("Fennel", extensions=[".fnl"])
language("mcfunction")
language("JSONiq", extra_filenames=[".jqrc"], filetype="jq", polyglot="jq")
language("Requirements", extensions=[".pip"], filenames=["*requirements.{txt,in}", "*require.{txt,in}", "constraints.{txt,in}"])
lines.append('" restore Vi compatibility settings')
lines.append('let &cpo = s:cpo_save')

View File

@@ -1160,6 +1160,13 @@ if index(g:polyglot_disabled, 'jq') == -1
au BufNewFile,BufRead {.,}jqrc set ft=jq
endif
if index(g:polyglot_disabled, 'requirements') == -1
au BufNewFile,BufRead *.pip set ft=requirements
au BufNewFile,BufRead *require.{txt,in} set ft=requirements
au BufNewFile,BufRead *requirements.{txt,in} set ft=requirements
au BufNewFile,BufRead constraints.{txt,in} set ft=requirements
endif
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save

57
syntax/requirements.vim Normal file
View File

@@ -0,0 +1,57 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'requirements') == -1
" the Requirements File Format syntax support for Vim
" Version: 1.5.3
" Author: raimon <raimon49@hotmail.com>
" License: MIT LICENSE
" The MIT License (MIT)
"
" Copyright (c) 2015 raimon
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to deal
" in the Software without restriction, including without limitation the rights
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
" copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in all
" copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
" SOFTWARE.
if exists("b:current_syntax") && b:current_syntax == "requirements"
finish
endif
syn case match
syn region requirementsComment start="[ \t]*#" end="$"
syn match requirementsCommandOption "\v^\[?--?[a-zA-Z\-]*\]?"
syn match requirementsVersionSpecifiers "\v(\=\=\=?|\<\=?|\>\=?|\~\=|\!\=)"
syn match requirementsPackageName "\v^([a-zA-Z0-9][a-zA-Z0-9\-_\.]*[a-zA-Z0-9])"
syn match requirementsExtras "\v\[\S+\]"
syn match requirementsVersionControls "\v(git\+?|hg\+|svn\+|bzr\+).*://.\S+"
syn match requirementsURLs "\v(\@\s)?(https?|ftp|gopher)://?[^\s/$.?#].\S*"
syn match requirementsEnvironmentMarkers "\v;\s[^#]+"
hi link requirementsComment Comment
hi link requirementsCommandOption Special
hi link requirementsVersionSpecifiers Boolean
hi link requirementsPackageName Identifier
hi link requirementsExtras Type
hi link requirementsVersionControls Underlined
hi link requirementsURLs Underlined
hi link requirementsEnvironmentMarkers Macro
let b:current_syntax = "requirements"
" vim: et sw=4 ts=4 sts=4:
endif