diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 49c4a6be..49c10bf7 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -62,7 +62,7 @@ module Linguist end # Language name index - @index[language.name] = @name_index[language.name] = language + @index[language.name.downcase] = @name_index[language.name.downcase] = language language.aliases.each do |name| # All Language aliases should be unique. Raise if there is a duplicate. @@ -70,7 +70,7 @@ module Linguist raise ArgumentError, "Duplicate alias: #{name}" end - @index[name] = @alias_index[name] = language + @index[name.downcase] = @alias_index[name.downcase] = language end language.extensions.each do |extension| @@ -164,7 +164,7 @@ module Linguist # # Returns the Language or nil if none was found. def self.find_by_name(name) - @name_index[name] + @name_index[name.downcase] end # Public: Look up Language by one of its aliases. @@ -178,7 +178,7 @@ module Linguist # # Returns the Lexer or nil if none was found. def self.find_by_alias(name) - @alias_index[name] + @alias_index[name.downcase] end # Public: Look up Languages by filename. @@ -227,7 +227,7 @@ module Linguist # # Returns the Language or nil if none was found. def self.[](name) - @index[name] + @index[name.downcase] end # Public: A List of popular languages diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 3521a2bd..7f42946f 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -90,6 +90,8 @@ ActionScript: color: "#e3491a" search_term: as3 aliases: + - actionscript 3 + - actionscript3 - as3 extensions: - .as @@ -99,7 +101,10 @@ Ada: color: "#02f88c" extensions: - .adb + - .ada - .ads + aliases: + - ada95ada2005 Agda: type: programming @@ -117,9 +122,11 @@ Alloy: ApacheConf: type: markup aliases: + - aconf - apache extensions: - .apacheconf + - .conf tm_scope: source.apache-config Apex: @@ -180,6 +187,7 @@ Assembly: - nasm extensions: - .asm + - .ASM - .a51 tm_scope: source.asm.x86 @@ -196,6 +204,7 @@ AutoHotkey: - ahk extensions: - .ahk + - .ahkl AutoIt: type: programming @@ -229,6 +238,9 @@ Batchfile: search_term: bat aliases: - bat + - batch + - dosbatch + - winbatch extensions: - .bat - .cmd @@ -241,8 +253,10 @@ Befunge: BlitzBasic: type: programming aliases: - - blitzplus + - b3d - blitz3d + - blitzplus + - bplus extensions: - .bb - .decls @@ -253,6 +267,8 @@ BlitzMax: color: "#cd6400" extensions: - .bmx + aliases: + - bmax Bluespec: type: programming @@ -291,6 +307,7 @@ C: - .c - .cats - .h + - .idc - .w C#: @@ -316,19 +333,20 @@ C++: extensions: - .cpp - .C + - .CPP + - .H - .c++ - .cc - .cxx - - .H - .h - .h++ - .hh - .hpp - .hxx - .inl + - .ipp - .tcc - .tpp - - .ipp C-ObjDump: type: data @@ -364,6 +382,8 @@ COBOL: type: programming extensions: - .cob + - .COB + - .CPY - .cbl - .ccp - .cobol @@ -455,8 +475,10 @@ ColdFusion: aliases: - cfm - cfml + - coldfusion html extensions: - .cfm + - .cfml tm_scope: text.html.cfm ColdFusion CFC: @@ -500,6 +522,9 @@ Component Pascal: - .cp - .cps tm_scope: source.pascal + aliases: + - delphi + - objectpascal Coq: type: programming @@ -512,9 +537,13 @@ Cpp-ObjDump: lexer: cpp-objdump extensions: - .cppobjdump + - .c++-objdump - .c++objdump + - .cpp-objdump - .cxx-objdump tm_scope: objdump.x86asm + aliases: + - c++-objdumb Creole: type: prose @@ -536,6 +565,8 @@ Cucumber: extensions: - .feature tm_scope: text.gherkin.feature + aliases: + - gherkin Cuda: type: programming @@ -559,6 +590,8 @@ Cython: - .pyx - .pxd - .pxi + aliases: + - pyrex D: type: programming @@ -609,6 +642,8 @@ Diff: extensions: - .diff - .patch + aliases: + - udiff Dogescript: type: programming @@ -622,6 +657,7 @@ Dylan: color: "#3ebc27" extensions: - .dylan + - .dyl - .intr - .lid @@ -706,6 +742,7 @@ Erlang: color: "#0faf8d" extensions: - .erl + - .es - .escript - .hrl @@ -848,6 +885,7 @@ GLSL: - .frag - .frg - .fshader + - .geo - .geom - .glslv - .gshader @@ -860,6 +898,9 @@ Genshi: extensions: - .kid tm_scope: text.xml.genshi + aliases: + - xml+genshi + - xml+kid Gentoo Ebuild: group: Shell @@ -955,6 +996,8 @@ Groff: - '.6' - '.7' tm_scope: text.groff + aliases: + - nroff Groovy: type: programming @@ -973,6 +1016,7 @@ Groovy Server Pages: lexer: Java Server Page aliases: - gsp + - java server page extensions: - .gsp tm_scope: text.html.jsp @@ -997,6 +1041,10 @@ HTML+Django: extensions: - .mustache - .jinja + aliases: + - html+django/jinja + - html+jinja + - htmldjango HTML+ERB: type: markup @@ -1076,6 +1124,8 @@ Hy: color: "#7891b1" extensions: - .hy + aliases: + - hylang IDL: type: programming @@ -1090,14 +1140,20 @@ IGOR Pro: lexer: Igor extensions: - .ipf + aliases: + - igor + - igorpro INI: type: data extensions: - .ini + - .cfg - .prefs - .properties tm_scope: source.ini + aliases: + - dosini Inno Setup: extensions: @@ -1119,6 +1175,9 @@ Inform 7: - .ni - .i7x tm_scope: source.inform + aliases: + - i7 + - inform7 Inno Setup: extensions: @@ -1130,6 +1189,7 @@ IRC log: search_term: irc aliases: - irc + - irc logs extensions: - .irclog - .weechatlog @@ -1330,9 +1390,12 @@ Lasso: extensions: - .lasso - .las + - .lasso8 - .lasso9 - .ldml tm_scope: file.lasso + aliases: + - lassoscript Latte: type: markup @@ -1387,6 +1450,7 @@ Literate Haskell: group: Haskell search_term: lhs aliases: + - lhaskell - lhs extensions: - .lhs @@ -1397,6 +1461,7 @@ LiveScript: ace_mode: ls color: "#499886" aliases: + - live-script - ls extensions: - .ls @@ -1408,6 +1473,8 @@ Logos: type: programming extensions: - .xm + - .x + - .xi Logtalk: type: programming @@ -1434,6 +1501,7 @@ Lua: - .nse - .pd_lua - .rbxs + - .wlua interpreters: - lua @@ -1457,7 +1525,9 @@ MTML: Makefile: aliases: + - bsdmake - make + - mf extensions: - .mak - .mk @@ -1501,9 +1571,14 @@ Mathematica: type: programming extensions: - .mathematica + - .cdf - .m + - .ma - .nb + - .nbp lexer: Mathematica + aliases: + - mma Matlab: type: programming @@ -1610,6 +1685,8 @@ Nginx: extensions: - .nginxconf tm_scope: source.nginx + aliases: + - nginx configuration file Nimrod: type: programming @@ -1630,6 +1707,8 @@ Nix: lexer: Nix extensions: - .nix + aliases: + - nixos Nu: type: programming @@ -1677,6 +1756,7 @@ Objective-C: aliases: - obj-c - objc + - objectivec extensions: - .m - .h @@ -1688,6 +1768,7 @@ Objective-C++: aliases: - obj-c++ - objc++ + - objectivec++ extensions: - .mm @@ -1696,6 +1777,8 @@ Objective-J: color: "#ff0c5a" aliases: - obj-j + - objectivej + - objj extensions: - .j - .sj @@ -1795,6 +1878,8 @@ PHP: - Phakefile interpreters: - php + aliases: + - inc Pan: type: programming @@ -1914,6 +1999,8 @@ PostScript: - .ps - .eps tm_scope: source.postscript + aliases: + - postscr PowerShell: type: programming @@ -1995,6 +2082,7 @@ Python: - .pyp - .pyt - .pyw + - .tac - .wsgi - .xpy filenames: @@ -2032,6 +2120,7 @@ R: aliases: - R - Rscript + - splus extensions: - .r - .R @@ -2070,6 +2159,8 @@ RHTML: extensions: - .rhtml tm_scope: text.html.ruby + aliases: + - html+ruby RMarkdown: type: prose @@ -2097,6 +2188,9 @@ Ragel in Ruby Host: color: "#ff9c2e" extensions: - .rl + aliases: + - ragel-rb + - ragel-ruby Raw token data: search_term: raw @@ -2123,6 +2217,8 @@ Red: extensions: - .red - .reds + aliases: + - red/system Redcode: extensions: @@ -2316,6 +2412,7 @@ Shell: - .cgi - .command - .fcgi + - .ksh - .tmux - .zsh interpreters: @@ -2330,6 +2427,9 @@ ShellSession: lexer: Bash Session extensions: - .sh-session + aliases: + - bash session + - console Shen: type: programming @@ -2358,6 +2458,8 @@ Smalltalk: color: "#596706" extensions: - .st + aliases: + - squeak Smarty: extensions: @@ -2612,6 +2714,9 @@ Visual Basic: - .vbhtml - .vbs tm_scope: source.vbnet + aliases: + - vb.net + - vbnet Volt: type: programming @@ -2682,6 +2787,7 @@ XML: - .vcxproj - .vxml - .wsdl + - .wsf - .wxi - .wxl - .wxs diff --git a/test/test_language.rb b/test/test_language.rb index f2bbfc8b..0039dc2b 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -303,6 +303,21 @@ class TestLanguage < Test::Unit::TestCase assert_nil Language['defunkt'] end + def test_find_ignores_case + assert_equal 'AGS Script', Language['ags script'].name + assert_equal 'AGS Script', Language['ags sCRIPT'].name + end + + def test_find_by_name_ignores_case + assert_equal 'AGS Script', Language.find_by_name('ags script').name + assert_equal 'AGS Script', Language.find_by_name('ags sCRIPT').name + end + + def test_find_by_alias_ignores_case + refute_includes Language['AGS Script'].aliases, 'AGS' + assert_equal 'AGS Script', Language.find_by_alias('AGS').name + end + def test_name assert_equal 'Perl', Language['Perl'].name assert_equal 'Python', Language['Python'].name