mirror of
https://github.com/zyedidia/micro.git
synced 2024-09-11 04:05:38 +03:00
parent
4b0348f64a
commit
bd83c6a8a9
@ -532,18 +532,29 @@ func (b *Buffer) UpdateRules() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: includes
|
||||
if b.SyntaxDef != nil && highlight.HasIncludes(b.SyntaxDef) {
|
||||
includes := highlight.GetIncludes(b.SyntaxDef)
|
||||
|
||||
var files []*highlight.File
|
||||
for _, f := range config.ListRuntimeFiles(config.RTSyntax) {
|
||||
data, _ := f.Data()
|
||||
header, _ := highlight.MakeHeaderYaml(data)
|
||||
data, err := f.Data()
|
||||
if err != nil {
|
||||
screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
|
||||
continue
|
||||
}
|
||||
header, err := highlight.MakeHeaderYaml(data)
|
||||
if err != nil {
|
||||
screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
for _, i := range includes {
|
||||
if header.FileType == i {
|
||||
file, _ := highlight.ParseFile(data)
|
||||
file, err := highlight.ParseFile(data)
|
||||
if err != nil {
|
||||
screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
|
||||
continue
|
||||
}
|
||||
files = append(files, file)
|
||||
break
|
||||
}
|
||||
|
@ -1214,7 +1214,7 @@ func runtimePluginsAutocloseAutocloseLua() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _runtimePluginsAutocloseInfoJson = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x8f\xc1\x4e\xc3\x30\x0c\x86\xcf\xf4\x29\xac\x9c\xab\x74\x70\x9c\x04\x12\xcf\x81\x38\xb8\xae\x59\x2d\xd2\xa4\xb3\x1d\xd0\x40\xbc\x3b\x4a\x60\xf7\x1d\xfd\xff\xfe\xf4\xd9\xdf\x03\x00\x40\xc8\xb8\x71\x38\x42\xc0\xea\x85\x52\x31\x0e\xe3\x5f\xb1\xb0\x91\xca\xee\x52\x72\xeb\x9f\xab\x97\x0d\x5d\x08\x53\xba\xc0\x9e\x90\xd8\xa0\x01\x92\x4f\x40\x2b\x2a\x92\xb3\x1a\xbc\x15\x85\x73\x2d\xce\x36\xc2\x8e\xca\xd9\x57\xb6\x36\xcc\x8a\xf4\xce\x6e\x23\xb0\x53\x8c\xf1\xea\xf9\xe4\xd9\xc4\xfb\x0d\xab\xfb\x6e\xc7\x69\x3a\x89\xaf\x75\x8e\x54\xb6\xe9\xeb\xc2\x8b\x2c\x82\xd3\x26\xa4\x25\x8c\xc3\x5d\x90\x6c\x8e\x29\xdd\x0a\x74\xc9\x07\xab\xfd\x3f\x72\x1f\x0f\xf1\x70\xcd\x95\xcf\x55\xb4\xc9\x5f\x7a\xd0\xc3\x4e\xc2\xd3\x23\x3c\xf4\xd5\x5e\xbc\x0e\x3f\xc3\x6f\x00\x00\x00\xff\xff\xd9\xec\x80\xc2\x32\x01\x00\x00"
|
||||
var _runtimePluginsAutocloseInfoJson = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x8f\xc1\x4e\xc4\x40\x08\x86\xef\x7d\x0a\xd2\x73\x33\x5d\x3d\x6e\xa2\x89\xcf\x61\x3c\x50\x8a\x5b\xe2\x74\xe8\x02\xa3\x59\x8d\xef\x6e\x3a\xda\x07\xf0\xc8\xff\xf1\xe5\x87\xaf\x0e\x00\xa0\x2f\xb8\x72\x7f\x86\x1e\x6b\x28\x65\x75\xee\x87\x5f\x30\xb3\x93\xc9\x16\xa2\x65\xe7\x4f\x35\x74\xc5\x10\xc2\x9c\x6f\xb0\x65\x24\x76\xd8\x05\x29\x17\xa0\x05\x0d\x29\xd8\x1c\x5e\xd5\xe0\x5a\x35\xd8\x07\xd8\xd0\xb8\xc4\xc2\xbe\x0f\x93\x21\xbd\x71\xf8\x00\x1c\x94\x52\x3a\x7a\x3e\x78\x72\x89\x76\xc3\x12\xb1\xf9\x79\x1c\x2f\x12\x4b\x9d\x12\xe9\x3a\x7e\xde\x78\x96\x59\x70\x5c\x85\x4c\x0f\x47\x8a\x07\xe6\xfc\x2f\xe7\x9d\xcd\xff\x7e\xb9\x4b\xa7\x74\x3a\x72\xe3\x6b\x15\xdb\xfb\x9f\x5b\xd0\xc2\x66\xc2\xe3\x03\xdc\xb7\xd5\x06\x5e\xba\xef\xee\x27\x00\x00\xff\xff\x1a\x2a\xb9\x2f\x35\x01\x00\x00"
|
||||
|
||||
func runtimePluginsAutocloseInfoJsonBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
@ -3654,7 +3654,7 @@ func runtimeSyntaxJavascriptYaml() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _runtimeSyntaxJinja2Hdr = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\xca\xcc\xcb\x4a\x34\xe2\x8a\xd1\xcb\x28\xc9\xcd\x51\xe1\xe2\x02\x04\x00\x00\xff\xff\x6c\x91\x60\xd7\x10\x00\x00\x00"
|
||||
var _runtimeSyntaxJinja2Hdr = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\xca\xcc\xcb\x4a\x34\xe2\xe2\xe2\x02\x04\x00\x00\xff\xff\x15\x55\xdb\x7b\x09\x00\x00\x00"
|
||||
|
||||
func runtimeSyntaxJinja2HdrBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
@ -3674,7 +3674,7 @@ func runtimeSyntaxJinja2Hdr() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _runtimeSyntaxJinja2Yaml = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x53\xc1\x8e\x22\x39\x0c\xbd\xf3\x15\x25\x66\x47\xea\x3e\x30\x87\x3d\x72\xe9\x0f\xd9\xde\x43\x2a\x79\x55\x98\x4d\x39\xc1\x71\xa0\x19\xcc\xbf\xaf\x12\x8a\xd1\x4c\xaf\xb4\x9a\x08\x61\x57\xfc\x12\xbf\x67\xc7\x13\x45\xe8\x35\x63\x3f\x1c\x89\x8f\xee\xcf\xcd\x26\x40\xe1\x75\xbf\x19\x86\x61\x68\x51\x76\x0b\xf6\xc3\xf6\xfd\xfd\xdb\x41\x97\xf8\xc7\x76\xb3\x91\x1a\x51\x1a\x60\x37\x10\xfb\x58\x43\x8b\xb7\xe0\xb6\xef\x95\x0c\x4f\x2e\xee\x87\xed\xcb\xed\x66\xf7\xbb\xdd\xbe\xee\xde\x6c\xf7\xf6\xf5\xfe\xfa\x00\x04\x4c\xae\xc6\x35\x45\x5b\x45\x9d\x68\xc7\x37\xe4\xed\xd6\x71\x8f\x05\x0e\x2d\xd0\x4e\xdb\xfd\xfe\x53\x20\xd2\x42\xba\x9b\x25\xd5\xbc\x7f\xa6\xfc\x11\xfc\xc1\xf0\xb9\x7e\x66\x9a\xaf\x7a\x48\xbc\xfd\x25\x5a\xd4\x29\x16\xb0\x76\xa5\xe3\x0b\xcd\x9c\x04\xc3\x42\xa5\x10\xcf\x76\x21\x3d\xbc\xa4\xaa\xaf\x6f\x83\x4f\xac\xf8\x50\x1b\x63\xf2\xff\x98\x77\x31\x1a\x38\x3c\xbe\xc0\xe1\xb9\x31\x51\x54\x48\xf7\x52\x37\x8b\xf3\x92\x9a\x23\xee\xd2\x4c\x81\x1a\x3e\xb4\x79\xb6\x82\x1b\x72\xa5\x69\x0f\x78\xc3\x0a\x7c\x95\x42\x67\x58\xf1\x29\x23\x58\x81\xbe\xbe\xbf\x8f\xbf\x0a\xa0\x00\x56\x9a\x08\xf2\x6d\xac\x14\x95\x78\xaa\xec\x57\x35\x4e\x55\x6c\x74\xea\x0f\xe6\x5d\x26\x75\x91\xbe\xc3\x3c\xb8\x65\xf5\xa9\xb2\x5a\xb0\xb5\x2b\x16\xc8\x6b\x49\xa2\x06\x43\xf1\x2e\xa3\xd1\x43\xa1\xef\x98\x92\x2c\x4e\x6d\x22\x29\xda\xc8\x7a\xac\x80\xde\x85\xf1\x6a\xc4\x8d\x85\x1d\x13\xb1\x45\x57\xd4\x22\x78\xd6\x83\xc5\x74\x81\x58\xce\x42\xac\x26\x8e\x43\x5a\x4c\x70\x84\xd7\xd5\x74\x82\x82\x1c\x9d\x87\x09\xce\x90\x02\x2b\x6e\x82\x15\xc4\x06\x7b\x98\x0e\x2b\x2a\x94\xd5\xcd\xc5\x94\x34\xc2\x34\x1d\x4b\x62\x53\xa1\xc5\x54\x2a\x7b\xa7\xb0\xca\x74\xaa\xb0\x9a\x33\xc4\xaa\x44\xb0\x4f\x01\xcd\x6b\xca\x2f\x49\xc2\x43\x76\xf3\x2e\xe2\xb2\x7d\x2c\xb1\xdd\xfe\x3b\x85\x55\x94\xe7\x33\x69\xdd\x76\x63\x44\x2b\x1e\x31\x82\x05\x3a\x53\xa1\x31\x62\xbc\x1a\x4e\x86\x53\x75\x51\xd3\x5a\xc8\x60\x38\x83\x6d\x86\xcd\x6a\xa4\x90\x7e\xb4\xfd\x7a\x7d\xa2\xda\xe2\x72\x6e\xef\x8d\x61\x9c\xda\x5f\x5d\x46\x88\xa5\x10\xac\xb8\x05\xae\x58\xc1\xa9\x82\x3d\x7a\x19\x78\xb6\xca\xcf\xd4\x5d\xeb\xff\xf2\x5f\x3b\x3c\xc7\x34\xf6\xf1\x6c\x0a\x22\xe5\x52\x17\xf3\x57\x1f\x21\xbd\x73\x10\x6b\x23\x5f\xb2\xf3\x78\x5e\xb7\x1b\x7c\x5a\xfa\x78\xfc\x67\x66\x6f\x5f\x3e\x0f\xeb\x97\xfb\xf6\xd3\x20\x0e\x7f\xfd\xbd\xf9\x37\x00\x00\xff\xff\x83\xe1\x3e\xeb\x69\x04\x00\x00"
|
||||
var _runtimeSyntaxJinja2Yaml = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x53\xc1\x6e\xeb\x38\x0c\xbc\xe7\x2b\x8c\x14\x05\xda\x43\xf6\xb0\xc7\x5c\xfa\x21\x9b\x3d\xc8\xd2\xd8\x61\x56\xa6\x14\x8a\x4a\x9a\x86\xf9\xf7\x85\x1c\xa7\x68\xfb\x80\x87\x27\x04\x21\x2d\x8e\xc4\x19\x52\x1c\x28\x42\x2f\x19\xdb\xee\x40\x7c\x70\x7f\xaf\x56\x52\x23\xca\x76\xd5\x75\x9b\x8e\xd8\xc7\x1a\xb0\xed\xd6\x7b\x9d\xe2\x7a\xde\x2b\x19\x9e\x5c\xdc\x76\xeb\x97\xeb\xd5\x6e\x37\xbb\x3e\x6f\xde\x6c\xf3\xf6\x7c\x7b\xbd\x03\x02\x06\x57\xa3\xb6\x1b\xee\xab\xa8\x13\x9d\xf1\x0d\x79\xbd\xce\xb8\xfb\x02\x87\x16\x68\xa7\xed\x76\xfb\x12\x88\x34\x91\x6e\x46\x49\x35\x6f\x1f\x29\x3f\x83\x9f\x0c\x1f\xeb\x2b\xd3\x7c\xd1\x7d\xe2\xf5\xb7\x68\x51\xa7\x98\xc0\x8d\xc5\x6e\xd7\xbf\xd0\xc8\x49\xd0\x4d\x54\x0a\xf1\x68\x67\xd2\xfd\x4b\xaa\xfa\xfa\xd6\xf9\xc4\x8a\x77\xb5\x3e\x26\xff\x9f\x79\x17\xa3\x81\xc3\xfd\x0b\x1c\x1e\x1b\x03\x45\x85\xcc\x5e\x9a\xcd\xe4\xbc\xa4\xe6\x88\x3b\x37\x53\xa0\x86\x77\x6d\x9e\x2d\xe0\x86\x5c\x68\xda\x1d\xde\xb0\x02\x5f\xa5\xd0\x09\x56\x7c\xca\x08\x56\xa0\xaf\xbb\x5d\xff\x5d\x00\x05\xb0\xd2\x40\x90\xbf\xfa\x4a\x51\x89\x87\xca\x7e\x51\xe3\x54\xc5\x7a\xa7\x7e\x6f\xde\x65\x52\x17\xe9\x03\xe6\xc1\x2d\xab\x4f\x95\xd5\x82\x2d\x5d\xb1\x40\x5e\x4b\x12\x35\x18\x8a\x77\x19\x8d\x1e\x0a\x7d\x60\x48\x32\x39\xb5\x81\xa4\x68\x23\xeb\xb1\x00\xe6\x2e\xf4\x17\x23\x6e\x2c\xec\x90\x88\x2d\xba\xa2\x16\xc1\xa3\xee\x2d\xa6\x33\xc4\x72\x16\x62\x35\x71\x1c\xd2\x64\x82\x03\xbc\x2e\x66\x26\x28\xc8\xd1\x79\x98\xe0\x04\x29\xb0\xe2\x06\x58\x41\x6c\xb0\xbb\x99\x61\x45\x85\xb2\xba\xb1\x98\x92\x46\x98\xa6\x43\x49\x6c\x2a\x34\x99\x4a\x65\xef\x14\x56\x99\x8e\x15\x56\x73\x86\x58\x95\x08\xf6\x29\xa0\x79\x4d\xf9\x39\x49\xb8\xcb\x6e\xde\x59\x5c\xb6\xf7\x29\xb6\xdb\xff\xa4\xb0\x8a\xf2\x78\x26\xad\xdb\xae\x8f\x68\xc5\x23\x46\xb0\x40\x27\x2a\xd4\x47\xf4\x17\xc3\xd1\x70\xac\x2e\x6a\x5a\x0a\x19\x0c\x27\xb0\x8d\xb0\x51\x8d\x14\x32\x1f\x6d\xbf\xb9\x3e\x51\x6d\x72\x39\xb7\xf7\xc6\x30\x4e\xed\xaf\x4e\x3d\xc4\x52\x08\x56\xdc\x04\x57\xac\xe0\x58\xc1\x1e\x73\x19\x78\xb4\xca\x8f\xd4\xb3\xd6\xdf\xf2\x5f\x3a\x3c\xc6\xd4\xcf\xe3\xd9\x14\x44\xca\xa5\x4e\xe6\x2f\x3e\x42\xe6\xce\x41\x8c\xdd\x84\x92\x9d\xc7\xe3\xba\x4d\xe7\xd3\x34\x8f\xc7\x2f\x33\x7b\x7d\xfa\x39\xac\x4f\xb7\xf5\x8f\x41\xec\xfe\xf9\x77\xf5\x7f\x00\x00\x00\xff\xff\xb4\x53\x06\xfd\x47\x04\x00\x00"
|
||||
|
||||
func runtimeSyntaxJinja2YamlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -6,7 +6,7 @@ import "regexp"
|
||||
// to determine the filetype of the file
|
||||
// It will return the corresponding syntax definition for the filetype
|
||||
func MatchFiletype(ftdetect [2]*regexp.Regexp, filename string, firstLine []byte) bool {
|
||||
if ftdetect[0].MatchString(filename) {
|
||||
if ftdetect[0] != nil && ftdetect[0].MatchString(filename) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -106,10 +106,6 @@ func MakeHeader(data []byte) (*Header, error) {
|
||||
fnameRgx := string(lines[1])
|
||||
headerRgx := string(lines[2])
|
||||
|
||||
if fnameRgx == "" && headerRgx == "" {
|
||||
return nil, errors.New("Syntax file must include at least one detection regex")
|
||||
}
|
||||
|
||||
if fnameRgx != "" {
|
||||
header.FtDetect[0], err = regexp.Compile(fnameRgx)
|
||||
}
|
||||
@ -136,10 +132,6 @@ func MakeHeaderYaml(data []byte) (*Header, error) {
|
||||
header := new(Header)
|
||||
header.FileType = hdrYaml.FileType
|
||||
|
||||
if hdrYaml.Detect.FNameRgx == "" && hdrYaml.Detect.HeaderRgx == "" {
|
||||
return nil, errors.New("Syntax file must include at least one detection regex")
|
||||
}
|
||||
|
||||
if hdrYaml.Detect.FNameRgx != "" {
|
||||
header.FtDetect[0], err = regexp.Compile(hdrYaml.Detect.FNameRgx)
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
filetype: jinja2
|
||||
|
||||
detect:
|
||||
filename: "\\.html$"
|
||||
|
||||
rules:
|
||||
- include: "html"
|
||||
- special: "({{|}}|{%-?|-?%})"
|
||||
|
Loading…
Reference in New Issue
Block a user