mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
State Ace compatible languages
This commit is contained in:
@@ -194,6 +194,13 @@ module Linguist
|
|||||||
@unpopular ||= all.select(&:unpopular?).sort_by { |lang| lang.name.downcase }
|
@unpopular ||= all.select(&:unpopular?).sort_by { |lang| lang.name.downcase }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: A List of languages compatible with Ace.
|
||||||
|
#
|
||||||
|
# Returns an Array of Languages.
|
||||||
|
def self.ace_modes
|
||||||
|
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
|
||||||
|
end
|
||||||
|
|
||||||
# Internal: Initialize a new Language
|
# Internal: Initialize a new Language
|
||||||
#
|
#
|
||||||
# attributes - A hash of attributes
|
# attributes - A hash of attributes
|
||||||
@@ -214,6 +221,8 @@ module Linguist
|
|||||||
@lexer = Pygments::Lexer.find_by_name(attributes[:lexer] || name) ||
|
@lexer = Pygments::Lexer.find_by_name(attributes[:lexer] || name) ||
|
||||||
raise(ArgumentError, "#{@name} is missing lexer")
|
raise(ArgumentError, "#{@name} is missing lexer")
|
||||||
|
|
||||||
|
@ace_mode = attributes[:ace_mode]
|
||||||
|
|
||||||
# Set legacy search term
|
# Set legacy search term
|
||||||
@search_term = attributes[:search_term] || default_alias_name
|
@search_term = attributes[:search_term] || default_alias_name
|
||||||
|
|
||||||
@@ -286,6 +295,17 @@ module Linguist
|
|||||||
# Returns the Lexer
|
# Returns the Lexer
|
||||||
attr_reader :lexer
|
attr_reader :lexer
|
||||||
|
|
||||||
|
# Public: Get Ace mode
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# # => "text"
|
||||||
|
# # => "javascript"
|
||||||
|
# # => "c_cpp"
|
||||||
|
#
|
||||||
|
# Returns a String name or nil
|
||||||
|
attr_reader :ace_mode
|
||||||
|
|
||||||
# Public: Get extensions
|
# Public: Get extensions
|
||||||
#
|
#
|
||||||
# Examples
|
# Examples
|
||||||
@@ -417,6 +437,7 @@ module Linguist
|
|||||||
:type => options['type'],
|
:type => options['type'],
|
||||||
:aliases => options['aliases'],
|
:aliases => options['aliases'],
|
||||||
:lexer => options['lexer'],
|
:lexer => options['lexer'],
|
||||||
|
:ace_mode => options['ace_mode'],
|
||||||
:group_name => options['group'],
|
:group_name => options['group'],
|
||||||
:searchable => options.key?('searchable') ? options['searchable'] : true,
|
:searchable => options.key?('searchable') ? options['searchable'] : true,
|
||||||
:search_term => options['search_term'],
|
:search_term => options['search_term'],
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
# lexer - An explicit lexer String (defaults to name.downcase)
|
# lexer - An explicit lexer String (defaults to name.downcase)
|
||||||
# aliases - An Array of additional aliases (implicitly
|
# aliases - An Array of additional aliases (implicitly
|
||||||
# includes name.downcase)
|
# includes name.downcase)
|
||||||
|
# ace_mode - A String name of Ace Mode (if available)
|
||||||
# extension - An Array of associated extensions
|
# extension - An Array of associated extensions
|
||||||
# primary_extension - A String for the main extension associated with
|
# primary_extension - A String for the main extension associated with
|
||||||
# the langauge. (defaults to extensions.first)
|
# the langauge. (defaults to extensions.first)
|
||||||
@@ -143,6 +144,7 @@ C:
|
|||||||
|
|
||||||
C#:
|
C#:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: csharp
|
||||||
search_term: csharp
|
search_term: csharp
|
||||||
aliases:
|
aliases:
|
||||||
- csharp
|
- csharp
|
||||||
@@ -151,6 +153,7 @@ C#:
|
|||||||
|
|
||||||
C++:
|
C++:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: c_cpp
|
||||||
search_term: cpp
|
search_term: cpp
|
||||||
aliases:
|
aliases:
|
||||||
- cpp
|
- cpp
|
||||||
@@ -191,6 +194,7 @@ CMake:
|
|||||||
- CMakeLists.txt
|
- CMakeLists.txt
|
||||||
|
|
||||||
CSS:
|
CSS:
|
||||||
|
ace_mode: css
|
||||||
extensions:
|
extensions:
|
||||||
- .css
|
- .css
|
||||||
|
|
||||||
@@ -201,6 +205,7 @@ ChucK:
|
|||||||
|
|
||||||
Clojure:
|
Clojure:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: clojure
|
||||||
primary_extension: .clj
|
primary_extension: .clj
|
||||||
extensions:
|
extensions:
|
||||||
- .clj
|
- .clj
|
||||||
@@ -208,6 +213,7 @@ Clojure:
|
|||||||
|
|
||||||
CoffeeScript:
|
CoffeeScript:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: coffee
|
||||||
aliases:
|
aliases:
|
||||||
- coffee
|
- coffee
|
||||||
extensions:
|
extensions:
|
||||||
@@ -218,6 +224,7 @@ CoffeeScript:
|
|||||||
ColdFusion:
|
ColdFusion:
|
||||||
type: programming
|
type: programming
|
||||||
lexer: Coldfusion HTML
|
lexer: Coldfusion HTML
|
||||||
|
ace_mode: coldfusion
|
||||||
search_term: cfm
|
search_term: cfm
|
||||||
aliases:
|
aliases:
|
||||||
- cfm
|
- cfm
|
||||||
@@ -444,6 +451,7 @@ Groff:
|
|||||||
Groovy:
|
Groovy:
|
||||||
type: programming
|
type: programming
|
||||||
lexer: Java
|
lexer: Java
|
||||||
|
ace_mode: groovy
|
||||||
primary_extension: .groovy
|
primary_extension: .groovy
|
||||||
extensions:
|
extensions:
|
||||||
- .gradle
|
- .gradle
|
||||||
@@ -461,6 +469,7 @@ Groovy Server Pages:
|
|||||||
|
|
||||||
HTML:
|
HTML:
|
||||||
type: markup
|
type: markup
|
||||||
|
ace_mode: html
|
||||||
primary_extension: .html
|
primary_extension: .html
|
||||||
extensions:
|
extensions:
|
||||||
- .htm
|
- .htm
|
||||||
@@ -493,6 +502,7 @@ HTML+PHP:
|
|||||||
HaXe:
|
HaXe:
|
||||||
type: programming
|
type: programming
|
||||||
lexer: haXe
|
lexer: haXe
|
||||||
|
ace_mode: haxe
|
||||||
extensions:
|
extensions:
|
||||||
- .hx
|
- .hx
|
||||||
- .hxml
|
- .hxml
|
||||||
@@ -542,12 +552,14 @@ JSON:
|
|||||||
type: data
|
type: data
|
||||||
group: JavaScript
|
group: JavaScript
|
||||||
lexer: JavaScript
|
lexer: JavaScript
|
||||||
|
ace_mode: json
|
||||||
searchable: false
|
searchable: false
|
||||||
extensions:
|
extensions:
|
||||||
- .json
|
- .json
|
||||||
|
|
||||||
Java:
|
Java:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: java
|
||||||
extensions:
|
extensions:
|
||||||
- .java
|
- .java
|
||||||
- .pde
|
- .pde
|
||||||
@@ -563,6 +575,7 @@ Java Server Pages:
|
|||||||
|
|
||||||
JavaScript:
|
JavaScript:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: javascript
|
||||||
aliases:
|
aliases:
|
||||||
- js
|
- js
|
||||||
- node
|
- node
|
||||||
@@ -608,6 +621,7 @@ Logtalk:
|
|||||||
|
|
||||||
Lua:
|
Lua:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: lua
|
||||||
primary_extension: .lua
|
primary_extension: .lua
|
||||||
extensions:
|
extensions:
|
||||||
- .lua
|
- .lua
|
||||||
@@ -630,6 +644,7 @@ Mako:
|
|||||||
Markdown:
|
Markdown:
|
||||||
type: markup
|
type: markup
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
|
ace_mode: markdown
|
||||||
primary_extension: .md
|
primary_extension: .md
|
||||||
extensions:
|
extensions:
|
||||||
- .markdown
|
- .markdown
|
||||||
@@ -704,6 +719,7 @@ NumPy:
|
|||||||
|
|
||||||
OCaml:
|
OCaml:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: ocaml
|
||||||
primary_extension: .ml
|
primary_extension: .ml
|
||||||
extensions:
|
extensions:
|
||||||
- .ml
|
- .ml
|
||||||
@@ -759,6 +775,7 @@ OpenEdge ABL:
|
|||||||
|
|
||||||
PHP:
|
PHP:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: php
|
||||||
extensions:
|
extensions:
|
||||||
- .aw
|
- .aw
|
||||||
- .ctp
|
- .ctp
|
||||||
@@ -793,6 +810,7 @@ Parrot Assembly:
|
|||||||
|
|
||||||
Perl:
|
Perl:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: perl
|
||||||
overrides:
|
overrides:
|
||||||
- .pl
|
- .pl
|
||||||
- .t
|
- .t
|
||||||
@@ -811,6 +829,7 @@ Perl:
|
|||||||
Powershell:
|
Powershell:
|
||||||
type: programming
|
type: programming
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
|
ace_mode: powershell
|
||||||
aliases:
|
aliases:
|
||||||
- posh
|
- posh
|
||||||
extensions:
|
extensions:
|
||||||
@@ -838,6 +857,7 @@ Pure Data:
|
|||||||
|
|
||||||
Python:
|
Python:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: python
|
||||||
primary_extension: .py
|
primary_extension: .py
|
||||||
extensions:
|
extensions:
|
||||||
- .py
|
- .py
|
||||||
@@ -901,6 +921,7 @@ Redcode:
|
|||||||
|
|
||||||
Ruby:
|
Ruby:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: ruby
|
||||||
aliases:
|
aliases:
|
||||||
- jruby
|
- jruby
|
||||||
- macruby
|
- macruby
|
||||||
@@ -941,11 +962,13 @@ Rust:
|
|||||||
SCSS:
|
SCSS:
|
||||||
type: markup
|
type: markup
|
||||||
group: CSS
|
group: CSS
|
||||||
|
ace_mode: scss
|
||||||
extensions:
|
extensions:
|
||||||
- .scss
|
- .scss
|
||||||
|
|
||||||
SQL:
|
SQL:
|
||||||
type: data
|
type: data
|
||||||
|
ace_mode: sql
|
||||||
searchable: false
|
searchable: false
|
||||||
extensions:
|
extensions:
|
||||||
- .sql
|
- .sql
|
||||||
@@ -966,6 +989,7 @@ Sass:
|
|||||||
|
|
||||||
Scala:
|
Scala:
|
||||||
type: programming
|
type: programming
|
||||||
|
ace_mode: scala
|
||||||
primary_extension: .scala
|
primary_extension: .scala
|
||||||
extensions:
|
extensions:
|
||||||
- .sbt
|
- .sbt
|
||||||
@@ -1056,6 +1080,7 @@ Tcsh:
|
|||||||
|
|
||||||
TeX:
|
TeX:
|
||||||
type: markup
|
type: markup
|
||||||
|
ace_mode: latex
|
||||||
primary_extension: .tex
|
primary_extension: .tex
|
||||||
overrides:
|
overrides:
|
||||||
- .cls
|
- .cls
|
||||||
@@ -1072,12 +1097,14 @@ TeX:
|
|||||||
Text:
|
Text:
|
||||||
type: data
|
type: data
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
|
ace_mode: text
|
||||||
extensions:
|
extensions:
|
||||||
- .txt
|
- .txt
|
||||||
|
|
||||||
Textile:
|
Textile:
|
||||||
type: markup
|
type: markup
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
|
ace_mode: textile
|
||||||
extensions:
|
extensions:
|
||||||
- .textile
|
- .textile
|
||||||
|
|
||||||
@@ -1144,6 +1171,7 @@ Visual Basic:
|
|||||||
|
|
||||||
XML:
|
XML:
|
||||||
type: markup
|
type: markup
|
||||||
|
ace_mode: xml
|
||||||
primary_extension: .xml
|
primary_extension: .xml
|
||||||
extensions:
|
extensions:
|
||||||
- .glade
|
- .glade
|
||||||
|
|||||||
@@ -306,6 +306,21 @@ class TestLanguage < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ace_mode
|
||||||
|
assert_equal 'c_cpp', Language['C++'].ace_mode
|
||||||
|
assert_equal 'coffee', Language['CoffeeScript'].ace_mode
|
||||||
|
assert_equal 'csharp', Language['C#'].ace_mode
|
||||||
|
assert_equal 'css', Language['CSS'].ace_mode
|
||||||
|
assert_equal 'javascript', Language['JavaScript'].ace_mode
|
||||||
|
assert_equal 'text', Language['Text'].ace_mode
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ace_modes
|
||||||
|
assert Language.ace_modes.include?(Language['Text'])
|
||||||
|
assert Language.ace_modes.include?(Language['Ruby'])
|
||||||
|
assert !Language.ace_modes.include?(Language['FORTRAN'])
|
||||||
|
end
|
||||||
|
|
||||||
def test_extensions
|
def test_extensions
|
||||||
assert Language['Perl'].extensions.include?('.pl')
|
assert Language['Perl'].extensions.include?('.pl')
|
||||||
assert Language['Python'].extensions.include?('.py')
|
assert Language['Python'].extensions.include?('.py')
|
||||||
|
|||||||
Reference in New Issue
Block a user