Merge branch 'master' into 3227-local

This commit is contained in:
Arfon Smith
2016-09-21 20:26:51 -07:00
15 changed files with 311 additions and 24 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
/Gemfile.lock
.bundle/
.idea
benchmark/
lib/linguist/samples.json
/grammars

6
.gitmodules vendored
View File

@@ -22,9 +22,9 @@
[submodule "vendor/grammars/Sublime-REBOL"]
path = vendor/grammars/Sublime-REBOL
url = https://github.com/Oldes/Sublime-REBOL
[submodule "vendor/grammars/Sublime-VimL"]
path = vendor/grammars/Sublime-VimL
url = https://github.com/SalGnt/Sublime-VimL
[submodule "vendor/grammars/language-viml"]
path = vendor/grammars/language-viml
url = https://github.com/Alhadis/language-viml
[submodule "vendor/grammars/ColdFusion"]
path = vendor/grammars/ColdFusion
url = https://github.com/SublimeText/ColdFusion

View File

@@ -103,8 +103,6 @@ vendor/grammars/Sublime-SQF-Language:
vendor/grammars/Sublime-Text-2-OpenEdge-ABL:
- source.abl
- text.html.abl
vendor/grammars/Sublime-VimL:
- source.viml
vendor/grammars/SublimeBrainfuck:
- source.bf
vendor/grammars/SublimeClarion:
@@ -414,6 +412,8 @@ vendor/grammars/language-toc-wow:
- source.toc
vendor/grammars/language-turing:
- source.turing
vendor/grammars/language-viml:
- source.viml
vendor/grammars/language-wavefront:
- source.wavefront.mtl
- source.wavefront.obj

View File

@@ -300,6 +300,7 @@ module Linguist
end
@ace_mode = attributes[:ace_mode]
@codemirror_mode = attributes[:codemirror_mode]
@wrap = attributes[:wrap] || false
# Set legacy search term
@@ -397,6 +398,17 @@ module Linguist
# Returns a String name or nil
attr_reader :ace_mode
# Public: Get Codemirror mode
#
# Examples
#
# # => "nil"
# # => "javascript"
# # => "clike"
#
# Returns a String name or nil
attr_reader :codemirror_mode
# Public: Should language lines be wrapped
#
# Returns true or false

File diff suppressed because it is too large Load Diff

View File

@@ -32,17 +32,67 @@ module Linguist
-\*-
/xi
# First form vim modeline
# [text]{white}{vi:|vim:|ex:}[white]{options}
# ex: 'vim: syntax=ruby'
VIM_MODELINE_1 = /(?:vim|vi|ex):\s*(?:ft|filetype|syntax)=(\w+)\s?/i
VIM_MODELINE = /
# Second form vim modeline (compatible with some versions of Vi)
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
# ex: 'vim set syntax=ruby:'
VIM_MODELINE_2 = /(?:vim|vi|Vim|ex):\s*se(?:t)?.*\s(?:ft|filetype|syntax)=(\w+)\s?.*:/i
# Start modeline. Could be `vim:`, `vi:` or `ex:`
(?:
(?:\s|^)
vi
(?:m[<=>]?\d+|m)? # Version-specific modeline
|
[\t\x20] # `ex:` requires whitespace, because "ex:" might be short for "example:"
ex
)
MODELINES = [EMACS_MODELINE, VIM_MODELINE_1, VIM_MODELINE_2]
# If the option-list begins with `set ` or `se `, it indicates an alternative
# modeline syntax partly-compatible with older versions of Vi. Here, the colon
# serves as a terminator for an option sequence, delimited by whitespace.
(?=
# So we have to ensure the modeline ends with a colon
: (?=\s* set? \s [^\n:]+ :) |
# Otherwise, it isn't valid syntax and should be ignored
: (?!\s* set? \s)
)
# Possible (unrelated) `option=value` pairs to skip past
(?:
# Option separator. Vim uses whitespace or colons to separate options (except if
# the alternate "vim: set " form is used, where only whitespace is used)
(?:
\s
|
\s* : \s* # Note that whitespace around colons is accepted too:
) # vim: noai : ft=ruby:noexpandtab
# Option's name. All recognised Vim options have an alphanumeric form.
\w*
# Possible value. Not every option takes an argument.
(?:
# Whitespace between name and value is allowed: `vim: ft =ruby`
\s*=
# Option's value. Might be blank; `vim: ft= ` says "use no filetype".
(?:
[^\\\s] # Beware of escaped characters: titlestring=\ ft=ruby
| # will be read by Vim as { titlestring: " ft=ruby" }.
\\.
)*
)?
)*
# The actual filetype declaration
[\s:] (?:filetype|ft|syntax) \s*=
# Language's name
(\w+)
# Ensure it's followed by a legal separator
(?=\s|:|$)
/xi
MODELINES = [EMACS_MODELINE, VIM_MODELINE]
# Scope of the search for modelines
# Number of lines to check at the beginning and at the end of the file

3
test/fixtures/Data/Modelines/iamjs.pl vendored Normal file
View File

@@ -0,0 +1,3 @@
# vim: noexpandtab: ft=javascript
"It's JavaScript, baby";

View File

@@ -0,0 +1,4 @@
# vim:noexpandtab titlestring=hi\|there\\\ ft=perl ts=4
# vim:noexpandtab titlestring=hi|there\\ ft=javascript ts=4
"Still JavaScript, bruh";

3
test/fixtures/Data/Modelines/ruby10 vendored Normal file
View File

@@ -0,0 +1,3 @@
ex: noexpandtab: ft=ruby
# Still Ruby

3
test/fixtures/Data/Modelines/ruby11 vendored Normal file
View File

@@ -0,0 +1,3 @@
# vim600: ft=ruby
# Targets Vim 6.0 or later

3
test/fixtures/Data/Modelines/ruby12 vendored Normal file
View File

@@ -0,0 +1,3 @@
vim<520: ft=ruby
# Targets Vim 5.20 and earlier

View File

@@ -5,8 +5,11 @@ class TestGrammars < Minitest::Test
# List of projects that are allowed without licenses
PROJECT_WHITELIST = [
# Dual MIT and GPL license
"vendor/grammars/factor",
"vendor/grammars/go-tmbundle",
"vendor/grammars/jflex.tmbundle",
"vendor/grammars/language-csharp",
"vendor/grammars/language-viml",
"vendor/grammars/sublimeassembly"
].freeze

View File

@@ -17,6 +17,9 @@ class TestModelines < Minitest::Test
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby7")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby8")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby9")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby10")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby11")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby12")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplus")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs1")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs2")
@@ -33,6 +36,8 @@ class TestModelines < Minitest::Test
assert_modeline Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c")
assert_modeline Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl")
assert_modeline Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md")
assert_modeline Language["JavaScript"], fixture_blob("Data/Modelines/iamjs.pl")
assert_modeline Language["JavaScript"], fixture_blob("Data/Modelines/iamjs2.pl")
assert_modeline Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc")
assert_modeline nil, sample_blob("C/main.c")
end
@@ -57,6 +62,8 @@ class TestModelines < Minitest::Test
assert_equal Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c").language
assert_equal Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl").language
assert_equal Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md").language
assert_equal Language["JavaScript"], fixture_blob("Data/Modelines/iamjs.pl").language
assert_equal Language["JavaScript"], fixture_blob("Data/Modelines/iamjs2.pl").language
assert_equal Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc").language
end
end

View File

@@ -1,11 +1,12 @@
---
type: grammar
name: Sublime-VimL
name: language-viml
license: mit
---
The MIT License (MIT)
Copyright (c) 2014 Max Vasiliev, Salvatore Gentile
Copyright (c) 2014-2016 Evan Hahn
Copyright (c) 2016 John Gardner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -14,13 +15,13 @@ 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 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.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.