Compare commits

..

66 Commits

Author SHA1 Message Date
Joshua Peek
e424e8e88c Linguist 4.8.15 2016-09-23 16:41:16 -07:00
Joshua Peek
07d4f218a3 Merge pull request #3243 from github/change_modes_to_mimetypes
Convert from mode names to mimetypes for better usage.
2016-09-23 16:38:13 -07:00
Joshua Peek
67ed060d37 Assert CodeMirror modes and mime types are valid against source 2016-09-23 16:33:12 -07:00
Joshua Peek
3abe081560 Validate codemirror modes 2016-09-23 16:30:38 -07:00
Joshua Peek
855f1a1f86 Validate CodeMirror modes 2016-09-23 14:47:49 -07:00
Joshua Peek
0406a5b326 Fix typescript indent 2016-09-23 14:39:15 -07:00
Joshua Peek
0108ef4386 Restore old mode 2016-09-23 14:35:02 -07:00
Joshua Peek
daefff86ff Fix JSX mode 2016-09-23 13:57:50 -07:00
Joshua Peek
fdb962518f Consistent CodeMirror casing 2016-09-23 13:54:55 -07:00
Joshua Peek
6564078061 Merge branch 'master' into change_modes_to_mimetypes 2016-09-23 13:54:20 -07:00
Joshua Peek
39ea9be5f8 Ignore ace mode warning while testing 2016-09-23 13:53:38 -07:00
Joshua Peek
152b5ade5e Fix shadowed path warning 2016-09-23 13:50:01 -07:00
Joshua Peek
c525e3fbef Ignore default external warnings 2016-09-23 13:49:30 -07:00
Todd Berman
88c74fa9c2 Convert from mode names to mimetypes for better usage. 2016-09-23 13:40:19 -07:00
Arfon Smith
2ea1ff2736 Merge pull request #3240 from github/cut-release-v4.8.14
v4.8.14 release
2016-09-22 21:36:30 -07:00
Arfon Smith
a1901fceff Bump version to v4.8.14 2016-09-22 21:03:33 -07:00
Arfon Smith
b4035a3804 Update grammars 2016-09-22 20:33:39 -07:00
Arfon Smith
fc67fc525c Merge pull request #3219 from Alhadis/emacs-files
Add .gnus, .viper and Project.ede as Emacs Lisp extensions
2016-09-22 08:10:12 -07:00
Arfon Smith
f0659d3aa5 Merge pull request #3213 from larsbrinkhoff/povray
POV-Ray heuristic: #declare
2016-09-21 22:36:49 -07:00
Lars Brinkhoff
a7a123a8db Add heuristic for .inc files: the #declare keyword is unique to POV-Ray.
Also added #local, #macro, and #while.
2016-09-22 07:02:44 +02:00
Arfon Smith
0e5327a77a Merge pull request #3238 from github/cut-release-v4.8.13
Bumping to v4.8.13
2016-09-21 21:35:19 -07:00
Arfon Smith
ecd4ae3bda Bumping to v4.8.13 2016-09-21 21:04:26 -07:00
Arfon Smith
7a8bd628e1 Merge pull request #3237 from github/3227-local
Revised Emacs modeline detection
2016-09-21 21:02:31 -07:00
Arfon Smith
8e19aea39e Removing stray Sublime-VimL grammar reference 2016-09-21 20:58:12 -07:00
Arfon Smith
6fcba83f3e Merge branch 'master' into 3227-local 2016-09-21 20:55:07 -07:00
Todd Berman
d6d7d38eb8 Fix w/ a test 2016-09-21 20:52:49 -07:00
Arfon Smith
c8094d3775 Merge branch 'master' into 3227-local 2016-09-21 20:26:51 -07:00
Arfon Smith
de478d2f2d Merge pull request #3235 from github/add_codemirror_mode
Add Codemirror modes
2016-09-21 20:17:48 -07:00
Arfon Smith
991dcef18b Merge pull request #3223 from Alhadis/vimscript
Swap grammar used for Vimscript highlighting
2016-09-21 20:16:12 -07:00
Arfon Smith
f30e9270f1 Merge pull request #3197 from Alhadis/modelines
Revise patterns for Vim modeline detection
2016-09-21 20:13:28 -07:00
Arfon Smith
1d7ba18b15 M scope 2016-09-21 20:12:27 -07:00
Arfon Smith
35a06d6cb8 Merge branch 'master' into add_codemirror_mode 2016-09-21 20:05:22 -07:00
Arfon Smith
4cf7feb275 Merge pull request #3236 from github/license-whitelist
Whitelist troublesome licenses
2016-09-21 19:54:27 -07:00
Arfon Smith
30298a9ef8 Whitelist troublesome licenses 2016-09-21 09:27:35 -07:00
Todd Berman
cc5f1c57ca Add Codemirror modes 2016-09-20 23:23:22 -07:00
Alhadis
697380336c Revise pattern for Emacs modeline detection
This is a rewrite of the regex that handles Emacs modeline matching. The
current one is a little flaky, causing some files to be misclassified as
"E", among other things.

It's worth noting malformed modelines can still change a file's language
in Emacs. Provided the -*- delimiters are intact, and the mode's name is
decipherable, Emacs will set the appropriate language mode *and* display
a warning about a malformed modeline:

    -*- foo-bar mode: ruby -*-   # Malformed, but understandable
            -*- mode: ruby--*-   # Completely invalid

The new pattern accommodates this leniency, making no effort to validate
a modeline's syntax beyond readable mode-names. In other words, if Emacs
accepts certain errors, we should too.
2016-09-17 19:45:43 +10:00
Alhadis
5fd8d71858 Remove license for old grammar 2016-09-16 06:17:16 +10:00
Alhadis
5bc88814e2 Swap grammar used for Vimscript highlighting 2016-09-16 04:22:09 +10:00
Lars Brinkhoff
00efd6a463 Add FORTRAN keyword "data" to .f and .for heuristics. (#3218)
bug-185631.f sample from OpenFortranProject; BSD license.
2016-09-15 19:24:53 +02:00
Alhadis
81ca6e7766 Add "abbrev_defs" and "_emacs" as Elisp filenames 2016-09-15 18:57:35 +10:00
Alhadis
cd288a8ee4 Add .gnus, .viper and Project.ede as Emacs Lisp extensions 2016-09-15 17:06:59 +10:00
Arfon Smith
a8d84f3d55 Merge pull request #3215 from github/cut-release-v4.8.12
Bumping to v4.8.12
2016-09-14 16:33:33 -07:00
Arfon Smith
600115afed Bumping to v4.8.12 2016-09-14 16:01:19 -07:00
Arfon Smith
e57273c839 Merge pull request #3214 from pchaigno/remove-sublime-syntax
Remove support for .sublime-syntax
2016-09-14 15:21:54 -07:00
Paul Chaignon
65491d460e Remove support for .sublime-syntax 2016-09-14 23:09:22 +02:00
Arfon Smith
8dc4a1308f Merge pull request #3212 from github/cut-release-v4.8.11
Cut release v4.8.11
2016-09-13 13:02:13 -07:00
Arfon Smith
6841b4d259 Updating to v4.8.11 2016-09-13 11:37:42 -07:00
Arfon Smith
a53423b6e0 Grammar updates 2016-09-13 11:33:20 -07:00
Arfon Smith
02f3ba1840 Merge pull request #3205 from github/language-id
Language ids
2016-09-13 11:27:25 -07:00
Arfon Smith
e1216ea4ee Merge branch 'language-id' of github.com:github/linguist into language-id 2016-09-13 11:14:19 -07:00
Arfon Smith
a3227c2c27 Adding basic find_by_id functionality to Language 2016-09-13 11:09:05 -07:00
Arfon Smith
9f1c950a1f Merge pull request #3206 from pchaigno/fix-elm-highlighting
Fix Elm highlighting
2016-09-13 10:44:46 -07:00
Arfon Smith
c7a0d7b83d Merge pull request #3208 from pchaigno/lock-grammar-versions
Lock grammar versions
2016-09-13 10:43:39 -07:00
Arfon Smith
53c9b2b435 Merge pull request #3207 from pchaigno/test-uniqueness-language-ids
Test the uniqueness of language ids
2016-09-13 10:42:53 -07:00
Paul Chaignon
b4a77abd82 Lock SourcePawn grammar to last working version 2016-09-13 13:50:57 +02:00
Paul Chaignon
8a622823b0 Lock NSIS grammar to last working version 2016-09-13 13:47:03 +02:00
Paul Chaignon
3310d925b6 Lock awk grammar to last working version 2016-09-13 13:41:11 +02:00
Paul Chaignon
65201b322a Test the uniqueness of language ids 2016-09-13 13:10:07 +02:00
Paul Chaignon
b71bf19e37 Fix Elm highlighting
Elm grammar repository contains several YAML files with a source.elm scope
We need to restrict the path to the Syntaxes directory
to make sure we select the appropriate YAML file
2016-09-13 11:04:49 +02:00
Arfon Smith
1f43664a51 Adding some tests for some known language_ids 2016-09-12 22:10:59 -07:00
Arfon Smith
7cda13afcb A Language should know about it's language_id 2016-09-12 22:02:49 -07:00
Arfon Smith
e0d890240b Adding basic script for adding language_id fields to languages.yml 2016-09-12 21:35:10 -07:00
Alhadis
abf7bee464 Include tests for version-specific Vim modelines 2016-09-12 20:00:05 +10:00
Alhadis
e73a4ecd0e Allow " ex:" to match at beginning of file
Although unlikely to be valid syntax in most programming languages, such
a modeline is valid syntax in Vim, and will trigger any filetype modes.
2016-09-12 19:59:08 +10:00
Alhadis
70779c9986 Merge branch 'master' into modelines 2016-09-12 18:48:45 +10:00
Alhadis
22d4865c52 Revise patterns for Vim modeline detection
The current expressions fail to match certain permutations of options:

    vim: noexpandtab: ft=javascript:
    vim: titlestring=foo\ ft=notperl ft=javascript:

Version-specific modelines are also unaccounted for:

    vim600: set foldmethod=marker ft=javascript:   # >= Vim 6.0
    vim<600: set ft=javascript:                    # <  Vim 6.0

See http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
2016-09-11 00:51:03 +10:00
62 changed files with 2489 additions and 1582 deletions

1
.gitignore vendored
View File

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

15
.gitmodules vendored
View File

@@ -12,7 +12,7 @@
url = https://github.com/Drako/SublimeBrainfuck url = https://github.com/Drako/SublimeBrainfuck
[submodule "vendor/grammars/awk-sublime"] [submodule "vendor/grammars/awk-sublime"]
path = vendor/grammars/awk-sublime path = vendor/grammars/awk-sublime
url = https://github.com/JohnNilsson/awk-sublime url = https://github.com/github-linguist/awk-sublime
[submodule "vendor/grammars/Sublime-SQF-Language"] [submodule "vendor/grammars/Sublime-SQF-Language"]
path = vendor/grammars/Sublime-SQF-Language path = vendor/grammars/Sublime-SQF-Language
url = https://github.com/JonBons/Sublime-SQF-Language url = https://github.com/JonBons/Sublime-SQF-Language
@@ -22,15 +22,15 @@
[submodule "vendor/grammars/Sublime-REBOL"] [submodule "vendor/grammars/Sublime-REBOL"]
path = vendor/grammars/Sublime-REBOL path = vendor/grammars/Sublime-REBOL
url = https://github.com/Oldes/Sublime-REBOL url = https://github.com/Oldes/Sublime-REBOL
[submodule "vendor/grammars/Sublime-VimL"] [submodule "vendor/grammars/language-viml"]
path = vendor/grammars/Sublime-VimL path = vendor/grammars/language-viml
url = https://github.com/SalGnt/Sublime-VimL url = https://github.com/Alhadis/language-viml
[submodule "vendor/grammars/ColdFusion"] [submodule "vendor/grammars/ColdFusion"]
path = vendor/grammars/ColdFusion path = vendor/grammars/ColdFusion
url = https://github.com/SublimeText/ColdFusion url = https://github.com/SublimeText/ColdFusion
[submodule "vendor/grammars/NSIS"] [submodule "vendor/grammars/NSIS"]
path = vendor/grammars/NSIS path = vendor/grammars/NSIS
url = https://github.com/SublimeText/NSIS url = https://github.com/github-linguist/NSIS
[submodule "vendor/grammars/NimLime"] [submodule "vendor/grammars/NimLime"]
path = vendor/grammars/NimLime path = vendor/grammars/NimLime
url = https://github.com/Varriount/NimLime url = https://github.com/Varriount/NimLime
@@ -667,7 +667,7 @@
url = https://github.com/goblindegook/sublime-text-pig-latin url = https://github.com/goblindegook/sublime-text-pig-latin
[submodule "vendor/grammars/sourcepawn"] [submodule "vendor/grammars/sourcepawn"]
path = vendor/grammars/sourcepawn path = vendor/grammars/sourcepawn
url = https://github.com/austinwagner/sublime-sourcepawn url = https://github.com/github-linguist/sublime-sourcepawn
[submodule "vendor/grammars/gdscript"] [submodule "vendor/grammars/gdscript"]
path = vendor/grammars/gdscript path = vendor/grammars/gdscript
url = https://github.com/beefsack/GDScript-sublime url = https://github.com/beefsack/GDScript-sublime
@@ -791,3 +791,6 @@
[submodule "vendor/grammars/language-babel"] [submodule "vendor/grammars/language-babel"]
path = vendor/grammars/language-babel path = vendor/grammars/language-babel
url = https://github.com/github-linguist/language-babel url = https://github.com/github-linguist/language-babel
[submodule "vendor/CodeMirror"]
path = vendor/CodeMirror
url = https://github.com/codemirror/CodeMirror

View File

@@ -33,6 +33,7 @@ To add support for a new language:
0. Add your grammar to [`grammars.yml`][grammars] by running `script/convert-grammars --add vendor/grammars/MyGrammar`. 0. Add your grammar to [`grammars.yml`][grammars] by running `script/convert-grammars --add vendor/grammars/MyGrammar`.
0. Download the license for the grammar: `script/licensed`. Be careful to only commit the file for the new grammar, as this script may update licenses for other grammars as well. 0. Download the license for the grammar: `script/licensed`. Be careful to only commit the file for the new grammar, as this script may update licenses for other grammars as well.
0. Add samples for your language to the [samples directory][samples] in the correct subdirectory. 0. Add samples for your language to the [samples directory][samples] in the correct subdirectory.
0. Add a `language_id` for your language. See `script/set-language-ids` for more information. **You should only ever need to run `script/set-language-ids --update`. Anything other than this risks breaking GitHub search :cry:**
0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage. 0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage.
In addition, if your new language defines an extension that's already listed in [`languages.yml`][languages] (such as `.foo`) then sometimes a few more steps will need to be taken: In addition, if your new language defines an extension that's already listed in [`languages.yml`][languages] (such as `.foo`) then sometimes a few more steps will need to be taken:
@@ -84,7 +85,7 @@ Linguist is maintained with :heart: by:
- @arfon (GitHub Staff) - @arfon (GitHub Staff)
- @larsbrinkhoff - @larsbrinkhoff
- @pchaigno - @pchaigno
As Linguist is a production dependency for GitHub we have a couple of workflow restrictions: As Linguist is a production dependency for GitHub we have a couple of workflow restrictions:
- Anyone with commit rights can merge Pull Requests provided that there is a :+1: from a GitHub member of staff - Anyone with commit rights can merge Pull Requests provided that there is a :+1: from a GitHub member of staff

View File

@@ -20,7 +20,7 @@ vendor/grammars/ColdFusion:
- text.html.cfm - text.html.cfm
vendor/grammars/Docker.tmbundle: vendor/grammars/Docker.tmbundle:
- source.dockerfile - source.dockerfile
vendor/grammars/Elm: vendor/grammars/Elm/Syntaxes:
- source.elm - source.elm
- text.html.mediawiki.elm-build-output - text.html.mediawiki.elm-build-output
- text.html.mediawiki.elm-documentation - text.html.mediawiki.elm-documentation
@@ -103,8 +103,6 @@ vendor/grammars/Sublime-SQF-Language:
vendor/grammars/Sublime-Text-2-OpenEdge-ABL: vendor/grammars/Sublime-Text-2-OpenEdge-ABL:
- source.abl - source.abl
- text.html.abl - text.html.abl
vendor/grammars/Sublime-VimL:
- source.viml
vendor/grammars/SublimeBrainfuck: vendor/grammars/SublimeBrainfuck:
- source.bf - source.bf
vendor/grammars/SublimeClarion: vendor/grammars/SublimeClarion:
@@ -414,6 +412,8 @@ vendor/grammars/language-toc-wow:
- source.toc - source.toc
vendor/grammars/language-turing: vendor/grammars/language-turing:
- source.turing - source.turing
vendor/grammars/language-viml:
- source.viml
vendor/grammars/language-wavefront: vendor/grammars/language-wavefront:
- source.wavefront.mtl - source.wavefront.mtl
- source.wavefront.obj - source.wavefront.obj

View File

@@ -144,7 +144,7 @@ module Linguist
end end
end end
fortran_rx = /^([c*][^abd-z]| (subroutine|program|end)\s|\s*!)/i fortran_rx = /^([c*][^abd-z]| (subroutine|program|end|data)\s|\s*!)/i
disambiguate ".f" do |data| disambiguate ".f" do |data|
if /^: /.match(data) if /^: /.match(data)
@@ -202,6 +202,8 @@ module Linguist
disambiguate ".inc" do |data| disambiguate ".inc" do |data|
if /^<\?(?:php)?/.match(data) if /^<\?(?:php)?/.match(data)
Language["PHP"] Language["PHP"]
elsif /^\s*#(declare|local|macro|while)\s/.match(data)
Language["POV-Ray SDL"]
end end
end end

View File

@@ -20,10 +20,11 @@ module Linguist
# #
# Languages are defined in `lib/linguist/languages.yml`. # Languages are defined in `lib/linguist/languages.yml`.
class Language class Language
@languages = [] @languages = []
@index = {} @index = {}
@name_index = {} @name_index = {}
@alias_index = {} @alias_index = {}
@language_id_index = {}
@extension_index = Hash.new { |h,k| h[k] = [] } @extension_index = Hash.new { |h,k| h[k] = [] }
@interpreter_index = Hash.new { |h,k| h[k] = [] } @interpreter_index = Hash.new { |h,k| h[k] = [] }
@@ -84,6 +85,8 @@ module Linguist
@filename_index[filename] << language @filename_index[filename] << language
end end
@language_id_index[language.language_id] = language
language language
end end
@@ -193,6 +196,19 @@ module Linguist
@interpreter_index[interpreter] @interpreter_index[interpreter]
end end
# Public: Look up Languages by its language_id.
#
# language_id - Integer of language_id
#
# Examples
#
# Language.find_by_id(100)
# # => [#<Language name="Elixir">]
#
# Returns the matching Language
def self.find_by_id(language_id)
@language_id_index[language_id.to_i]
end
# Public: Look up Language by its name. # Public: Look up Language by its name.
# #
@@ -251,6 +267,7 @@ module Linguist
# Returns an Array of Languages. # Returns an Array of Languages.
def self.ace_modes def self.ace_modes
warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set." warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set."
warn caller
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase } @ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
end end
@@ -284,11 +301,16 @@ module Linguist
end end
@ace_mode = attributes[:ace_mode] @ace_mode = attributes[:ace_mode]
@codemirror_mode = attributes[:codemirror_mode]
@codemirror_mime_type = attributes[:codemirror_mime_type]
@wrap = attributes[:wrap] || false @wrap = attributes[:wrap] || false
# Set legacy search term # Set legacy search term
@search_term = attributes[:search_term] || default_alias_name @search_term = attributes[:search_term] || default_alias_name
# Set the language_id
@language_id = attributes[:language_id]
# Set extensions or default to []. # Set extensions or default to [].
@extensions = attributes[:extensions] || [] @extensions = attributes[:extensions] || []
@interpreters = attributes[:interpreters] || [] @interpreters = attributes[:interpreters] || []
@@ -351,6 +373,17 @@ module Linguist
# Returns the name String # Returns the name String
attr_reader :search_term attr_reader :search_term
# Public: Get language_id (used in GitHub search)
#
# Examples
#
# # => "1"
# # => "2"
# # => "3"
#
# Returns the integer language_id
attr_reader :language_id
# Public: Get the name of a TextMate-compatible scope # Public: Get the name of a TextMate-compatible scope
# #
# Returns the scope # Returns the scope
@@ -367,6 +400,31 @@ module Linguist
# Returns a String name or nil # Returns a String name or nil
attr_reader :ace_mode attr_reader :ace_mode
# Public: Get CodeMirror mode
#
# Maps to a directory in the `mode/` source code.
# https://github.com/codemirror/CodeMirror/tree/master/mode
#
# Examples
#
# # => "nil"
# # => "javascript"
# # => "clike"
#
# Returns a String name or nil
attr_reader :codemirror_mode
# Public: Get CodeMirror MIME type mode
#
# Examples
#
# # => "nil"
# # => "text/x-javascript"
# # => "text/x-csrc"
#
# Returns a String name or nil
attr_reader :codemirror_mime_type
# Public: Should language lines be wrapped # Public: Should language lines be wrapped
# #
# Returns true or false # Returns true or false
@@ -543,10 +601,13 @@ module Linguist
:aliases => options['aliases'], :aliases => options['aliases'],
:tm_scope => options['tm_scope'], :tm_scope => options['tm_scope'],
:ace_mode => options['ace_mode'], :ace_mode => options['ace_mode'],
:codemirror_mode => options['codemirror_mode'],
:codemirror_mime_type => options['codemirror_mime_type'],
:wrap => options['wrap'], :wrap => options['wrap'],
:group_name => options['group'], :group_name => options['group'],
:searchable => options.fetch('searchable', true), :searchable => options.fetch('searchable', true),
:search_term => options['search_term'], :search_term => options['search_term'],
:language_id => options['language_id'],
:extensions => Array(options['extensions']), :extensions => Array(options['extensions']),
:interpreters => options['interpreters'].sort, :interpreters => options['interpreters'].sort,
:filenames => options['filenames'], :filenames => options['filenames'],

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,98 @@
module Linguist module Linguist
module Strategy module Strategy
class Modeline class Modeline
EMACS_MODELINE = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i EMACS_MODELINE = /
-\*-
(?:
# Short form: `-*- ruby -*-`
\s* (?= [^:;\s]+ \s* -\*-)
|
# Longer form: `-*- foo:bar; mode: ruby; -*-`
(?:
.*? # Preceding variables: `-*- foo:bar bar:baz;`
[;\s] # Which are delimited by spaces or semicolons
|
(?<=-\*-) # Not preceded by anything: `-*-mode:ruby-*-`
)
mode # Major mode indicator
\s*:\s* # Allow whitespace around colon: `mode : ruby`
)
([^:;\s]+) # Name of mode
# First form vim modeline # Ensure the mode is terminated correctly
# [text]{white}{vi:|vim:|ex:}[white]{options} (?=
# ex: 'vim: syntax=ruby' # Followed by semicolon or whitespace
VIM_MODELINE_1 = /(?:vim|vi|ex):\s*(?:ft|filetype|syntax)=(\w+)\s?/i [\s;]
|
# Touching the ending sequence: `ruby-*-`
(?<![-*]) # Don't allow stuff like `ruby--*-` to match; it'll invalidate the mode
-\*- # Emacs has no problems reading `ruby --*-`, however.
)
.*? # Anything between a cleanly-terminated mode and the ending -*-
-\*-
/xi
# Second form vim modeline (compatible with some versions of Vi) VIM_MODELINE = /
# [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
MODELINES = [EMACS_MODELINE, VIM_MODELINE_1, VIM_MODELINE_2] # 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
)
# 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 # Scope of the search for modelines
# Number of lines to check at the beginning and at the end of the file # Number of lines to check at the beginning and at the end of the file

View File

@@ -165,7 +165,7 @@
# Chart.js # Chart.js
- (^|/)Chart\.js$ - (^|/)Chart\.js$
# Codemirror # CodeMirror
- (^|/)[Cc]ode[Mm]irror/(\d+\.\d+/)?(lib|mode|theme|addon|keymap|demo) - (^|/)[Cc]ode[Mm]irror/(\d+\.\d+/)?(lib|mode|theme|addon|keymap|demo)
# SyntaxHighlighter - http://alexgorbatchev.com/ # SyntaxHighlighter - http://alexgorbatchev.com/

View File

@@ -1,3 +1,3 @@
module Linguist module Linguist
VERSION = "4.8.10" VERSION = "4.8.15"
end end

View File

@@ -0,0 +1,6 @@
(define-abbrev-table 'c-mode-abbrev-table '(
))
(define-abbrev-table 'fundamental-mode-abbrev-table '(
("TM" "™" nil 0)
("(R)" "®" nil 0)
("C=" "€" nil 0)))

View File

@@ -0,0 +1,20 @@
(setq user-full-name "Alhadis")
(setq user-mail-address "fake.account@gmail.com")
(auto-image-file-mode)
(setq mm-inline-large-images t)
(add-to-list 'mm-attachment-override-types "image/*")
(setq gnus-select-method
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 777)
(nnimap-stream ssl)))
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-starttls-credentials '(("smtp.gmail.com" 600 nil nil))
smtpmail-auth-credentials '(("smtp.gmail.com" 700 "me@lisp.com" nil))
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 800
setq gnus-ignored-from-addresses "^from\\.Telstra[ \t\r\n]+Thanks")

View File

@@ -0,0 +1,10 @@
(setq viper-inhibit-startup-message 't)
(setq viper-expert-level '5)
; Key bindings
(define-key viper-vi-global-user-map "\C-d" 'end-of-line)
; Return to top of window
(defun my-viper-return-to-top ()
(interactive)
(beginning-of-buffer))

View File

@@ -0,0 +1,34 @@
;; Object EDE
(ede-proj-project "Linguist"
:name "Linguist"
:version "4.9"
:file "Project.ede"
:targets (list
(ede-proj-target-elisp-autoloads "autoloads"
:name "autoloads"
:path "test/samples/Emacs Lisp"
:autoload-file "dude.el"
)
(ede-proj-target-elisp "init"
:name "init"
:path ""
:source '("ede-load.el" "wait-what.el")
:compiler 'ede-emacs-preload-compiler
:pre-load-packages '("sample-names")
)
(ede-proj-target-elisp "what"
:name "the"
:path ""
:source '("h.el" "am-i-writing.el")
:versionsource '("hell.el")
:compiler 'ede-emacs-preload-compiler
:aux-packages '("what" "the" "hell-files" "am-i-writing")
)
)
:web-site-url "https://github.com/github/linguist"
:web-site-directory "../"
:web-site-file "CONTRIBUTING.md"
:ftp-upload-site "/ftp@git.hub.com:/madeup"
:configuration-variables 'nil
:metasubproject 't
)

View File

@@ -0,0 +1,70 @@
;; UTF-8 support
;; (set-language-environment "UTF-8")
(setenv "LANG" "en_AU.UTF-8")
(setenv "LC_ALL" "en_AU.UTF-8")
(setq default-tab-width 4)
;;; Function to load all ".el" files in ~/.emacs.d/config
(defun load-directory (directory)
"Recursively load all Emacs Lisp files in a directory."
(dolist (element (directory-files-and-attributes directory nil nil nil))
(let* ((path (car element))
(fullpath (concat directory "/" path))
(isdir (car (cdr element)))
(ignore-dir (or (string= path ".") (string= path ".."))))
(cond
((and (eq isdir t) (not ignore-dir))
(load-directory fullpath))
((and (eq isdir nil) (string= (substring path -3) ".el"))
(load (file-name-sans-extension fullpath)))))))
;; Tell Emacs we'd like to use Hunspell for spell-checking
(setq ispell-program-name (executable-find "hunspell"))
;; Load Homebrew-installed packages
(let ((default-directory "/usr/local/share/emacs/site-lisp/"))
(normal-top-level-add-subdirs-to-load-path))
(load "aggressive-indent")
(add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
(autoload 'rust-mode "rust-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
;; Load Git-related syntax highlighting
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "git-modes")
(load "git-commit")
;; Keybindings
(global-set-key (kbd "C-u") (lambda ()
(interactive)
(kill-line 0)))
;; Show cursor's current column number
(setq column-number-mode t)
;; Disable autosave
(setq auto-save-default nil)
;; Use a single directory for storing backup files
(setq backup-directory-alist `(("." . "~/.emacs.d/auto-save-list")))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
'(column-number-mode t)
'(show-paren-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View File

@@ -0,0 +1,8 @@
(define-abbrev-table 'fundamental-mode-abbrev-table '(
("cat" "Concatenate" nil 0)
("WTF" "World Trade Federation " nil 0)
("rtbtm" "Read that back to me" nil 0)))
(define-abbrev-table 'shell-script-mode-abbrev-table '(
("brake", "bundle rake exec" nil 0)
("pls", "warning: setting Encoding.default_external")))

View File

@@ -0,0 +1,6 @@
! Codes/HYCOM/hycom/ATLb2.00/src_2.0.01_22_one/
real onemu, twomu
data onemu/0.0098/
data twomu/1./
data threemu/0.e9/
end

View File

@@ -42,7 +42,7 @@ class DirectoryPackage
case File.extname(path.downcase) case File.extname(path.downcase)
when '.plist' when '.plist'
path.split('/')[-2] == 'Syntaxes' path.split('/')[-2] == 'Syntaxes'
when '.tmlanguage', '.yaml-tmlanguage', '.sublime-syntax' when '.tmlanguage', '.yaml-tmlanguage'
true true
when '.cson', '.json' when '.cson', '.json'
path.split('/')[-2] == 'grammars' path.split('/')[-2] == 'grammars'
@@ -114,7 +114,7 @@ class SVNPackage
def fetch(tmp_dir) def fetch(tmp_dir)
`svn export -q "#{url}/Syntaxes" "#{tmp_dir}/Syntaxes"` `svn export -q "#{url}/Syntaxes" "#{tmp_dir}/Syntaxes"`
raise "Failed to export SVN repository: #{url}: #{$?.to_s}" unless $?.success? raise "Failed to export SVN repository: #{url}: #{$?.to_s}" unless $?.success?
Dir["#{tmp_dir}/Syntaxes/*.{plist,tmLanguage,tmlanguage,YAML-tmLanguage,sublime-syntax}"] Dir["#{tmp_dir}/Syntaxes/*.{plist,tmLanguage,tmlanguage,YAML-tmLanguage}"]
end end
end end
@@ -148,7 +148,7 @@ def load_grammar(path)
case File.extname(path.downcase) case File.extname(path.downcase)
when '.plist', '.tmlanguage' when '.plist', '.tmlanguage'
Plist::parse_xml(path) Plist::parse_xml(path)
when '.yaml-tmlanguage', '.sublime-syntax' when '.yaml-tmlanguage'
content = File.read(path) content = File.read(path)
# Attempt to parse YAML file even if it has a YAML 1.2 header # Attempt to parse YAML file even if it has a YAML 1.2 header
if content.lines[0] =~ /^%YAML[ :]1\.2/ if content.lines[0] =~ /^%YAML[ :]1\.2/
@@ -180,7 +180,7 @@ def load_grammars(tmp_dir, source, all_scopes)
else else
SingleFile.new(source) SingleFile.new(source)
end end
elsif source.end_with?('.tmLanguage', '.plist', '.YAML-tmLanguage', '.sublime-syntax') elsif source.end_with?('.tmLanguage', '.plist', '.YAML-tmLanguage')
SingleGrammar.new(source) SingleGrammar.new(source)
elsif source.start_with?('https://github.com') elsif source.start_with?('https://github.com')
GitHubPackage.new(source) GitHubPackage.new(source)

82
script/set-language-ids Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env ruby
require 'yaml'
require 'pry'
header = <<-EOF
# Defines all Languages known to GitHub.
#
# type - Either data, programming, markup, prose, or nil
# aliases - An Array of additional aliases (implicitly
# includes name.downcase)
# ace_mode - A String name of the Ace Mode used for highlighting whenever
# a file is edited. This must match one of the filenames in http://git.io/3XO_Cg.
# Use "text" if a mode does not exist.
# wrap - Boolean wrap to enable line wrapping (default: false)
# extensions - An Array of associated extensions (the first one is
# considered the primary extension, the others should be
# listed alphabetically)
# interpreters - An Array of associated interpreters
# searchable - Boolean flag to enable searching (defaults to true)
# search_term - Deprecated: Some languages may be indexed under a
# different alias. Avoid defining new exceptions.
# language_id - Integer used as a language-name-independent indexed field so that we can rename
# languages in Linguist without reindexing all the code on GitHub. Must not be
# changed for existing languages without the explicit permission of GitHub staff.
# color - CSS hex color to represent the language.
# tm_scope - The TextMate scope that represents this programming
# language. This should match one of the scopes listed in
# the grammars.yml file. Use "none" if there is no grammar
# for this language.
# group - Name of the parent language. Languages in a group are counted
# in the statistics as the parent language.
#
# Any additions or modifications (even trivial) should have corresponding
# test changes in `test/test_blob.rb`.
#
# Please keep this list alphabetized. Capitalization comes before lowercase.
EOF
generated = true if ARGV[0] == "--force"
update = true if ARGV[0] == "--update"
if generated
puts "You're regenerating all of the language_id attributes for all Linguist "
puts "languages defined in languages.yml. This is almost certainly NOT what"
puts "you meant to do!"
language_index = 0
languages = YAML.load(File.read("lib/linguist/languages.yml"))
languages.each do |name, vals|
vals.merge!('language_id' => language_index)
language_index += 1
end
File.write("lib/linguist/languages.yml", header + YAML.dump(languages))
elsif update
puts "Adding new language_id attributes to languages.yml that don't have one set"
languages = YAML.load(File.read("lib/linguist/languages.yml"))
# First grab the maximum language_id
language_ids = []
languages.each { |name, vals| language_ids << vals['language_id'] if vals.has_key?('language_id')}
max_language_id = language_ids.max
puts "Current maximum language_id is #{max_language_id}"
missing_count = 0
language_index = max_language_id
languages.each do |name, vals|
unless vals.has_key?('language_id')
language_index += 1
missing_count += 1
vals.merge!('language_id' => language_index)
end
end
File.write("lib/linguist/languages.yml", header + YAML.dump(languages))
puts "Updated language_id attributes for #{missing_count} languages"
else
puts "Whatever you want me to do, I can't figure it out. Giving up..."
end

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

@@ -0,0 +1,3 @@
// -*- foo-bar mode: c++ -*-
"Malformed modeline, but still understood by Emacs to be C++."

View File

@@ -0,0 +1 @@
/* -*- mode: c++ -------*- */

View File

@@ -0,0 +1 @@
-*--------- foo:bar mode: c++ -*-

View File

@@ -35,3 +35,11 @@ def sample_blob_memory(name)
content = File.read(filepath) content = File.read(filepath)
Linguist::Blob.new(name, content) Linguist::Blob.new(name, content)
end end
def silence_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
yield
ensure
$VERBOSE = original_verbosity
end

View File

@@ -4,14 +4,18 @@ class TestBlob < Minitest::Test
include Linguist include Linguist
def setup def setup
# git blobs are normally loaded as ASCII-8BIT since they may contain data silence_warnings do
# with arbitrary encoding not known ahead of time # git blobs are normally loaded as ASCII-8BIT since they may contain data
@original_external = Encoding.default_external # with arbitrary encoding not known ahead of time
Encoding.default_external = Encoding.find("ASCII-8BIT") @original_external = Encoding.default_external
Encoding.default_external = Encoding.find("ASCII-8BIT")
end
end end
def teardown def teardown
Encoding.default_external = @original_external silence_warnings do
Encoding.default_external = @original_external
end
end end
def script_blob(name) def script_blob(name)

View File

@@ -3,15 +3,27 @@ require_relative "./helper"
class TestFileBlob < Minitest::Test class TestFileBlob < Minitest::Test
include Linguist include Linguist
def silence_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
yield
ensure
$VERBOSE = original_verbosity
end
def setup def setup
# git blobs are normally loaded as ASCII-8BIT since they may contain data silence_warnings do
# with arbitrary encoding not known ahead of time # git blobs are normally loaded as ASCII-8BIT since they may contain data
@original_external = Encoding.default_external # with arbitrary encoding not known ahead of time
Encoding.default_external = Encoding.find("ASCII-8BIT") @original_external = Encoding.default_external
Encoding.default_external = Encoding.find("ASCII-8BIT")
end
end end
def teardown def teardown
Encoding.default_external = @original_external silence_warnings do
Encoding.default_external = @original_external
end
end end
def script_blob(name) def script_blob(name)
@@ -305,7 +317,7 @@ class TestFileBlob < Minitest::Test
assert sample_blob("some/vendored/path/Chart.js").vendored? assert sample_blob("some/vendored/path/Chart.js").vendored?
assert !sample_blob("some/vendored/path/chart.js").vendored? assert !sample_blob("some/vendored/path/chart.js").vendored?
# Codemirror deps # CodeMirror deps
assert sample_blob("codemirror/mode/blah.js").vendored? assert sample_blob("codemirror/mode/blah.js").vendored?
assert sample_blob("codemirror/5.0/mode/blah.js").vendored? assert sample_blob("codemirror/5.0/mode/blah.js").vendored?

View File

@@ -5,8 +5,11 @@ class TestGrammars < Minitest::Test
# List of projects that are allowed without licenses # List of projects that are allowed without licenses
PROJECT_WHITELIST = [ 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-csharp",
"vendor/grammars/language-viml",
"vendor/grammars/sublimeassembly" "vendor/grammars/sublimeassembly"
].freeze ].freeze
@@ -123,7 +126,7 @@ class TestGrammars < Minitest::Test
private private
def submodule_paths def submodule_paths
@submodule_paths ||= `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last } @submodule_paths ||= `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last }.reject { |path| path =~ /CodeMirror/ }
end end
# Returns a hash of submodules in the form of submodule_path => license # Returns a hash of submodules in the form of submodule_path => license
@@ -151,7 +154,7 @@ class TestGrammars < Minitest::Test
# Neither Licensee nor our own regex was able to detect the license, let's check the readme # Neither Licensee nor our own regex was able to detect the license, let's check the readme
files = Dir[File.join(ROOT, submodule, "*")] files = Dir[File.join(ROOT, submodule, "*")]
if readme = files.find { |path| File.basename(path) =~ /\Areadme\b/i } if readme = files.find { |file| File.basename(file) =~ /\Areadme\b/i }
classify_license(readme) classify_license(readme)
end end
end end

View File

@@ -122,9 +122,12 @@ class TestHeuristcs < Minitest::Test
}) })
end end
# Candidate languages = ["Assembly", "C++", "HTML", "PAWN", "PHP",
# "POV-Ray SDL", "Pascal", "SQL", "SourcePawn"]
def test_inc_by_heuristics def test_inc_by_heuristics
assert_heuristics({ assert_heuristics({
"PHP" => all_fixtures("PHP", "*.inc") "PHP" => all_fixtures("PHP", "*.inc"),
"POV-Ray SDL" => all_fixtures("POV-Ray SDL", "*.inc")
}) })
end end

View File

@@ -67,6 +67,22 @@ class TestLanguage < Minitest::Test
assert_nil Language.find_by_alias(nil) assert_nil Language.find_by_alias(nil)
end end
# Note these are set by script/set-language-ids. If these tests fail then someone
# has changed the language_id fields set in languages.yml which is almost certainly
# not what you want to happen (these fields are used in GitHub's search indexes)
def test_language_ids
assert_equal 4, Language['ANTLR'].language_id
assert_equal 54, Language['Ceylon'].language_id
assert_equal 326, Language['Ruby'].language_id
assert_equal 421, Language['xBase'].language_id
end
def test_find_by_id
assert_equal Language['Elixir'], Language.find_by_id(100)
assert_equal Language['Ruby'], Language.find_by_id(326)
assert_equal Language['xBase'], Language.find_by_id(421)
end
def test_groups def test_groups
# Test a couple identity cases # Test a couple identity cases
assert_equal Language['Perl'], Language['Perl'].group assert_equal Language['Perl'], Language['Perl'].group
@@ -329,8 +345,24 @@ class TestLanguage < Minitest::Test
end end
def test_ace_modes def test_ace_modes
assert Language.ace_modes.include?(Language['Ruby']) silence_warnings do
assert Language.ace_modes.include?(Language['FORTRAN']) assert Language.ace_modes.include?(Language['Ruby'])
assert Language.ace_modes.include?(Language['FORTRAN'])
end
end
def test_codemirror_mode
assert_equal 'ruby', Language['Ruby'].codemirror_mode
assert_equal 'javascript', Language['JavaScript'].codemirror_mode
assert_equal 'clike', Language['C'].codemirror_mode
assert_equal 'clike', Language['C++'].codemirror_mode
end
def test_codemirror_mime_type
assert_equal 'text/x-ruby', Language['Ruby'].codemirror_mime_type
assert_equal 'text/javascript', Language['JavaScript'].codemirror_mime_type
assert_equal 'text/x-csrc', Language['C'].codemirror_mime_type
assert_equal 'text/x-c++src', Language['C++'].codemirror_mime_type
end end
def test_wrap def test_wrap
@@ -386,6 +418,22 @@ class TestLanguage < Minitest::Test
assert missing.empty?, message assert missing.empty?, message
end end
def test_all_languages_have_a_language_id_set
missing = Language.all.select { |language| language.language_id.nil? }
message = "The following languages do not have a language_id listed in languages.yml. Please add language_id fields for all new languages.\n"
missing.each { |language| message << "#{language.name}\n" }
assert missing.empty?, message
end
def test_all_language_id_are_unique
duplicates = Language.all.group_by{ |language| language.language_id }.select { |k, v| v.size > 1 }.map(&:first)
message = "The following language_id are used several times in languages.yml. Please use script/set-language-ids --update as per the contribution guidelines.\n"
duplicates.each { |language_id| message << "#{language_id}\n" }
assert duplicates.empty?, message
end
def test_all_languages_have_a_valid_ace_mode def test_all_languages_have_a_valid_ace_mode
ace_fixture_path = File.join('test', 'fixtures', 'ace_modes.json') ace_fixture_path = File.join('test', 'fixtures', 'ace_modes.json')
skip("No ace_modes.json file") unless File.exist?(ace_fixture_path) skip("No ace_modes.json file") unless File.exist?(ace_fixture_path)
@@ -404,6 +452,40 @@ class TestLanguage < Minitest::Test
assert missing.empty?, message assert missing.empty?, message
end end
def test_codemirror_modes_present
Language.all.each do |language|
if language.codemirror_mode || language.codemirror_mime_type
assert language.codemirror_mode, "#{language.inspect} missing CodeMirror mode"
assert language.codemirror_mime_type, "#{language.inspect} missing CodeMirror MIME mode"
end
end
end
def test_valid_codemirror_mode
Language.all.each do |language|
if mode = language.codemirror_mode
assert File.exist?(File.expand_path("../../vendor/CodeMirror/mode/#{mode}", __FILE__)), "#{mode} isn't a valid CodeMirror mode"
end
end
end
def test_codemirror_mode_and_mime_defined_by_meta_mapping
meta = File.read(File.expand_path("../../vendor/CodeMirror/mode/meta.js", __FILE__))
Language.all.each do |language|
next unless language.codemirror_mode && language.codemirror_mime_type
assert meta.match(/^.+#{Regexp.escape(language.codemirror_mime_type)}.+#{Regexp.escape(language.codemirror_mode)}.+$/), "#{language.inspect}: #{language.codemirror_mime_type} not defined under #{language.codemirror_mode}"
end
end
def test_codemirror_mime_declared_in_mode_file
Language.all.each do |language|
next unless language.codemirror_mode && language.codemirror_mime_type
filename = File.expand_path("../../vendor/CodeMirror/mode/#{language.codemirror_mode}/#{language.codemirror_mode}.js", __FILE__)
assert File.exist?(filename), "#{filename} does not exist"
assert File.read(filename).match(language.codemirror_mime_type), "#{language.inspect}: #{language.codemirror_mime_type} not defined in #{filename}"
end
end
def test_all_popular_languages_exist def test_all_popular_languages_exist
popular = YAML.load(File.read(File.expand_path("../../lib/linguist/popular.yml", __FILE__))) popular = YAML.load(File.read(File.expand_path("../../lib/linguist/popular.yml", __FILE__)))

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/ruby7")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby8") 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/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/seeplusplus")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs1") assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs1")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs2") assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs2")
@@ -27,9 +30,14 @@ class TestModelines < Minitest::Test
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7") assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8") assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9") assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs10")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs11")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs12")
assert_modeline Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c") assert_modeline Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c")
assert_modeline Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl") 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["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 Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc")
assert_modeline nil, sample_blob("C/main.c") assert_modeline nil, sample_blob("C/main.c")
end end
@@ -48,9 +56,14 @@ class TestModelines < Minitest::Test
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7").language assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8").language assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9").language assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs10").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs11").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs12").language
assert_equal Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c").language 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["Prolog"], fixture_blob("Data/Modelines/not_perl.pl").language
assert_equal Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md").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 assert_equal Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc").language
end end
end end

1
vendor/CodeMirror vendored Submodule

Submodule vendor/CodeMirror added at 562e8eff5b

View File

@@ -1,11 +1,12 @@
--- ---
type: grammar type: grammar
name: Sublime-VimL name: language-viml
license: mit license: mit
--- ---
The MIT 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal 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 copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in
copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
SOFTWARE. THE SOFTWARE.