mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-11 04:53:51 -05:00
Update
This commit is contained in:
@@ -53,8 +53,8 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
let blocks_stack = []
|
||||
let num_closed_blocks = 0
|
||||
while 1
|
||||
let fb = JuliaMatch(a:lnum, line, '@\@<!\<\%(if\|else\%(if\)\?\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e)
|
||||
let fe = JuliaMatch(a:lnum, line, '@\@<!\<end\>', s, e)
|
||||
let fb = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(if\|else\%(if\)\?\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e)
|
||||
let fe = JuliaMatch(a:lnum, line, '[@.]\@<!\<end\>', s, e)
|
||||
|
||||
if fb < 0 && fe < 0
|
||||
" No blocks found
|
||||
@@ -66,13 +66,13 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
" Note: some keywords (elseif,else,catch,finally) are both
|
||||
" closing blocks and opening new ones
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<if\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<if\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
call add(blocks_stack, 'if')
|
||||
continue
|
||||
endif
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<elseif\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<elseif\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
if len(blocks_stack) > 0 && blocks_stack[-1] == 'if'
|
||||
@@ -83,7 +83,7 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<else\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<else\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>'
|
||||
@@ -95,13 +95,13 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<try\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<try\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
call add(blocks_stack, 'try')
|
||||
continue
|
||||
endif
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<catch\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<catch\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
if len(blocks_stack) > 0 && blocks_stack[-1] == 'try'
|
||||
@@ -112,7 +112,7 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<finally\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<finally\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
if len(blocks_stack) > 0 && (blocks_stack[-1] == 'try' || blocks_stack[-1] == 'catch')
|
||||
@@ -124,7 +124,7 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(bare\)\?module\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(bare\)\?module\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
if i == 0
|
||||
@@ -135,7 +135,7 @@ function GetJuliaNestingStruct(lnum, ...)
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(while\|for\|\%(staged\)\?function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\|immutable\|let\|quote\|do\)\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(while\|for\|\%(staged\)\?function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\|immutable\|let\|quote\|do\)\>', s)
|
||||
if i >= 0 && i == fb
|
||||
if match(line, '\C\<\%(mutable\|abstract\|primitive\)', i) != -1
|
||||
let s = i+11
|
||||
@@ -278,7 +278,7 @@ endfunction
|
||||
|
||||
function IsInDocString(lnum)
|
||||
let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")')
|
||||
call filter(stack, 'v:val =~# "\\<juliaDocString\\(Delim\\)\\?\\>"')
|
||||
call filter(stack, 'v:val =~# "\\<juliaDocString\\(Delim\\|M\\)\\?\\>"')
|
||||
return len(stack) > 0
|
||||
endfunction
|
||||
|
||||
|
||||
79
indent/mlir.vim
Normal file
79
indent/mlir.vim
Normal file
@@ -0,0 +1,79 @@
|
||||
if polyglot#init#is_disabled(expand('<sfile>:p'), 'llvm', 'indent/mlir.vim')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim indent file
|
||||
" Language: mlir
|
||||
" Maintainer: The MLIR team
|
||||
" Adapted from the LLVM vim indent file
|
||||
" What this indent plugin currently does:
|
||||
" - If no other rule matches copy indent from previous non-empty,
|
||||
" non-commented line.
|
||||
" - On '}' align the same as the line containing the matching '{'.
|
||||
" - If previous line starts with a block label, increase indentation.
|
||||
" - If the current line is a block label and ends with ':' indent at the same
|
||||
" level as the enclosing '{'/'}' block.
|
||||
" Stuff that would be nice to add:
|
||||
" - Continue comments on next line.
|
||||
" - If there is an opening+unclosed parenthesis on previous line indent to
|
||||
" that.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal shiftwidth=2 expandtab
|
||||
|
||||
setlocal indentkeys=0{,0},<:>,!^F,o,O,e
|
||||
setlocal indentexpr=GetMLIRIndent()
|
||||
|
||||
if exists("*GetMLIRIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! FindOpenBrace(lnum)
|
||||
call cursor(a:lnum, 1)
|
||||
return searchpair('{', '', '}', 'bW')
|
||||
endfun
|
||||
|
||||
function! GetMLIRIndent()
|
||||
" On '}' align the same as the line containing the matching '{'
|
||||
let thisline = getline(v:lnum)
|
||||
if thisline =~ '^\s*}'
|
||||
call cursor(v:lnum, 1)
|
||||
silent normal %
|
||||
let opening_lnum = line('.')
|
||||
if opening_lnum != v:lnum
|
||||
return indent(opening_lnum)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Indent labels the same as the current opening block
|
||||
if thisline =~ '\^\h\+.*:\s*$'
|
||||
let blockbegin = FindOpenBrace(v:lnum)
|
||||
if blockbegin > 0
|
||||
return indent(blockbegin)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Find a non-blank not-completely commented line above the current line.
|
||||
let prev_lnum = prevnonblank(v:lnum - 1)
|
||||
while prev_lnum > 0 && synIDattr(synID(prev_lnum, 1 + indent(prev_lnum), 0), "name") == "mlirComment"
|
||||
let prev_lnum = prevnonblank(prev_lnum-1)
|
||||
endwhile
|
||||
" Hit the start of the file, use zero indent.
|
||||
if prev_lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(prev_lnum)
|
||||
let prevline = getline(prev_lnum)
|
||||
|
||||
" Add a 'shiftwidth' after lines that start a function, block/labels, or a
|
||||
" region.
|
||||
if prevline =~ '{\s*$' || prevline =~ '\^\h\+.*:\s*$'
|
||||
let ind = ind + &shiftwidth
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
@@ -12,12 +12,6 @@ if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime! indent/html.vim
|
||||
unlet! b:did_indent
|
||||
|
||||
let s:html_indent = &l:indentexpr
|
||||
let b:did_indent = 1
|
||||
|
||||
if !exists('g:svelte_indent_script')
|
||||
let g:svelte_indent_script = 1
|
||||
endif
|
||||
@@ -26,6 +20,25 @@ if !exists('g:svelte_indent_style')
|
||||
let g:svelte_indent_style = 1
|
||||
endif
|
||||
|
||||
" Try to mirror Svelte's indent settings so the HTML indenting scripts match.
|
||||
if g:svelte_indent_script
|
||||
let b:html_indent_script1 = "inc"
|
||||
else
|
||||
let b:html_indent_script1 = "zero"
|
||||
endif
|
||||
|
||||
if g:svelte_indent_style
|
||||
let b:html_indent_style1 = "inc"
|
||||
else
|
||||
let b:html_indent_style1 = "zero"
|
||||
endif
|
||||
|
||||
runtime! indent/html.vim
|
||||
unlet! b:did_indent
|
||||
|
||||
let s:html_indent = &l:indentexpr
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetSvelteIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],!^F,;,=:else,=:then,=:catch,=/if,=/each,=/await
|
||||
|
||||
|
||||
Reference in New Issue
Block a user