mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
255345bf95 | ||
|
|
3169f80169 | ||
|
|
e9b3bcd5e1 | ||
|
|
d9ee362537 | ||
|
|
57badea2dc | ||
|
|
3baafd5c33 |
@@ -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.
|
||||
|
||||
- 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-->190<!--/Package Count--> packages it consists of.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->191<!--/Package Count--> packages it consists of.
|
||||
- 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.
|
||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||
@@ -130,6 +130,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [html5](https://github.com/othree/html5.vim)
|
||||
- [i3](https://github.com/mboughaba/i3config.vim)
|
||||
- [icalendar](https://github.com/chutzpah/icalendar.vim)
|
||||
- [idris2](https://github.com/edwinb/idris2-vim)
|
||||
- [idris](https://github.com/idris-hackers/idris-vim)
|
||||
- [ion](https://github.com/vmchale/ion-vim)
|
||||
- [javascript-sql](https://github.com/statico/vim-javascript-sql)
|
||||
@@ -228,7 +229,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [xdc](https://github.com/amal-khailtash/vim-xdc-syntax)
|
||||
- [xml](https://github.com/amadeus/vim-xml)
|
||||
- [xsl](https://github.com/vim-scripts/XSLT-syntax)
|
||||
- [yaml](https://github.com/stephpy/vim-yaml)
|
||||
- [yaml](https://github.com/vim/vim/tree/df44a27b53586fccfc6a3aedc89061fdd9a515ff/runtime)
|
||||
- [yard](https://github.com/sheerun/vim-yardoc)
|
||||
- [zephir](https://github.com/xwsoul/vim-zephir)
|
||||
- [zig](https://github.com/ziglang/zig.vim)
|
||||
|
||||
5
after/ftplugin/idris2.vim
Normal file
5
after/ftplugin/idris2.vim
Normal file
@@ -0,0 +1,5 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1
|
||||
|
||||
setlocal iskeyword+='
|
||||
|
||||
endif
|
||||
@@ -1,11 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: Yaml
|
||||
" Author: Henrique Barcelos
|
||||
" Date: 2014-10-08
|
||||
" URL: https://github.com/hjpbarcelos
|
||||
setlocal autoindent sw=2 ts=2 expandtab
|
||||
" vim:set sw=2:
|
||||
|
||||
endif
|
||||
82
after/syntax/idris2.vim
Normal file
82
after/syntax/idris2.vim
Normal file
@@ -0,0 +1,82 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1
|
||||
|
||||
" This script allows for unicode concealing of certain characters
|
||||
" For instance -> goes to →
|
||||
"
|
||||
" It needs vim >= 7.3, set nocompatible, set enc=utf-8
|
||||
"
|
||||
" If you want to turn this on, let g:idris_conceal = 1
|
||||
|
||||
if !exists('g:idris_conceal') || !has('conceal') || &enc != 'utf-8'
|
||||
finish
|
||||
endif
|
||||
|
||||
" vim: set fenc=utf-8:
|
||||
syntax match idrNiceOperator "\\\ze[[:alpha:][:space:]_([]" conceal cchar=λ
|
||||
syntax match idrNiceOperator "<-" conceal cchar=←
|
||||
syntax match idrNiceOperator "->" conceal cchar=→
|
||||
syntax match idrNiceOperator "\<sum\>" conceal cchar=∑
|
||||
syntax match idrNiceOperator "\<product\>" conceal cchar=∏
|
||||
syntax match idrNiceOperator "\<sqrt\>" conceal cchar=√
|
||||
syntax match idrNiceOperator "\<pi\>" conceal cchar=π
|
||||
syntax match idrNiceOperator "==" conceal cchar=≡
|
||||
syntax match idrNiceOperator "\/=" conceal cchar=≠
|
||||
|
||||
|
||||
let s:extraConceal = 1
|
||||
|
||||
let s:doubleArrow = 1
|
||||
" Set this to 0 to use the more technically correct arrow from bar
|
||||
|
||||
" Some windows font don't support some of the characters,
|
||||
" so if they are the main font, we don't load them :)
|
||||
if has("win32")
|
||||
let s:incompleteFont = [ 'Consolas'
|
||||
\ , 'Lucida Console'
|
||||
\ , 'Courier New'
|
||||
\ ]
|
||||
let s:mainfont = substitute( &guifont, '^\([^:,]\+\).*', '\1', '')
|
||||
for s:fontName in s:incompleteFont
|
||||
if s:mainfont ==? s:fontName
|
||||
let s:extraConceal = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if s:extraConceal
|
||||
syntax match idrNiceOperator "Void" conceal cchar=⊥
|
||||
|
||||
" Match greater than and lower than w/o messing with Kleisli composition
|
||||
syntax match idrNiceOperator "<=\ze[^<]" conceal cchar=≤
|
||||
syntax match idrNiceOperator ">=\ze[^>]" conceal cchar=≥
|
||||
|
||||
if s:doubleArrow
|
||||
syntax match idrNiceOperator "=>" conceal cchar=⇒
|
||||
else
|
||||
syntax match idrNiceOperator "=>" conceal cchar=↦
|
||||
endif
|
||||
|
||||
syntax match idrNiceOperator "=\zs<<" conceal cchar=«
|
||||
|
||||
syntax match idrNiceOperator "++" conceal cchar=⧺
|
||||
syntax match idrNiceOperator "::" conceal cchar=∷
|
||||
syntax match idrNiceOperator "-<" conceal cchar=↢
|
||||
syntax match idrNiceOperator ">-" conceal cchar=↣
|
||||
syntax match idrNiceOperator "-<<" conceal cchar=⤛
|
||||
syntax match idrNiceOperator ">>-" conceal cchar=⤜
|
||||
|
||||
" Only replace the dot, avoid taking spaces around.
|
||||
syntax match idrNiceOperator /\s\.\s/ms=s+1,me=e-1 conceal cchar=∘
|
||||
syntax match idrNiceOperator "\.\." conceal cchar=‥
|
||||
|
||||
syntax match idrNiceOperator "`elem`" conceal cchar=∈
|
||||
syntax match idrNiceOperator "`notElem`" conceal cchar=∉
|
||||
endif
|
||||
|
||||
hi link idrNiceOperator Operator
|
||||
hi! link Conceal Operator
|
||||
setlocal conceallevel=2
|
||||
|
||||
|
||||
endif
|
||||
@@ -1,65 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1
|
||||
|
||||
" To make this file do stuff, add something like the following (without the
|
||||
" leading ") to your ~/.vimrc:
|
||||
" au BufNewFile,BufRead *.yaml,*.yml so ~/src/PyYaml/YAML.vim
|
||||
|
||||
" Vim syntax/macro file
|
||||
" Language: YAML
|
||||
" Author: Igor Vergeichik <iverg@mail.ru>
|
||||
" Sponsor: Tom Sawyer <transami@transami.net>
|
||||
" Stayven: Ryan King <jking@panoptic.com>
|
||||
" Copyright (c) 2002 Tom Saywer
|
||||
|
||||
" Add an item to a gangly list:
|
||||
"map , o<bs><bs><bs><bs>-<esc>o
|
||||
" Convert to Canonical form:
|
||||
"map \c :%!python -c 'from yaml.redump import redump; import sys; print redump(sys.stdin.read()).rstrip()'
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
endif
|
||||
syntax clear
|
||||
|
||||
syn match yamlInline "[\[\]\{\}]"
|
||||
syn match yamlBlock "[>|]\d\?[+-]"
|
||||
|
||||
syn region yamlComment start="\#" end="$"
|
||||
syn match yamlIndicator "#YAML:\S\+"
|
||||
|
||||
syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'"
|
||||
syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape
|
||||
syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1
|
||||
syn region yamlString matchgroup=yamlBlock start=/[>|]\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+2 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1
|
||||
syn region yamlString matchgroup=yamlBlock start=/[>|]\d\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+3 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1
|
||||
syn match yamlEscape +\\[abfnrtv'"\\]+ contained
|
||||
syn match yamlEscape "\\\o\o\=\o\=" contained
|
||||
syn match yamlEscape "\\x\x\+" contained
|
||||
|
||||
syn match yamlType "!\S\+"
|
||||
|
||||
syn keyword yamlConstant NULL Null null NONE None none NIL Nil nil
|
||||
syn keyword yamlConstant TRUE True true YES Yes yes ON On on
|
||||
syn keyword yamlConstant FALSE False false NO No no OFF Off off
|
||||
|
||||
syn match yamlKey "^\s*\zs[^ \t\"\'#]\+\ze\s*:"
|
||||
syn match yamlKey "^\s*-\s*\zs[^ \t\"\'#]\+\ze\s*:"
|
||||
syn match yamlAnchor "&\S\+"
|
||||
syn match yamlAlias "*\S\+"
|
||||
|
||||
" Setup the highlighting links
|
||||
|
||||
hi link yamlConstant Keyword
|
||||
hi link yamlIndicator PreCondit
|
||||
hi link yamlAnchor Function
|
||||
hi link yamlAlias Function
|
||||
hi link yamlKey Identifier
|
||||
hi link yamlType Type
|
||||
|
||||
hi link yamlComment Comment
|
||||
hi link yamlInline Operator
|
||||
hi link yamlBlock Operator
|
||||
hi link yamlString String
|
||||
hi link yamlEscape Special
|
||||
|
||||
endif
|
||||
@@ -1,7 +1,8 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
|
||||
function! cargo#quickfix#CmdPre() abort
|
||||
if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo'
|
||||
if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' &&
|
||||
\ &makeprg =~ '\V\^cargo\ \.\*'
|
||||
" Preserve the current directory, and 'lcd' to the nearest Cargo file.
|
||||
let b:rust_compiler_cargo_qf_has_lcd = haslocaldir()
|
||||
let b:rust_compiler_cargo_qf_prev_cd = getcwd()
|
||||
|
||||
@@ -212,6 +212,50 @@ func! polyglot#DetectReFiletype()
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
func! polyglot#DetectIdrFiletype()
|
||||
for lnum in range(1, min([line("$"), 5]))
|
||||
let line = getline(lnum)
|
||||
if line =~# '^\s*--.*[Ii]dris \=1'
|
||||
setf idris | return
|
||||
endif
|
||||
if line =~# '^\s*--.*[Ii]dris \=2'
|
||||
setf idris2 | return
|
||||
endif
|
||||
endfor
|
||||
for lnum in range(1, min([line("$"), 30]))
|
||||
let line = getline(lnum)
|
||||
if line =~# '^pkgs =.*'
|
||||
setf idris | return
|
||||
endif
|
||||
if line =~# '^depends =.*'
|
||||
setf idris2 | return
|
||||
endif
|
||||
if line =~# '^%language \(TypeProviders\|ElabReflection\)'
|
||||
setf idris | return
|
||||
endif
|
||||
if line =~# '^%language PostfixProjections'
|
||||
setf idris2 | return
|
||||
endif
|
||||
if line =~# '^%access .*'
|
||||
setf idris | return
|
||||
endif
|
||||
if exists("g:filetype_idr")
|
||||
exe "setf " . g:filetype_idr | return
|
||||
endif
|
||||
endfor
|
||||
setf idris2 | return
|
||||
endfunc
|
||||
|
||||
func! polyglot#DetectLidrFiletype()
|
||||
for lnum in range(1, min([line("$"), 200]))
|
||||
let line = getline(lnum)
|
||||
if line =~# '^>\s*--.*[Ii]dris \=1'
|
||||
setf lidris | return
|
||||
endif
|
||||
endfor
|
||||
setf lidris2 | return
|
||||
endfunc
|
||||
|
||||
" Restore 'cpoptions'
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
@@ -65,12 +65,12 @@ endfunction
|
||||
function! s:RustfmtConfigOptions()
|
||||
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
|
||||
if l:rustfmt_toml !=# ''
|
||||
return '--config-path '.fnamemodify(l:rustfmt_toml, ":p")
|
||||
return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p"))
|
||||
endif
|
||||
|
||||
let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';')
|
||||
if l:_rustfmt_toml !=# ''
|
||||
return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p")
|
||||
return '--config-path '.shellescape(fnamemodify(l:_rustfmt_toml, ":p"))
|
||||
endif
|
||||
|
||||
" Default to edition 2018 in case no rustfmt.toml was found.
|
||||
|
||||
@@ -103,6 +103,7 @@ let s:globs = {
|
||||
\ 'i3config': '*.i3.config,*.i3config,i3.config,i3config',
|
||||
\ 'icalendar': '*.ics',
|
||||
\ 'idris': '*.idr,*.lidr,idris-response',
|
||||
\ 'idris2': '*.idr,*.ipkg,idris-response',
|
||||
\ 'ion': '*.ion',
|
||||
\ 'javascript': '*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile',
|
||||
\ 'javascriptreact': '*.jsx',
|
||||
@@ -116,6 +117,7 @@ let s:globs = {
|
||||
\ 'kotlin': '*.kt,*.ktm,*.kts',
|
||||
\ 'ledger': '*.ldg,*.ledger,*.journal',
|
||||
\ 'less': '*.less',
|
||||
\ 'lidris2': '*.lidr',
|
||||
\ 'lilypond': '*.ly,*.ily',
|
||||
\ 'litcoffee': '*.litcoffee,*.coffee.md',
|
||||
\ 'livescript': '*.ls,*._ls,Slakefile',
|
||||
|
||||
@@ -515,9 +515,6 @@ if !has_key(s:disabled_packages, 'coffee-script')
|
||||
au BufNewFile,BufRead *.litcoffee setf litcoffee
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'cjsx')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'cryptol')
|
||||
au BufNewFile,BufRead *.cry setf cryptol
|
||||
au BufNewFile,BufRead *.cyl setf cryptol
|
||||
@@ -795,9 +792,16 @@ if !has_key(s:disabled_packages, 'icalendar')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'idris')
|
||||
au BufNewFile,BufRead *.idr setf idris
|
||||
au BufNewFile,BufRead *.lidr setf idris
|
||||
au BufNewFile,BufRead idris-response setf idris
|
||||
au! BufNewFile,BufRead *.idr call polyglot#DetectIdrFiletype()
|
||||
au! BufNewFile,BufRead *.lidr call polyglot#DetectLidrFiletype()
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'idris2')
|
||||
au BufNewFile,BufRead *.ipkg setf idris2
|
||||
au BufNewFile,BufRead idris-response setf idris2
|
||||
au! BufNewFile,BufRead *.idr call polyglot#DetectIdrFiletype()
|
||||
au! BufNewFile,BufRead *.lidr call polyglot#DetectLidrFiletype()
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'ion')
|
||||
@@ -805,9 +809,6 @@ if !has_key(s:disabled_packages, 'ion')
|
||||
au BufNewFile,BufRead ~/.config/ion/initrc setf ion
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'javascript-sql')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'javascript')
|
||||
au BufNewFile,BufRead *._js setf javascript
|
||||
au BufNewFile,BufRead *.bones setf javascript
|
||||
@@ -1197,12 +1198,6 @@ if !has_key(s:disabled_packages, 'python')
|
||||
au BufNewFile,BufRead wscript setf python
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'python-indent')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'python-compiler')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'requirements')
|
||||
au BufNewFile,BufRead *.pip setf requirements
|
||||
au BufNewFile,BufRead *require.{txt,in} setf requirements
|
||||
@@ -1345,9 +1340,6 @@ if !has_key(s:disabled_packages, 'rspec')
|
||||
au BufNewFile,BufRead *_spec.rb if !did_filetype() | set ft=ruby syntax=rspec | endif
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'yard')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'brewfile')
|
||||
au BufNewFile,BufRead Brewfile setf brewfile
|
||||
endif
|
||||
@@ -1413,9 +1405,6 @@ if !has_key(s:disabled_packages, 'sh')
|
||||
au BufNewFile,BufRead {.,}zshrc setf zsh
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'zinit')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'slim')
|
||||
au BufNewFile,BufRead *.slim setf slim
|
||||
endif
|
||||
@@ -1446,9 +1435,6 @@ if !has_key(s:disabled_packages, 'svg')
|
||||
au BufNewFile,BufRead *.svg setf svg
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'svg-indent')
|
||||
endif
|
||||
|
||||
if !has_key(s:disabled_packages, 'swift')
|
||||
au BufNewFile,BufRead *.swift setf swift
|
||||
endif
|
||||
|
||||
334
ftplugin/idris2.vim
Normal file
334
ftplugin/idris2.vim
Normal file
@@ -0,0 +1,334 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1
|
||||
|
||||
if bufname('%') == "idris-response"
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
setlocal shiftwidth=2
|
||||
setlocal tabstop=2
|
||||
if !exists("g:idris_allow_tabchar") || g:idris_allow_tabchar == 0
|
||||
setlocal expandtab
|
||||
endif
|
||||
setlocal comments=s1:{-,mb:-,ex:-},:\|\|\|,:--
|
||||
setlocal commentstring=--%s
|
||||
setlocal iskeyword+=?
|
||||
setlocal wildignore+=*.ibc
|
||||
|
||||
let idris_response = 0
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" Text near cursor position that needs to be passed to a command.
|
||||
" Refinment of `expand(<cword>)` to accomodate differences between
|
||||
" a (n)vim word and what Idris requires.
|
||||
function! s:currentQueryObject()
|
||||
let word = expand("<cword>")
|
||||
if word =~ '^?'
|
||||
" Cut off '?' that introduces a hole identifier.
|
||||
let word = strpart(word, 1)
|
||||
endif
|
||||
return word
|
||||
endfunction
|
||||
|
||||
function! s:IdrisCommand(...)
|
||||
let idriscmd = shellescape(join(a:000))
|
||||
" echo("idris2 " . expand ('%:p') . " --client " . idriscmd)
|
||||
return system("idris2 --find-ipkg " . shellescape(expand('%:p')) . " --client " . idriscmd)
|
||||
endfunction
|
||||
|
||||
function! IdrisDocFold(lineNum)
|
||||
let line = getline(a:lineNum)
|
||||
|
||||
if line =~ "^\s*|||"
|
||||
return "1"
|
||||
endif
|
||||
|
||||
return "0"
|
||||
endfunction
|
||||
|
||||
function! IdrisFold(lineNum)
|
||||
return IdrisDocFold(a:lineNum)
|
||||
endfunction
|
||||
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=IdrisFold(v:lnum)
|
||||
|
||||
function! IdrisResponseWin()
|
||||
if (!bufexists("idris-response"))
|
||||
botright 10split
|
||||
badd idris-response
|
||||
b idris-response
|
||||
let g:idris_respwin = "active"
|
||||
set buftype=nofile
|
||||
wincmd k
|
||||
elseif (bufexists("idris-response") && g:idris_respwin == "hidden")
|
||||
botright 10split
|
||||
b idris-response
|
||||
let g:idris_respwin = "active"
|
||||
wincmd k
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisHideResponseWin()
|
||||
let g:idris_respwin = "hidden"
|
||||
endfunction
|
||||
|
||||
function! IdrisShowResponseWin()
|
||||
let g:idris_respwin = "active"
|
||||
endfunction
|
||||
|
||||
function! IWrite(str)
|
||||
if (bufexists("idris-response"))
|
||||
let save_cursor = getcurpos()
|
||||
b idris-response
|
||||
%delete
|
||||
let resp = split(a:str, '\n')
|
||||
call append(1, resp)
|
||||
b #
|
||||
call setpos('.', save_cursor)
|
||||
else
|
||||
echo a:str
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisReload(q)
|
||||
w
|
||||
let file = expand('%:p')
|
||||
let tc = system("idris2 --find-ipkg " . shellescape(file) . " --client ''")
|
||||
if (! (tc is ""))
|
||||
call IWrite(tc)
|
||||
else
|
||||
if (a:q==0)
|
||||
call IWrite("Successfully reloaded " . file)
|
||||
endif
|
||||
endif
|
||||
return tc
|
||||
endfunction
|
||||
|
||||
function! IdrisReloadToLine(cline)
|
||||
return IdrisReload(1)
|
||||
"w
|
||||
"let file = expand("%:p")
|
||||
"let tc = s:IdrisCommand(":lto", a:cline, file)
|
||||
"if (! (tc is ""))
|
||||
" call IWrite(tc)
|
||||
"endif
|
||||
"return tc
|
||||
endfunction
|
||||
|
||||
function! IdrisShowType()
|
||||
w
|
||||
let word = s:currentQueryObject()
|
||||
let cline = line(".")
|
||||
let ccol = col(".")
|
||||
let ty = s:IdrisCommand(":t", word)
|
||||
call IWrite(ty)
|
||||
endfunction
|
||||
|
||||
function! IdrisShowDoc()
|
||||
w
|
||||
let word = expand("<cword>")
|
||||
let ty = s:IdrisCommand(":doc", word)
|
||||
call IWrite(ty)
|
||||
endfunction
|
||||
|
||||
function! IdrisProofSearch(hint)
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = s:currentQueryObject()
|
||||
|
||||
if (a:hint==0)
|
||||
let hints = ""
|
||||
else
|
||||
let hints = input ("Hints: ")
|
||||
endif
|
||||
|
||||
let result = s:IdrisCommand(":ps!", cline, word, hints)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisGenerateDef()
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = s:currentQueryObject()
|
||||
|
||||
let result = s:IdrisCommand(":gd!", cline, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisMakeLemma()
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = s:currentQueryObject()
|
||||
|
||||
let result = s:IdrisCommand(":ml!", cline, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
call search(word, "b")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisRefine()
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = expand("<cword>")
|
||||
let name = input ("Name: ")
|
||||
|
||||
let result = s:IdrisCommand(":ref!", cline, word, name)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisAddMissing()
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = expand("<cword>")
|
||||
|
||||
let result = s:IdrisCommand(":am!", cline, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisCaseSplit()
|
||||
w
|
||||
let view = winsaveview()
|
||||
let cline = line(".")
|
||||
let ccol = col(".")
|
||||
let word = expand("<cword>")
|
||||
let result = s:IdrisCommand(":cs!", cline, ccol, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisMakeWith()
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = s:currentQueryObject()
|
||||
let tc = IdrisReload(1)
|
||||
|
||||
let result = s:IdrisCommand(":mw!", cline, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
call search("_")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisMakeCase()
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = s:currentQueryObject()
|
||||
|
||||
let result = s:IdrisCommand(":mc!", cline, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
call search("_")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisAddClause(proof)
|
||||
let view = winsaveview()
|
||||
w
|
||||
let cline = line(".")
|
||||
let word = expand("<cword>")
|
||||
|
||||
if (a:proof==0)
|
||||
let fn = ":ac!"
|
||||
else
|
||||
let fn = ":apc!"
|
||||
endif
|
||||
|
||||
let result = s:IdrisCommand(fn, cline, word)
|
||||
if (! (result is ""))
|
||||
call IWrite(result)
|
||||
else
|
||||
e
|
||||
call winrestview(view)
|
||||
call search(word)
|
||||
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! IdrisEval()
|
||||
w
|
||||
let expr = input ("Expression: ")
|
||||
let result = s:IdrisCommand(expr)
|
||||
call IWrite(" = " . result)
|
||||
endfunction
|
||||
|
||||
nnoremap <buffer> <silent> <LocalLeader>t :call IdrisShowType()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>r :call IdrisReload(0)<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>c :call IdrisCaseSplit()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>a 0:call search(":")<ENTER>b:call IdrisAddClause(0)<ENTER>w
|
||||
nnoremap <buffer> <silent> <LocalLeader>d 0:call search(":")<ENTER>b:call IdrisAddClause(0)<ENTER>w
|
||||
nnoremap <buffer> <silent> <LocalLeader>b 0:call IdrisAddClause(0)<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>m :call IdrisAddMissing()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>md 0:call search(":")<ENTER>b:call IdrisAddClause(1)<ENTER>w
|
||||
nnoremap <buffer> <silent> <LocalLeader>f :call IdrisRefine()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>o :call IdrisProofSearch(0)<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>s :call IdrisProofSearch(0)<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>g :call IdrisGenerateDef()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>p :call IdrisProofSearch(1)<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>l :call IdrisMakeLemma()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>e :call IdrisEval()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>w 0:call IdrisMakeWith()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>mc :call IdrisMakeCase()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>i 0:call IdrisResponseWin()<ENTER>
|
||||
nnoremap <buffer> <silent> <LocalLeader>h :call IdrisShowDoc()<ENTER>
|
||||
|
||||
menu Idris.Reload <LocalLeader>r
|
||||
menu Idris.Show\ Type <LocalLeader>t
|
||||
menu Idris.Evaluate <LocalLeader>e
|
||||
menu Idris.-SEP0- :
|
||||
menu Idris.Add\ Clause <LocalLeader>a
|
||||
menu Idris.Generate\ Definition <LocalLeader>g
|
||||
menu Idris.Add\ with <LocalLeader>w
|
||||
menu Idris.Case\ Split <LocalLeader>c
|
||||
menu Idris.Add\ missing\ cases <LocalLeader>m
|
||||
menu Idris.Proof\ Search <LocalLeader>s
|
||||
menu Idris.Proof\ Search\ with\ hints <LocalLeader>p
|
||||
|
||||
au BufHidden idris-response call IdrisHideResponseWin()
|
||||
au BufEnter idris-response call IdrisShowResponseWin()
|
||||
|
||||
endif
|
||||
29
ftplugin/yaml.vim
Normal file
29
ftplugin/yaml.vim
Normal file
@@ -0,0 +1,29 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1
|
||||
|
||||
" Vim filetype plugin file
|
||||
" Language: YAML (YAML Ain't Markup Language)
|
||||
" Previous Maintainer: Nikolai Weibull <now@bitwi.se> (inactive)
|
||||
" Last Change: 2020 Mar 02
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let b:undo_ftplugin = "setl com< cms< et< fo<"
|
||||
|
||||
setlocal comments=:# commentstring=#\ %s expandtab
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
|
||||
if !exists("g:yaml_recommended_style") || g:yaml_recommended_style != 0
|
||||
let b:undo_ftplugin ..= " sw< sts<"
|
||||
setlocal shiftwidth=2 softtabstop=2
|
||||
endif
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
endif
|
||||
@@ -63,3 +63,33 @@ rules:
|
||||
- pattern: '^\s*#(?:(?:if|ifdef|define|pragma)\s+\w|\s*include\s+[<"]|template\s*<)'
|
||||
filetype: cpp
|
||||
- filetype: reason
|
||||
---
|
||||
extensions: [idr]
|
||||
rules:
|
||||
- lines: 5
|
||||
rules:
|
||||
- pattern: '^\s*--.*[Ii]dris ?1'
|
||||
filetype: idris
|
||||
- pattern: '^\s*--.*[Ii]dris ?2'
|
||||
filetype: idris2
|
||||
- lines: 30
|
||||
rules:
|
||||
- pattern: '^pkgs =.*'
|
||||
filetype: idris
|
||||
- pattern: '^depends =.*'
|
||||
filetype: idris2
|
||||
- pattern: '^%language (TypeProviders|ElabReflection)'
|
||||
filetype: idris
|
||||
- pattern: '^%language PostfixProjections'
|
||||
filetype: idris2
|
||||
- pattern: '^%access .*'
|
||||
filetype: idris
|
||||
- override: 'g:filetype_idr'
|
||||
- filetype: idris2
|
||||
---
|
||||
extensions: [lidr]
|
||||
rules:
|
||||
- lines: 200
|
||||
pattern: '^>\s*--.*[Ii]dris ?1'
|
||||
filetype: lidris
|
||||
- filetype: lidris2
|
||||
|
||||
148
indent/idris2.vim
Normal file
148
indent/idris2.vim
Normal file
@@ -0,0 +1,148 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1
|
||||
|
||||
" indentation for idris (idris-lang.org)
|
||||
"
|
||||
" Based on haskell indentation by motemen <motemen@gmail.com>
|
||||
"
|
||||
" author: raichoo (raichoo@googlemail.com)
|
||||
"
|
||||
" Modify g:idris_indent_if and g:idris_indent_case to
|
||||
" change indentation for `if'(default 3) and `case'(default 5).
|
||||
" Example (in .vimrc):
|
||||
" > let g:idris_indent_if = 2
|
||||
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
if !exists('g:idris_indent_if')
|
||||
" if bool
|
||||
" >>>then ...
|
||||
" >>>else ...
|
||||
let g:idris_indent_if = 3
|
||||
endif
|
||||
|
||||
if !exists('g:idris_indent_case')
|
||||
" case xs of
|
||||
" >>>>>[] => ...
|
||||
" >>>>>(y::ys) => ...
|
||||
let g:idris_indent_case = 5
|
||||
endif
|
||||
|
||||
if !exists('g:idris_indent_let')
|
||||
" let x : Nat = O in
|
||||
" >>>>x
|
||||
let g:idris_indent_let = 4
|
||||
endif
|
||||
|
||||
if !exists('g:idris_indent_rewrite')
|
||||
" rewrite prf in expr
|
||||
" >>>>>>>>x
|
||||
let g:idris_indent_rewrite = 8
|
||||
endif
|
||||
|
||||
if !exists('g:idris_indent_where')
|
||||
" where f : Nat -> Nat
|
||||
" >>>>>>f x = x
|
||||
let g:idris_indent_where = 6
|
||||
endif
|
||||
|
||||
if !exists('g:idris_indent_do')
|
||||
" do x <- a
|
||||
" >>>y <- b
|
||||
let g:idris_indent_do = 3
|
||||
endif
|
||||
|
||||
setlocal indentexpr=GetIdrisIndent()
|
||||
setlocal indentkeys=!^F,o,O,}
|
||||
|
||||
function! GetIdrisIndent()
|
||||
let prevline = getline(v:lnum - 1)
|
||||
|
||||
if prevline =~ '\s\+(\s*.\+\s\+:\s\+.\+\s*)\s\+->\s*$'
|
||||
return match(prevline, '(')
|
||||
elseif prevline =~ '\s\+{\s*.\+\s\+:\s\+.\+\s*}\s\+->\s*$'
|
||||
return match(prevline, '{')
|
||||
endif
|
||||
|
||||
if prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
|
||||
let s = match(prevline, '[:=]')
|
||||
if s > 0
|
||||
return s + 2
|
||||
else
|
||||
return match(prevline, '\S')
|
||||
endif
|
||||
endif
|
||||
|
||||
if prevline =~ '[{([][^})\]]\+$'
|
||||
return match(prevline, '[{([]')
|
||||
endif
|
||||
|
||||
if prevline =~ '\<let\>\s\+.\+\<in\>\s*$'
|
||||
return match(prevline, '\<let\>') + g:idris_indent_let
|
||||
endif
|
||||
|
||||
if prevline =~ '\<rewrite\>\s\+.\+\<in\>\s*$'
|
||||
return match(prevline, '\<rewrite\>') + g:idris_indent_rewrite
|
||||
endif
|
||||
|
||||
if prevline !~ '\<else\>'
|
||||
let s = match(prevline, '\<if\>.*\&.*\zs\<then\>')
|
||||
if s > 0
|
||||
return s
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<if\>')
|
||||
if s > 0
|
||||
return s + g:idris_indent_if
|
||||
endif
|
||||
endif
|
||||
|
||||
if prevline =~ '\(\<where\>\|\<do\>\|=\|[{([]\)\s*$'
|
||||
return match(prevline, '\S') + &shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '\<where\>\s\+\S\+.*$'
|
||||
return match(prevline, '\<where\>') + g:idris_indent_where
|
||||
endif
|
||||
|
||||
if prevline =~ '\<do\>\s\+\S\+.*$'
|
||||
return match(prevline, '\<do\>') + g:idris_indent_do
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\<\(co\)\?data\>\s\+[^=]\+\s\+=\s\+\S\+.*$'
|
||||
return match(prevline, '=')
|
||||
endif
|
||||
|
||||
if prevline =~ '\<with\>\s\+([^)]*)\s*$'
|
||||
return match(prevline, '\S') + &shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '\<case\>\s\+.\+\<of\>\s*$'
|
||||
return match(prevline, '\<case\>') + g:idris_indent_case
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\(\<namespace\>\|\<\(co\)\?data\>\)\s\+\S\+\s*$'
|
||||
return match(prevline, '\(\<namespace\>\|\<\(co\)\?data\>\)') + &shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\(\<using\>\|\<parameters\>\)\s*([^(]*)\s*$'
|
||||
return match(prevline, '\(\<using\>\|\<parameters\>\)') + &shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\<mutual\>\s*$'
|
||||
return match(prevline, '\<mutual\>') + &shiftwidth
|
||||
endif
|
||||
|
||||
let line = getline(v:lnum)
|
||||
|
||||
if (line =~ '^\s*}\s*' && prevline !~ '^\s*;')
|
||||
return match(prevline, '\S') - &shiftwidth
|
||||
endif
|
||||
|
||||
return match(prevline, '\S')
|
||||
endfunction
|
||||
|
||||
endif
|
||||
159
indent/yaml.vim
Normal file
159
indent/yaml.vim
Normal file
@@ -0,0 +1,159 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: YAML
|
||||
" Maintainer: Nikolai Pavlov <zyx.vim@gmail.com>
|
||||
" Last Change: 2019 Sep 28
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetYAMLIndent(v:lnum)
|
||||
setlocal indentkeys=!^F,o,O,0#,0},0],<:>,0-
|
||||
setlocal nosmartindent
|
||||
|
||||
let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<'
|
||||
|
||||
" Only define the function once.
|
||||
if exists('*GetYAMLIndent')
|
||||
finish
|
||||
endif
|
||||
|
||||
function s:FindPrevLessIndentedLine(lnum, ...)
|
||||
let prevlnum = prevnonblank(a:lnum-1)
|
||||
let curindent = a:0 ? a:1 : indent(a:lnum)
|
||||
while prevlnum
|
||||
\&& indent(prevlnum) >= curindent
|
||||
\&& getline(prevlnum) !~# '^\s*#'
|
||||
let prevlnum = prevnonblank(prevlnum-1)
|
||||
endwhile
|
||||
return prevlnum
|
||||
endfunction
|
||||
|
||||
function s:FindPrevLEIndentedLineMatchingRegex(lnum, regex)
|
||||
let plilnum = s:FindPrevLessIndentedLine(a:lnum, indent(a:lnum)+1)
|
||||
while plilnum && getline(plilnum) !~# a:regex
|
||||
let plilnum = s:FindPrevLessIndentedLine(plilnum)
|
||||
endwhile
|
||||
return plilnum
|
||||
endfunction
|
||||
|
||||
let s:mapkeyregex='\v^\s*\#@!\S@=%(\''%([^'']|\''\'')*\'''.
|
||||
\ '|\"%([^"\\]|\\.)*\"'.
|
||||
\ '|%(%(\:\ )@!.)*)\:%(\ |$)'
|
||||
let s:liststartregex='\v^\s*%(\-%(\ |$))'
|
||||
|
||||
let s:c_ns_anchor_char = '\v%([\n\r\uFEFF \t,[\]{}]@!\p)'
|
||||
let s:c_ns_anchor_name = s:c_ns_anchor_char.'+'
|
||||
let s:c_ns_anchor_property = '\v\&'.s:c_ns_anchor_name
|
||||
|
||||
let s:ns_word_char = '\v[[:alnum:]_\-]'
|
||||
let s:ns_tag_char = '\v%(%\x\x|'.s:ns_word_char.'|[#/;?:@&=+$.~*''()])'
|
||||
let s:c_named_tag_handle = '\v\!'.s:ns_word_char.'+\!'
|
||||
let s:c_secondary_tag_handle = '\v\!\!'
|
||||
let s:c_primary_tag_handle = '\v\!'
|
||||
let s:c_tag_handle = '\v%('.s:c_named_tag_handle.
|
||||
\ '|'.s:c_secondary_tag_handle.
|
||||
\ '|'.s:c_primary_tag_handle.')'
|
||||
let s:c_ns_shorthand_tag = '\v'.s:c_tag_handle . s:ns_tag_char.'+'
|
||||
let s:c_non_specific_tag = '\v\!'
|
||||
let s:ns_uri_char = '\v%(%\x\x|'.s:ns_word_char.'\v|[#/;?:@&=+$,.!~*''()[\]])'
|
||||
let s:c_verbatim_tag = '\v\!\<'.s:ns_uri_char.'+\>'
|
||||
let s:c_ns_tag_property = '\v'.s:c_verbatim_tag.
|
||||
\ '\v|'.s:c_ns_shorthand_tag.
|
||||
\ '\v|'.s:c_non_specific_tag
|
||||
|
||||
let s:block_scalar_header = '\v[|>]%([+-]?[1-9]|[1-9]?[+-])?'
|
||||
|
||||
function GetYAMLIndent(lnum)
|
||||
if a:lnum == 1 || !prevnonblank(a:lnum-1)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let prevlnum = prevnonblank(a:lnum-1)
|
||||
let previndent = indent(prevlnum)
|
||||
|
||||
let line = getline(a:lnum)
|
||||
if line =~# '^\s*#' && getline(a:lnum-1) =~# '^\s*#'
|
||||
" Comment blocks should have identical indent
|
||||
return previndent
|
||||
elseif line =~# '^\s*[\]}]'
|
||||
" Lines containing only closing braces should have previous indent
|
||||
return indent(s:FindPrevLessIndentedLine(a:lnum))
|
||||
endif
|
||||
|
||||
" Ignore comment lines when calculating indent
|
||||
while getline(prevlnum) =~# '^\s*#'
|
||||
let prevlnum = prevnonblank(prevlnum-1)
|
||||
if !prevlnum
|
||||
return previndent
|
||||
endif
|
||||
endwhile
|
||||
|
||||
let prevline = getline(prevlnum)
|
||||
let previndent = indent(prevlnum)
|
||||
|
||||
" Any examples below assume that shiftwidth=2
|
||||
if prevline =~# '\v[{[:]$|[:-]\ [|>][+\-]?%(\s+\#.*|\s*)$'
|
||||
" Mapping key:
|
||||
" nested mapping: ...
|
||||
"
|
||||
" - {
|
||||
" key: [
|
||||
" list value
|
||||
" ]
|
||||
" }
|
||||
"
|
||||
" - |-
|
||||
" Block scalar without indentation indicator
|
||||
return previndent+shiftwidth()
|
||||
elseif prevline =~# '\v[:-]\ [|>]%(\d+[+\-]?|[+\-]?\d+)%(\#.*|\s*)$'
|
||||
" - |+2
|
||||
" block scalar with indentation indicator
|
||||
"#^^ indent+2, not indent+shiftwidth
|
||||
return previndent + str2nr(matchstr(prevline,
|
||||
\'\v([:-]\ [|>])@<=[+\-]?\d+%([+\-]?%(\s+\#.*|\s*)$)@='))
|
||||
elseif prevline =~# '\v\"%([^"\\]|\\.)*\\$'
|
||||
" "Multiline string \
|
||||
" with escaped end"
|
||||
let qidx = match(prevline, '\v\"%([^"\\]|\\.)*\\')
|
||||
return virtcol([prevlnum, qidx+1])
|
||||
elseif line =~# s:liststartregex
|
||||
" List line should have indent equal to previous list line unless it was
|
||||
" caught by one of the previous rules
|
||||
return indent(s:FindPrevLEIndentedLineMatchingRegex(a:lnum,
|
||||
\ s:liststartregex))
|
||||
elseif line =~# s:mapkeyregex
|
||||
" Same for line containing mapping key
|
||||
let prevmapline = s:FindPrevLEIndentedLineMatchingRegex(a:lnum,
|
||||
\ s:mapkeyregex)
|
||||
if getline(prevmapline) =~# '^\s*- '
|
||||
return indent(prevmapline) + 2
|
||||
else
|
||||
return indent(prevmapline)
|
||||
endif
|
||||
elseif prevline =~# '^\s*- '
|
||||
" - List with
|
||||
" multiline scalar
|
||||
return previndent+2
|
||||
elseif prevline =~# s:mapkeyregex . '\v\s*%(%('.s:c_ns_tag_property.
|
||||
\ '\v|'.s:c_ns_anchor_property.
|
||||
\ '\v|'.s:block_scalar_header.
|
||||
\ '\v)%(\s+|\s*%(\#.*)?$))*'
|
||||
" Mapping with: value
|
||||
" that is multiline scalar
|
||||
return previndent+shiftwidth()
|
||||
endif
|
||||
return previndent
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
||||
endif
|
||||
@@ -755,6 +755,21 @@ filetypes:
|
||||
extra_filenames:
|
||||
- idris-response
|
||||
---
|
||||
name: idris2
|
||||
remote: edwinb/idris2-vim
|
||||
ignored_dirs:
|
||||
- doc
|
||||
filetypes:
|
||||
- name: idris2
|
||||
extensions:
|
||||
- idr
|
||||
- ipkg
|
||||
filenames:
|
||||
- idris-response
|
||||
- name: lidris2
|
||||
extensions:
|
||||
- lidr
|
||||
---
|
||||
name: ion
|
||||
remote: vmchale/ion-vim
|
||||
filetypes:
|
||||
@@ -1635,7 +1650,9 @@ filetypes:
|
||||
linguist: XSLT
|
||||
---
|
||||
name: yaml
|
||||
remote: stephpy/vim-yaml
|
||||
# Fixes indentation issue: https://github.com/vim/vim/issues/6417
|
||||
remote: vim/vim@df44a27b53586fccfc6a3aedc89061fdd9a515ff:runtime
|
||||
glob: '**/yaml.vim'
|
||||
filetypes:
|
||||
- name: yaml
|
||||
linguist: YAML
|
||||
|
||||
@@ -77,6 +77,12 @@ def load_data()
|
||||
filetype["extensions"] ||= []
|
||||
filetype["filenames"] ||= []
|
||||
filetype["interpreters"] ||= []
|
||||
|
||||
filetype.keys.each do |key|
|
||||
if key.start_with?("extra_")
|
||||
raise "[#{filetype["name"]}]: #{key} is not allowed if linguist is not used"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -149,7 +155,8 @@ end
|
||||
|
||||
def parse_remote(remote)
|
||||
match = remote.match(/(?<repo>[^@:]+)(?:@(?<branch>[^:]+))?(?::(?<path>.*))?/)
|
||||
[match[:repo], match[:branch] || "master", match[:path]]
|
||||
dir = "tmp/" + match[:repo] + (match[:branch] ? "-#{match[:branch]}" : "")
|
||||
[match[:repo], match[:branch] || "master", match[:path], dir]
|
||||
end
|
||||
|
||||
def copy_file(package, src, dest)
|
||||
@@ -173,8 +180,7 @@ def download(packages)
|
||||
packages.map { |p| p["remote"] or raise "No remote for: " + p["name"] }.uniq.each_slice(20) do |remotes|
|
||||
remotes.map do |remote|
|
||||
Thread.new do
|
||||
repo, branch, path = parse_remote(remote)
|
||||
dir = "tmp/" + repo
|
||||
repo, branch, path, dir = parse_remote(remote)
|
||||
unless File.exist?(dir)
|
||||
FileUtils.mkdir_p(dir)
|
||||
url = "https://codeload.github.com/#{repo}/tar.gz/#{branch}"
|
||||
@@ -315,8 +321,7 @@ def extract(packages)
|
||||
|
||||
output = []
|
||||
packages.map do |package|
|
||||
repo, branch, path = parse_remote(package["remote"])
|
||||
dir = "tmp/" + repo
|
||||
repo, branch, path, dir = parse_remote(package["remote"])
|
||||
dirs = package.fetch("dirs", default_dirs)
|
||||
ignored_dirs = package.fetch("ignored_dirs", [])
|
||||
if ignored_dirs.size > 0
|
||||
@@ -411,14 +416,11 @@ def generate_ftdetect(packages, heuristics)
|
||||
end
|
||||
|
||||
for package in packages
|
||||
name = package.fetch("name")
|
||||
|
||||
output << "if !has_key(s:disabled_packages, '#{name}')\n"
|
||||
|
||||
filetypes = package["filetypes"] or raise "Unknown filetype for: #{package["name"]}"
|
||||
|
||||
package_heuristics = []
|
||||
|
||||
autocommands = ""
|
||||
for filetype in filetypes
|
||||
name = filetype.fetch("name")
|
||||
syntax = filetype["syntax"] ? " | set syntax=#{filetype["syntax"]}" : ""
|
||||
@@ -449,8 +451,8 @@ def generate_ftdetect(packages, heuristics)
|
||||
for extension in extensions.sort
|
||||
outer_filetype = filetype["outer_filetype"]
|
||||
if outer_filetype
|
||||
output << " au BufNewFile *.*.#{extension} execute \"do BufNewFile filetypedetect \" . expand(\"<afile>:r\") | #{outer_filetype}\n"
|
||||
output << " au BufReadPre *.*.#{extension} execute \"do BufRead filetypedetect \" . expand(\"<afile>:r\") | #{outer_filetype}\n"
|
||||
autocommands << " au BufNewFile *.*.#{extension} execute \"do BufNewFile filetypedetect \" . expand(\"<afile>:r\") | #{outer_filetype}\n"
|
||||
autocommands << " au BufReadPre *.*.#{extension} execute \"do BufRead filetypedetect \" . expand(\"<afile>:r\") | #{outer_filetype}\n"
|
||||
end
|
||||
|
||||
heuristic = heuristics.find { |h| h["extensions"].include?(extension) }
|
||||
@@ -461,7 +463,7 @@ def generate_ftdetect(packages, heuristics)
|
||||
# puts "Ambiguous extension without heuristic: #{extension} => #{filetype["name"]}"
|
||||
# end
|
||||
#
|
||||
output << " au BufNewFile,BufRead *.#{extension} #{set_command}\n"
|
||||
autocommands << " au BufNewFile,BufRead *.#{extension} #{set_command}\n"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -469,16 +471,20 @@ def generate_ftdetect(packages, heuristics)
|
||||
if filename[0] == "."
|
||||
filename = "{.,}" + filename[1..]
|
||||
end
|
||||
output << " au BufNewFile,BufRead #{filename} #{set_command}\n"
|
||||
autocommands << " au BufNewFile,BufRead #{filename} #{set_command}\n"
|
||||
end
|
||||
end
|
||||
|
||||
for heuristic in package_heuristics.uniq
|
||||
extensions = heuristic["extensions"].map { |e| "*.#{e}" }
|
||||
output << " au! BufNewFile,BufRead #{extensions.join(",")} call polyglot#Detect#{camelize(heuristic["extensions"].first)}Filetype()\n"
|
||||
autocommands << " au! BufNewFile,BufRead #{extensions.join(",")} call polyglot#Detect#{camelize(heuristic["extensions"].first)}Filetype()\n"
|
||||
end
|
||||
|
||||
output << "endif\n\n"
|
||||
if autocommands != ""
|
||||
output << "if !has_key(s:disabled_packages, '#{package["name"]}')\n"
|
||||
output << autocommands
|
||||
output << "endif\n\n"
|
||||
end
|
||||
end
|
||||
|
||||
ftdetect = File.read('ftdetect/polyglot.vim')
|
||||
|
||||
@@ -9,3 +9,8 @@ vim --clean -N -u <(echo "
|
||||
\"source scripts/test_filetypes.vim
|
||||
qa!
|
||||
")
|
||||
|
||||
if ! expect -c 'set timeout 1' -c 'spawn vim -N --clean -c "set nomore | :helptags ./doc | q"' -c 'expect "ENTER" { exit 1 }' > /dev/null; then
|
||||
echo "Please ensure ':helptags ./doc' works properly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -190,6 +190,11 @@ call TestExtension('yaml.ansible', 'requirements.yaml', '')
|
||||
call TestExtension('ps1xml', 'foobar.ps1xml', '')
|
||||
call TestExtension('terraform', 'terraform.tf', '')
|
||||
|
||||
call TestExtension('idris2', 'foobar.idr', '')
|
||||
call TestExtension('idris', 'foobar.idr', "pkgs : List String\npkgs = [\"NCurses\", \"Readline\"]")
|
||||
let g:filetype_idr = 'fizfuz'
|
||||
call TestExtension('fizfuz', 'fizfuz.idr', '')
|
||||
|
||||
" .m extension
|
||||
call TestExtension('octave', 'matlab.m', '')
|
||||
call TestExtension('objc', 'objc.m', "\n\n #import <Foundation/Foundation.h>")
|
||||
@@ -215,3 +220,28 @@ 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("");')
|
||||
|
||||
" Idris
|
||||
call TestExtension('idris', 'lowercase.idr', '--idris1')
|
||||
call TestExtension('idris', 'uppercase.idr', '--Idris1')
|
||||
call TestExtension('idris', 'start-space-l.idr', '-- idris1')
|
||||
call TestExtension('idris', 'start-space-u.idr', '-- Idris1')
|
||||
call TestExtension('idris', 'two-spaces-l.idr', '-- idris 1')
|
||||
call TestExtension('idris', 'two-spaces-u.idr', '-- Idris 1')
|
||||
"call TestExtension('idris', 'mypkg.ipkg', 'package mypkg\n\npkgs = pruviloj, lightyear')
|
||||
call TestExtension('idris', 'use-type-prov.idr', '%language TypeProviders')
|
||||
call TestExtension('idris', 'use-elab-refl.idr', '%language ElabReflection')
|
||||
call TestExtension('idris', 'access-modifier.idr', '%access export\n\npublic export\nMyTest : Type-> Type\n\nfact : Nat -> Nat')
|
||||
call TestExtension('idris2', 'lowercase.idr', '--idris2')
|
||||
call TestExtension('idris2', 'uppercase.idr', '--Idris2')
|
||||
call TestExtension('idris2', 'start-space-l.idr', '-- idris2')
|
||||
call TestExtension('idris2', 'start-space-u.idr', '-- Idris2')
|
||||
call TestExtension('idris2', 'two-spaces-l.idr', '-- idris 2')
|
||||
call TestExtension('idris2', 'two-spaces-u.idr', '-- Idris 2')
|
||||
call TestExtension('idris2', 'mypkg.ipkg', 'package mypkg\n\ndepends = effects')
|
||||
call TestExtension('idris2', 'use-post-proj.idr', '%language PostfixProjections')
|
||||
|
||||
" Literate Idris
|
||||
call TestExtension('lidris', 'lidris-1.lidr', "Some test plaintext\n\n> --idris1\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext")
|
||||
call TestExtension('lidris2', 'lidris-2.lidr', "Some test plaintext\n\n> --idris2\n> myfact : Nat -> Nat\n> myfact Z = 1\n> myfact (S k) = (S k) * myfact k\n\nMore plaintext")
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ call TestFiletype('html')
|
||||
call TestFiletype('i3config')
|
||||
call TestFiletype('icalendar')
|
||||
call TestFiletype('idris')
|
||||
call TestFiletype('idris2')
|
||||
call TestFiletype('lidris2')
|
||||
call TestFiletype('ion')
|
||||
call TestFiletype('javascript')
|
||||
call TestFiletype('flow')
|
||||
|
||||
85
syntax/idris2.vim
Normal file
85
syntax/idris2.vim
Normal file
@@ -0,0 +1,85 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1
|
||||
|
||||
" syntax highlighting for Idris 2 (idris-lang.org)
|
||||
"
|
||||
" Heavily modified version of the haskell syntax
|
||||
" highlighter to support Idris 2.
|
||||
"
|
||||
" author: raichoo (raichoo@googlemail.com)
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn match idrisTypeDecl "[a-zA-Z][a-zA-z0-9_']*\s\+:\s\+"
|
||||
\ contains=idrisIdentifier,idrisOperators
|
||||
syn region idrisParens matchgroup=idrisDelimiter start="(" end=")" contains=TOP,idrisTypeDecl
|
||||
syn region idrisBrackets matchgroup=idrisDelimiter start="\[" end="]" contains=TOP,idrisTypeDecl
|
||||
syn region idrisBlock matchgroup=idrisDelimiter start="{" end="}" contains=TOP,idrisTypeDecl
|
||||
syn keyword idrisModule module namespace
|
||||
syn keyword idrisImport import
|
||||
syn keyword idrisStructure data record interface implementation
|
||||
syn keyword idrisWhere where
|
||||
syn keyword idrisVisibility public abstract private export
|
||||
syn keyword idrisBlock parameters mutual using
|
||||
syn keyword idrisTotality total partial covering
|
||||
syn keyword idrisAnnotation auto impossible default constructor
|
||||
syn keyword idrisStatement do case of rewrite with
|
||||
syn keyword idrisLet let in
|
||||
syn keyword idrisForall forall
|
||||
syn keyword idrisDataOpt noHints uniqueSearch search external noNewtype containedin=idrisBrackets
|
||||
syn match idrisSyntax "\(pattern \+\|term \+\)\?syntax"
|
||||
syn keyword idrisConditional if then else
|
||||
syn match idrisNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
|
||||
syn match idrisFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
|
||||
syn match idrisDelimiter "[,;]"
|
||||
syn keyword idrisInfix prefix infix infixl infixr
|
||||
syn match idrisOperators "\([-!#$%&\*\+./<=>\?@\\^|~:]\|\<_\>\)"
|
||||
syn match idrisType "\<[A-Z][a-zA-Z0-9_']*\>"
|
||||
syn keyword idrisTodo TODO FIXME XXX HACK contained
|
||||
syn match idrisLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=idrisTodo,@Spell
|
||||
syn match idrisDocComment "|||\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=idrisTodo,@Spell
|
||||
syn match idrisMetaVar "?[a-z][A-Za-z0-9_']*"
|
||||
syn match idrisPragma "%\(hide\|logging\|auto_lazy\|unbound_implicits\|undotted_record_projections\|amibguity_depth\|pair\|rewrite\|integerLit\|stringLit\|charLit\|name\|start\|allow_overloads\|language\|default\|transform\|hint\|global_hint\|defaulthint\|inline\|extern\|macro\|spec\|foreign\|runElab\|tcinline\)"
|
||||
syn match idrisChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
|
||||
syn match idrisBacktick "`[A-Za-z][A-Za-z0-9_']*`"
|
||||
syn region idrisString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
|
||||
syn region idrisBlockComment start="{-" end="-}" contains=idrisBlockComment,idrisTodo,@Spell
|
||||
syn match idrisIdentifier "[a-zA-Z][a-zA-z0-9_']*" contained
|
||||
|
||||
highlight def link idrisDeprecated Error
|
||||
highlight def link idrisIdentifier Identifier
|
||||
highlight def link idrisImport Structure
|
||||
highlight def link idrisModule Structure
|
||||
highlight def link idrisStructure Structure
|
||||
highlight def link idrisStatement Statement
|
||||
highlight def link idrisForall Structure
|
||||
highlight def link idrisDataOpt Statement
|
||||
highlight def link idrisDSL Statement
|
||||
highlight def link idrisBlock Statement
|
||||
highlight def link idrisAnnotation Statement
|
||||
highlight def link idrisWhere Structure
|
||||
highlight def link idrisLet Structure
|
||||
highlight def link idrisTotality Statement
|
||||
highlight def link idrisSyntax Statement
|
||||
highlight def link idrisVisibility Statement
|
||||
highlight def link idrisConditional Conditional
|
||||
highlight def link idrisPragma Statement
|
||||
highlight def link idrisNumber Number
|
||||
highlight def link idrisFloat Float
|
||||
highlight def link idrisDelimiter Delimiter
|
||||
highlight def link idrisInfix PreProc
|
||||
highlight def link idrisOperators Operator
|
||||
highlight def link idrisType Include
|
||||
highlight def link idrisDocComment Comment
|
||||
highlight def link idrisLineComment Comment
|
||||
highlight def link idrisBlockComment Comment
|
||||
highlight def link idrisTodo Todo
|
||||
highlight def link idrisMetaVar Macro
|
||||
highlight def link idrisString String
|
||||
highlight def link idrisChar String
|
||||
highlight def link idrisBacktick Operator
|
||||
|
||||
let b:current_syntax = "idris2"
|
||||
|
||||
endif
|
||||
26
syntax/lidris2.vim
Normal file
26
syntax/lidris2.vim
Normal file
@@ -0,0 +1,26 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'idris2') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Literate Idris 2
|
||||
" Maintainer: Idris Hackers (https://github.com/edwinb/idris2-vim)
|
||||
" Last Change: 2020 May 19
|
||||
" Version: 0.1
|
||||
"
|
||||
" This is just a minimal adaption of the Literate Haskell syntax file.
|
||||
|
||||
|
||||
" Read Idris highlighting.
|
||||
if version < 600
|
||||
syntax include @idrisTop <sfile>:p:h/idris2.vim
|
||||
else
|
||||
syntax include @idrisTop syntax/idris2.vim
|
||||
endif
|
||||
|
||||
" Recognize blocks of Bird tracks, highlight as Idris.
|
||||
syntax region lidrisBirdTrackBlock start="^>" end="\%(^[^>]\)\@=" contains=@idrisTop,lidrisBirdTrack
|
||||
syntax match lidrisBirdTrack "^>" contained
|
||||
hi def link lidrisBirdTrack Comment
|
||||
|
||||
let b:current_syntax = "lidris2"
|
||||
|
||||
endif
|
||||
@@ -67,10 +67,11 @@ syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifie
|
||||
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty
|
||||
|
||||
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||
syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||
|
||||
syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP
|
||||
syn match rustMacroVariable "$\w\+"
|
||||
syn match rustRawIdent "\<r#\h\w*" contains=NONE
|
||||
|
||||
" Reserved (but not yet used) keywords {{{2
|
||||
syn keyword rustReservedKeyword become do priv typeof unsized abstract virtual final override
|
||||
|
||||
247
syntax/yaml.vim
Normal file
247
syntax/yaml.vim
Normal file
@@ -0,0 +1,247 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'yaml') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: YAML (YAML Ain't Markup Language) 1.2
|
||||
" Maintainer: Nikolai Pavlov <zyx.vim@gmail.com>
|
||||
" First author: Nikolai Weibull <now@bitwi.se>
|
||||
" Latest Revision: 2015-03-28
|
||||
" removed duplicate yamlKeyValueDelimiter (pull #4799)
|
||||
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Choose the schema to use
|
||||
" TODO: Validate schema
|
||||
if !exists('b:yaml_schema')
|
||||
if exists('g:yaml_schema')
|
||||
let b:yaml_schema = g:yaml_schema
|
||||
else
|
||||
let b:yaml_schema = 'core'
|
||||
endif
|
||||
endif
|
||||
|
||||
let s:ns_char = '\%([\n\r\uFEFF \t]\@!\p\)'
|
||||
let s:ns_word_char = '[[:alnum:]_\-]'
|
||||
let s:ns_uri_char = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$,.!~*''()[\]]\)'
|
||||
let s:ns_tag_char = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$.~*''()]\)'
|
||||
let s:c_ns_anchor_char = '\%([\n\r\uFEFF \t,[\]{}]\@!\p\)'
|
||||
let s:c_indicator = '[\-?:,[\]{}#&*!|>''"%@`]'
|
||||
let s:c_flow_indicator = '[,[\]{}]'
|
||||
|
||||
let s:ns_char_without_c_indicator = substitute(s:ns_char, '\v\C[\zs', '\=s:c_indicator[1:-2]', '')
|
||||
|
||||
let s:_collection = '[^\@!\(\%(\\\.\|\[^\\\]]\)\+\)]'
|
||||
let s:_neg_collection = '[^\(\%(\\\.\|\[^\\\]]\)\+\)]'
|
||||
function s:SimplifyToAssumeAllPrintable(p)
|
||||
return substitute(a:p, '\V\C\\%('.s:_collection.'\\@!\\p\\)', '[^\1]', '')
|
||||
endfunction
|
||||
let s:ns_char = s:SimplifyToAssumeAllPrintable(s:ns_char)
|
||||
let s:ns_char_without_c_indicator = s:SimplifyToAssumeAllPrintable(s:ns_char_without_c_indicator)
|
||||
let s:c_ns_anchor_char = s:SimplifyToAssumeAllPrintable(s:c_ns_anchor_char)
|
||||
|
||||
function s:SimplifyAdjacentCollections(p)
|
||||
return substitute(a:p, '\V\C'.s:_collection.'\\|'.s:_collection, '[\1\2]', 'g')
|
||||
endfunction
|
||||
let s:ns_uri_char = s:SimplifyAdjacentCollections(s:ns_uri_char)
|
||||
let s:ns_tag_char = s:SimplifyAdjacentCollections(s:ns_tag_char)
|
||||
|
||||
let s:c_verbatim_tag = '!<'.s:ns_uri_char.'\+>'
|
||||
let s:c_named_tag_handle = '!'.s:ns_word_char.'\+!'
|
||||
let s:c_secondary_tag_handle = '!!'
|
||||
let s:c_primary_tag_handle = '!'
|
||||
let s:c_tag_handle = '\%('.s:c_named_tag_handle.
|
||||
\ '\|'.s:c_secondary_tag_handle.
|
||||
\ '\|'.s:c_primary_tag_handle.'\)'
|
||||
let s:c_ns_shorthand_tag = s:c_tag_handle . s:ns_tag_char.'\+'
|
||||
let s:c_non_specific_tag = '!'
|
||||
let s:c_ns_tag_property = s:c_verbatim_tag.
|
||||
\ '\|'.s:c_ns_shorthand_tag.
|
||||
\ '\|'.s:c_non_specific_tag
|
||||
|
||||
let s:c_ns_anchor_name = s:c_ns_anchor_char.'\+'
|
||||
let s:c_ns_anchor_property = '&'.s:c_ns_anchor_name
|
||||
let s:c_ns_alias_node = '\*'.s:c_ns_anchor_name
|
||||
|
||||
let s:ns_directive_name = s:ns_char.'\+'
|
||||
|
||||
let s:ns_local_tag_prefix = '!'.s:ns_uri_char.'*'
|
||||
let s:ns_global_tag_prefix = s:ns_tag_char.s:ns_uri_char.'*'
|
||||
let s:ns_tag_prefix = s:ns_local_tag_prefix.
|
||||
\ '\|'.s:ns_global_tag_prefix
|
||||
|
||||
let s:ns_plain_safe_out = s:ns_char
|
||||
let s:ns_plain_safe_in = '\%('.s:c_flow_indicator.'\@!'.s:ns_char.'\)'
|
||||
|
||||
let s:ns_plain_safe_in = substitute(s:ns_plain_safe_in, '\V\C\\%('.s:_collection.'\\@!'.s:_neg_collection.'\\)', '[^\1\2]', '')
|
||||
let s:ns_plain_safe_in_without_colhash = substitute(s:ns_plain_safe_in, '\V\C'.s:_neg_collection, '[^\1:#]', '')
|
||||
let s:ns_plain_safe_out_without_colhash = substitute(s:ns_plain_safe_out, '\V\C'.s:_neg_collection, '[^\1:#]', '')
|
||||
|
||||
let s:ns_plain_first_in = '\%('.s:ns_char_without_c_indicator.'\|[?:\-]\%('.s:ns_plain_safe_in.'\)\@=\)'
|
||||
let s:ns_plain_first_out = '\%('.s:ns_char_without_c_indicator.'\|[?:\-]\%('.s:ns_plain_safe_out.'\)\@=\)'
|
||||
|
||||
let s:ns_plain_char_in = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_in.'\|'.s:ns_plain_safe_in_without_colhash.'\)'
|
||||
let s:ns_plain_char_out = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_out.'\|'.s:ns_plain_safe_out_without_colhash.'\)'
|
||||
|
||||
let s:ns_plain_out = s:ns_plain_first_out . s:ns_plain_char_out.'*'
|
||||
let s:ns_plain_in = s:ns_plain_first_in . s:ns_plain_char_in.'*'
|
||||
|
||||
|
||||
syn keyword yamlTodo contained TODO FIXME XXX NOTE
|
||||
|
||||
syn region yamlComment display oneline start='\%\(^\|\s\)#' end='$'
|
||||
\ contains=yamlTodo
|
||||
|
||||
execute 'syn region yamlDirective oneline start='.string('^\ze%'.s:ns_directive_name.'\s\+').' '.
|
||||
\ 'end="$" '.
|
||||
\ 'contains=yamlTAGDirective,'.
|
||||
\ 'yamlYAMLDirective,'.
|
||||
\ 'yamlReservedDirective '.
|
||||
\ 'keepend'
|
||||
|
||||
syn match yamlTAGDirective '%TAG\s\+' contained nextgroup=yamlTagHandle
|
||||
execute 'syn match yamlTagHandle contained nextgroup=yamlTagPrefix '.string(s:c_tag_handle.'\s\+')
|
||||
execute 'syn match yamlTagPrefix contained nextgroup=yamlComment ' . string(s:ns_tag_prefix)
|
||||
|
||||
syn match yamlYAMLDirective '%YAML\s\+' contained nextgroup=yamlYAMLVersion
|
||||
syn match yamlYAMLVersion '\d\+\.\d\+' contained nextgroup=yamlComment
|
||||
|
||||
execute 'syn match yamlReservedDirective contained nextgroup=yamlComment '.
|
||||
\string('%\%(\%(TAG\|YAML\)\s\)\@!'.s:ns_directive_name)
|
||||
|
||||
syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start='"' skip='\\"' end='"'
|
||||
\ contains=yamlEscape
|
||||
\ nextgroup=yamlKeyValueDelimiter
|
||||
syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start="'" skip="''" end="'"
|
||||
\ contains=yamlSingleEscape
|
||||
\ nextgroup=yamlKeyValueDelimiter
|
||||
syn match yamlEscape contained '\\\%([\\"abefnrtv\^0_ NLP\n]\|x\x\x\|u\x\{4}\|U\x\{8}\)'
|
||||
syn match yamlSingleEscape contained "''"
|
||||
|
||||
syn match yamlBlockScalarHeader contained '\s\+\zs[|>]\%([+-]\=[1-9]\|[1-9]\=[+-]\)\='
|
||||
|
||||
syn cluster yamlConstant contains=yamlBool,yamlNull
|
||||
|
||||
syn cluster yamlFlow contains=yamlFlowString,yamlFlowMapping,yamlFlowCollection
|
||||
syn cluster yamlFlow add=yamlFlowMappingKey,yamlFlowMappingMerge
|
||||
syn cluster yamlFlow add=@yamlConstant,yamlPlainScalar,yamlFloat
|
||||
syn cluster yamlFlow add=yamlTimestamp,yamlInteger,yamlMappingKeyStart
|
||||
syn cluster yamlFlow add=yamlComment
|
||||
syn region yamlFlowMapping matchgroup=yamlFlowIndicator start='{' end='}' contains=@yamlFlow
|
||||
syn region yamlFlowCollection matchgroup=yamlFlowIndicator start='\[' end='\]' contains=@yamlFlow
|
||||
|
||||
execute 'syn match yamlPlainScalar /'.s:ns_plain_out.'/'
|
||||
execute 'syn match yamlPlainScalar contained /'.s:ns_plain_in.'/'
|
||||
|
||||
syn match yamlMappingKeyStart '?\ze\s'
|
||||
syn match yamlMappingKeyStart '?' contained
|
||||
|
||||
execute 'syn match yamlFlowMappingKey /\%#=1'.s:ns_plain_in.'\%(\s\+'.s:ns_plain_in.'\)*\ze\s*:/ contained '.
|
||||
\'nextgroup=yamlKeyValueDelimiter'
|
||||
syn match yamlFlowMappingMerge /<<\ze\s*:/ contained nextgroup=yamlKeyValueDelimiter
|
||||
|
||||
syn match yamlBlockCollectionItemStart '^\s*\zs-\%(\s\+-\)*\s' nextgroup=yamlBlockMappingKey,yamlBlockMappingMerge
|
||||
" Use the old regexp engine, the NFA engine doesn't like all the \@ items.
|
||||
execute 'syn match yamlBlockMappingKey /\%#=1^\s*\zs'.s:ns_plain_out.'\%(\s\+'.s:ns_plain_out.'\)*\ze\s*:\%(\s\|$\)/ '.
|
||||
\'nextgroup=yamlKeyValueDelimiter'
|
||||
execute 'syn match yamlBlockMappingKey /\%#=1\s*\zs'.s:ns_plain_out.'\%(\s\+'.s:ns_plain_out.'\)*\ze\s*:\%(\s\|$\)/ contained '.
|
||||
\'nextgroup=yamlKeyValueDelimiter'
|
||||
syn match yamlBlockMappingMerge /^\s*\zs<<\ze:\%(\s\|$\)/ nextgroup=yamlKeyValueDelimiter
|
||||
syn match yamlBlockMappingMerge /<<\ze\s*:\%(\s\|$\)/ nextgroup=yamlKeyValueDelimiter contained
|
||||
|
||||
syn match yamlKeyValueDelimiter /\s*:/ contained
|
||||
|
||||
syn cluster yamlScalarWithSpecials contains=yamlPlainScalar,yamlBlockMappingKey,yamlFlowMappingKey
|
||||
|
||||
let s:_bounder = s:SimplifyToAssumeAllPrintable('\%([[\]{}, \t]\@!\p\)')
|
||||
if b:yaml_schema is# 'json'
|
||||
syn keyword yamlNull null contained containedin=@yamlScalarWithSpecials
|
||||
syn keyword yamlBool true false
|
||||
exe 'syn match yamlInteger /'.s:_bounder.'\@1<!\%(0\|-\=[1-9][0-9]*\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
exe 'syn match yamlFloat /'.s:_bounder.'\@1<!\%(-\=[1-9][0-9]*\%(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\|0\|-\=\.inf\|\.nan\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
elseif b:yaml_schema is# 'core'
|
||||
syn keyword yamlNull null Null NULL contained containedin=@yamlScalarWithSpecials
|
||||
syn keyword yamlBool true True TRUE false False FALSE contained containedin=@yamlScalarWithSpecials
|
||||
exe 'syn match yamlNull /'.s:_bounder.'\@1<!\~'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
exe 'syn match yamlInteger /'.s:_bounder.'\@1<!\%([+-]\=\%(0\%(b[0-1_]\+\|[0-7_]\+\|x[0-9a-fA-F_]\+\)\=\|\%([1-9][0-9_]*\%(:[0-5]\=\d\)\+\)\)\|[1-9][0-9_]*\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
exe 'syn match yamlFloat /'.s:_bounder.'\@1<!\%([+-]\=\%(\%(\d[0-9_]*\)\.[0-9_]*\%([eE][+-]\=\d\+\)\=\|\.[0-9_]\+\%([eE][-+]\=[0-9]\+\)\=\|\d[0-9_]*\%(:[0-5]\=\d\)\+\.[0-9_]*\|\.\%(inf\|Inf\|INF\)\)\|\%(\.\%(nan\|NaN\|NAN\)\)\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
elseif b:yaml_schema is# 'pyyaml'
|
||||
syn keyword yamlNull null Null NULL contained containedin=@yamlScalarWithSpecials
|
||||
syn keyword yamlBool true True TRUE false False FALSE yes Yes YES no No NO on On ON off Off OFF contained containedin=@yamlScalarWithSpecials
|
||||
exe 'syn match yamlNull /'.s:_bounder.'\@1<!\~'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
exe 'syn match yamlFloat /'.s:_bounder.'\@1<!\%(\v[-+]?%(\d[0-9_]*)\.[0-9_]*%([eE][-+]\d+)?|\.[0-9_]+%([eE][-+]\d+)?|[-+]?\d[0-9_]*%(\:[0-5]?\d)+\.[0-9_]*|[-+]?\.%(inf|Inf|INF)|\.%(nan|NaN|NAN)\m\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
exe 'syn match yamlInteger /'.s:_bounder.'\@1<!\%(\v[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?%(0|[1-9][0-9_]*)|[-+]?0x[0-9a-fA-F_]+|[-+]?[1-9][0-9_]*%(:[0-5]?\d)+\m\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
exe 'syn match yamlTimestamp /'.s:_bounder.'\@1<!\%(\v\d\d\d\d\-\d\d\-\d\d|\d\d\d\d \-\d\d? \-\d\d?%([Tt]|[ \t]+)\d\d?\:\d\d \:\d\d %(\.\d*)?%([ \t]*%(Z|[-+]\d\d?%(\:\d\d)?))?\m\)'.s:_bounder.'\@!/ contained containedin=@yamlScalarWithSpecials'
|
||||
elseif b:yaml_schema is# 'failsafe'
|
||||
" Nothing
|
||||
endif
|
||||
unlet s:_bounder
|
||||
|
||||
|
||||
execute 'syn match yamlNodeTag '.string(s:c_ns_tag_property)
|
||||
execute 'syn match yamlAnchor '.string(s:c_ns_anchor_property)
|
||||
execute 'syn match yamlAlias '.string(s:c_ns_alias_node)
|
||||
|
||||
syn match yamlDocumentStart '^---\ze\%(\s\|$\)'
|
||||
syn match yamlDocumentEnd '^\.\.\.\ze\%(\s\|$\)'
|
||||
|
||||
hi def link yamlTodo Todo
|
||||
hi def link yamlComment Comment
|
||||
|
||||
hi def link yamlDocumentStart PreProc
|
||||
hi def link yamlDocumentEnd PreProc
|
||||
|
||||
hi def link yamlDirectiveName Keyword
|
||||
|
||||
hi def link yamlTAGDirective yamlDirectiveName
|
||||
hi def link yamlTagHandle String
|
||||
hi def link yamlTagPrefix String
|
||||
|
||||
hi def link yamlYAMLDirective yamlDirectiveName
|
||||
hi def link yamlReservedDirective Error
|
||||
hi def link yamlYAMLVersion Number
|
||||
|
||||
hi def link yamlString String
|
||||
hi def link yamlFlowString yamlString
|
||||
hi def link yamlFlowStringDelimiter yamlString
|
||||
hi def link yamlEscape SpecialChar
|
||||
hi def link yamlSingleEscape SpecialChar
|
||||
|
||||
hi def link yamlBlockCollectionItemStart Label
|
||||
hi def link yamlBlockMappingKey Identifier
|
||||
hi def link yamlBlockMappingMerge Special
|
||||
|
||||
hi def link yamlFlowMappingKey Identifier
|
||||
hi def link yamlFlowMappingMerge Special
|
||||
|
||||
hi def link yamlMappingKeyStart Special
|
||||
hi def link yamlFlowIndicator Special
|
||||
hi def link yamlKeyValueDelimiter Special
|
||||
|
||||
hi def link yamlConstant Constant
|
||||
|
||||
hi def link yamlNull yamlConstant
|
||||
hi def link yamlBool yamlConstant
|
||||
|
||||
hi def link yamlAnchor Type
|
||||
hi def link yamlAlias Type
|
||||
hi def link yamlNodeTag Type
|
||||
|
||||
hi def link yamlInteger Number
|
||||
hi def link yamlFloat Float
|
||||
hi def link yamlTimestamp Number
|
||||
|
||||
let b:current_syntax = "yaml"
|
||||
|
||||
unlet s:ns_word_char s:ns_uri_char s:c_verbatim_tag s:c_named_tag_handle s:c_secondary_tag_handle s:c_primary_tag_handle s:c_tag_handle s:ns_tag_char s:c_ns_shorthand_tag s:c_non_specific_tag s:c_ns_tag_property s:c_ns_anchor_char s:c_ns_anchor_name s:c_ns_anchor_property s:c_ns_alias_node s:ns_char s:ns_directive_name s:ns_local_tag_prefix s:ns_global_tag_prefix s:ns_tag_prefix s:c_indicator s:ns_plain_safe_out s:c_flow_indicator s:ns_plain_safe_in s:ns_plain_first_in s:ns_plain_first_out s:ns_plain_char_in s:ns_plain_char_out s:ns_plain_out s:ns_plain_in s:ns_char_without_c_indicator s:ns_plain_safe_in_without_colhash s:ns_plain_safe_out_without_colhash
|
||||
unlet s:_collection s:_neg_collection
|
||||
delfunction s:SimplifyAdjacentCollections
|
||||
delfunction s:SimplifyToAssumeAllPrintable
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
endif
|
||||
Reference in New Issue
Block a user