comparison runtime/syntax/requirements.vim @ 34938:84bd7cb1251d v9.1.0326

patch 9.1.0326: filetype: some requirements files are not recognized Commit: https://github.com/vim/vim/commit/f9f5424d3e75bbdb35aa48fa6f9241d9479b35e8 Author: Wu, Zhenyu <wuzhenyu@ustc.edu> Date: Sun Apr 14 20:38:24 2024 +0200 patch 9.1.0326: filetype: some requirements files are not recognized Problem: filetype: some requirements files are not recognized Solution: Detect '*-requirements.txt', 'constraints.txt', 'requirements.in', 'requirements/*.txt' and 'requires/*.txt' as requirements filetype, include pip compiler, include requirements filetype and syntax plugin (Wu, Zhenyu, @raimon49) closes: #14379 Co-authored-by: raimon <raimon49@hotmail.com> Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 14 Apr 2024 20:45:08 +0200
parents
children
comparison
equal deleted inserted replaced
34937:ee7394ed5f9c 34938:84bd7cb1251d
1 " the Requirements File Format syntax support for Vim
2 " Version: 1.8.0
3 " Author: raimon <raimon49@hotmail.com>
4 " Upstream: https://github.com/raimon49/requirements.txt.vim
5 " License: MIT LICENSE
6 " The MIT License (MIT)
7 "
8 " Copyright (c) 2015 raimon
9 "
10 " Permission is hereby granted, free of charge, to any person obtaining a copy
11 " of this software and associated documentation files (the "Software"), to deal
12 " in the Software without restriction, including without limitation the rights
13 " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 " copies of the Software, and to permit persons to whom the Software is
15 " furnished to do so, subject to the following conditions:
16 "
17 " The above copyright notice and this permission notice shall be included in all
18 " copies or substantial portions of the Software.
19 "
20 " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 " SOFTWARE.
27
28 if exists("b:current_syntax") && b:current_syntax == "requirements"
29 finish
30 endif
31
32 syn case match
33
34 " https://pip.pypa.io/en/stable/reference/requirements-file-format/
35 " https://pip.pypa.io/en/stable/reference/inspect-report/#example
36 syn keyword requirementsKeyword implementation_name implementation_version os_name platform_machine platform_release platform_system platform_version python_full_version platform_python_implementation python_version sys_platform contained
37 syn region requirementsSubst matchgroup=requirementsSubstDelim start="\V${" end="\V}"
38 syn region requirementsString matchgroup=requirementsStringDelim start=`'` skip=`\\'` end=`'`
39 syn region requirementsString matchgroup=requirementsStringDelim start=`"` skip=`\\"` end=`"`
40 syn match requirementsVersion "\v\d+[a-zA-Z0-9\.\-\*]*"
41 syn region requirementsComment start="[ \t]*#" end="$"
42 syn match requirementsCommandOption "\v^\[?--?[a-zA-Z\-]*\]?"
43 syn match requirementsVersionSpecifiers "\v(\=\=\=?|\<\=?|\>\=?|\~\=|\!\=)"
44 syn match requirementsPackageName "\v^([a-zA-Z0-9][a-zA-Z0-9\-_\.]*[a-zA-Z0-9])"
45 syn match requirementsExtras "\v\[\S+\]"
46 syn match requirementsVersionControls "\v(git\+?|hg\+|svn\+|bzr\+).*://.\S+"
47 syn match requirementsURLs "\v(\@\s)?(https?|ftp|gopher)://?[^\s/$.?#].\S*"
48 syn match requirementsEnvironmentMarkers "\v;\s[^#]+" contains=requirementsKeyword,requirementsVersionSpecifiers,requirementsString
49
50 hi def link requirementsKeyword Keyword
51 hi def link requirementsSubstDelim Delimiter
52 hi def link requirementsSubst PreProc
53 hi def link requirementsStringDelim Delimiter
54 hi def link requirementsString String
55 hi def link requirementsVersion Number
56 hi def link requirementsComment Comment
57 hi def link requirementsCommandOption Special
58 hi def link requirementsVersionSpecifiers Boolean
59 hi def link requirementsPackageName Identifier
60 hi def link requirementsExtras Type
61 hi def link requirementsVersionControls Underlined
62 hi def link requirementsURLs Underlined
63 hi def link requirementsEnvironmentMarkers Macro
64
65 let b:current_syntax = "requirements"
66
67 " vim: et sw=4 ts=4 sts=4: