github-linguist 7.14.0 → 7.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/github-linguist +115 -71
- data/grammars/annotation.liquidhaskell.haskell.json +1 -1
- data/grammars/etc.json +1 -1
- data/grammars/go.mod.json +1 -0
- data/grammars/go.sum.json +1 -0
- data/grammars/hint.haskell.json +1 -1
- data/grammars/hint.message.haskell.json +1 -1
- data/grammars/hint.type.haskell.json +1 -1
- data/grammars/markdown.bicep.codeblock.json +1 -0
- data/grammars/markdown.codeblock.proto.json +1 -0
- data/grammars/markdown.mcfunction.codeblock.json +1 -0
- data/grammars/source.abap.json +1 -1
- data/grammars/source.aidl.json +1 -0
- data/grammars/source.al.json +1 -1
- data/grammars/source.angelscript.json +1 -1
- data/grammars/source.avro.json +1 -1
- data/grammars/source.ballerina.json +1 -1
- data/grammars/source.batchfile.json +1 -1
- data/grammars/source.bc.json +1 -0
- data/grammars/source.bicep.json +1 -1
- data/grammars/source.boo.json +1 -1
- data/grammars/source.bp.json +1 -0
- data/grammars/source.cil.json +1 -0
- data/grammars/source.cirru.json +1 -1
- data/grammars/source.cs.json +1 -1
- data/grammars/source.csound.json +1 -1
- data/grammars/source.css.json +1 -1
- data/grammars/source.cue.json +1 -0
- data/grammars/source.cuesheet.json +1 -0
- data/grammars/source.dart.json +1 -1
- data/grammars/source.dc.json +1 -0
- data/grammars/source.ditroff.json +1 -1
- data/grammars/source.dotenv.json +1 -0
- data/grammars/source.ebnf.json +1 -1
- data/grammars/source.ecl.json +1 -0
- data/grammars/source.ed.json +1 -0
- data/grammars/source.fnl.json +1 -0
- data/grammars/source.fontforge.json +1 -1
- data/grammars/source.fstar.json +1 -1
- data/grammars/source.ftl.json +1 -0
- data/grammars/source.gcode.json +1 -1
- data/grammars/source.gdscript.json +1 -1
- data/grammars/source.hack.json +1 -1
- data/grammars/source.haskell.json +1 -1
- data/grammars/source.hlcode.json +1 -0
- data/grammars/source.hsig.json +1 -1
- data/grammars/source.hx.json +1 -1
- data/grammars/source.hy.json +1 -1
- data/grammars/source.jest.snap.json +1 -0
- data/grammars/source.jq.json +1 -1
- data/grammars/source.json.json +1 -1
- data/grammars/source.julia.json +1 -1
- data/grammars/source.kakscript.json +1 -0
- data/grammars/source.keyvalues.json +1 -0
- data/grammars/source.kotlin.json +1 -1
- data/grammars/source.lean.json +1 -1
- data/grammars/source.m2.json +1 -1
- data/grammars/source.matlab.json +1 -1
- data/grammars/source.mcfunction.json +1 -1
- data/grammars/source.odin.json +1 -1
- data/grammars/source.opentype.json +1 -1
- data/grammars/source.pegjs.json +1 -0
- data/grammars/source.postscript.json +1 -1
- data/grammars/source.powershell.json +1 -1
- data/grammars/source.proto.json +1 -0
- data/grammars/source.purescript.json +1 -1
- data/grammars/source.regexp.json +1 -1
- data/grammars/source.regexp.oniguruma.json +1 -0
- data/grammars/source.rego.json +1 -1
- data/grammars/source.renpy.json +1 -1
- data/grammars/source.rescript.json +1 -1
- data/grammars/source.sed.json +1 -1
- data/grammars/source.sepolicy.json +1 -0
- data/grammars/source.shellcheckrc.json +1 -0
- data/grammars/source.sqf.json +1 -1
- data/grammars/source.swift.json +1 -1
- data/grammars/source.sy.json +1 -1
- data/grammars/source.tm-properties.json +1 -0
- data/grammars/source.ts.json +1 -1
- data/grammars/source.tsx.json +1 -1
- data/grammars/source.v.json +1 -1
- data/grammars/source.viml.json +1 -1
- data/grammars/source.webassembly.json +1 -1
- data/grammars/source.ws.json +1 -0
- data/grammars/source.wsd.json +1 -1
- data/grammars/source.xojo.json +1 -1
- data/grammars/source.yara.json +1 -1
- data/grammars/source.yasnippet.json +1 -1
- data/grammars/source.zig.json +1 -1
- data/grammars/text.html.astro.json +1 -0
- data/grammars/text.html.markdown.astro.json +1 -0
- data/grammars/text.info.json +1 -0
- data/grammars/text.lesshst.json +1 -0
- data/grammars/text.marko.json +1 -1
- data/grammars/text.sfd.json +1 -1
- data/grammars/text.tex.latex.haskell.json +1 -1
- data/grammars/text.xml.svg.json +1 -1
- data/grammars/textmate.format-string.json +1 -0
- data/grammars/version +1 -1
- data/lib/linguist/VERSION +1 -1
- data/lib/linguist/documentation.yml +1 -0
- data/lib/linguist/generated.rb +13 -0
- data/lib/linguist/heuristics.rb +6 -2
- data/lib/linguist/heuristics.yml +18 -4
- data/lib/linguist/language.rb +6 -3
- data/lib/linguist/languages.json +1 -1
- data/lib/linguist/languages.yml +385 -43
- data/lib/linguist/linguist.bundle +0 -0
- data/lib/linguist/linguist.so +0 -0
- data/lib/linguist/repository.rb +7 -3
- data/lib/linguist/samples.json +1 -1
- data/lib/linguist/shebang.rb +4 -1
- data/lib/linguist/strategy/modeline.rb +4 -0
- data/lib/linguist/vendor.yml +3 -0
- metadata +36 -5
- data/grammars/source.SASLog.json +0 -1
- data/grammars/source.mcfunction-snapshot.json +0 -1
- data/grammars/source.protobuf.json +0 -1
data/lib/linguist/heuristics.rb
CHANGED
@@ -46,7 +46,7 @@ module Linguist
|
|
46
46
|
return
|
47
47
|
end
|
48
48
|
|
49
|
-
data =
|
49
|
+
data = self.load_config
|
50
50
|
named_patterns = data['named_patterns'].map { |k,v| [k, self.to_regex(v)] }.to_h
|
51
51
|
|
52
52
|
data['disambiguations'].each do |disambiguation|
|
@@ -60,6 +60,10 @@ module Linguist
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def self.load_config
|
64
|
+
YAML.load_file(File.expand_path("../heuristics.yml", __FILE__))
|
65
|
+
end
|
66
|
+
|
63
67
|
def self.parse_rule(named_patterns, rule)
|
64
68
|
if !rule['and'].nil?
|
65
69
|
rules = rule['and'].map { |block| self.parse_rule(named_patterns, block) }
|
@@ -160,6 +164,6 @@ module Linguist
|
|
160
164
|
def match(input)
|
161
165
|
return !@pat.match(input)
|
162
166
|
end
|
163
|
-
|
167
|
+
|
164
168
|
end
|
165
169
|
end
|
data/lib/linguist/heuristics.yml
CHANGED
@@ -200,6 +200,12 @@ disambiguations:
|
|
200
200
|
pattern: '^\s*(#version|precision|uniform|varying|vec[234])'
|
201
201
|
- language: Filterscript
|
202
202
|
pattern: '#include|#pragma\s+(rs|version)|__attribute__'
|
203
|
+
- extensions: ['.ftl']
|
204
|
+
rules:
|
205
|
+
- language: FreeMarker
|
206
|
+
pattern: '^(?:<|[a-zA-Z-][a-zA-Z0-9_-]+[ \t]+\w)|\${\w+[^\n]*?}|^[ \t]*(?:<#--.*?-->|<#([a-z]+)(?=\s|>)[^>]*>.*?</#\1>|\[#--.*?--\]|\[#([a-z]+)(?=\s|\])[^\]]*\].*?\[#\2\])'
|
207
|
+
- language: Fluent
|
208
|
+
pattern: '^-?[a-zA-Z][a-zA-Z0-9_-]* *=|\{\$-?[a-zA-Z][-\w]*(?:\.[a-zA-Z][-\w]*)?\}'
|
203
209
|
- extensions: ['.gd']
|
204
210
|
rules:
|
205
211
|
- language: GAP
|
@@ -229,6 +235,7 @@ disambiguations:
|
|
229
235
|
named_pattern: objectivec
|
230
236
|
- language: C++
|
231
237
|
named_pattern: cpp
|
238
|
+
- language: C
|
232
239
|
- extensions: ['.hh']
|
233
240
|
rules:
|
234
241
|
- language: Hack
|
@@ -251,7 +258,10 @@ disambiguations:
|
|
251
258
|
- language: PHP
|
252
259
|
pattern: '^<\?(?:php)?'
|
253
260
|
- language: SourcePawn
|
254
|
-
pattern:
|
261
|
+
pattern:
|
262
|
+
- '^public\s+(?:SharedPlugin(?:\s+|:)__pl_\w+\s*=(?:\s*{)?|(?:void\s+)?__pl_\w+_SetNTVOptional\(\)(?:\s*{)?)'
|
263
|
+
- '^methodmap\s+\w+\s+<\s+\w+'
|
264
|
+
- '^\s*MarkNativeAsOptional\s*\('
|
255
265
|
- language: NASL
|
256
266
|
pattern:
|
257
267
|
- '^\s*include\s*\(\s*(?:"|'')[\\/\w\-\.:\s]+\.(?:nasl|inc)\s*(?:"|'')\s*\)\s*;'
|
@@ -261,6 +271,10 @@ disambiguations:
|
|
261
271
|
- '^\s*(?:public\s+|private\s+|\s*)function\s+\w+\s*\([\w\s,]*\)\s*{'
|
262
272
|
- language: POV-Ray SDL
|
263
273
|
pattern: '^\s*#(declare|local|macro|while)\s'
|
274
|
+
- language: Pascal
|
275
|
+
pattern:
|
276
|
+
- '(?i:^\s*{\$(?:mode|ifdef|undef|define)[ ]+[a-z0-9_]+})'
|
277
|
+
- '^\s*end[.;]\s*$'
|
264
278
|
- extensions: ['.l']
|
265
279
|
rules:
|
266
280
|
- language: Common Lisp
|
@@ -438,7 +452,7 @@ disambiguations:
|
|
438
452
|
- pattern: '^[#!]'
|
439
453
|
- language: INI
|
440
454
|
named_pattern: key_equals_value
|
441
|
-
- language: Java
|
455
|
+
- language: Java Properties
|
442
456
|
pattern: '^[^#!][^:]*:'
|
443
457
|
- extensions: ['.q']
|
444
458
|
rules:
|
@@ -571,7 +585,7 @@ disambiguations:
|
|
571
585
|
# The following RegExp is simply a collapsed and simplified form of the
|
572
586
|
# VIM_MODELINE pattern in `./lib/linguist/strategy/modeline.rb`.
|
573
587
|
- language: Vim Help File
|
574
|
-
pattern: '(?:(
|
588
|
+
pattern: '(?:(?:^|[ \t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \t]ex)(?=:(?=[ \t]*set?[ \t][^\r\n:]+:)|:(?![ \t]*set?[ \t]))(?:(?:[ \t]*:[ \t]*|[ \t])\w*(?:[ \t]*=(?:[^\\\s]|\\.)*)?)*[ \t:](?:filetype|ft|syntax)[ \t]*=(help)(?=$|\s|:)'
|
575
589
|
# HACK: This is a contrived use of heuristics needed to address
|
576
590
|
# an unusual edge-case. See https://git.io/JULye for discussion.
|
577
591
|
- language: Text
|
@@ -585,7 +599,7 @@ disambiguations:
|
|
585
599
|
pattern: '\$(?:if|else)[ \t]|^[ \t]*fn\s+[^\s()]+\(.*?\).*?\{|^[ \t]*for\s*\{'
|
586
600
|
- extensions: ['.vba']
|
587
601
|
rules:
|
588
|
-
- language: Vim
|
602
|
+
- language: Vim Script
|
589
603
|
pattern: '^UseVimball'
|
590
604
|
- language: VBA
|
591
605
|
- extensions: ['.w']
|
data/lib/linguist/language.rb
CHANGED
@@ -32,8 +32,6 @@ module Linguist
|
|
32
32
|
@interpreter_index = Hash.new { |h,k| h[k] = [] }
|
33
33
|
@filename_index = Hash.new { |h,k| h[k] = [] }
|
34
34
|
|
35
|
-
# Valid Languages types
|
36
|
-
TYPES = [:data, :markup, :programming, :prose]
|
37
35
|
|
38
36
|
# Detect languages by a specific type
|
39
37
|
#
|
@@ -265,7 +263,7 @@ module Linguist
|
|
265
263
|
|
266
264
|
# Set type
|
267
265
|
@type = attributes[:type] ? attributes[:type].to_sym : nil
|
268
|
-
if @type && !
|
266
|
+
if @type && !get_types.include?(@type)
|
269
267
|
raise ArgumentError, "invalid type: #{@type}"
|
270
268
|
end
|
271
269
|
|
@@ -302,6 +300,11 @@ module Linguist
|
|
302
300
|
end
|
303
301
|
end
|
304
302
|
|
303
|
+
def get_types
|
304
|
+
# Valid Languages types
|
305
|
+
@types = [:data, :markup, :programming, :prose]
|
306
|
+
end
|
307
|
+
|
305
308
|
# Public: Get proper name
|
306
309
|
#
|
307
310
|
# Examples
|