mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-04 08:25:34 +00:00
Merge branch 'master' into go-vendor
* master: (168 commits) ruby for example Bumping version Updating grammars Grammar for Less from Atom package Remove Less grammar Updating to latest perl6 grammar Adding Perl6-specific grammar. Grammar for YANG from Atom package Support for YANG language Add detection of GrammarKit-generated files Add .xproj to list of XML extensions Test submodules are using HTTPS links Improved vim modeline detection Heuristic for Pod vs. Perl Bumping to v4.7.4 Grammar update Support .rs.in as a file extension for Rust files. HTTPS links for submodules Add the LFE lexer as an example of erlang .xrl Add the Elixir parser as an example of erlang .yrl ...
This commit is contained in:
73
lib/linguist/blob.rb
Normal file
73
lib/linguist/blob.rb
Normal file
@@ -0,0 +1,73 @@
|
||||
require 'linguist/blob_helper'
|
||||
|
||||
module Linguist
|
||||
# A Blob is a wrapper around the content of a file to make it quack
|
||||
# like a Grit::Blob. It provides the basic interface: `name`,
|
||||
# `data`, `path` and `size`.
|
||||
class Blob
|
||||
include BlobHelper
|
||||
|
||||
# Public: Initialize a new Blob.
|
||||
#
|
||||
# path - A path String (does not necessarily exists on the file system).
|
||||
# content - Content of the file.
|
||||
#
|
||||
# Returns a Blob.
|
||||
def initialize(path, content)
|
||||
@path = path
|
||||
@content = content
|
||||
end
|
||||
|
||||
# Public: Filename
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# Blob.new("/path/to/linguist/lib/linguist.rb", "").path
|
||||
# # => "/path/to/linguist/lib/linguist.rb"
|
||||
#
|
||||
# Returns a String
|
||||
attr_reader :path
|
||||
|
||||
# Public: File name
|
||||
#
|
||||
# Returns a String
|
||||
def name
|
||||
File.basename(@path)
|
||||
end
|
||||
|
||||
# Public: File contents.
|
||||
#
|
||||
# Returns a String.
|
||||
def data
|
||||
@content
|
||||
end
|
||||
|
||||
# Public: Get byte size
|
||||
#
|
||||
# Returns an Integer.
|
||||
def size
|
||||
@content.bytesize
|
||||
end
|
||||
|
||||
# Public: Get file extension.
|
||||
#
|
||||
# Returns a String.
|
||||
def extension
|
||||
extensions.last || ""
|
||||
end
|
||||
|
||||
# Public: Return an array of the file extensions
|
||||
#
|
||||
# >> Linguist::Blob.new("app/views/things/index.html.erb").extensions
|
||||
# => [".html.erb", ".erb"]
|
||||
#
|
||||
# Returns an Array
|
||||
def extensions
|
||||
basename, *segments = name.downcase.split(".")
|
||||
|
||||
segments.map.with_index do |segment, index|
|
||||
"." + segments[index..-1].join(".")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1,11 @@
|
||||
require 'linguist/blob_helper'
|
||||
require 'linguist/blob'
|
||||
|
||||
module Linguist
|
||||
# A FileBlob is a wrapper around a File object to make it quack
|
||||
# like a Grit::Blob. It provides the basic interface: `name`,
|
||||
# `data`, `path` and `size`.
|
||||
class FileBlob
|
||||
class FileBlob < Blob
|
||||
include BlobHelper
|
||||
|
||||
# Public: Initialize a new FileBlob from a path
|
||||
@@ -18,20 +19,6 @@ module Linguist
|
||||
@path = base_path ? path.sub("#{base_path}/", '') : path
|
||||
end
|
||||
|
||||
# Public: Filename
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# FileBlob.new("/path/to/linguist/lib/linguist.rb").path
|
||||
# # => "/path/to/linguist/lib/linguist.rb"
|
||||
#
|
||||
# FileBlob.new("/path/to/linguist/lib/linguist.rb",
|
||||
# "/path/to/linguist").path
|
||||
# # => "lib/linguist.rb"
|
||||
#
|
||||
# Returns a String
|
||||
attr_reader :path
|
||||
|
||||
# Public: Read file permissions
|
||||
#
|
||||
# Returns a String like '100644'
|
||||
@@ -39,13 +26,6 @@ module Linguist
|
||||
File.stat(@fullpath).mode.to_s(8)
|
||||
end
|
||||
|
||||
# Public: File name
|
||||
#
|
||||
# Returns a String
|
||||
def name
|
||||
File.basename(@fullpath)
|
||||
end
|
||||
|
||||
# Public: Read file contents.
|
||||
#
|
||||
# Returns a String.
|
||||
@@ -59,26 +39,5 @@ module Linguist
|
||||
def size
|
||||
File.size(@fullpath)
|
||||
end
|
||||
|
||||
# Public: Get file extension.
|
||||
#
|
||||
# Returns a String.
|
||||
def extension
|
||||
extensions.last || ""
|
||||
end
|
||||
|
||||
# Public: Return an array of the file extensions
|
||||
#
|
||||
# >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions
|
||||
# => [".html.erb", ".erb"]
|
||||
#
|
||||
# Returns an Array
|
||||
def extensions
|
||||
basename, *segments = name.downcase.split(".")
|
||||
|
||||
segments.map.with_index do |segment, index|
|
||||
"." + segments[index..-1].join(".")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,7 +72,10 @@ module Linguist
|
||||
generated_jni_header? ||
|
||||
vcr_cassette? ||
|
||||
generated_module? ||
|
||||
generated_unity3d_meta?
|
||||
generated_unity3d_meta? ||
|
||||
generated_racc? ||
|
||||
generated_jflex? ||
|
||||
generated_grammarkit?
|
||||
end
|
||||
|
||||
# Internal: Is the blob an Xcode file?
|
||||
@@ -242,22 +245,26 @@ module Linguist
|
||||
return lines[0].include?("Code generated by")
|
||||
end
|
||||
|
||||
PROTOBUF_EXTENSIONS = ['.py', '.java', '.h', '.cc', '.cpp']
|
||||
|
||||
# Internal: Is the blob a C++, Java or Python source file generated by the
|
||||
# Protocol Buffer compiler?
|
||||
#
|
||||
# Returns true of false.
|
||||
def generated_protocol_buffer?
|
||||
return false unless ['.py', '.java', '.h', '.cc', '.cpp'].include?(extname)
|
||||
return false unless PROTOBUF_EXTENSIONS.include?(extname)
|
||||
return false unless lines.count > 1
|
||||
|
||||
return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!")
|
||||
end
|
||||
|
||||
APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp']
|
||||
|
||||
# Internal: Is the blob generated by Apache Thrift compiler?
|
||||
#
|
||||
# Returns true or false
|
||||
def generated_apache_thrift?
|
||||
return false unless ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp'].include?(extname)
|
||||
return false unless APACHE_THRIFT_EXTENSIONS.include?(extname)
|
||||
return false unless lines.count > 1
|
||||
|
||||
return lines[0].include?("Autogenerated by Thrift Compiler") || lines[1].include?("Autogenerated by Thrift Compiler")
|
||||
@@ -366,5 +373,45 @@ module Linguist
|
||||
return false unless lines.count > 1
|
||||
return lines[0].include?("fileFormatVersion: ")
|
||||
end
|
||||
|
||||
# Internal: Is this a Racc-generated file?
|
||||
#
|
||||
# A Racc-generated file contains:
|
||||
# # This file is automatically generated by Racc x.y.z
|
||||
# on the third line.
|
||||
#
|
||||
# Return true or false
|
||||
def generated_racc?
|
||||
return false unless extname == '.rb'
|
||||
return false unless lines.count > 2
|
||||
return lines[2].start_with?("# This file is automatically generated by Racc")
|
||||
end
|
||||
|
||||
# Internal: Is this a JFlex-generated file?
|
||||
#
|
||||
# A JFlex-generated file contains:
|
||||
# /* The following code was generated by JFlex x.y.z on d/at/e ti:me */
|
||||
# on the first line.
|
||||
#
|
||||
# Return true or false
|
||||
def generated_jflex?
|
||||
return false unless extname == '.java'
|
||||
return false unless lines.count > 1
|
||||
return lines[0].start_with?("/* The following code was generated by JFlex ")
|
||||
end
|
||||
|
||||
# Internal: Is this a GrammarKit-generated file?
|
||||
#
|
||||
# A GrammarKit-generated file typically contain:
|
||||
# // This is a generated file. Not intended for manual editing.
|
||||
# on the first line. This is not always the case, as it's possible to
|
||||
# customize the class header.
|
||||
#
|
||||
# Return true or false
|
||||
def generated_grammarkit?
|
||||
return false unless extname == '.java'
|
||||
return false unless lines.count > 1
|
||||
return lines[0].start_with?("// This is a generated file. Not intended for manual editing.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,7 +56,8 @@ module Linguist
|
||||
|
||||
# Internal: Check if this heuristic matches the candidate languages.
|
||||
def matches?(filename)
|
||||
@extensions.any? { |ext| filename.downcase.end_with?(ext) }
|
||||
filename = filename.downcase
|
||||
@extensions.any? { |ext| filename.end_with?(ext) }
|
||||
end
|
||||
|
||||
# Internal: Perform the heuristic
|
||||
@@ -65,7 +66,7 @@ module Linguist
|
||||
end
|
||||
|
||||
# Common heuristics
|
||||
ObjectiveCRegex = /^[ \t]*@(interface|class|protocol|property|end|synchronized|selector|implementation)\b/
|
||||
ObjectiveCRegex = /^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])/
|
||||
|
||||
disambiguate ".asc" do |data|
|
||||
if /^(----[- ]BEGIN|ssh-(rsa|dss)) /.match(data)
|
||||
@@ -130,7 +131,7 @@ module Linguist
|
||||
disambiguate ".for", ".f" do |data|
|
||||
if /^: /.match(data)
|
||||
Language["Forth"]
|
||||
elsif /^([c*][^a-z]| (subroutine|program)\s|\s*!)/i.match(data)
|
||||
elsif /^([c*][^abd-z]| (subroutine|program|end)\s|\s*!)/i.match(data)
|
||||
Language["FORTRAN"]
|
||||
end
|
||||
end
|
||||
@@ -237,8 +238,10 @@ module Linguist
|
||||
disambiguate ".ms" do |data|
|
||||
if /^[.'][a-z][a-z](\s|$)/i.match(data)
|
||||
Language["Groff"]
|
||||
elsif /((^|\s)move?[. ])|\.(include|globa?l)\s/.match(data)
|
||||
elsif /(?<!\S)\.(include|globa?l)\s/.match(data) || /(?<!\/\*)(\A|\n)\s*\.[A-Za-z]/.match(data.gsub(/"([^\\"]|\\.)*"|'([^\\']|\\.)*'|\\\s*(?:--.*)?\n/, ""))
|
||||
Language["GAS"]
|
||||
else
|
||||
Language["MAXScript"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -273,19 +276,27 @@ module Linguist
|
||||
end
|
||||
|
||||
disambiguate ".pl" do |data|
|
||||
if /^(use v6|(my )?class|module)/.match(data)
|
||||
Language["Perl6"]
|
||||
if /^[^#]+:-/.match(data)
|
||||
Language["Prolog"]
|
||||
elsif /use strict|use\s+v?5\./.match(data)
|
||||
Language["Perl"]
|
||||
elsif /^[^#]+:-/.match(data)
|
||||
Language["Prolog"]
|
||||
elsif /^(use v6|(my )?class|module)/.match(data)
|
||||
Language["Perl6"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate ".pm", ".t" do |data|
|
||||
if /^(use v6|(my )?class|module)/.match(data)
|
||||
if /use strict|use\s+v?5\./.match(data)
|
||||
Language["Perl"]
|
||||
elsif /^(use v6|(my )?class|module)/.match(data)
|
||||
Language["Perl6"]
|
||||
elsif /use strict|use\s+v?5\./.match(data)
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate ".pod" do |data|
|
||||
if /^=\w+$/.match(data)
|
||||
Language["Pod"]
|
||||
else
|
||||
Language["Perl"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
# 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)
|
||||
# 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 maybe indexed under a
|
||||
@@ -141,7 +142,7 @@ Agda:
|
||||
|
||||
Alloy:
|
||||
type: programming # 'modeling' would be more appropiate
|
||||
color: "#cc5c24"
|
||||
color: "#64C800"
|
||||
extensions:
|
||||
- .als
|
||||
ace_mode: text
|
||||
@@ -182,6 +183,7 @@ AppleScript:
|
||||
interpreters:
|
||||
- osascript
|
||||
ace_mode: applescript
|
||||
color: "#101F1F"
|
||||
|
||||
Arc:
|
||||
type: programming
|
||||
@@ -289,6 +291,7 @@ Batchfile:
|
||||
- .cmd
|
||||
tm_scope: source.dosbatch
|
||||
ace_mode: batchfile
|
||||
color: "#C1F12E"
|
||||
|
||||
Befunge:
|
||||
type: programming
|
||||
@@ -303,6 +306,7 @@ Bison:
|
||||
extensions:
|
||||
- .bison
|
||||
ace_mode: text
|
||||
color: "#6A463F"
|
||||
|
||||
BitBake:
|
||||
type: programming
|
||||
@@ -392,6 +396,7 @@ C#:
|
||||
- csharp
|
||||
extensions:
|
||||
- .cs
|
||||
- .cake
|
||||
- .cshtml
|
||||
- .csx
|
||||
|
||||
@@ -539,6 +544,14 @@ Clean:
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
Click:
|
||||
type: programming
|
||||
color: "#E4E6F3"
|
||||
extensions:
|
||||
- .click
|
||||
tm_scope: source.click
|
||||
ace_mode: text
|
||||
|
||||
Clojure:
|
||||
type: programming
|
||||
ace_mode: clojure
|
||||
@@ -567,6 +580,7 @@ CoffeeScript:
|
||||
extensions:
|
||||
- .coffee
|
||||
- ._coffee
|
||||
- .cake
|
||||
- .cjsx
|
||||
- .cson
|
||||
- .iced
|
||||
@@ -627,7 +641,7 @@ Common Lisp:
|
||||
|
||||
Component Pascal:
|
||||
type: programming
|
||||
color: "#b0ce4e"
|
||||
color: "#B0CE4E"
|
||||
extensions:
|
||||
- .cp
|
||||
- .cps
|
||||
@@ -690,6 +704,7 @@ Cucumber:
|
||||
aliases:
|
||||
- gherkin
|
||||
ace_mode: text
|
||||
color: "#5B2063"
|
||||
|
||||
Cuda:
|
||||
type: programming
|
||||
@@ -698,6 +713,7 @@ Cuda:
|
||||
- .cuh
|
||||
tm_scope: source.cuda-c++
|
||||
ace_mode: c_cpp
|
||||
color: "#3A4E3A"
|
||||
|
||||
Cycript:
|
||||
type: programming
|
||||
@@ -719,7 +735,7 @@ Cython:
|
||||
|
||||
D:
|
||||
type: programming
|
||||
color: "#fcd46d"
|
||||
color: "#ba595e"
|
||||
extensions:
|
||||
- .d
|
||||
- .di
|
||||
@@ -790,7 +806,6 @@ Dart:
|
||||
|
||||
Diff:
|
||||
type: data
|
||||
color: "#88dddd"
|
||||
extensions:
|
||||
- .diff
|
||||
- .patch
|
||||
@@ -884,6 +899,8 @@ Elixir:
|
||||
ace_mode: elixir
|
||||
filenames:
|
||||
- mix.lock
|
||||
interpreters:
|
||||
- elixir
|
||||
|
||||
Elm:
|
||||
type: programming
|
||||
@@ -926,6 +943,8 @@ Erlang:
|
||||
- .es
|
||||
- .escript
|
||||
- .hrl
|
||||
- .xrl
|
||||
- .yrl
|
||||
filenames:
|
||||
- rebar.config
|
||||
- rebar.config.lock
|
||||
@@ -1011,6 +1030,7 @@ Formatted:
|
||||
type: data
|
||||
extensions:
|
||||
- .for
|
||||
- .eam.fs
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
@@ -1028,6 +1048,16 @@ Forth:
|
||||
- .fs
|
||||
ace_mode: forth
|
||||
|
||||
FreeMarker:
|
||||
type: programming
|
||||
color: "#0050b2"
|
||||
aliases:
|
||||
- ftl
|
||||
extensions:
|
||||
- .ftl
|
||||
tm_scope: text.html.ftl
|
||||
ace_mode: ftl
|
||||
|
||||
Frege:
|
||||
type: programming
|
||||
color: "#00cafe"
|
||||
@@ -1317,11 +1347,22 @@ HTML+Django:
|
||||
- .mustache
|
||||
- .jinja
|
||||
aliases:
|
||||
- django
|
||||
- html+django/jinja
|
||||
- html+jinja
|
||||
- htmldjango
|
||||
ace_mode: django
|
||||
|
||||
HTML+EEX:
|
||||
type: markup
|
||||
tm_scope: text.html.elixir
|
||||
group: HTML
|
||||
aliases:
|
||||
- eex
|
||||
extensions:
|
||||
- .eex
|
||||
ace_mode: text
|
||||
|
||||
HTML+ERB:
|
||||
type: markup
|
||||
tm_scope: text.html.erb
|
||||
@@ -1331,7 +1372,7 @@ HTML+ERB:
|
||||
extensions:
|
||||
- .erb
|
||||
- .erb.deface
|
||||
ace_mode: html_ruby
|
||||
ace_mode: text
|
||||
|
||||
HTML+PHP:
|
||||
type: markup
|
||||
@@ -1355,6 +1396,7 @@ Hack:
|
||||
- .hh
|
||||
- .php
|
||||
tm_scope: text.html.php
|
||||
color: "#878787"
|
||||
|
||||
Haml:
|
||||
group: HTML
|
||||
@@ -1363,10 +1405,12 @@ Haml:
|
||||
- .haml
|
||||
- .haml.deface
|
||||
ace_mode: haml
|
||||
color: "#ECE2A9"
|
||||
|
||||
Handlebars:
|
||||
type: markup
|
||||
color: "#01a9d6"
|
||||
group: HTML
|
||||
aliases:
|
||||
- hbs
|
||||
- htmlbars
|
||||
@@ -1474,7 +1518,7 @@ Inform 7:
|
||||
extensions:
|
||||
- .ni
|
||||
- .i7x
|
||||
tm_scope: source.Inform7
|
||||
tm_scope: source.inform7
|
||||
aliases:
|
||||
- i7
|
||||
- inform7
|
||||
@@ -1575,12 +1619,20 @@ JSONiq:
|
||||
- .jq
|
||||
tm_scope: source.jq
|
||||
|
||||
JSX:
|
||||
type: programming
|
||||
group: JavaScript
|
||||
extensions:
|
||||
- .jsx
|
||||
tm_scope: source.js.jsx
|
||||
ace_mode: javascript
|
||||
|
||||
Jade:
|
||||
group: HTML
|
||||
type: markup
|
||||
extensions:
|
||||
- .jade
|
||||
tm_scope: source.jade
|
||||
tm_scope: text.jade
|
||||
ace_mode: jade
|
||||
|
||||
Jasmin:
|
||||
@@ -1625,10 +1677,10 @@ JavaScript:
|
||||
- .gs
|
||||
- .jake
|
||||
- .jsb
|
||||
- .jscad
|
||||
- .jsfl
|
||||
- .jsm
|
||||
- .jss
|
||||
- .jsx
|
||||
- .njs
|
||||
- .pac
|
||||
- .sjs
|
||||
@@ -1660,6 +1712,18 @@ Julia:
|
||||
color: "#a270ba"
|
||||
ace_mode: julia
|
||||
|
||||
Jupyter Notebook:
|
||||
type: markup
|
||||
ace_mode: json
|
||||
tm_scope: source.json
|
||||
color: "#DA5B0B"
|
||||
extensions:
|
||||
- .ipynb
|
||||
filenames:
|
||||
- Notebook
|
||||
aliases:
|
||||
- IPython Notebook
|
||||
|
||||
KRL:
|
||||
type: programming
|
||||
color: "#28431f"
|
||||
@@ -1672,6 +1736,7 @@ KiCad:
|
||||
type: programming
|
||||
extensions:
|
||||
- .sch
|
||||
- .brd
|
||||
- .kicad_pcb
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
@@ -1707,6 +1772,7 @@ LLVM:
|
||||
extensions:
|
||||
- .ll
|
||||
ace_mode: text
|
||||
color: "#185619"
|
||||
|
||||
LOLCODE:
|
||||
type: programming
|
||||
@@ -1770,6 +1836,7 @@ Less:
|
||||
- .less
|
||||
tm_scope: source.css.less
|
||||
ace_mode: less
|
||||
color: "#A1D9A1"
|
||||
|
||||
Lex:
|
||||
type: programming
|
||||
@@ -1921,6 +1988,15 @@ M:
|
||||
tm_scope: source.lisp
|
||||
ace_mode: lisp
|
||||
|
||||
MAXScript:
|
||||
type: programming
|
||||
color: "#00a6a6"
|
||||
extensions:
|
||||
- .ms
|
||||
- .mcr
|
||||
tm_scope: source.maxscript
|
||||
ace_mode: text
|
||||
|
||||
MTML:
|
||||
type: markup
|
||||
color: "#b7e1f4"
|
||||
@@ -1979,6 +2055,7 @@ Markdown:
|
||||
- .mkdown
|
||||
- .ron
|
||||
tm_scope: source.gfm
|
||||
color: "#083FA1"
|
||||
|
||||
Mask:
|
||||
type: markup
|
||||
@@ -1995,6 +2072,7 @@ Mathematica:
|
||||
- .cdf
|
||||
- .m
|
||||
- .ma
|
||||
- .mt
|
||||
- .nb
|
||||
- .nbp
|
||||
- .wl
|
||||
@@ -2006,6 +2084,8 @@ Mathematica:
|
||||
Matlab:
|
||||
type: programming
|
||||
color: "#bb92ac"
|
||||
aliases:
|
||||
- octave
|
||||
extensions:
|
||||
- .matlab
|
||||
- .m
|
||||
@@ -2039,6 +2119,7 @@ MediaWiki:
|
||||
wrap: true
|
||||
extensions:
|
||||
- .mediawiki
|
||||
- .wiki
|
||||
tm_scope: text.html.mediawiki
|
||||
ace_mode: text
|
||||
|
||||
@@ -2054,6 +2135,14 @@ Mercury:
|
||||
tm_scope: source.mercury
|
||||
ace_mode: prolog
|
||||
|
||||
Metal:
|
||||
type: programming
|
||||
color: "#8f14e9"
|
||||
extensions:
|
||||
- .metal
|
||||
tm_scope: source.c++
|
||||
ace_mode: c_cpp
|
||||
|
||||
MiniD: # Legacy
|
||||
type: programming
|
||||
searchable: false
|
||||
@@ -2206,6 +2295,7 @@ Nginx:
|
||||
aliases:
|
||||
- nginx configuration file
|
||||
ace_mode: text
|
||||
color: "#9469E9"
|
||||
|
||||
Nimrod:
|
||||
type: programming
|
||||
@@ -2264,6 +2354,7 @@ NumPy:
|
||||
- .numsc
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
color: "#9C8AF9"
|
||||
|
||||
OCaml:
|
||||
type: programming
|
||||
@@ -2432,6 +2523,7 @@ PHP:
|
||||
- .php3
|
||||
- .php4
|
||||
- .php5
|
||||
- .phps
|
||||
- .phpt
|
||||
filenames:
|
||||
- Phakefile
|
||||
@@ -2448,6 +2540,7 @@ PLSQL:
|
||||
color: "#dad8d8"
|
||||
extensions:
|
||||
- .pls
|
||||
- .pck
|
||||
- .pkb
|
||||
- .pks
|
||||
- .plb
|
||||
@@ -2512,7 +2605,7 @@ Parrot Internal Representation:
|
||||
|
||||
Pascal:
|
||||
type: programming
|
||||
color: "#b0ce4e"
|
||||
color: "#E3F171"
|
||||
extensions:
|
||||
- .pas
|
||||
- .dfm
|
||||
@@ -2561,9 +2654,16 @@ Perl6:
|
||||
- Rexfile
|
||||
interpreters:
|
||||
- perl6
|
||||
tm_scope: source.perl.6
|
||||
tm_scope: source.perl6fe
|
||||
ace_mode: perl
|
||||
|
||||
Pickle:
|
||||
type: data
|
||||
extensions:
|
||||
- .pkl
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
PicoLisp:
|
||||
type: programming
|
||||
extensions:
|
||||
@@ -2608,6 +2708,13 @@ PogoScript:
|
||||
tm_scope: source.pogoscript
|
||||
ace_mode: text
|
||||
|
||||
Pony:
|
||||
type: programming
|
||||
extensions:
|
||||
- .pony
|
||||
tm_scope: source.pony
|
||||
ace_mode: text
|
||||
|
||||
PostScript:
|
||||
type: markup
|
||||
extensions:
|
||||
@@ -2766,7 +2873,7 @@ QMake:
|
||||
|
||||
R:
|
||||
type: programming
|
||||
color: "#198ce7"
|
||||
color: "#198CE7"
|
||||
aliases:
|
||||
- R
|
||||
- Rscript
|
||||
@@ -2796,6 +2903,7 @@ RDoc:
|
||||
extensions:
|
||||
- .rdoc
|
||||
tm_scope: text.rdoc
|
||||
color: "#8E84BF"
|
||||
|
||||
REALbasic:
|
||||
type: programming
|
||||
@@ -2891,6 +2999,17 @@ Redcode:
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
Ren'Py:
|
||||
type: programming
|
||||
group: Python
|
||||
aliases:
|
||||
- renpy
|
||||
color: "#ff7f7f"
|
||||
extensions:
|
||||
- .rpy
|
||||
tm_scope: source.renpy
|
||||
ace_mode: python
|
||||
|
||||
RenderScript:
|
||||
type: programming
|
||||
extensions:
|
||||
@@ -2976,6 +3095,7 @@ Rust:
|
||||
color: "#dea584"
|
||||
extensions:
|
||||
- .rs
|
||||
- .rs.in
|
||||
ace_mode: rust
|
||||
|
||||
SAS:
|
||||
@@ -2993,6 +3113,7 @@ SCSS:
|
||||
ace_mode: scss
|
||||
extensions:
|
||||
- .scss
|
||||
color: "#CF649A"
|
||||
|
||||
SMT:
|
||||
type: programming
|
||||
@@ -3095,11 +3216,12 @@ Sass:
|
||||
extensions:
|
||||
- .sass
|
||||
ace_mode: sass
|
||||
color: "#CF649A"
|
||||
|
||||
Scala:
|
||||
type: programming
|
||||
ace_mode: scala
|
||||
color: "#7dd3b0"
|
||||
color: "#DC322F"
|
||||
extensions:
|
||||
- .scala
|
||||
- .sbt
|
||||
@@ -3251,6 +3373,14 @@ Squirrel:
|
||||
tm_scope: source.c++
|
||||
ace_mode: c_cpp
|
||||
|
||||
Stan:
|
||||
type: programming
|
||||
color: "#b2011d"
|
||||
extensions:
|
||||
- .stan
|
||||
ace_mode: text
|
||||
tm_scope: source.stan
|
||||
|
||||
Standard ML:
|
||||
type: programming
|
||||
color: "#dc566d"
|
||||
@@ -3288,9 +3418,12 @@ SuperCollider:
|
||||
type: programming
|
||||
color: "#46390b"
|
||||
extensions:
|
||||
- .scd
|
||||
- .sc
|
||||
tm_scope: none
|
||||
- .scd
|
||||
interpreters:
|
||||
- sclang
|
||||
- scsynth
|
||||
tm_scope: source.supercollider
|
||||
ace_mode: text
|
||||
|
||||
Swift:
|
||||
@@ -3433,6 +3566,7 @@ TypeScript:
|
||||
- ts
|
||||
extensions:
|
||||
- .ts
|
||||
- .tsx
|
||||
tm_scope: source.ts
|
||||
ace_mode: typescript
|
||||
|
||||
@@ -3448,7 +3582,6 @@ Unified Parallel C:
|
||||
Unity3D Asset:
|
||||
type: data
|
||||
ace_mode: yaml
|
||||
color: "#ab69a1"
|
||||
extensions:
|
||||
- .anim
|
||||
- .asset
|
||||
@@ -3466,6 +3599,17 @@ UnrealScript:
|
||||
tm_scope: source.java
|
||||
ace_mode: java
|
||||
|
||||
UrWeb:
|
||||
type: programming
|
||||
aliases:
|
||||
- Ur/Web
|
||||
- Ur
|
||||
extensions:
|
||||
- .ur
|
||||
- .urs
|
||||
tm_scope: source.ur
|
||||
ace_mode: text
|
||||
|
||||
VCL:
|
||||
group: Perl
|
||||
type: programming
|
||||
@@ -3603,6 +3747,7 @@ XML:
|
||||
- .ccxml
|
||||
- .clixml
|
||||
- .cproject
|
||||
- .csl
|
||||
- .csproj
|
||||
- .ct
|
||||
- .dita
|
||||
@@ -3649,6 +3794,7 @@ XML:
|
||||
- .tmSnippet
|
||||
- .tmTheme
|
||||
- .ts
|
||||
- .tsx
|
||||
- .ui
|
||||
- .urdf
|
||||
- .vbproj
|
||||
@@ -3667,6 +3813,7 @@ XML:
|
||||
- .xliff
|
||||
- .xmi
|
||||
- .xml.dist
|
||||
- .xproj
|
||||
- .xsd
|
||||
- .xul
|
||||
- .zcml
|
||||
@@ -3723,6 +3870,7 @@ XSLT:
|
||||
- .xsl
|
||||
tm_scope: text.xml.xsl
|
||||
ace_mode: xml
|
||||
color: "#EB8CEB"
|
||||
|
||||
Xojo:
|
||||
type: programming
|
||||
@@ -3756,6 +3904,13 @@ YAML:
|
||||
- .yaml-tmlanguage
|
||||
ace_mode: yaml
|
||||
|
||||
YANG:
|
||||
type: data
|
||||
extensions:
|
||||
- .yang
|
||||
tm_scope: source.yang
|
||||
ace_mode: text
|
||||
|
||||
Yacc:
|
||||
type: programming
|
||||
extensions:
|
||||
@@ -3764,6 +3919,7 @@ Yacc:
|
||||
- .yy
|
||||
tm_scope: source.bison
|
||||
ace_mode: text
|
||||
color: "#4B6C4B"
|
||||
|
||||
Zephir:
|
||||
type: programming
|
||||
@@ -3803,7 +3959,6 @@ eC:
|
||||
edn:
|
||||
type: data
|
||||
ace_mode: clojure
|
||||
color: "#db5855"
|
||||
extensions:
|
||||
- .edn
|
||||
tm_scope: source.clojure
|
||||
@@ -3845,7 +4000,10 @@ reStructuredText:
|
||||
extensions:
|
||||
- .rst
|
||||
- .rest
|
||||
- .rest.txt
|
||||
- .rst.txt
|
||||
ace_mode: text
|
||||
color: "#B3BCBC"
|
||||
|
||||
wisp:
|
||||
type: programming
|
||||
|
||||
@@ -79,11 +79,15 @@ module Linguist
|
||||
@size
|
||||
end
|
||||
|
||||
def cleanup!
|
||||
@data.clear if @data
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Returns true if the attribute is present and not the string "false".
|
||||
def boolean_attribute(attr)
|
||||
attr != "false"
|
||||
def boolean_attribute(attribute)
|
||||
attribute != "false"
|
||||
end
|
||||
|
||||
def load_blob!
|
||||
|
||||
@@ -126,12 +126,13 @@ module Linguist
|
||||
end
|
||||
|
||||
protected
|
||||
MAX_TREE_SIZE = 100_000
|
||||
|
||||
def compute_stats(old_commit_oid, cache = nil)
|
||||
return {} if current_tree.count_recursive(MAX_TREE_SIZE) >= MAX_TREE_SIZE
|
||||
|
||||
old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree
|
||||
|
||||
read_index
|
||||
|
||||
diff = Rugged::Tree.diff(repository, old_tree, current_tree)
|
||||
|
||||
# Clear file map and fetch full diff if any .gitattributes files are changed
|
||||
@@ -157,8 +158,11 @@ module Linguist
|
||||
|
||||
blob = Linguist::LazyBlob.new(repository, delta.new_file[:oid], new, mode.to_s(8))
|
||||
|
||||
next unless blob.include_in_language_stats?
|
||||
file_map[new] = [blob.language.group.name, blob.size]
|
||||
if blob.include_in_language_stats?
|
||||
file_map[new] = [blob.language.group.name, blob.size]
|
||||
end
|
||||
|
||||
blob.cleanup!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
module Linguist
|
||||
module Strategy
|
||||
class Modeline
|
||||
EmacsModeline = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i
|
||||
VimModeline = /vim:\s*set.*\s(?:ft|filetype)=(\w+)\s?.*:/i
|
||||
EMACS_MODELINE = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
MODELINES = [EMACS_MODELINE, VIM_MODELINE_1, VIM_MODELINE_2]
|
||||
|
||||
# Public: Detects language based on Vim and Emacs modelines
|
||||
#
|
||||
@@ -22,7 +33,7 @@ module Linguist
|
||||
#
|
||||
# Returns a String or nil
|
||||
def self.modeline(data)
|
||||
match = data.match(EmacsModeline) || data.match(VimModeline)
|
||||
match = MODELINES.map { |regex| data.match(regex) }.reject(&:nil?).first
|
||||
match[1] if match
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,13 +86,13 @@ module Linguist
|
||||
if s.peek(1) == "\""
|
||||
s.getch
|
||||
else
|
||||
s.skip_until(/[^\\]"/)
|
||||
s.skip_until(/(?<!\\)"/)
|
||||
end
|
||||
elsif s.scan(/'/)
|
||||
if s.peek(1) == "'"
|
||||
s.getch
|
||||
else
|
||||
s.skip_until(/[^\\]'/)
|
||||
s.skip_until(/(?<!\\)'/)
|
||||
end
|
||||
|
||||
# Skip number literals
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
- jquery.fn.gantt.js
|
||||
|
||||
# jQuery fancyBox
|
||||
- jquery.fancybox.js
|
||||
- jquery.fancybox.(js|css)
|
||||
|
||||
# Fuel UX
|
||||
- fuelux.js
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Linguist
|
||||
VERSION = "4.5.15"
|
||||
VERSION = "4.7.5"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user