mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-09 12:03:53 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2ef4cedec | ||
|
|
45c1923f43 |
@@ -7,7 +7,7 @@ A collection of language packs for Vim.
|
|||||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||||
|
|
||||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->189<!--/Package Count--> packages it consists of.
|
- It **installs and updates 120+ times faster** than the <!--Package Count-->190<!--/Package Count--> packages it consists of.
|
||||||
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).
|
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).
|
||||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||||
@@ -132,6 +132,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
|||||||
- [icalendar](https://github.com/chutzpah/icalendar.vim)
|
- [icalendar](https://github.com/chutzpah/icalendar.vim)
|
||||||
- [idris](https://github.com/idris-hackers/idris-vim)
|
- [idris](https://github.com/idris-hackers/idris-vim)
|
||||||
- [ion](https://github.com/vmchale/ion-vim)
|
- [ion](https://github.com/vmchale/ion-vim)
|
||||||
|
- [javascript-sql](https://github.com/statico/vim-javascript-sql)
|
||||||
- [javascript](https://github.com/pangloss/vim-javascript)
|
- [javascript](https://github.com/pangloss/vim-javascript)
|
||||||
- [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax)
|
- [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax)
|
||||||
- [jinja](https://github.com/lepture/vim-jinja)
|
- [jinja](https://github.com/lepture/vim-jinja)
|
||||||
|
|||||||
26
after/syntax/javascript/sql.vim
Normal file
26
after/syntax/javascript/sql.vim
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript-sql') == -1
|
||||||
|
|
||||||
|
" Vim plugin
|
||||||
|
" Language: JavaScript
|
||||||
|
" Maintainer: Ian Langworth <ian@langworth.com>
|
||||||
|
|
||||||
|
if exists('b:current_syntax')
|
||||||
|
let s:current_syntax = b:current_syntax
|
||||||
|
unlet b:current_syntax
|
||||||
|
endif
|
||||||
|
|
||||||
|
exec 'syntax include @SQLSyntax syntax/' . g:javascript_sql_dialect . '.vim'
|
||||||
|
if exists('s:current_syntax')
|
||||||
|
let b:current_syntax = s:current_syntax
|
||||||
|
endif
|
||||||
|
|
||||||
|
syntax region sqlTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=@SQLSyntax,jsTemplateExpression,jsSpecial extend
|
||||||
|
exec 'syntax match sqlTaggedTemplate +\%(SQL\)\%(`\)\@=+ nextgroup=sqlTemplateString'
|
||||||
|
|
||||||
|
hi def link sqlTemplateString jsTemplateString
|
||||||
|
hi def link sqlTaggedTemplate jsTaggedTemplate
|
||||||
|
|
||||||
|
syn cluster jsExpression add=sqlTaggedTemplate
|
||||||
|
syn cluster sqlTaggedTemplate add=sqlTemplateString
|
||||||
|
|
||||||
|
endif
|
||||||
@@ -202,6 +202,16 @@ func! polyglot#DetectFsFiletype()
|
|||||||
setf forth | return
|
setf forth | return
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func! polyglot#DetectReFiletype()
|
||||||
|
for lnum in range(1, min([line("$"), 50]))
|
||||||
|
let line = getline(lnum)
|
||||||
|
if line =~# '^\s*#\%(\%(if\|ifdef\|define\|pragma\)\s\+\w\|\s*include\s\+[<"]\|template\s*<\)'
|
||||||
|
setf cpp | return
|
||||||
|
endif
|
||||||
|
setf reason | return
|
||||||
|
endfor
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Restore 'cpoptions'
|
" Restore 'cpoptions'
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ call s:SetDefault('g:markdown_enable_mappings', 0)
|
|||||||
" Enable jsx syntax by default
|
" Enable jsx syntax by default
|
||||||
call s:SetDefault('g:jsx_ext_required', 0)
|
call s:SetDefault('g:jsx_ext_required', 0)
|
||||||
|
|
||||||
|
" Needed for sql highlighting
|
||||||
|
call s:SetDefault('g:javascript_sql_dialect', 'sql')
|
||||||
|
|
||||||
" Make csv loading faster
|
" Make csv loading faster
|
||||||
call s:SetDefault('g:csv_start', 1)
|
call s:SetDefault('g:csv_start', 1)
|
||||||
call s:SetDefault('g:csv_end', 2)
|
call s:SetDefault('g:csv_end', 2)
|
||||||
@@ -215,6 +218,11 @@ if !has_key(s:disabled_packages, 'awk')
|
|||||||
au BufNewFile,BufRead *.awk setf awk
|
au BufNewFile,BufRead *.awk setf awk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !has_key(s:disabled_packages, 'reason')
|
||||||
|
au BufNewFile,BufRead *.rei setf reason
|
||||||
|
au! BufNewFile,BufRead *.re call polyglot#DetectReFiletype()
|
||||||
|
endif
|
||||||
|
|
||||||
if !has_key(s:disabled_packages, 'c/c++')
|
if !has_key(s:disabled_packages, 'c/c++')
|
||||||
au BufNewFile,BufRead *.c setf c
|
au BufNewFile,BufRead *.c setf c
|
||||||
au BufNewFile,BufRead *.cats setf c
|
au BufNewFile,BufRead *.cats setf c
|
||||||
@@ -234,9 +242,9 @@ if !has_key(s:disabled_packages, 'c/c++')
|
|||||||
au BufNewFile,BufRead *.inl setf cpp
|
au BufNewFile,BufRead *.inl setf cpp
|
||||||
au BufNewFile,BufRead *.ino setf cpp
|
au BufNewFile,BufRead *.ino setf cpp
|
||||||
au BufNewFile,BufRead *.ipp setf cpp
|
au BufNewFile,BufRead *.ipp setf cpp
|
||||||
au BufNewFile,BufRead *.re setf cpp
|
|
||||||
au BufNewFile,BufRead *.tcc setf cpp
|
au BufNewFile,BufRead *.tcc setf cpp
|
||||||
au BufNewFile,BufRead *.tpp setf cpp
|
au BufNewFile,BufRead *.tpp setf cpp
|
||||||
|
au! BufNewFile,BufRead *.re call polyglot#DetectReFiletype()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !has_key(s:disabled_packages, 'caddyfile')
|
if !has_key(s:disabled_packages, 'caddyfile')
|
||||||
@@ -573,6 +581,9 @@ if !has_key(s:disabled_packages, 'ion')
|
|||||||
au BufNewFile,BufRead ~/.config/ion/initrc setf ion
|
au BufNewFile,BufRead ~/.config/ion/initrc setf ion
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !has_key(s:disabled_packages, 'javascript-sql')
|
||||||
|
endif
|
||||||
|
|
||||||
if !has_key(s:disabled_packages, 'javascript')
|
if !has_key(s:disabled_packages, 'javascript')
|
||||||
au BufNewFile,BufRead *._js setf javascript
|
au BufNewFile,BufRead *._js setf javascript
|
||||||
au BufNewFile,BufRead *.bones setf javascript
|
au BufNewFile,BufRead *.bones setf javascript
|
||||||
@@ -1039,11 +1050,6 @@ if !has_key(s:disabled_packages, 'razor')
|
|||||||
au BufNewFile,BufRead *.razor setf razor
|
au BufNewFile,BufRead *.razor setf razor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !has_key(s:disabled_packages, 'reason')
|
|
||||||
au BufNewFile,BufRead *.re setf reason
|
|
||||||
au BufNewFile,BufRead *.rei setf reason
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !has_key(s:disabled_packages, 'rst')
|
if !has_key(s:disabled_packages, 'rst')
|
||||||
au BufNewFile,BufRead *.rest setf rst
|
au BufNewFile,BufRead *.rest setf rst
|
||||||
au BufNewFile,BufRead *.rest.txt setf rst
|
au BufNewFile,BufRead *.rest.txt setf rst
|
||||||
|
|||||||
@@ -55,3 +55,11 @@ rules:
|
|||||||
filetype: glsl
|
filetype: glsl
|
||||||
- override: "g:filetype_fs"
|
- override: "g:filetype_fs"
|
||||||
- filetype: forth
|
- filetype: forth
|
||||||
|
---
|
||||||
|
extensions: [re]
|
||||||
|
rules:
|
||||||
|
- lines: 50
|
||||||
|
rules:
|
||||||
|
- pattern: '^\s*#(?:(?:if|ifdef|define|pragma)\s+\w|\s*include\s+[<"]|template\s*<)'
|
||||||
|
filetype: cpp
|
||||||
|
- filetype: reason
|
||||||
|
|||||||
@@ -773,6 +773,11 @@ filetypes:
|
|||||||
extensions:
|
extensions:
|
||||||
- flow
|
- flow
|
||||||
---
|
---
|
||||||
|
name: javascript-sql
|
||||||
|
remote: statico/vim-javascript-sql
|
||||||
|
after: javascript
|
||||||
|
filetypes: []
|
||||||
|
---
|
||||||
name: jenkins
|
name: jenkins
|
||||||
remote: martinda/Jenkinsfile-vim-syntax
|
remote: martinda/Jenkinsfile-vim-syntax
|
||||||
filetypes:
|
filetypes:
|
||||||
@@ -1271,6 +1276,7 @@ filetypes:
|
|||||||
---
|
---
|
||||||
name: reason
|
name: reason
|
||||||
remote: reasonml-editor/vim-reason-plus
|
remote: reasonml-editor/vim-reason-plus
|
||||||
|
after: c/c++
|
||||||
filetypes:
|
filetypes:
|
||||||
- name: reason
|
- name: reason
|
||||||
linguist: Reason
|
linguist: Reason
|
||||||
|
|||||||
@@ -202,9 +202,17 @@ def indent(str, amount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pattern_to_condition(rule)
|
def pattern_to_condition(rule)
|
||||||
|
if rule.has_key?("or")
|
||||||
|
return rule["or"].map { |p| pattern_to_condition(p) }.join(" || ")
|
||||||
|
end
|
||||||
|
|
||||||
|
if rule.has_key?("or")
|
||||||
|
return rule["and"].map { |p| pattern_to_condition(p) }.join(" && ")
|
||||||
|
end
|
||||||
|
|
||||||
operator = (rule["negative"] ? "!" : "=") + "~" + (rule["ignore_case"] ? "?" : "#")
|
operator = (rule["negative"] ? "!" : "=") + "~" + (rule["ignore_case"] ? "?" : "#")
|
||||||
|
|
||||||
"line #{operator} '#{rule["pattern"]}'"
|
return "line #{operator} '#{rule["pattern"]}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
def rules_to_code(rules)
|
def rules_to_code(rules)
|
||||||
@@ -250,10 +258,10 @@ def rule_to_code(rule)
|
|||||||
return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n")
|
return rule["rules"].map { |r| indent(rule_to_code(r), 0) }.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
if rule.has_key?("pattern")
|
if rule.has_key?("pattern") || rule.has_key?("or") || rule.has_key?("and")
|
||||||
return <<~EOS
|
return <<~EOS
|
||||||
if #{pattern_to_condition(rule)}
|
if #{pattern_to_condition(rule)}
|
||||||
#{indent(rule_to_code(except(rule, "pattern", "ignore_case", "negative")), 2)}
|
#{indent(rule_to_code(except(rule, "pattern", "or", "and", "ignore_case", "negative")), 2)}
|
||||||
endif
|
endif
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
@@ -391,6 +399,9 @@ def generate_ftdetect(packages, heuristics)
|
|||||||
" Enable jsx syntax by default
|
" Enable jsx syntax by default
|
||||||
call s:SetDefault('g:jsx_ext_required', 0)
|
call s:SetDefault('g:jsx_ext_required', 0)
|
||||||
|
|
||||||
|
" Needed for sql highlighting
|
||||||
|
call s:SetDefault('g:javascript_sql_dialect', 'sql')
|
||||||
|
|
||||||
" Make csv loading faster
|
" Make csv loading faster
|
||||||
call s:SetDefault('g:csv_start', 1)
|
call s:SetDefault('g:csv_start', 1)
|
||||||
call s:SetDefault('g:csv_end', 2)
|
call s:SetDefault('g:csv_end', 2)
|
||||||
|
|||||||
@@ -207,3 +207,10 @@ call TestExtension('fsharp', 'fsharp.fs', "let myInt = 5")
|
|||||||
call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}")
|
call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}")
|
||||||
let g:filetype_fs = 'fizfuz'
|
let g:filetype_fs = 'fizfuz'
|
||||||
call TestExtension('fizfuz', 'fizfuz.fs', '')
|
call TestExtension('fizfuz', 'fizfuz.fs', '')
|
||||||
|
|
||||||
|
" .re extension
|
||||||
|
call TestExtension('reason', 'empty.re', '')
|
||||||
|
call TestExtension('cpp', 'cpp.re', '#include "config.h"')
|
||||||
|
call TestExtension('cpp', 'cpp2.re', '#ifdef HAVE_CONFIG_H')
|
||||||
|
call TestExtension('cpp', 'cpp3.re', '#define YYCTYPE unsigned char')
|
||||||
|
call TestExtension('reason', 'react.re', 'ReasonReact.Router.push("");')
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ call TestFiletype('atlas')
|
|||||||
call TestFiletype('autoit')
|
call TestFiletype('autoit')
|
||||||
call TestFiletype('ave')
|
call TestFiletype('ave')
|
||||||
call TestFiletype('awk')
|
call TestFiletype('awk')
|
||||||
|
call TestFiletype('reason')
|
||||||
call TestFiletype('c')
|
call TestFiletype('c')
|
||||||
call TestFiletype('cpp')
|
call TestFiletype('cpp')
|
||||||
call TestFiletype('caddyfile')
|
call TestFiletype('caddyfile')
|
||||||
@@ -175,7 +176,6 @@ call TestFiletype('ragel')
|
|||||||
call TestFiletype('raku')
|
call TestFiletype('raku')
|
||||||
call TestFiletype('raml')
|
call TestFiletype('raml')
|
||||||
call TestFiletype('razor')
|
call TestFiletype('razor')
|
||||||
call TestFiletype('reason')
|
|
||||||
call TestFiletype('rst')
|
call TestFiletype('rst')
|
||||||
call TestFiletype('ruby')
|
call TestFiletype('ruby')
|
||||||
call TestFiletype('eruby')
|
call TestFiletype('eruby')
|
||||||
|
|||||||
Reference in New Issue
Block a user