mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a18ad1d489 | ||
|
|
25ac140d58 | ||
|
|
f7835f7119 | ||
|
|
a7f835a653 | ||
|
|
6220286f42 |
@@ -1,3 +1,3 @@
|
|||||||
module Linguist
|
module Linguist
|
||||||
VERSION = "6.0.0"
|
VERSION = "6.0.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
FROM golang:1.9.2
|
FROM golang:1.9.2
|
||||||
|
|
||||||
RUN apt-get update
|
WORKDIR /go/src/github.com/github/linguist/tools/grammars
|
||||||
RUN apt-get upgrade -y
|
|
||||||
RUN apt-get install -y curl gnupg
|
|
||||||
|
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
|
||||||
RUN apt-get install -y nodejs
|
apt-get update && \
|
||||||
RUN npm install -g season
|
apt-get install -y nodejs cmake && \
|
||||||
|
npm install -g season && \
|
||||||
RUN apt-get install -y cmake
|
cd /tmp && git clone https://github.com/vmg/pcre && \
|
||||||
RUN cd /tmp && git clone https://github.com/vmg/pcre
|
mkdir -p /tmp/pcre/build && cd /tmp/pcre/build && \
|
||||||
RUN mkdir -p /tmp/pcre/build && cd /tmp/pcre/build && \
|
|
||||||
cmake .. \
|
cmake .. \
|
||||||
-DPCRE_SUPPORT_JIT=ON \
|
-DPCRE_SUPPORT_JIT=ON \
|
||||||
-DPCRE_SUPPORT_UTF=ON \
|
-DPCRE_SUPPORT_UTF=ON \
|
||||||
@@ -22,14 +19,12 @@ RUN mkdir -p /tmp/pcre/build && cd /tmp/pcre/build && \
|
|||||||
-DPCRE_BUILD_PCREGREP=OFF \
|
-DPCRE_BUILD_PCREGREP=OFF \
|
||||||
-DPCRE_BUILD_TESTS=OFF \
|
-DPCRE_BUILD_TESTS=OFF \
|
||||||
-G "Unix Makefiles" && \
|
-G "Unix Makefiles" && \
|
||||||
make && make install
|
make && make install && \
|
||||||
RUN rm -rf /tmp/pcre
|
rm -rf /tmp/pcre && \
|
||||||
|
cd /go && go get -u github.com/golang/dep/cmd/dep && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN go get -u github.com/golang/dep/cmd/dep
|
|
||||||
WORKDIR /go/src/github.com/github/linguist/tools/grammars
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN dep ensure && go install ./cmd/grammar-compiler
|
||||||
RUN dep ensure
|
|
||||||
RUN go install ./cmd/grammar-compiler
|
|
||||||
|
|
||||||
ENTRYPOINT ["grammar-compiler"]
|
ENTRYPOINT ["grammar-compiler"]
|
||||||
|
|||||||
@@ -108,6 +108,11 @@ func isValidGrammar(path string, info os.FileInfo) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tree-Sitter grammars are not supported
|
||||||
|
if strings.HasPrefix(filepath.Base(path), "tree-sitter-") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
dir := filepath.Dir(path)
|
dir := filepath.Dir(path)
|
||||||
ext := filepath.Ext(path)
|
ext := filepath.Ext(path)
|
||||||
|
|
||||||
@@ -117,7 +122,7 @@ func isValidGrammar(path string, info os.FileInfo) bool {
|
|||||||
case ".tmlanguage", ".yaml-tmlanguage":
|
case ".tmlanguage", ".yaml-tmlanguage":
|
||||||
return true
|
return true
|
||||||
case ".cson", ".json":
|
case ".cson", ".json":
|
||||||
return strings.HasSuffix(dir, "/grammars")
|
return strings.HasSuffix(dir, "/grammars") || strings.HasSuffix(dir, "/syntaxes")
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,14 +15,43 @@ type fsLoader struct {
|
|||||||
abspath string
|
abspath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var preferredGrammars = map[string]int{
|
||||||
|
".tmlanguage": 0,
|
||||||
|
".cson": 1,
|
||||||
|
".json": 1,
|
||||||
|
".plist": 2,
|
||||||
|
".yaml-tmlanguage": 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
func findPreferredExtension(ext []string) string {
|
||||||
|
if len(ext) > 1 {
|
||||||
|
sort.Slice(ext, func(i, j int) bool {
|
||||||
|
a := strings.ToLower(ext[i])
|
||||||
|
b := strings.ToLower(ext[j])
|
||||||
|
return preferredGrammars[a] < preferredGrammars[b]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return ext[0]
|
||||||
|
}
|
||||||
|
|
||||||
func (l *fsLoader) findGrammars() (files []string, err error) {
|
func (l *fsLoader) findGrammars() (files []string, err error) {
|
||||||
|
grammars := make(map[string][]string)
|
||||||
|
|
||||||
err = filepath.Walk(l.abspath,
|
err = filepath.Walk(l.abspath,
|
||||||
func(path string, info os.FileInfo, err error) error {
|
func(path string, info os.FileInfo, err error) error {
|
||||||
if err == nil && isValidGrammar(path, info) {
|
if err == nil && isValidGrammar(path, info) {
|
||||||
files = append(files, path)
|
ext := filepath.Ext(path)
|
||||||
|
base := path[0 : len(path)-len(ext)]
|
||||||
|
grammars[base] = append(grammars[base], ext)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for base, ext := range grammars {
|
||||||
|
pref := findPreferredExtension(ext)
|
||||||
|
files = append(files, base+pref)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
vendor/CodeMirror
vendored
2
vendor/CodeMirror
vendored
Submodule vendor/CodeMirror updated: d0dca6532d...15d9d4e201
2
vendor/grammars/Elm
vendored
2
vendor/grammars/Elm
vendored
Submodule vendor/grammars/Elm updated: 6f2e53603a...6bbbca9ccd
2
vendor/grammars/atom-language-julia
vendored
2
vendor/grammars/atom-language-julia
vendored
Submodule vendor/grammars/atom-language-julia updated: ffe80d6cbc...7803a437f8
2
vendor/grammars/atom-language-nextflow
vendored
2
vendor/grammars/atom-language-nextflow
vendored
Submodule vendor/grammars/atom-language-nextflow updated: a8a91d7e10...557669e2ae
2
vendor/grammars/language-clojure
vendored
2
vendor/grammars/language-clojure
vendored
Submodule vendor/grammars/language-clojure updated: ecc790326b...a6dcd90d25
2
vendor/grammars/language-css
vendored
2
vendor/grammars/language-css
vendored
Submodule vendor/grammars/language-css updated: c23826b63c...d57ce703cd
2
vendor/grammars/sublime-mask
vendored
2
vendor/grammars/sublime-mask
vendored
Submodule vendor/grammars/sublime-mask updated: 4227ec78f3...ac22df6662
2
vendor/grammars/vue-syntax-highlight
vendored
2
vendor/grammars/vue-syntax-highlight
vendored
Submodule vendor/grammars/vue-syntax-highlight updated: 5f24639e88...5c2b5afbb3
Reference in New Issue
Block a user