Compare commits

...

4 Commits

Author SHA1 Message Date
Adam Stankiewicz
cea0d08a06 Replace markdown plugin for faster one 2019-12-12 16:43:09 +01:00
Adam Stankiewicz
43085dc02f Update 2019-12-12 16:33:01 +01:00
Adam Stankiewicz
4d8423c962 Add v language, closes #437 2019-12-07 17:39:31 +01:00
Adam Stankiewicz
e204a7223b Add ftplugin to markdown, fixes #447 2019-12-07 13:01:03 +01:00
19 changed files with 2113 additions and 291 deletions

View File

@@ -10,7 +10,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-->146<!--/Package Count--> packages it consists of.
- It **installs and updates 120+ times faster** than the <!--Package Count-->147<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -119,7 +119,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [log](https://github.com/MTDL9/vim-log-highlighting) (syntax)
- [lua](https://github.com/tbastos/vim-lua) (syntax, indent)
- [mako](https://github.com/sophacles/vim-bundle-mako) (syntax, indent, ftplugin)
- [markdown](https://github.com/plasticboy/vim-markdown) (syntax, indent)
- [markdown](https://github.com/gabrielelana/vim-markdown) (syntax, autoload, ftplugin)
- [mathematica](https://github.com/voldikss/vim-mma) (syntax, ftplugin)
- [mdx](https://github.com/jxnblk/vim-mdx-js) (syntax)
- [meson](https://github.com/mesonbuild/meson) (syntax, indent, ftplugin)
@@ -178,6 +178,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [tptp](https://github.com/c-cube/vim-tptp) (syntax)
- [twig](https://github.com/lumiliet/vim-twig) (syntax, indent, ftplugin)
- [typescript](https://github.com/HerringtonDarkholme/yats.vim) (syntax, indent, compiler, ftplugin)
- [v](https://github.com/ollykel/v-vim) (syntax, indent, ftplugin)
- [vala](https://github.com/arrufat/vala.vim) (syntax, indent, ftplugin)
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)
- [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax)

View File

@@ -20,7 +20,7 @@ syntax region jsxTag
\ matchgroup=NONE
\ end=+\%(/\_s*>\)\@=+
\ contained
\ contains=jsxOpenTag,jsxAttrib,jsxEscapeJs,jsxSpreadOperator,jsComment,@javascriptComments,javaScriptLineComment,javaScriptComment,typescriptLineComment,typescriptComment
\ contains=jsxOpenTag,jsxAttrib,jsxExpressionBlock,jsxSpreadOperator,jsComment,@javascriptComments,javaScriptLineComment,javaScriptComment,typescriptLineComment,typescriptComment
\ keepend
\ extend
\ skipwhite
@@ -39,7 +39,7 @@ syntax region jsxElement
\ start=+<\_s*\%(>\|\${\|\z(\<[-:._$A-Za-z0-9]\+\>\)\)+
\ end=+/\_s*>+
\ end=+<\_s*/\_s*\z1\_s*>+
\ contains=jsxElement,jsxTag,jsxEscapeJs,jsxComment,jsxCloseTag,@Spell
\ contains=jsxElement,jsxTag,jsxExpressionBlock,jsxComment,jsxCloseTag,@Spell
\ keepend
\ extend
\ contained
@@ -66,7 +66,7 @@ exe 'syntax region jsxOpenTag
" <tag key={this.props.key}>
" ~~~~~~~~~~~~~~~~
syntax region jsxEscapeJs
syntax region jsxExpressionBlock
\ matchgroup=jsxBraces
\ start=+{+
\ end=+}+
@@ -84,7 +84,7 @@ syntax match jsxNamespace +:+ contained
" <tag id="sample">
" ~
syntax match jsxEqual +=+ contained skipwhite skipempty nextgroup=jsxString,jsxEscapeJs,jsxRegion
syntax match jsxEqual +=+ contained skipwhite skipempty nextgroup=jsxString,jsxExpressionBlock,jsxRegion
" <tag />
" ~~
@@ -154,10 +154,10 @@ if s:enable_tagged_jsx
\ end=+`+
\ extend
\ contained
\ contains=jsxElement,jsxEscapeJs
\ contains=jsxElement,jsxExpressionBlock
\ transparent
syntax region jsxEscapeJs
syntax region jsxExpressionBlock
\ matchgroup=jsxBraces
\ start=+\${+
\ end=+}+
@@ -171,14 +171,14 @@ if s:enable_tagged_jsx
\ matchgroup=NONE
\ end=+}\@1<=+
\ contained
\ contains=jsxEscapeJs
\ contains=jsxExpressionBlock
\ skipwhite
\ skipempty
\ nextgroup=jsxAttrib,jsxSpreadOperator
syntax keyword jsxAttribKeyword class contained
syntax match jsxSpreadOperator +\.\.\.+ contained nextgroup=jsxEscapeJs skipwhite
syntax match jsxSpreadOperator +\.\.\.+ contained nextgroup=jsxExpressionBlock skipwhite
syntax match jsxCloseTag +<//>+ contained

View File

@@ -122,7 +122,7 @@ fu! csv#Init(start, end, ...) "{{{3
" Enable vartabs for tab delimited files
if b:delimiter=="\t" && has("vartabs")&& !exists("b:csv_fixed_width_cols")
if get(b:, 'col_width', []) ==# []
call csv#CalculateColumnWidth('')
call csv#CalculateColumnWidth(line('$'))
endif
let &l:vts=join(b:col_width, ',')
let g:csv_no_conceal=1
@@ -574,7 +574,7 @@ fu! csv#MaxColumns(...) "{{{3
return len(b:csv_fixed_width_cols)
endif
endfu
fu! csv#ColWidth(colnr, ...) "{{{3
fu! csv#ColWidth(colnr, row, silent) "{{{3
" if a:1 is given, specifies the row, for which to calculate the width
"
" Return the width of a column
@@ -586,14 +586,13 @@ fu! csv#ColWidth(colnr, ...) "{{{3
if !exists("b:csv_fixed_width_cols")
if !exists("b:csv_list")
" only check first 10000 lines, to be faster
let last = line('$')
if exists("a:1") && !empty(a:1)
let last = a:1
endif
let last = a:row
if !get(b:, 'csv_arrange_use_all_rows', 0)
if last > 10000
let last = 10000
call csv#Warn('File too large, only checking the first 10000 rows for the width')
if !a:silent
call csv#Warn('File too large, only checking the first 10000 rows for the width')
endif
endif
endif
let b:csv_list=getline(skipfirst+1,last)
@@ -750,7 +749,7 @@ fu! csv#UnArrangeCol(match) "{{{3
" Strip leading white space, also trims empty recordcsv#
return substitute(a:match, '\%(^ \+\)\|\%( \+\ze'.b:delimiter. '\?$\)', '', 'g')
endfu
fu! csv#CalculateColumnWidth(row) "{{{3
fu! csv#CalculateColumnWidth(row, silent) "{{{3
" Internal function, not called from external,
" does not work with fixed width columns
" row for the row for which to calculate the width
@@ -763,7 +762,7 @@ fu! csv#CalculateColumnWidth(row) "{{{3
endif
let s:max_cols=csv#MaxColumns(line('.'))
for i in range(1,s:max_cols)
call add(b:col_width, csv#ColWidth(i, a:row))
call add(b:col_width, csv#ColWidth(i, a:row, a:silent))
endfor
catch /csv:no_col/
call csv#Warn("Error: getting Column numbers, aborting!")
@@ -1053,7 +1052,7 @@ fu! csv#MoveCol(forward, line, ...) "{{{3
let maxcol=csv#MaxColumns(line('.'))
let cpos=getpos('.')[2]
if !exists("b:csv_fixed_width_cols")
let curwidth=CSVWidth()
let curwidth=CSVWidth(1)
call search(b:col, 'bc', line('.'))
endif
let spos=getpos('.')[2]
@@ -1146,7 +1145,7 @@ fu! csv#MoveCol(forward, line, ...) "{{{3
" leave the column (if the next column is shorter)
if !exists("b:csv_fixed_width_cols")
let a = getpos('.')
if CSVWidth() == curwidth
if CSVWidth(1) == curwidth
let a[2]+= cpos-spos
endif
else
@@ -1159,7 +1158,7 @@ fu! csv#MoveCol(forward, line, ...) "{{{3
" Move to the correct screen column
if !exists("b:csv_fixed_width_cols")
let a = getpos('.')
if CSVWidth() == curwidth
if CSVWidth(1) == curwidth
let a[2]+= cpos-spos
endif
else
@@ -1835,7 +1834,7 @@ fu! csv#ProcessFieldValue(field) "{{{3
if a == b:delimiter
try
let a=repeat(' ', csv#ColWidth(col))
let a=repeat(' ', csv#ColWidth(col, line('$'), 1))
catch
" no-op
endtry
@@ -2134,7 +2133,7 @@ fu! csv#NewRecord(line1, line2, count) "{{{3
if !exists("b:col_width")
" Best guess width
if exists("b:csv_fixed_width_cols")
let record .= printf("%*s", csv#ColWidth(item),
let record .= printf("%*s", csv#ColWidth(item, line('$'), 1),
\ b:delimiter)
else
let record .= printf("%20s", b:delimiter)
@@ -3145,7 +3144,9 @@ fu! CSVCount(col, fmt, first, last, ...) "{{{3
unlet! s:additional['distinct']
return (empty(result) ? 0 : result)
endfu
fu! CSVWidth() "{{{3
fu! CSVWidth(...) "{{{3
" do not output any warning
let silent = get(a:000, 0, 1)
" does not work with fixed width columns
if exists("b:csv_fixed_width_cols")
let c = getline(1,'$')
@@ -3164,7 +3165,7 @@ fu! CSVWidth() "{{{3
" Add width for last column
call add(width, max-y+1)
else
call csv#CalculateColumnWidth('')
call csv#CalculateColumnWidth(line('$'), silent)
let width=map(copy(b:col_width), 'v:val-1')
endif
return width

View File

@@ -353,7 +353,7 @@ function! go#config#FmtCommand() abort
endfunction
function! go#config#FmtOptions() abort
return get(g:, "go_fmt_options", {})
return get(b:, "go_fmt_options", get(g:, "go_fmt_options", {}))
endfunction
function! go#config#FmtFailSilently() abort
@@ -368,9 +368,9 @@ function! go#config#PlayOpenBrowser() abort
return get(g:, "go_play_open_browser", 1)
endfunction
function! go#config#GorenameCommand() abort
function! go#config#RenameCommand() abort
" delegate to go#config#GorenameBin for backwards compatability.
return get(g:, "go_gorename_command", go#config#GorenameBin())
return get(g:, "go_rename_command", go#config#GorenameBin())
endfunction
function! go#config#GorenameBin() abort

View File

@@ -70,9 +70,9 @@ function s:is_jsx_element(syntax)
return a:syntax =~? 'jsxElement'
endfunction
" Whether the specified syntax group is the jsxEscapeJs
function s:is_jsx_escape(syntax)
return a:syntax =~? 'jsxEscapeJs'
" Whether the specified syntax group is the jsxExpressionBlock
function s:is_jsx_expression(syntax)
return a:syntax =~? 'jsxExpressionBlock'
endfunction
" Whether the specified syntax group is the jsxBraces
@@ -191,7 +191,7 @@ endfunction
" - jsxRegion
" - jsxTaggedRegion
" - jsxElement
" - jsxEscapeJs
" - jsxExpressionBlock
" - Other
function s:syntax_context(lnum)
let start_col = s:start_col(a:lnum)
@@ -201,9 +201,9 @@ function s:syntax_context(lnum)
let i = 0
for syntax_name in reversed
" If the current line is jsxEscapeJs and not starts with jsxBraces
if s:is_jsx_escape(syntax_name)
return 'jsxEscapeJs'
" If the current line is jsxExpressionBlock and not starts with jsxBraces
if s:is_jsx_expression(syntax_name)
return 'jsxExpressionBlock'
endif
if s:is_jsx_region(syntax_name)
@@ -287,7 +287,7 @@ function! jsx_pretty#indent#get(js_indent)
endif
return s:jsx_indent_element(v:lnum)
elseif syntax_context == 'jsxEscapeJs'
elseif syntax_context == 'jsxExpressionBlock'
let prev_lnum = s:prev_lnum(v:lnum)
let prev_line = s:trim(getline(prev_lnum))

532
autoload/markdown.vim Normal file
View File

@@ -0,0 +1,532 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'markdown') == -1
" {{{ FOLDING
function! markdown#FoldLevelOfLine(lnum)
let currentline = getline(a:lnum)
let nextline = getline(a:lnum + 1)
" an empty line is not going to change the indentation level
if match(currentline, '^\s*$') >= 0
return '='
endif
" folding lists
if s:SyntaxGroupOfLineIs(a:lnum, '^markdownListItem')
if s:SyntaxGroupOfLineIs(a:lnum - 1, '^markdownListItem')
return 'a1'
endif
if s:SyntaxGroupOfLineIs(a:lnum + 1, '^markdownListItem')
return 's1'
endif
return '='
endif
" we are not going to fold things inside list items, too hairy
let is_inside_a_list_item = s:SyntaxGroupOfLineIs(a:lnum, '^markdownListItem')
if is_inside_a_list_item
return '='
endif
" folding atx headers
if match(currentline, '^#\{1,6}\s') >= 0
let header_level = strlen(substitute(currentline, '^\(#\{1,6}\).*', '\1', ''))
return '>' . header_level
endif
" folding fenced code blocks
let next_line_syntax_group = synIDattr(synID(a:lnum + 1, 1, 1), 'name')
if match(currentline, '^\s*```') >= 0
if next_line_syntax_group ==# 'markdownFencedCodeBlock'
return 'a1'
endif
return 's1'
endif
" folding code blocks
let current_line_syntax_group = synIDattr(synID(a:lnum, 1, 1), 'name')
let prev_line_syntax_group = synIDattr(synID(a:lnum - 1, 1, 1), 'name')
if match(currentline, '^\s\{4,}') >= 0
if current_line_syntax_group ==# 'markdownCodeBlock'
if prev_line_syntax_group !=# 'markdownCodeBlock'
return 'a1'
endif
if next_line_syntax_group !=# 'markdownCodeBlock'
return 's1'
endif
endif
return '='
endif
" folding setex headers
if (match(currentline, '^.*$') >= 0)
if (match(nextline, '^=\+$') >= 0)
return '>1'
endif
if (match(nextline, '^-\+$') >= 0)
return '>2'
endif
endif
return '='
endfunction
function! s:SyntaxGroupOfLineIs(lnum, pattern)
let stack = synstack(a:lnum, a:cnum)
if len(stack) > 0
return synIDattr(stack[0], 'name') =~# a:pattern
endif
return 0
endfunction
" }}}
" {{{ EDIT
function! markdown#EditBlock() range abort
if exists('b:markdown_temporary_buffer') && b:markdown_temporary_buffer
echo 'Sorry, you cannot edit a code block inside a temporary buffer'
return
endif
" Github fenced code blocks like ```ruby
let code_block = s:LocateFencedCodeBlock(a:firstline,
\ '^\s*`\{3,}\(\w\+\)\%(\s.*$\|$\)',
\ '^\s*`\{3,}\s*$'
\ )
if code_block['from'] == 0 || code_block['to'] == 0
" Github fenced code blocks with metadata like ```{ruby, <WHATEVER>}
let code_block = s:LocateFencedCodeBlock(a:firstline,
\ '^\s*`\{3,}{\(\w\+\),[^}]\+}\%(\s.*$\|$\)',
\ '^\s*`\{3,}\s*$'
\ )
endif
if code_block['from'] == 0 || code_block['to'] == 0
" Github fenced code blocks alternate style like ~~~ruby
let code_block = s:LocateFencedCodeBlock(a:firstline,
\ '^\s*\~\{3,}\(\w\+\)\%(\s.*$\|$\)',
\ '^\s*\~\{3,}\s*$'
\ )
endif
if code_block['from'] == 0 || code_block['to'] == 0
" Liquid fenced code blocks {% highlight ruby %}
" (since we support some liquid/jekyll tags, why not?)
let code_block = s:LocateFencedCodeBlock(a:firstline,
\ '^\s*{%\s*highlight\s\+\(\w\+\)\s*%}\%(\s.*$\|$\)',
\ '^\s*{%\s*endhighlight\s*%}\%(\s.*$\|$\)'
\ )
endif
if code_block['from'] == 0 || code_block['to'] == 0
let code_block = s:LocateRangeBlock(a:firstline, a:lastline)
endif
if code_block['from'] == 0 || code_block['to'] == 0
echo 'Sorry, I did not find any suitable code block to edit or create'
return
endif
let code_block['file_extension'] = '.' . code_block['language']
if has_key(s:known_file_extensions, code_block['language'])
let code_block['file_extension'] = s:known_file_extensions[code_block['language']]
endif
let code_block['file_path'] = tempname() . code_block['file_extension']
let code_block['content'] = getline(code_block['from'], code_block['to'])
let code_block['content'] = s:UnindentBlock(code_block['content'], code_block['indentation'])
call writefile(code_block['content'], code_block['file_path'])
augroup MarkdownReplaceEditedBlock
autocmd BufEnter <buffer> call s:ReplaceEditedBlock()
augroup END
let b:code_block = code_block
execute 'split ' . code_block['file_path']
let b:markdown_temporary_buffer = 1
autocmd BufLeave <buffer> wq
endfunction
function! s:ReplaceEditedBlock()
augroup MarkdownReplaceEditedBlock
autocmd!
augroup END
augroup! MarkdownReplaceEditedBlock
if b:code_block['to'] - b:code_block['from'] >= 0
execute b:code_block['from'] . ',' b:code_block['to'] . ' delete _'
endif
let content = readfile(b:code_block['file_path'])
let content = s:IndentBlock(l:content, b:code_block['indentation'])
let content = s:SurroundWithFencedCodeBlock(l:content, b:code_block)
call append(b:code_block['from']-1, content)
call setpos('.', b:code_block['back_to_position'])
execute 'silent bwipeout! ' . b:code_block['file_path']
call delete(b:code_block['file_path'])
unlet! b:code_block
endfunction
function! s:UnindentBlock(content, indentation)
return map(a:content, 'substitute(v:val, ''^' . a:indentation . ''', '''', ''g'')')
endfunction
function! s:IndentBlock(content, indentation)
return map(a:content, 'substitute(v:val, ''^'', ''' . a:indentation . ''', ''g'')')
endfunction
function! s:SurroundWithFencedCodeBlock(code, editing)
if !a:editing['surround'] | return a:code | endif
if a:editing['language'] =~# 'markdown' | return a:code | endif
let before =
\ (a:editing['make_room_before'] ? [''] : []) +
\ [a:editing['indentation'] . '```' . a:editing['language']]
let after =
\ [a:editing['indentation'] . '```'] +
\ (a:editing['make_room_after'] ? [''] : [])
return l:before + a:code + l:after
endfunction
function! s:LocateRangeBlock(from, to)
" TODO: extract initialize_code_block
let code_block = {'from': 0, 'to': 0, 'language': 'txt', 'indentation': '', 'surround': 0}
if a:to >= a:from
let code_block['from'] = a:from
let code_block['to'] = a:to
let code_block['back_to_position'] = getpos('.')
let code_block['language'] = 'markdown'
if a:from == a:to && getline(a:from) =~ '^\s*$'
let code_block['surround'] = 1
let code_block['make_room_before'] = getline(a:from - 1) !~ '^\s*$'
let code_block['make_room_after'] = getline(a:to + 1) !~ '^\s*$'
let code_block['language'] = input('filetype? (default: markdown) ', '', 'filetype')
if code_block['language'] =~ '^\s*$'
let code_block['language'] = 'markdown'
endif
endif
endif
return code_block
endfunction
function! s:LocateFencedCodeBlock(starting_from, upper_delimiter, lower_delimiter)
" TODO: extract initialize_code_block
let code_block = {'from': 0, 'to': 0, 'language': 'txt', 'indentation': '', 'surround': 0}
let initial_position = getpos('.')
let search_position = copy(initial_position)
let search_position[1] = a:starting_from
let search_position[2] = 0
cal setpos('.', search_position)
let start_code_block_backward = search(a:upper_delimiter, 'cbnW')
let end_code_block_backward = search(a:lower_delimiter, 'cbnW')
let end_code_block_forward = search(a:lower_delimiter, 'cnW')
let found_code_block =
\ start_code_block_backward > 0 &&
\ end_code_block_forward > 0
let between_two_code_blocks =
\ start_code_block_backward < end_code_block_backward &&
\ end_code_block_backward <= a:starting_from
let starting_inside_code_block =
\ found_code_block &&
\ !between_two_code_blocks &&
\ start_code_block_backward <= a:starting_from &&
\ end_code_block_forward >= a:starting_from
if starting_inside_code_block
let code_block['language'] = s:ExtractLanguage(start_code_block_backward, a:upper_delimiter)
let code_block['indentation'] = s:ExtractIndentation(start_code_block_backward)
let code_block['back_to_position'] = initial_position
let code_block['back_to_position'][1] = start_code_block_backward
let code_block['back_to_position'][2] = 0
let code_block['from'] = start_code_block_backward + 1
let code_block['to'] = end_code_block_forward - 1
endif
return code_block
endfunction
function! s:ExtractLanguage(start_at, upper_delimiter)
return substitute(getline(a:start_at), a:upper_delimiter, '\1', '')
endfunction
function! s:ExtractIndentation(start_at)
return substitute(getline(a:start_at), '\(^\s*\).\+$', '\1', '')
endfunction
let s:known_file_extensions = {
\ 'abap': '.abap',
\ 'antlr': '.g4',
\ 'asp': '.asp',
\ 'ats': '.dats',
\ 'actionscript': '.as',
\ 'ada': '.adb',
\ 'agda': '.agda',
\ 'apacheconf': '.apacheconf',
\ 'apex': '.cls',
\ 'applescript': '.applescript',
\ 'arc': '.arc',
\ 'arduino': '.ino',
\ 'asciidoc': '.asciidoc',
\ 'assembly': '.asm',
\ 'augeas': '.aug',
\ 'autohotkey': '.ahk',
\ 'autoit': '.au3',
\ 'awk': '.awk',
\ 'batchfile': '.bat',
\ 'befunge': '.befunge',
\ 'blitzbasic': '.bb',
\ 'blitzmax': '.bmx',
\ 'bluespec': '.bsv',
\ 'boo': '.boo',
\ 'brainfuck': '.b',
\ 'brightscript': '.brs',
\ 'bro': '.bro',
\ 'c': '.c',
\ 'c++': '.cpp',
\ 'cpp': '.cpp',
\ 'clips': '.clp',
\ 'cmake': '.cmake',
\ 'cobol': '.cob',
\ 'css': '.css',
\ 'ceylon': '.ceylon',
\ 'chuck': '.ck',
\ 'cirru': '.cirru',
\ 'clean': '.icl',
\ 'clojure': '.clj',
\ 'coffeescript': '.coffee',
\ 'coldfusion': '.cfm',
\ 'coq': '.coq',
\ 'creole': '.creole',
\ 'crystal': '.cr',
\ 'cucumber': '.feature',
\ 'cuda': '.cu',
\ 'cython': '.pyx',
\ 'd': '.d',
\ 'dm': '.dm',
\ 'dot': '.dot',
\ 'dart': '.dart',
\ 'diff': '.diff',
\ 'dylan': '.dylan',
\ 'ecl': '.ecl',
\ 'eiffel': '.e',
\ 'elixir': '.ex',
\ 'elm': '.elm',
\ 'erlang': '.erl',
\ 'flux': '.fx',
\ 'fortran': '.f90',
\ 'factor': '.factor',
\ 'fancy': '.fy',
\ 'fantom': '.fan',
\ 'forth': '.fth',
\ 'gas': '.s',
\ 'glsl': '.glsl',
\ 'genshi': '.kid',
\ 'glyph': '.glf',
\ 'go': '.go',
\ 'gosu': '.gs',
\ 'groff': '.man',
\ 'groovy': '.groovy',
\ 'html': '.html',
\ 'http': '.http',
\ 'haml': '.haml',
\ 'handlebars': '.handlebars',
\ 'harbour': '.hb',
\ 'haskell': '.hs',
\ 'haxe': '.hx',
\ 'hy': '.hy',
\ 'idl': '.pro',
\ 'ini': '.ini',
\ 'idris': '.idr',
\ 'io': '.io',
\ 'ioke': '.ik',
\ 'j': '.ijs',
\ 'json': '.json',
\ 'json5': '.json5',
\ 'jsonld': '.jsonld',
\ 'jade': '.jade',
\ 'java': '.java',
\ 'javascript': '.js',
\ 'julia': '.jl',
\ 'krl': '.krl',
\ 'kotlin': '.kt',
\ 'lfe': '.lfe',
\ 'llvm': '.ll',
\ 'lasso': '.lasso',
\ 'less': '.less',
\ 'lilypond': '.ly',
\ 'livescript': '.ls',
\ 'logos': '.xm',
\ 'logtalk': '.lgt',
\ 'lua': '.lua',
\ 'm': '.mumps',
\ 'makefile': '.mak',
\ 'mako': '.mako',
\ 'markdown': '.md',
\ 'mask': '.mask',
\ 'matlab': '.matlab',
\ 'max': '.maxpat',
\ 'mediawiki': '.mediawiki',
\ 'mirah': '.druby',
\ 'monkey': '.monkey',
\ 'moocode': '.moo',
\ 'moonscript': '.moon',
\ 'myghty': '.myt',
\ 'nsis': '.nsi',
\ 'nemerle': '.n',
\ 'netlogo': '.nlogo',
\ 'nginx': '.nginxconf',
\ 'nimrod': '.nim',
\ 'nu': '.nu',
\ 'numpy': '.numpy',
\ 'ocaml': '.ml',
\ 'objdump': '.objdump',
\ 'omgrofl': '.omgrofl',
\ 'opa': '.opa',
\ 'opencl': '.cl',
\ 'org': '.org',
\ 'oxygene': '.oxygene',
\ 'pawn': '.pwn',
\ 'php': '.php',
\ 'parrot': '.parrot',
\ 'pascal': '.pas',
\ 'perl': '.pl',
\ 'perl6': '.p6',
\ 'pike': '.pike',
\ 'pod': '.pod',
\ 'pogoscript': '.pogo',
\ 'postscript': '.ps',
\ 'powershell': '.ps1',
\ 'processing': '.pde',
\ 'prolog': '.prolog',
\ 'puppet': '.pp',
\ 'python': '.py',
\ 'qml': '.qml',
\ 'r': '.r',
\ 'rdoc': '.rdoc',
\ 'realbasic': '.rbbas',
\ 'rhtml': '.rhtml',
\ 'rmarkdown': '.rmd',
\ 'racket': '.rkt',
\ 'rebol': '.rebol',
\ 'redcode': '.cw',
\ 'robotframework': '.robot',
\ 'rouge': '.rg',
\ 'ruby': '.rb',
\ 'rust': '.rs',
\ 'scss': '.scss',
\ 'sql': '.sql',
\ 'sage': '.sage',
\ 'sass': '.sass',
\ 'scala': '.scala',
\ 'scaml': '.scaml',
\ 'scheme': '.scm',
\ 'scilab': '.sci',
\ 'self': '.self',
\ 'shell': '.sh',
\ 'shen': '.shen',
\ 'slash': '.sl',
\ 'smalltalk': '.st',
\ 'smarty': '.tpl',
\ 'squirrel': '.nut',
\ 'stylus': '.styl',
\ 'supercollider': '.scd',
\ 'toml': '.toml',
\ 'txl': '.txl',
\ 'tcl': '.tcl',
\ 'tcsh': '.tcsh',
\ 'tex': '.tex',
\ 'tea': '.tea',
\ 'textile': '.textile',
\ 'turing': '.t',
\ 'twig': '.twig',
\ 'typescript': '.ts',
\ 'unrealscript': '.uc',
\ 'vhdl': '.vhdl',
\ 'vala': '.vala',
\ 'verilog': '.v',
\ 'viml': '.vim',
\ 'volt': '.volt',
\ 'xc': '.xc',
\ 'xml': '.xml',
\ 'xproc': '.xpl',
\ 'xquery': '.xquery',
\ 'xs': '.xs',
\ 'xslt': '.xslt',
\ 'xtend': '.xtend',
\ 'yaml': '.yml',
\ 'ec': '.ec',
\ 'edn': '.edn',
\ 'fish': '.fish',
\ 'mupad': '.mu',
\ 'nesc': '.nc',
\ 'ooc': '.ooc',
\ 'restructuredtext': '.rst',
\ 'wisp': '.wisp',
\ 'xbase': '.prg',
\ }
" }}}
" {{{ FORMAT
function! markdown#FormatTable()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
let separator_line_number = search('^\s*|\s*-\{3,}', 'cbnW')
call s:ShrinkTableHeaderSeparator(separator_line_number)
Tabularize/|/l1
call s:ExpandTableHeaderSeparator(separator_line_number)
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
function! s:ShrinkTableHeaderSeparator(separator_line_number)
if a:separator_line_number > 0
let separator_line = getline(a:separator_line_number)
let separator_line = substitute(separator_line, '-\+', '---', 'g')
call setline(a:separator_line_number, separator_line)
endif
endfunction
function! s:ExpandTableHeaderSeparator(separator_line_number)
if a:separator_line_number > 0
let separator_line = getline(a:separator_line_number)
let separator_line = substitute(
\ separator_line,
\ '|\([^|]*\)',
\ '\="| " . repeat("-", strlen(submatch(1)) - 2) . " "',
\ 'g')
let separator_line = substitute(separator_line, '\s*$', '', '')
call setline(a:separator_line_number, separator_line)
endif
endfunction
" }}}
" {{{ SWITCH STATUS
function! markdown#SwitchStatus()
let current_line = getline('.')
if match(current_line, '^\s*[*\-+] \[ \]') >= 0
call setline('.', substitute(current_line, '^\(\s*[*\-+]\) \[ \]', '\1 [x]', ''))
return
endif
if match(current_line, '^\s*[*\-+] \[x\]') >= 0
call setline('.', substitute(current_line, '^\(\s*[*\-+]\) \[x\]', '\1', ''))
return
endif
if match(current_line, '^\s*[*\-+] \(\[[x ]\]\)\@!') >= 0
call setline('.', substitute(current_line, '^\(\s*[*\-+]\)', '\1 [ ]', ''))
return
endif
if match(current_line, '^\s*#\{1,5}\s') >= 0
call setline('.', substitute(current_line, '^\(\s*#\{1,5}\) \(.*$\)', '\1# \2', ''))
return
endif
if match(current_line, '^\s*#\{6}\s') >= 0
call setline('.', substitute(current_line, '^\(\s*\)#\{6} \(.*$\)', '\1# \2', ''))
return
endif
endfunction
" }}}
endif

3
build
View File

@@ -233,7 +233,7 @@ PACKS="
log:MTDL9/vim-log-highlighting
lua:tbastos/vim-lua
mako:sophacles/vim-bundle-mako
markdown:plasticboy/vim-markdown:_SYNTAX
markdown:gabrielelana/vim-markdown
mathematica:voldikss/vim-mma
mdx:jxnblk/vim-mdx-js
meson:mesonbuild/meson:_ALL:/data/syntax-highlighting/vim/
@@ -292,6 +292,7 @@ PACKS="
tptp:c-cube/vim-tptp
twig:lumiliet/vim-twig
typescript:HerringtonDarkholme/yats.vim
v:ollykel/v-vim
vala:arrufat/vala.vim
vbnet:vim-scripts/vbnet.vim
vcl:smerrill/vcl-vim-plugin

View File

@@ -1,3 +1,15 @@
if !exists('g:markdown_enable_spell_checking')
let g:markdown_enable_spell_checking = 0
end
if !exists('g:markdown_enable_input_abbreviations')
let g:markdown_enable_input_abbreviations = 0
end
if !exists('g:markdown_enable_mappings')
let g:markdown_enable_mappings = 0
end
" Enable jsx syntax by default
if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 0

View File

@@ -1,3 +1,15 @@
if !exists('g:markdown_enable_spell_checking')
let g:markdown_enable_spell_checking = 0
end
if !exists('g:markdown_enable_input_abbreviations')
let g:markdown_enable_input_abbreviations = 0
end
if !exists('g:markdown_enable_mappings')
let g:markdown_enable_mappings = 0
end
" Enable jsx syntax by default
if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 0
@@ -781,15 +793,8 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'markdown') == -1
augroup filetypedetect
" markdown, from markdown.vim in plasticboy/vim-markdown:_SYNTAX
if !has('patch-7.4.480')
" Before this patch, vim used modula2 for .md.
au! filetypedetect BufRead,BufNewFile *.md
endif
" markdown filetype file
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown
" markdown, from markdown.vim in gabrielelana/vim-markdown
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
augroup end
endif
@@ -1473,6 +1478,14 @@ autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescriptreact
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
augroup filetypedetect
" v, from vlang.vim in ollykel/v-vim
au BufNewFile,BufRead *.v set filetype=vlang
au BufNewFile,BufRead *.v set syntax=vlang
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vala') == -1
augroup filetypedetect
" vala, from vala.vim in arrufat/vala.vim

202
ftplugin/markdown.vim Normal file
View File

@@ -0,0 +1,202 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'markdown') == -1
if exists('b:did_ftplugin') | finish | endif
" {{{ CONFIGURATION
if !exists('g:markdown_flavor')
let g:markdown_flavor = 'github'
endif
if !exists('g:markdown_enable_folding')
let g:markdown_enable_folding = 0
endif
if !exists('g:markdown_enable_mappings')
" make it compatible with previous configuration value
if exists('g:markdown_include_default_mappings')
let g:markdown_enable_mappings = g:markdown_include_default_mappings
else
let g:markdown_enable_mappings = 1
endif
endif
if !exists('g:markdown_enable_insert_mode_mappings')
" make it compatible with previous configuration value
if exists('g:markdown_include_insert_mode_default_mappings')
let g:markdown_enable_insert_mode_mappings = g:markdown_include_insert_mode_default_mappings
else
let g:markdown_enable_insert_mode_mappings = 1
endif
endif
if !exists('g:markdown_enable_insert_mode_leader_mappings')
let g:markdown_enable_insert_mode_leader_mappings = 0
endif
if !exists('g:markdown_drop_empty_blockquotes')
let g:markdown_drop_empty_blockquotes = 0
endif
if !exists('g:markdown_mapping_switch_status')
let g:markdown_mapping_switch_status = '<space>'
endif
if !exists('g:markdown_enable_spell_checking')
let g:markdown_enable_spell_checking = 1
endif
if !exists('g:markdown_enable_input_abbreviations')
let g:markdown_enable_input_abbreviations = 1
endif
" }}}
" {{{ OPTIONS
setlocal textwidth=0
setlocal ts=2 sw=2 expandtab smarttab
setlocal comments=b:*,b:-,b:+,n:>,se:``` commentstring=>\ %s
setlocal formatoptions=tron
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\\|^\\s*[+-\\*]\\s\\+
setlocal nolisp
setlocal autoindent
" Enable spelling and completion based on dictionary words
if &spelllang !~# '^\s*$' && g:markdown_enable_spell_checking
setlocal spell
endif
" Custom dictionary for emoji
execute 'setlocal dictionary+=' . shellescape(expand('<sfile>:p:h:h')) . '/dict/emoticons.dict'
setlocal iskeyword+=:,+,-
setlocal complete+=k
if g:markdown_enable_input_abbreviations
" Replace common ascii emoticons with supported emoji
iabbrev <buffer> :-) :smile:
iabbrev <buffer> :-D :laughing:
iabbrev <buffer> :-( :disappointed:
" Replace common punctuation
iabbrev <buffer> ... …
iabbrev <buffer> << «
iabbrev <buffer> >> »
endif
" Folding
if g:markdown_enable_folding
setlocal foldmethod=expr
setlocal foldexpr=markdown#FoldLevelOfLine(v:lnum)
endif
" }}}
" {{{ FUNCTIONS
function! s:JumpToHeader(forward, visual)
let cnt = v:count1
let save = @/
let pattern = '\v^#{1,6}.*$|^.+\n%(\-+|\=+)$'
if a:visual
normal! gv
endif
if a:forward
let motion = '/' . pattern
else
let motion = '?' . pattern
endif
while cnt > 0
silent! execute motion
let cnt = cnt - 1
endwhile
call histdel('/', -1)
let @/ = save
endfunction
function! s:Indent(indent)
if getline('.') =~ '\v^\s*%([-*+]|\d\.)\s*$'
if a:indent
normal >>
else
normal <<
endif
call setline('.', substitute(getline('.'), '\([-*+]\|\d\.\)\s*$', '\1 ', ''))
normal $
elseif getline('.') =~ '\v^\s*(\s?\>)+\s*$'
if a:indent
call setline('.', substitute(getline('.'), '>\s*$', '>> ', ''))
else
call setline('.', substitute(getline('.'), '\s*>\s*$', ' ', ''))
call setline('.', substitute(getline('.'), '^\s\+$', '', ''))
endif
normal $
endif
endfunction
function! s:IsAnEmptyListItem()
return getline('.') =~ '\v^\s*%([-*+]|\d\.)\s*$'
endfunction
function! s:IsAnEmptyQuote()
return getline('.') =~ '\v^\s*(\s?\>)+\s*$'
endfunction
" }}}
" {{{ MAPPINGS
" Commands
command! -nargs=0 -range MarkdownEditBlock :<line1>,<line2>call markdown#EditBlock()
if g:markdown_enable_mappings
" Jumping around
noremap <silent> <buffer> <script> ]] :<C-u>call <SID>JumpToHeader(1, 0)<CR>
noremap <silent> <buffer> <script> [[ :<C-u>call <SID>JumpToHeader(0, 0)<CR>
vnoremap <silent> <buffer> <script> ]] :<C-u>call <SID>JumpToHeader(1, 1)<CR>
vnoremap <silent> <buffer> <script> [[ :<C-u>call <SID>JumpToHeader(0, 1)<CR>
noremap <silent> <buffer> <script> ][ <nop>
noremap <silent> <buffer> <script> [] <nop>
if g:markdown_enable_insert_mode_mappings
" Indenting things
inoremap <silent> <buffer> <script> <expr> <Tab>
\ <SID>IsAnEmptyListItem() \|\| <SID>IsAnEmptyQuote() ? '<C-O>:call <SID>Indent(1)<CR>' : '<Tab>'
inoremap <silent> <buffer> <script> <expr> <S-Tab>
\ <SID>IsAnEmptyListItem() \|\| <SID>IsAnEmptyQuote() ? '<C-O>:call <SID>Indent(0)<CR>' : '<Tab>'
if g:markdown_drop_empty_blockquotes
" Remove empty quote and list items when press <CR>
inoremap <silent> <buffer> <script> <expr> <CR> <SID>IsAnEmptyQuote() \|\| <SID>IsAnEmptyListItem() ? '<C-O>:normal 0D<CR>' : '<CR>'
else
" Remove only empty list items when press <CR>
inoremap <silent> <buffer> <script> <expr> <CR> <SID>IsAnEmptyListItem() ? '<C-O>:normal 0D<CR>' : '<CR>'
endif
" Format tables
inoremap <silent> <buffer> <Bar> <Bar><Esc>:call markdown#FormatTable()<CR>a
endif
" Switch status of things
execute 'nnoremap <silent> <buffer> ' . g:markdown_mapping_switch_status . ' :call markdown#SwitchStatus()<CR>'
" Leader mappings
nnoremap <buffer> <Leader>e :MarkdownEditBlock<CR>
vnoremap <buffer> <Leader>e :MarkdownEditBlock<CR>
nnoremap <silent> <buffer> <Leader>ft :call markdown#FormatTable()<CR>
" Insert Mode mappings
if g:markdown_enable_insert_mode_leader_mappings
inoremap <buffer> <Leader>e <Esc>:MarkdownEditBlock<CR>
inoremap <silent> <buffer> <Leader>ft <Esc>:call markdown#FormatTable()<CR>a
endif
endif
" }}}
let b:did_ftplugin = 1
endif

6
ftplugin/vlang.vim Normal file
View File

@@ -0,0 +1,6 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
setlocal commentstring=//\ %s
setlocal makeprg=v\ %
endif

View File

@@ -1,79 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'markdown') == -1
if exists("b:did_indent") | finish | endif
let b:did_indent = 1
setlocal indentexpr=GetMarkdownIndent()
setlocal nolisp
setlocal autoindent
" Automatically continue blockquote on line break
setlocal formatoptions+=r
setlocal comments=b:>
if get(g:, "vim_markdown_auto_insert_bullets", 1)
" Do not automatically insert bullets when auto-wrapping with text-width
setlocal formatoptions-=c
" Accept various markers as bullets
setlocal comments+=b:*,b:+,b:-
endif
" Only define the function once
if exists("*GetMarkdownIndent") | finish | endif
function! s:IsMkdCode(lnum)
let name = synIDattr(synID(a:lnum, 1, 0), 'name')
return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
endfunction
function! s:IsLiStart(line)
return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' &&
\ a:line =~ '^\s*[*+-] \+'
endfunction
function! s:IsHeaderLine(line)
return a:line =~ '^\s*#'
endfunction
function! s:IsBlankLine(line)
return a:line =~ '^$'
endfunction
function! s:PrevNonBlank(lnum)
let i = a:lnum
while i > 1 && s:IsBlankLine(getline(i))
let i -= 1
endwhile
return i
endfunction
function GetMarkdownIndent()
if v:lnum > 2 && s:IsBlankLine(getline(v:lnum - 1)) && s:IsBlankLine(getline(v:lnum - 2))
return 0
endif
let list_ind = get(g:, "vim_markdown_new_list_item_indent", 4)
" Find a non-blank line above the current line.
let lnum = s:PrevNonBlank(v:lnum - 1)
" At the start of the file use zero indent.
if lnum == 0 | return 0 | endif
let ind = indent(lnum)
let line = getline(lnum) " Last line
let cline = getline(v:lnum) " Current line
if s:IsLiStart(cline)
" Current line is the first line of a list item, do not change indent
return indent(v:lnum)
elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum)
" Current line is the header, do not indent
return 0
elseif s:IsLiStart(line)
if s:IsMkdCode(lnum)
return ind
else
" Last line is the first line of a list item, increase indent
return ind + list_ind
end
else
return ind
endif
endfunction
endif

View File

@@ -66,6 +66,7 @@ let s:syng_strcom = s:syng_stringdoc + [
\ 'PercentStringDelimiter',
\ 'PercentSymbolDelimiter',
\ 'Regexp',
\ 'RegexpCharClass',
\ 'RegexpDelimiter',
\ 'RegexpEscape',
\ 'StringDelimiter',

69
indent/vlang.vim Normal file
View File

@@ -0,0 +1,69 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
" Based on the Go identation file.
"
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal nolisp
setlocal autoindent
setlocal indentexpr=VlangIndent(v:lnum)
setlocal indentkeys+=<:>,0=},0=)
if exists("*VlangIndent")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
function! VlangIndent(lnum) abort
let prevlnum = prevnonblank(a:lnum-1)
if prevlnum == 0
return 0
endif
let prevl = substitute(getline(prevlnum), '//.*$', '', '')
let thisl = substitute(getline(a:lnum), '//.*$', '', '')
let previ = indent(prevlnum)
let ind = previ
if prevl =~ '[({]\s*$'
" previous line opened a block
let ind += shiftwidth()
endif
if prevl =~# '^\s*\(case .*\|default\):$'
" previous line is part of a switch statement
let ind += shiftwidth()
endif
if thisl =~ '^\s*[)}]'
" this line closed a block
let ind -= shiftwidth()
endif
" Colons are tricky.
" We want to outdent if it's part of a switch ("case foo:" or "default:").
" We ignore trying to deal with jump labels because (a) they're rare, and
" (b) they're hard to disambiguate from a composite literal key.
if thisl =~# '^\s*\(case .*\|default\):$'
let ind -= shiftwidth()
endif
return ind
endfunction
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: sw=2 ts=2 et
endif

View File

@@ -39,6 +39,7 @@ syntax region dhallString start=+''+ end=+''+ contains=@Spell,dhallInterpolation
syntax region dhallString start=+"+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax region dhallString start=+"/+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax keyword dhallBool True False
syntax match dhallHash "sha256:[a-f0-9]+"
highlight link dhallSingleSpecial Special
highlight link dhallIndex Special
@@ -60,6 +61,7 @@ highlight link dhallType Structure
highlight link dhallParens Special
highlight link dhallComment Comment
highlight link dhallMultilineComment Comment
highlight link dhallHash Keyword
let b:current_syntax = 'dhall'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'markdown') == -1
let b:markdown_in_jekyll=0
if getline(1) =~ '^---\s*$'
let b:markdown_in_jekyll=1
syn region markdownJekyllFrontMatter matchgroup=markdownJekyllDelimiter contains=@NoSpell
\ start="\%^---" end="^---$"
syn region markdownJekyllLiquidTag matchgroup=markdownJekyllDelimiter contains=@NoSpell oneline
\ start="{%" end="%}"
syn region markdownJekyllLiquidOutputTag matchgroup=markdownJekyllDelimiter contains=@NoSpell oneline
\ start="{{" skip=/"}}"/ end="}}"
syn region markdownJekyllLiquidBlockTag matchgroup=markdownJekyllDelimiter contains=@NoSpell
\ start="{%\s*\z(comment\|raw\|highlight\)[^%]*%}" end="{%\s*\%(no\|end\)\z1\s*%}"
silent spell! nocomment
silent spell! endcomment
silent spell! nohighlight
silent spell! endhighlight
silent spell! noraw
silent spell! endraw
hi def link markdownJekyllFrontMatter NonText
hi def link markdownJekyllLiquidTag NonText
hi def link markdownJekyllLiquidOutputTag NonText
hi def link markdownJekyllLiquidBlockTag NonText
hi def link markdownJekyllDelimiter Delimiter
endif
endif

268
syntax/vlang.vim Normal file
View File

@@ -0,0 +1,268 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
" Vim syntax file
" Language: V
" Maintainer: Oliver Kelton (https://github.com/ollykel)
" Last Change: 2019 Jun 13
" NOTE: largely based on go.vim, maintained by David Barnett
" see David Barnett (https://github.com/google/vim-ft-go)
" Options:
" There are some options for customizing the highlighting; the recommended
" settings are the default values, but you can write:
" let OPTION_NAME = 0
" in your ~/.vimrc file to disable particular options. You can also write:
" let OPTION_NAME = 1
" to enable particular options. At present, all options default to on.
"
" - g:v_highlight_array_whitespace_error
" Highlights white space after "[]".
" - g:v_highlight_chan_whitespace_error
" Highlights white space around the communications operator that don't
" follow the standard style.
" Highlights commonly used library types (io.Reader, etc.).
" - g:v_highlight_space_tab_error
" Highlights instances of tabs following spaces.
" - g:v_highlight_trailing_whitespace_error
" Highlights trailing white space.
" Quit when a (custom) syntax file was already loaded
if exists('b:current_syntax')
finish
endif
if !exists('g:v_highlight_array_whitespace_error')
let g:v_highlight_array_whitespace_error = 1
endif
if !exists('g:v_highlight_chan_whitespace_error')
let g:v_highlight_chan_whitespace_error = 1
endif
if !exists('g:v_highlight_space_tab_error')
let g:v_highlight_space_tab_error = 1
endif
if !exists('g:v_highlight_trailing_whitespace_error')
let g:v_highlight_trailing_whitespace_error = 1
endif
if !exists('g:v_highlight_function_calls')
let g:v_highlight_function_calls = 1
endif
if !exists('g:v_highlight_fields')
let g:v_highlight_fields = 1
endif
syn case match
syn match vDeclType "\<\(struct\|interface\)\>"
syn keyword vDirective module import
syn keyword vDeclaration pub mut const type enum
syn region vIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match vIncluded display contained "<[^>]*>"
syn match vFlagDefinition display contained "\s\i[^\n]*"
syn match vInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=vIncluded
syn match vFlag display "^\s*\zs\(%:\|#\)\s*flag\>\s*[^\n]*" contains=vFlagDefinition
syn region vShebang display start=/^#!/ end=/$/
hi def link vDirective Statement
hi def link vDeclaration Keyword
hi def link vDeclType Keyword
hi def link vInclude Include
hi def link vFlag Include
hi def link vIncluded vString
hi def link vFlagDefinition vString
hi def link vShebang Include
" Keywords within functions
syn keyword vStatement defer go goto return break continue fallthrough
syn keyword vConditional if else switch match or
syn keyword vLabel case default
syn keyword vRepeat for in
syn match vCodeGen /$if\>/
syn match vCodeGen /\.fields\>/
syn match vCodeGen /\.$\i*\>/
hi def link vStatement Statement
hi def link vConditional Conditional
hi def link vLabel Label
hi def link vRepeat Repeat
hi def link vCodeGen Identifier
" Predefined types
syn keyword vType chan map bool string error voidptr
syn keyword vSignedInts int i8 i16 i32 i64 rune intptr
syn keyword vUnsignedInts byte uint u8 u16 u32 u64 byteptr
syn keyword vFloats f32 f64 floatptr
syn keyword vComplexes complex64 complex128
hi def link vType Type
hi def link vSignedInts Type
hi def link vUnsignedInts Type
hi def link vFloats Type
hi def link vComplexes Type
" Treat fn specially: it's a declaration at the start of a line, but a type
" elsewhere. Order matters here.
" syn match vType /\<fn\>/
syn match vDeclaration /\<fn\>/
syn match vDeclaration contained /\<fn\>/
" Predefined functions and values
syn keyword vBuiltins assert C cap complex copy delete exit imag
syn keyword vBuiltins print println eprint eprintln print_backtrace
syn keyword vBuiltins float_calloc ok memdup range_int real recover
syn keyword vBuiltins malloc byte_calloc float_calloc
syn keyword vBuiltins isok isnil panic on_panic
syn keyword vConstants iota true false
syn match vBuiltins /\<json\.\(encode\|decode\)\>/
hi def link vBuiltins Keyword
hi def link vConstants Keyword
" Comments; their contents
syn keyword vTodo contained TODO FIXME XXX BUG
syn cluster vCommentGroup contains=vTodo
syn region vComment start="/\*" end="\*/" contains=@vCommentGroup,@Spell
syn region vComment start="//" end="$" contains=@vCommentGroup,@Spell
hi def link vComment Comment
hi def link vTodo Todo
" Go escapes
syn match vEscapeOctal display contained "\\[0-7]\{3}"
syn match vEscapeVar display contained "\$[0-9A-Za-z\.]*"
syn match vEscapeVar display contained "\${[^}]*}"
syn match vEscapeC display contained +\\[abfnrtv\\'"]+
syn match vEscapeX display contained "\\x\x\{2}"
syn match vEscapeU display contained "\\u\x\{4}"
syn match vEscapeBigU display contained "\\U\x\{8}"
syn match vEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
hi def link vEscapeOctal vSpecialString
hi def link vEscapeVar vSpecialString
hi def link vEscapeC vSpecialString
hi def link vEscapeX vSpecialString
hi def link vEscapeU vSpecialString
hi def link vEscapeBigU vSpecialString
hi def link vSpecialString Special
hi def link vEscapeError Error
" Strings and their contents
syn cluster vStringGroup contains=vEscapeOctal,vEscapeVar,vEscapeC,vEscapeX,vEscapeU,vEscapeBigU,vEscapeError
syn region vString start=+"+ skip=+\\\\\|\\'+ end=+"+ contains=@vStringGroup
syn region vRawString start=+`+ end=+`+
hi def link vString String
hi def link vRawString String
" Characters; their contents
syn cluster vCharacterGroup contains=vEscapeOctal,vEscapeC,vEscapeVar,vEscapeX,vEscapeU,vEscapeBigU
syn region vCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@vCharacterGroup
hi def link vCharacter Character
" Regions
syn region vBlock start="{" end="}" transparent fold
syn region vParen start='(' end=')' transparent
" Integers
syn match vDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
syn match vHexadecimalInt "\<0x\x\+\>"
syn match vOctalInt "\<0\o\+\>"
syn match vOctalError "\<0\o*[89]\d*\>"
hi def link vDecimalInt Integer
hi def link vHexadecimalInt Integer
hi def link vOctalInt Integer
hi def link Integer Number
" Floating point
syn match vFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
syn match vFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
syn match vFloat "\<\d\+[Ee][-+]\d\+\>"
hi def link vFloat Float
" Imaginary literals
syn match vImaginary "\<\d\+i\>"
syn match vImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
syn match vImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
syn match vImaginary "\<\d\+[Ee][-+]\d\+i\>"
hi def link vImaginary Number
" Generics
syn match vGenericBrackets display contained "[<>]"
syn match vInterfaceDeclaration display "\s*\zsinterface\s*\i*\s*<[^>]*>" contains=vDeclType,vGenericBrackets
syn match vStructDeclaration display "\s*\zsstruct\s*\i*\s*<[^>]*>" contains=vDeclType,vGenericBrackets
" vFunctionName only appears when v_highlight_function_calls set
syn match vFuncDeclaration display "\s*\zsfn\s*\i*\s*<[^>]*>" contains=vFunctionName,vDeclaration,vGenericBrackets
hi def link vGenericBrackets Identifier
" Spaces after "[]"
if v_highlight_array_whitespace_error != 0
syn match vSpaceError display "\(\[\]\)\@<=\s\+"
endif
" Spacing errors around the 'chan' keyword
if v_highlight_chan_whitespace_error != 0
" receive-only annotation on chan type
syn match vSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@="
" send-only annotation on chan type
syn match vSpaceError display "\(\<chan\)\@<=\s\+\(<-\)\@="
" value-ignoring receives in a few contexts
syn match vSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
endif
" Space-tab error
if v_highlight_space_tab_error != 0
syn match vSpaceError display " \+\t"me=e-1
endif
" Trailing white space error
if v_highlight_trailing_whitespace_error != 0
syn match vSpaceError display excludenl "\s\+$"
endif
hi def link vSpaceError Error
" Function calls and Fields are from: https://github.com/fatih/vim-go/blob/master/syntax/go.vim
" Function calls;
if v_highlight_function_calls
syn match vFunctionCall /\w\+\ze\s*(/ contains=vBuiltins,vDeclaration
syn match vFunctionName display contained /\s\w\+/
hi def link vFunctionName Special
endif
hi def link vFunctionCall Special
" Fields;
if v_highlight_fields
" 1. Match a sequence of word characters coming after a '.'
" 2. Require the following but dont match it: ( \@= see :h E59)
" - The symbols: / - + * % OR
" - The symbols: [] {} <> ) OR
" - The symbols: \n \r space OR
" - The symbols: , : .
" 3. Have the start of highlight (hs) be the start of matched
" pattern (s) offsetted one to the right (+1) (see :h E401)
syn match vField /\.\w\+\
\%(\%([\/\-\+*%]\)\|\
\%([\[\]{}<\>\)]\)\|\
\%([\!=\^|&]\)\|\
\%([\n\r\ ]\)\|\
\%([,\:.]\)\)\@=/hs=s+1
endif
hi def link vField Identifier
" Search backwards for a global declaration to start processing the syntax.
"syn sync match vSync grouphere NONE /^\(const\|var\|type\|func\)\>/
" There's a bug in the implementation of grouphere. For now, use the
" following as a more expensive/less precise workaround.
syn sync minlines=500
let b:current_syntax = 'vlang'
" vim: sw=2 sts=2 et
endif

View File

@@ -43,7 +43,7 @@ syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold|Type|shuffle)>"
syn match zigBuiltinFn "\v\@(setRuntimeSafety|setEvalBranchQuota|setFloatMode)>"
syn match zigBuiltinFn "\v\@(setGlobalLinkage|setGlobalSection|shlExact|This|hasDecl|hasField)>"
syn match zigBuiltinFn "\v\@(shlWithOverflow|shrExact|sizeOf|sqrt|byteSwap|subWithOverflow|intCast|floatCast|intToFloat|floatToInt|boolToInt|errSetCast)>"
syn match zigBuiltinFn "\v\@(truncate|typeId|typeInfo|typeName|typeOf|atomicRmw|bytesToSlice|sliceToBytes)>"
syn match zigBuiltinFn "\v\@(truncate|typeId|typeInfo|typeName|TypeOf|atomicRmw|bytesToSlice|sliceToBytes)>"
syn match zigBuiltinFn "\v\@(intToError|errorToInt|intToEnum|enumToInt|setAlignStack|frame|Frame|frameSize|bitReverse|Vector)>"
syn match zigBuiltinFn "\v\@(sin|cos|exp|exp2|ln|log2|log10|fabs|floor|ceil|trunc|round)>"