From 14dc82fc4e6c0c08078f97a24a6c1639c1cc5113 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 14 Apr 2020 13:17:26 +0200 Subject: Update --- README.md | 2 +- after/ftplugin/javascript.vim | 4 +- after/ftplugin/llvm.vim | 26 +- after/ftplugin/tsx.vim | 4 +- after/indent/tsx.vim | 2 + after/syntax/javascript/graphql.vim | 2 +- after/syntax/typescript/graphql.vim | 2 +- autoload/cargo.vim | 16 ++ autoload/crystal/indent.vim | 371 ++++++++++++++++++++++++++ autoload/csv.vim | 4 + autoload/dart.vim | 12 +- autoload/ecrystal.vim | 34 +++ autoload/fish.vim | 2 +- autoload/go/config.vim | 20 ++ autoload/graphql.vim | 2 +- autoload/jsx_pretty/comment.vim | 16 +- autoload/rubycomplete.vim | 9 +- autoload/rust.vim | 33 ++- compiler/ocaml.vim | 3 +- compiler/powershell.vim | 15 +- compiler/rustc.vim | 2 +- ftdetect/polyglot.vim | 23 +- ftplugin/crystal.vim | 10 + ftplugin/ecrystal.vim | 100 +++++++ ftplugin/fish.vim | 1 - ftplugin/graphql.vim | 2 +- ftplugin/ps1.vim | 24 +- ftplugin/racket.vim | 2 - ftplugin/razor.vim | 20 -- ftplugin/rust.vim | 2 +- ftplugin/svelte.vim | 47 ++++ ftplugin/typescriptreact.vim | 4 + ftplugin/vala.vim | 2 +- indent/crystal.vim | 515 ++++++------------------------------ indent/cython.vim | 6 +- indent/dart.vim | 2 +- indent/ecrystal.vim | 489 ++++++++++++++++++++++++++++++++++ indent/graphql.vim | 2 +- indent/julia.vim | 14 +- indent/plantuml.vim | 2 +- indent/python.vim | 6 +- syntax/basic/function.vim | 2 +- syntax/crystal.vim | 151 ++++++----- syntax/dart.vim | 20 +- syntax/ecrystal.vim | 37 +++ syntax/elixir.vim | 5 + syntax/go.vim | 2 +- syntax/graphql.vim | 4 +- syntax/i3config.vim | 6 +- syntax/javascript.vim | 2 +- syntax/meson.vim | 2 +- syntax/plantuml.vim | 15 +- syntax/python.vim | 11 +- syntax/racket.vim | 3 +- syntax/razor.vim | 1 - syntax/tmux.vim | 43 +-- syntax/vifm.vim | 6 +- syntax/zig.vim | 7 +- 58 files changed, 1505 insertions(+), 666 deletions(-) create mode 100644 autoload/crystal/indent.vim create mode 100644 autoload/ecrystal.vim create mode 100644 ftplugin/ecrystal.vim create mode 100644 ftplugin/svelte.vim create mode 100644 indent/ecrystal.vim create mode 100644 syntax/ecrystal.vim diff --git a/README.md b/README.md index 74a13b30..539ff594 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ If you need full functionality of any plugin, please use it directly with your p - [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin) - [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin) - [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin) -- [svelte](https://github.com/evanleck/vim-svelte) (syntax, indent) +- [svelte](https://github.com/evanleck/vim-svelte) (syntax, indent, ftplugin) - [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent) - [svg](https://github.com/vim-scripts/svg.vim) (syntax) - [swift](https://github.com/keith/swift.vim) (syntax, indent, compiler, ftplugin, ctags) diff --git a/after/ftplugin/javascript.vim b/after/ftplugin/javascript.vim index 4c1549a8..663e2d8a 100644 --- a/after/ftplugin/javascript.vim +++ b/after/ftplugin/javascript.vim @@ -39,11 +39,11 @@ if exists("loaded_matchup") let b:match_skip = 's:comment\|string' endif -let b:original_commentstring = &l:commentstring +let b:jsx_pretty_old_cms = &l:commentstring augroup jsx_comment autocmd! CursorMoved - autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:original_commentstring) + autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:jsx_pretty_old_cms) augroup end setlocal suffixesadd+=.jsx diff --git a/after/ftplugin/llvm.vim b/after/ftplugin/llvm.vim index d67c94b5..fbd4b7ff 100644 --- a/after/ftplugin/llvm.vim +++ b/after/ftplugin/llvm.vim @@ -57,7 +57,7 @@ function! s:is_section_delim(line, func_delim) abort return 0 endif let kind = sec[0] - return kind == s:KIND_BLOCK_PREC || kind == s:KIND_BLOCK_FOLLOW || kind == func_delim + return kind == s:KIND_BLOCK_PREC || kind == s:KIND_BLOCK_FOLLOW || kind == a:func_delim endfunction function! s:next_section(stop_func_begin) abort @@ -85,11 +85,16 @@ function! s:prev_section(stop_func_begin) abort endwhile endfunction +nnoremap (llvm-next-section-begin) :call next_section(1) +nnoremap (llvm-prev-section-begin) :call prev_section(1) +nnoremap (llvm-next-section-end) :call next_section(0) +nnoremap (llvm-prev-section-end) :call prev_section(0) + if !g:llvm_ext_no_mapping - nnoremap ]] :call next_section(1) - nnoremap [[ :call prev_section(1) - nnoremap ][ :call next_section(0) - nnoremap [] :call prev_section(0) + nmap ]] (llvm-next-section-begin) + nmap [[ (llvm-prev-section-begin) + nmap ][ (llvm-next-section-end) + nmap [] (llvm-prev-section-end) endif function! s:function_range_at(linum) abort @@ -222,9 +227,12 @@ function! s:move_to_following_block() abort endtry endfunction +nnoremap (llvm-move-block-prev) :call move_to_pred_block() +nnoremap (llvm-move-block-next) :call move_to_following_block() + if !g:llvm_ext_no_mapping - nnoremap [b :call move_to_pred_block() - nnoremap ]b :call move_to_following_block() + nmap [b (llvm-move-block-prev) + nmap ]b (llvm-move-block-next) endif function! s:get_func_identifiers(line) abort @@ -438,8 +446,10 @@ function! s:goto_definition() abort echom "No definition for '" . ident . "' found" endfunction +nnoremap (llvm-goto-definition) :call goto_definition() + if !g:llvm_ext_no_mapping - nnoremap K :call goto_definition() + nmap K (llvm-goto-definition) endif function! s:run_lli(...) abort diff --git a/after/ftplugin/tsx.vim b/after/ftplugin/tsx.vim index e29d1e41..7cca61cf 100644 --- a/after/ftplugin/tsx.vim +++ b/after/ftplugin/tsx.vim @@ -20,11 +20,11 @@ if exists("loaded_matchup") let b:match_skip = 's:comment\|string' endif -let b:original_commentstring = &l:commentstring +let b:jsx_pretty_old_cms = &l:commentstring augroup jsx_comment autocmd! CursorMoved - autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:original_commentstring) + autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:jsx_pretty_old_cms) augroup end setlocal suffixesadd+=.tsx diff --git a/after/indent/tsx.vim b/after/indent/tsx.vim index dd8ee271..084cac57 100644 --- a/after/indent/tsx.vim +++ b/after/indent/tsx.vim @@ -25,6 +25,8 @@ if exists('s:did_indent') let b:did_indent = s:did_indent endif +runtime! indent/typescript.vim + setlocal indentexpr=GetJsxIndent() setlocal indentkeys=0.,0{,0},0),0],0?,0\*,0\,,!^F,:,<:>,o,O,e,<>>,=*/ diff --git a/after/syntax/javascript/graphql.vim b/after/syntax/javascript/graphql.vim index 1c5732ca..f085a301 100644 --- a/after/syntax/javascript/graphql.vim +++ b/after/syntax/javascript/graphql.vim @@ -1,6 +1,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 -" Copyright (c) 2016-2019 Jon Parise +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to diff --git a/after/syntax/typescript/graphql.vim b/after/syntax/typescript/graphql.vim index f30c4efd..30075e6d 100644 --- a/after/syntax/typescript/graphql.vim +++ b/after/syntax/typescript/graphql.vim @@ -1,6 +1,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 -" Copyright (c) 2016-2019 Jon Parise +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to diff --git a/autoload/cargo.vim b/autoload/cargo.vim index fefd28de..bd453ac7 100644 --- a/autoload/cargo.vim +++ b/autoload/cargo.vim @@ -102,6 +102,22 @@ function! cargo#bench(args) call cargo#cmd("bench " . a:args) endfunction +function! cargo#update(args) + call cargo#cmd("update " . a:args) +endfunction + +function! cargo#search(args) + call cargo#cmd("search " . a:args) +endfunction + +function! cargo#publish(args) + call cargo#cmd("publish " . a:args) +endfunction + +function! cargo#install(args) + call cargo#cmd("install " . a:args) +endfunction + function! cargo#runtarget(args) let l:filename = expand('%:p') let l:read_manifest = system('cargo read-manifest') diff --git a/autoload/crystal/indent.vim b/autoload/crystal/indent.vim new file mode 100644 index 00000000..dbf4c141 --- /dev/null +++ b/autoload/crystal/indent.vim @@ -0,0 +1,371 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + +" Variables {{{1 +" ========= + +" Regex of syntax group names that are strings or characters. +let g:crystal#indent#syng_string = + \ '\' +lockvar g:crystal#indent#syng_string + +" Regex of syntax group names that are strings, characters, symbols, +" regexps, or comments. +let g:crystal#indent#syng_strcom = + \ g:crystal#indent#syng_string.'\|' . + \ '\' +lockvar g:crystal#indent#syng_strcom + +" Expression used to check whether we should skip a match with searchpair(). +let g:crystal#indent#skip_expr = + \ 'synIDattr(synID(line("."), col("."), 1), "name") =~# "'.g:crystal#indent#syng_strcom.'"' +lockvar g:crystal#indent#skip_expr + +" Regex for the start of a line: +" start of line + whitespace + optional opening macro delimiter +let g:crystal#indent#sol = '^\s*\zs\%(\\\={%\s*\)\=' +lockvar g:crystal#indent#sol + +" Regex for the end of a line: +" whitespace + optional closing macro delimiter + whitespace + +" optional comment + end of line +let g:crystal#indent#eol = '\s*\%(%}\)\=\ze\s*\%(#.*\)\=$' +lockvar g:crystal#indent#eol + +" Regex that defines the start-match for the 'end' keyword. +" NOTE: This *should* properly match the 'do' only at the end of the +" line +let g:crystal#indent#end_start_regex = + \ g:crystal#indent#sol . + \ '\%(' . + \ '\%(\<\%(private\|protected\)\s\+\)\=' . + \ '\%(\<\%(abstract\s\+\)\=\%(class\|struct\)\>\|\<\%(def\|module\|macro\|lib\|enum\)\>\)' . + \ '\|' . + \ '\<\%(if\|unless\|while\|until\|case\|begin\|for\|union\)\>' . + \ '\)' . + \ '\|' . + \ '.\{-}\zs\' +lockvar g:crystal#indent#end_middle_regex + +" Regex that defines the end-match for the 'end' keyword. +let g:crystal#indent#end_end_regex = + \ g:crystal#indent#sol . + \ '\' +lockvar g:crystal#indent#end_end_regex + +" Regex used for words that add a level of indent. +let g:crystal#indent#crystal_indent_keywords = + \ g:crystal#indent#end_start_regex . + \ '\|' . + \ g:crystal#indent#end_middle_regex +lockvar g:crystal#indent#crystal_indent_keywords + +" Regex used for words that remove a level of indent. +let g:crystal#indent#crystal_deindent_keywords = + \ g:crystal#indent#end_middle_regex . + \ '\|' . + \ g:crystal#indent#end_end_regex +lockvar g:crystal#indent#crystal_deindent_keywords + +" Regex that defines a type declaration +let g:crystal#indent#crystal_type_declaration = + \ '@\=\h\k*\s\+:\s\+\S.*' +lockvar g:crystal#indent#crystal_type_declaration + +" Regex that defines continuation lines, not including (, {, or [. +let g:crystal#indent#non_bracket_continuation_regex = + \ '\%(' . + \ '[\\.,:/%+\-=~<>|&^]' . + \ '\|' . + \ '\W?' . + \ '\|' . + \ '\<\%(if\|unless\)\>' . + \ '\|' . + \ '\%('.g:crystal#indent#sol.g:crystal#indent#crystal_type_declaration.'\h\k*\)\@>\|:\s\)\s*\zs' . + \ '\<\%(if\|for\|while\|until\|unless\):\@!\>' +lockvar g:crystal#indent#continuable_regex + +" Regex that defines the first part of a splat pattern +let g:crystal#indent#splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$' +lockvar g:crystal#indent#splat_regex + +" Regex that defines blocks. +" +" Note that there's a slight problem with this regex and crystal#indent#continuation_regex. +" Code like this will be matched by both: +" +" method_call do |(a, b)| +" +" The reason is that the pipe matches a hanging "|" operator. +" +let g:crystal#indent#block_regex = + \ '\%(\\|%\@1' +endfunction + +" Find line above 'lnum' that isn't empty, in a comment, or in a string. +function! crystal#indent#PrevNonBlankNonString(lnum) abort + let lnum = prevnonblank(a:lnum) + + while lnum > 0 + let line = getline(lnum) + let start = match(line, '\S') + + if !crystal#indent#IsInStringOrComment(lnum, start + 1) + break + endif + + let lnum = prevnonblank(lnum - 1) + endwhile + + return lnum +endfunction + +" Find line above 'lnum' that started the continuation 'lnum' may be part of. +function! crystal#indent#GetMSL(lnum) abort + " Start on the line we're at and use its indent. + let msl = a:lnum + let msl_body = getline(msl) + let lnum = crystal#indent#PrevNonBlankNonString(a:lnum - 1) + + while lnum > 0 + " If we have a continuation line, or we're in a string, use line as MSL. + " Otherwise, terminate search as we have found our MSL already. + let line = getline(lnum) + + if crystal#indent#Match(msl, g:crystal#indent#leading_operator_regex) + " If the current line starts with a leading operator, keep its indent + " and keep looking for an MSL. + let msl = lnum + elseif crystal#indent#Match(lnum, g:crystal#indent#splat_regex) + " If the above line looks like the "*" of a splat, use the current one's + " indentation. + " + " Example: + " Hash[* + " method_call do + " something + " + return msl + elseif crystal#indent#Match(lnum, g:crystal#indent#non_bracket_continuation_regex) && + \ crystal#indent#Match(msl, g:crystal#indent#non_bracket_continuation_regex) + " If the current line is a non-bracket continuation and so is the + " previous one, keep its indent and continue looking for an MSL. + " + " Example: + " method_call one, + " two, + " three + " + let msl = lnum + elseif crystal#indent#Match(lnum, g:crystal#indent#non_bracket_continuation_regex) && + \ ( + \ crystal#indent#Match(msl, g:crystal#indent#bracket_continuation_regex) || + \ crystal#indent#Match(msl, g:crystal#indent#block_continuation_regex) + \ ) + " If the current line is a bracket continuation or a block-starter, but + " the previous is a non-bracket one, respect the previous' indentation, + " and stop here. + " + " Example: + " method_call one, + " two { + " three + " + return lnum + elseif crystal#indent#Match(lnum, g:crystal#indent#bracket_continuation_regex) && + \ ( + \ crystal#indent#Match(msl, g:crystal#indent#bracket_continuation_regex) || + \ crystal#indent#Match(msl, g:crystal#indent#block_continuation_regex) + \ ) + " If both lines are bracket continuations (the current may also be a + " block-starter), use the current one's and stop here + " + " Example: + " method_call( + " other_method_call( + " foo + return msl + elseif crystal#indent#Match(lnum, g:crystal#indent#block_regex) && + \ !crystal#indent#Match(msl, g:crystal#indent#continuation_regex) && + \ !crystal#indent#Match(msl, g:crystal#indent#block_continuation_regex) + " If the previous line is a block-starter and the current one is + " mostly ordinary, use the current one as the MSL. + " + " Example: + " method_call do + " something + " something_else + return msl + else + let col = match(line, g:crystal#indent#continuation_regex) + 1 + + if (col > 0 && !crystal#indent#IsInStringOrComment(lnum, col)) + \ || crystal#indent#IsInString(lnum, strlen(line)) + let msl = lnum + else + break + endif + endif + + let msl_body = getline(msl) + let lnum = crystal#indent#PrevNonBlankNonString(lnum - 1) + endwhile + + return msl +endfunction + +" Check if line 'lnum' has more opening brackets than closing ones. +function! crystal#indent#ExtraBrackets(lnum) abort + let opening = {'parentheses': [], 'braces': [], 'brackets': []} + let closing = {'parentheses': [], 'braces': [], 'brackets': []} + + let line = getline(a:lnum) + let pos = match(line, '[][(){}]', 0) + + " Save any encountered opening brackets, and remove them once a matching + " closing one has been found. If a closing bracket shows up that doesn't + " close anything, save it for later. + while pos != -1 + if !crystal#indent#IsInStringOrComment(a:lnum, pos + 1) + if line[pos] ==# '(' + call add(opening.parentheses, {'type': '(', 'pos': pos}) + elseif line[pos] ==# ')' + if empty(opening.parentheses) + call add(closing.parentheses, {'type': ')', 'pos': pos}) + else + let opening.parentheses = opening.parentheses[0:-2] + endif + elseif line[pos] ==# '{' + call add(opening.braces, {'type': '{', 'pos': pos}) + elseif line[pos] ==# '}' + if empty(opening.braces) + call add(closing.braces, {'type': '}', 'pos': pos}) + else + let opening.braces = opening.braces[0:-2] + endif + elseif line[pos] ==# '[' + call add(opening.brackets, {'type': '[', 'pos': pos}) + elseif line[pos] ==# ']' + if empty(opening.brackets) + call add(closing.brackets, {'type': ']', 'pos': pos}) + else + let opening.brackets = opening.brackets[0:-2] + endif + endif + endif + + let pos = match(line, '[][(){}]', pos + 1) + endwhile + + " Find the rightmost brackets, since they're the ones that are important in + " both opening and closing cases + let rightmost_opening = {'type': '(', 'pos': -1} + let rightmost_closing = {'type': ')', 'pos': -1} + + for opening in opening.parentheses + opening.braces + opening.brackets + if opening.pos > rightmost_opening.pos + let rightmost_opening = opening + endif + endfor + + for closing in closing.parentheses + closing.braces + closing.brackets + if closing.pos > rightmost_closing.pos + let rightmost_closing = closing + endif + endfor + + return [rightmost_opening, rightmost_closing] +endfunction + +function! crystal#indent#Match(lnum, regex) abort + let regex = '\C'.a:regex + + let line = getline(a:lnum) + let col = match(line, regex) + 1 + + while col && + \ crystal#indent#IsInStringOrComment(a:lnum, col) || + \ crystal#indent#IsInStringDelimiter(a:lnum, col) + let col = match(line, regex, col) + 1 + endwhile + + return col +endfunction + +" Locates the containing class/module/struct/enum/lib's definition line, +" ignoring nested classes along the way. +function! crystal#indent#FindContainingClass() abort + let saved_position = getcurpos() + + while searchpair( + \ g:crystal#indent#end_start_regex, + \ g:crystal#indent#end_middle_regex, + \ g:crystal#indent#end_end_regex, + \ 'bWz', + \ g:crystal#indent#skip_expr) > 0 + if expand('') =~# '\<\%(class\|module\|struct\|enum\|lib\)\>' + let found_lnum = line('.') + call setpos('.', saved_position) + return found_lnum + endif + endwhile + + call setpos('.', saved_position) + return 0 +endfunction + +endif diff --git a/autoload/csv.vim b/autoload/csv.vim index 5d63a24d..5926c59a 100644 --- a/autoload/csv.vim +++ b/autoload/csv.vim @@ -69,6 +69,10 @@ fu! csv#Init(start, end, ...) "{{{3 else let b:csv_cmt = split(g:csv_comment, '%s') endif + " Make sure it is a list with 2 chars + if b:csv_cmt == [] + let b:csv_cmt = ["", ""] + endif if empty(b:delimiter) && !exists("b:csv_fixed_width") call csv#Warn("No delimiter found. See :h csv-delimiter to set it manually!") diff --git a/autoload/dart.vim b/autoload/dart.vim index 3776da4e..367e54e4 100644 --- a/autoload/dart.vim +++ b/autoload/dart.vim @@ -86,7 +86,7 @@ endfunction " If the path cannot be resolved, or is not a package: uri, returns the " original. function! dart#resolveUri(uri) abort - if a:uri !~ 'package:' + if a:uri !~# 'package:' return a:uri endif let package_name = substitute(a:uri, 'package:\(\w\+\)\/.*', '\1', '') @@ -118,20 +118,20 @@ function! s:PackageMap() abort let lines = readfile(dot_packages) let map = {} for line in lines - if line =~ '\s*#' + if line =~# '\s*#' continue endif let package = substitute(line, ':.*$', '', '') let lib_dir = substitute(line, '^[^:]*:', '', '') - if lib_dir =~ 'file:/' + if lib_dir =~# 'file:/' let lib_dir = substitute(lib_dir, 'file://', '', '') - if lib_dir =~ '/[A-Z]:/' + if lib_dir =~# '/[A-Z]:/' let lib_dir = lib_dir[1:] endif else let lib_dir = resolve(dot_packages_dir.'/'.lib_dir) endif - if lib_dir =~ '/$' + if lib_dir =~# '/$' let lib_dir = lib_dir[:len(lib_dir) - 2] endif let map[package] = lib_dir @@ -141,7 +141,7 @@ endfunction " Toggle whether dartfmt is run on save or not. function! dart#ToggleFormatOnSave() abort - if get(g:, "dart_format_on_save", 0) + if get(g:, 'dart_format_on_save', 0) let g:dart_format_on_save = 0 return endif diff --git a/autoload/ecrystal.vim b/autoload/ecrystal.vim new file mode 100644 index 00000000..1a00b894 --- /dev/null +++ b/autoload/ecrystal.vim @@ -0,0 +1,34 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + +let s:ecrystal_extensions = { + \ 'cr': 'crystal', + \ 'yml': 'yaml', + \ 'js': 'javascript', + \ 'txt': 'text', + \ 'md': 'markdown' + \ } + +if exists('g:ecrystal_extensions') + call extend(s:ecrystal_extensions, g:ecrystal_extensions, 'force') +endif + +function! ecrystal#SetSubtype() abort + if exists('b:ecrystal_subtype') + return + endif + + let b:ecrystal_subtype = matchstr(substitute(expand('%:t'), '\c\%(\.ecr\)\+$', '', ''), '\.\zs\w\+\%(\ze+\w\+\)\=$') + + let b:ecrystal_subtype = get(s:ecrystal_extensions, b:ecrystal_subtype, b:ecrystal_subtype) + + if b:ecrystal_subtype ==# '' + let b:ecrystal_subtype = get(g:, 'ecrystal_default_subtype', 'html') + endif + + if b:ecrystal_subtype !=# '' + exec 'setlocal filetype=ecrystal.' . b:ecrystal_subtype + exec 'setlocal syntax=ecrystal.' . b:ecrystal_subtype + endif +endfunction + +endif diff --git a/autoload/fish.vim b/autoload/fish.vim index fcf10bd1..33b03e6b 100644 --- a/autoload/fish.vim +++ b/autoload/fish.vim @@ -54,7 +54,7 @@ function! fish#Complete(findstart, base) let l:completions = \ system('fish -c "complete -C'.shellescape(a:base).'"') let l:cmd = substitute(a:base, '\v\S+$', '', '') - for l:line in split(l:completions, '\n') + for l:line in filter(split(l:completions, '\n'), 'len(v:val)') let l:tokens = split(l:line, '\t') call add(l:results, {'word': l:cmd.l:tokens[0], \'abbr': l:tokens[0], diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 9599ebb0..a2df286f 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -309,6 +309,10 @@ function! go#config#FmtAutosave() abort return get(g:, "go_fmt_autosave", 1) endfunction +function! go#config#ImportsAutosave() abort + return get(g:, 'go_imports_autosave', 1) +endfunction + function! go#config#SetFmtAutosave(value) abort let g:go_fmt_autosave = a:value endfunction @@ -353,6 +357,10 @@ function! go#config#FmtCommand() abort return get(g:, "go_fmt_command", "gofmt") endfunction +function! go#config#ImportsMode() abort + return get(g:, "go_imports_mode", "goimports") +endfunction + function! go#config#FmtOptions() abort return get(b:, "go_fmt_options", get(g:, "go_fmt_options", {})) endfunction @@ -509,6 +517,10 @@ function! go#config#ReferrersMode() abort return get(g:, 'go_referrers_mode', 'gopls') endfunction +function! go#config#ImplementsMode() abort + return get(g:, 'go_implements_mode', 'guru') +endfunction + function! go#config#GoplsCompleteUnimported() abort return get(g:, 'go_gopls_complete_unimported', v:null) endfunction @@ -536,6 +548,14 @@ function! go#config#GoplsTempModfile() abort return get(g:, 'go_gopls_temp_modfile', v:null) endfunction +function! go#config#GoplsAnalyses() abort + return get(g:, 'go_gopls_analyses', v:null) +endfunction + +function! go#config#GoplsLocal() abort + return get(g:, 'go_gopls_local', v:null) +endfunction + function! go#config#GoplsEnabled() abort return get(g:, 'go_gopls_enabled', 1) endfunction diff --git a/autoload/graphql.vim b/autoload/graphql.vim index 820a83c3..5a0a8c54 100644 --- a/autoload/graphql.vim +++ b/autoload/graphql.vim @@ -1,6 +1,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 -" Copyright (c) 2016-2019 Jon Parise +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to diff --git a/autoload/jsx_pretty/comment.vim b/autoload/jsx_pretty/comment.vim index c202ebf4..98eab5e3 100644 --- a/autoload/jsx_pretty/comment.vim +++ b/autoload/jsx_pretty/comment.vim @@ -1,20 +1,20 @@ if !exists('g:polyglot_disabled') || !(index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1) function! jsx_pretty#comment#update_commentstring(original) - let syn_current = s:syn_name(line('.'), col('.')) - let syn_start = s:syn_name(line('.'), 1) + let line = getline(".") + let col = col('.') + if line !~# '^\s*$' && line[: col - 1] =~# '^\s*$' " skip indent + let col = indent('.') + 1 + endif + let syn_start = s:syn_name(line('.'), col) let save_cursor = getcurpos() if syn_start =~? '^jsx' - let line = getline(".") - let start = len(matchstr(line, '^\s*')) - let syn_name = s:syn_name(line('.'), start + 1) - if line =~ '^\s*//' let &l:commentstring = '// %s' - elseif s:syn_contains(line('.'), col('.'), 'jsxTaggedRegion') + elseif s:syn_contains(line('.'), col, 'jsxTaggedRegion') let &l:commentstring = '' - elseif syn_name =~? '^jsxAttrib' + elseif syn_start =~? '^jsxAttrib' let &l:commentstring = '// %s' else let &l:commentstring = '{/* %s */}' diff --git a/autoload/rubycomplete.vim b/autoload/rubycomplete.vim index 98f3b275..54b7e1b8 100644 --- a/autoload/rubycomplete.vim +++ b/autoload/rubycomplete.vim @@ -502,13 +502,8 @@ class VimRubyCompletion return if rails_base == nil $:.push rails_base unless $:.index( rails_base ) - rails_config = rails_base + "config/" - rails_lib = rails_base + "lib/" - $:.push rails_config unless $:.index( rails_config ) - $:.push rails_lib unless $:.index( rails_lib ) - - bootfile = rails_config + "boot.rb" - envfile = rails_config + "environment.rb" + bootfile = rails_base + "config/boot.rb" + envfile = rails_base + "config/environment.rb" if File.exists?( bootfile ) && File.exists?( envfile ) begin require bootfile diff --git a/autoload/rust.vim b/autoload/rust.vim index 8bb2b126..373be590 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -501,7 +501,15 @@ function! s:SearchTestFunctionNameUnderCursor() abort " Search the end of test function (closing brace) to ensure that the " cursor position is within function definition - normal! % + if maparg('(MatchitNormalForward)') ==# '' + normal! % + else + " Prefer matchit.vim official plugin to native % since the plugin + " provides better behavior than original % (#391) + " To load the plugin, run: + " :packadd matchit + execute 'normal' "\(MatchitNormalForward)" + endif if line('.') < cursor_line return '' endif @@ -543,21 +551,20 @@ function! rust#Test(mods, winsize, all, options) abort let saved = getpos('.') try let func_name = s:SearchTestFunctionNameUnderCursor() - if func_name ==# '' - echohl ErrorMsg - echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' - echohl None - return - endif - if a:options ==# '' - execute cmd . 'cargo test --manifest-path' manifest func_name - else - execute cmd . 'cargo test --manifest-path' manifest func_name a:options - endif - return finally call setpos('.', saved) endtry + if func_name ==# '' + echohl ErrorMsg + echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' + echohl None + return + endif + if a:options ==# '' + execute cmd . 'cargo test --manifest-path' manifest func_name + else + execute cmd . 'cargo test --manifest-path' manifest func_name a:options + endif endfunction " }}}1 diff --git a/compiler/ocaml.vim b/compiler/ocaml.vim index 0f64c8a0..c8fa745e 100644 --- a/compiler/ocaml.vim +++ b/compiler/ocaml.vim @@ -5,9 +5,9 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ocaml') == -1 " Maintainer: Markus Mottl " URL: http://www.ocaml.info/vim/compiler/ocaml.vim " Last Change: +" 2020 Mar 28 - Improved error format (Thomas Leonard) " 2017 Nov 26 - Improved error format (Markus Mottl) " 2013 Aug 27 - Added a new OCaml error format (Markus Mottl) -" 2013 Jun 30 - Initial version (Marc Weber) " " Marc Weber's comments: " Setting makeprg doesn't make sense, because there is ocamlc, ocamlopt, @@ -33,6 +33,7 @@ let s:cpo_save = &cpo set cpo&vim CompilerSet errorformat = + \%EFile\ \"%f\"\\,\ lines\ %*\\d-%l\\,\ characters\ %c-%*\\d:, \%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d:, \%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d\ %.%#, \%EFile\ \"%f\"\\,\ line\ %l\\,\ character\ %c:%m, diff --git a/compiler/powershell.vim b/compiler/powershell.vim index 4d9d76b0..1737a5a5 100644 --- a/compiler/powershell.vim +++ b/compiler/powershell.vim @@ -17,21 +17,28 @@ let s:cpo_save = &cpo set cpo-=C if !exists("g:ps1_makeprg_cmd") - if !has('win32') || executable('pwsh') + if executable('pwsh') " pwsh is the future let g:ps1_makeprg_cmd = 'pwsh' + elseif executable('pwsh.exe') + let g:ps1_makeprg_cmd = 'pwsh.exe' + elseif executable('powershell.exe') + let g:ps1_makeprg_cmd = 'powershell.exe' else - " powershell is Windows-only - let g:ps1_makeprg_cmd = 'powershell' + let g:ps1_makeprg_cmd = '' endif endif +if !executable(g:ps1_makeprg_cmd) + echoerr "To use the powershell compiler, please set g:ps1_makeprg_cmd to the powershell executable!" +endif + " Show CategoryInfo, FullyQualifiedErrorId, etc? let g:ps1_efm_show_error_categories = get(g:, 'ps1_efm_show_error_categories', 0) " Use absolute path because powershell requires explicit relative paths " (./file.ps1 is okay, but # expands to file.ps1) -let &l:makeprg = g:ps1_makeprg_cmd .' %:p' +let &l:makeprg = g:ps1_makeprg_cmd .' %:p:S' " Parse file, line, char from callstacks: " Write-Ouput : The term 'Write-Ouput' is not recognized as the name of a diff --git a/compiler/rustc.vim b/compiler/rustc.vim index 3c378850..14034ae4 100644 --- a/compiler/rustc.vim +++ b/compiler/rustc.vim @@ -26,7 +26,7 @@ else if has('patch-7.4.191') CompilerSet makeprg=rustc\ \%:S else - CompilerSet makeprg=rustc\ \% + CompilerSet makeprg=rustc\ \"%\" endif endif diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index ed39b7c9..5a10dfff 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -111,7 +111,7 @@ function! s:isAnsible() let filename = expand("%:t") if filepath =~ '\v/(tasks|roles|handlers)/.*\.ya?ml$' | return 1 | en if filepath =~ '\v/(group|host)_vars/' | return 1 | en - if filename =~ '\v(playbook|site|main|local)\.ya?ml$' | return 1 | en + if filename =~ '\v(playbook|site|main|local|requirements)\.ya?ml$' | return 1 | en let shebang = getline(1) if shebang =~# '^#!.*/bin/env\s\+ansible-playbook\>' | return 1 | en @@ -260,7 +260,14 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 " vint: -ProhibitAutocmdWithNoGroup autocmd BufNewFile,BufReadPost *.cr setlocal filetype=crystal autocmd BufNewFile,BufReadPost Projectfile setlocal filetype=crystal -autocmd BufNewFile,BufReadPost *.ecr setlocal filetype=eruby + augroup end +endif + +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + augroup filetypedetect + " crystal, from ecrystal.vim in rhysd/vim-crystal +" vint: -ProhibitAutocmdWithNoGroup +autocmd BufNewFile,BufReadPost *.ecr setlocal filetype=ecrystal augroup end endif @@ -290,16 +297,18 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dart') == -1 augroup filetypedetect " dart, from dart.vim in dart-lang/dart-vim-plugin -autocmd BufRead,BufNewFile *.dart set filetype=dart +augroup dart-vim-plugin-ftdetec + autocmd! + autocmd BufRead,BufNewFile *.dart set filetype=dart + autocmd BufRead * call s:DetectShebang() +augroup END function! s:DetectShebang() if did_filetype() | return | endif - if getline(1) == '#!/usr/bin/env dart' + if getline(1) ==# '#!/usr/bin/env dart' setlocal filetype=dart endif endfunction - -autocmd BufRead * call s:DetectShebang() augroup end endif @@ -522,7 +531,7 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 augroup filetypedetect " graphql, from graphql.vim in jparise/vim-graphql:_ALL -" Copyright (c) 2016-2019 Jon Parise +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to diff --git a/ftplugin/crystal.vim b/ftplugin/crystal.vim index c23d93f6..441e069f 100644 --- a/ftplugin/crystal.vim +++ b/ftplugin/crystal.vim @@ -5,6 +5,11 @@ if exists('b:did_ftplugin') endif let b:did_ftplugin = 1 +" This file is loaded on 'ecrystal' filetype +if &filetype !=# 'crystal' + finish +endif + let s:save_cpo = &cpo set cpo&vim @@ -76,6 +81,11 @@ if &l:ofu ==# '' setlocal omnifunc=crystal_lang#complete endif +if exists('AutoPairsLoaded') + let b:AutoPairs = { '{%': '%}' } + call extend(b:AutoPairs, g:AutoPairs, 'force') +endif + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/ftplugin/ecrystal.vim b/ftplugin/ecrystal.vim new file mode 100644 index 00000000..b8687853 --- /dev/null +++ b/ftplugin/ecrystal.vim @@ -0,0 +1,100 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + +if exists('b:did_ftplugin') + finish +endif + +" Define some defaults in case the included ftplugins don't set them. +let s:comments = '' +let s:shiftwidth = '' +let s:undo_ftplugin = '' +let s:browsefilter = 'All Files (*.*)\t*.*\n' +let s:match_words = '' + +call ecrystal#SetSubtype() + +if b:ecrystal_subtype !=# '' + exe 'runtime! ftplugin/'.b:ecrystal_subtype.'.vim ftplugin/'.b:ecrystal_subtype.'_*.vim ftplugin/'.b:ecrystal_subtype.'/*.vim' + unlet! b:did_ftplugin + + " Keep the comments for this filetype + let s:comments = escape(&comments, ' \') + + " Keep the shiftwidth for this filetype + let s:shiftwidth = &shiftwidth + + " Override our defaults if these were set by an included ftplugin. + if exists('b:undo_ftplugin') + let s:undo_ftplugin = b:undo_ftplugin + unlet b:undo_ftplugin + endif + if exists('b:browsefilter') + let s:browsefilter = b:browsefilter + unlet b:browsefilter + endif + if exists('b:match_words') + let s:match_words = b:match_words + unlet b:match_words + endif +endif + +runtime! ftplugin/crystal.vim ftplugin/crystal_*.vim ftplugin/crystal/*.vim +let b:did_ftplugin = 1 + +" Combine the new set of values with those previously included. +if exists('b:undo_ftplugin') + let s:undo_ftplugin = b:undo_ftplugin . ' | ' . s:undo_ftplugin +endif +if exists ('b:browsefilter') + let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter +endif +if exists('b:match_words') + let s:match_words = b:match_words . ',' . s:match_words +endif + +" Change the browse dialog on Win32 to show mainly eCrystal-related files +if has('gui_win32') + let b:browsefilter='eCrystal Files (*.ecr)\t*.ecr\n' . s:browsefilter +endif + +" Load the combined list of match_words for matchit.vim +if exists('loaded_matchit') + let b:match_words = s:match_words +endif + +" Define additional pairs for jiangmiao/auto-pairs +if exists('AutoPairsLoaded') + let b:AutoPairs = { + \ '<%': '%>', + \ '<%=': '%>', + \ '<%#': '%>', + \ '<%-': '-%>', + \ '<%-=': '-%>', + \ '<%-#': '-%>', + \ } + + call extend(b:AutoPairs, g:AutoPairs, 'force') +endif + +" Load the subtype's vim-endwise settings +if exists('loaded_endwise') && b:ecrystal_subtype !=# '' + exec 'doautocmd endwise FileType ' . b:ecrystal_subtype +endif + +" Start RagTag +if exists('loaded_ragtag') + call RagtagInit() +endif + +exec 'setlocal comments='.s:comments +exec 'setlocal shiftwidth='.s:shiftwidth +setlocal commentstring=<%#%s%> + +setlocal suffixesadd=.ecr + +let b:undo_ftplugin = 'setlocal comments< commentstring< shiftwidth<' . + \ '| unlet! b:browsefilter b:match_words ' . + \ '| unlet! b:AutoPairs ' . + \ '| ' . s:undo_ftplugin + +endif diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim index 7ba9c927..393b84e4 100644 --- a/ftplugin/fish.vim +++ b/ftplugin/fish.vim @@ -7,7 +7,6 @@ setlocal foldexpr=fish#Fold() setlocal formatoptions+=ron1 setlocal formatoptions-=t setlocal include=\\v^\\s*\\.> -setlocal iskeyword=@,48-57,-,_,.,/ setlocal suffixesadd^=.fish " Use the 'j' format option when available. diff --git a/ftplugin/graphql.vim b/ftplugin/graphql.vim index df6004fb..524be44c 100644 --- a/ftplugin/graphql.vim +++ b/ftplugin/graphql.vim @@ -1,6 +1,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 -" Copyright (c) 2016-2019 Jon Parise +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to diff --git a/ftplugin/ps1.vim b/ftplugin/ps1.vim index 4baa4665..f14a31eb 100644 --- a/ftplugin/ps1.vim +++ b/ftplugin/ps1.vim @@ -30,8 +30,30 @@ if has("gui_win32") \ "All Files (*.*)\t*.*\n" endif +" Look up keywords by Get-Help: +" check for PowerShell Core in Windows, Linux or MacOS +if executable('pwsh') | let s:pwsh_cmd = 'pwsh' + " on Windows Subsystem for Linux, check for PowerShell Core in Windows +elseif exists('$WSLENV') && executable('pwsh.exe') | let s:pwsh_cmd = 'pwsh.exe' + " check for PowerShell <= 5.1 in Windows +elseif executable('powershell.exe') | let s:pwsh_cmd = 'powershell.exe' +endif + +if exists('s:pwsh_cmd') + if !has('gui_running') && executable('less') && + \ !(exists('$ConEmuBuild') && &term =~? '^xterm') + " For exclusion of ConEmu, see https://github.com/Maximus5/ConEmu/issues/2048 + command! -buffer -nargs=1 GetHelp silent exe '!' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full "" | ' . (has('unix') ? 'LESS= less' : 'less') | redraw! + elseif has('terminal') + command! -buffer -nargs=1 GetHelp silent exe 'term ' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full ""' . (executable('less') ? ' | less' : '') + else + command! -buffer -nargs=1 GetHelp echo system(s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full ') + endif +endif +setlocal keywordprg=:GetHelp + " Undo the stuff we changed -let b:undo_ftplugin = "setlocal tw< cms< fo<" . +let b:undo_ftplugin = "setlocal tw< cms< fo< iskeyword< keywordprg<" . \ " | unlet! b:browsefilter" diff --git a/ftplugin/racket.vim b/ftplugin/racket.vim index ccdcdef4..89990061 100644 --- a/ftplugin/racket.vim +++ b/ftplugin/racket.vim @@ -55,8 +55,6 @@ endfunction vnoremap K :call Racket_visual_doc() -nnoremap :!racket -t % - "setl commentstring=;;%s setl commentstring=#\|\ %s\ \|# diff --git a/ftplugin/razor.vim b/ftplugin/razor.vim index 76348dd0..2d516bfc 100644 --- a/ftplugin/razor.vim +++ b/ftplugin/razor.vim @@ -1,30 +1,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'razor') == -1 -" Vim filetype plugin -" Language: LessCSS -" Author: Tim Pope -" Maintainer: Leonard Ehrenfried -" Last Change: 2011 Sep 30 - -" Only do this when not done yet for this buffer -:UltiSnipsAddFiletypes razor.html - if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 -"let b:undo_ftplugin = "setl cms< def< inc< inex< ofu< sua<" - -"setlocal iskeyword+=- -"setlocal commentstring=//\ %s -"setlocal define=^\\s*\\%(@mixin\\\|=\\) -"setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','') -"setlocal omnifunc=csscomplete#CompleteCSS -"setlocal suffixesadd=.less - -"let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\=' - " vim:set sw=2: endif diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim index dab5d5ab..211f86b0 100644 --- a/ftplugin/rust.vim +++ b/ftplugin/rust.vim @@ -123,7 +123,7 @@ command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", ) command! -range=% RustPlay :call rust#Play(, , , ) " See |:RustFmt| for docs -command! -buffer RustFmt call rustfmt#Format() +command! -bar -buffer RustFmt call rustfmt#Format() " See |:RustFmtRange| for docs command! -range -buffer RustFmtRange call rustfmt#FormatRange(, ) diff --git a/ftplugin/svelte.vim b/ftplugin/svelte.vim new file mode 100644 index 00000000..3c3df23a --- /dev/null +++ b/ftplugin/svelte.vim @@ -0,0 +1,47 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1 + +" Vim filetype plugin +" Language: Svelte 3 (HTML/JavaScript) +" Author: Evan Lecklider +" Maintainer: Evan Lecklide +" URL: https://github.com/evanleck/vim-svelte +if (exists('b:did_ftplugin')) + finish +endif +let b:did_ftplugin = 1 + +" Matchit support +if exists('loaded_matchit') && !exists('b:match_words') + let b:match_ignorecase = 0 + + " In order: + " + " 1. Svelte control flow keywords. + " 2. Parens. + " 3-5. HTML tags pulled from Vim itself. + " + " https://github.com/vim/vim/blob/5259275347667a90fb88d8ea74331f88ad68edfc/runtime/ftplugin/html.vim#L29-L35 + let b:match_words = + \ '#\%(if\|await\|each\)\>:\:\%(else\|catch\|then\)\>:\/\%(if\|await\|each\)\>,' . + \ '{:},' . + \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . + \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' . + \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' +endif + +" ALE fixing and linting. +if exists('g:loaded_ale') + if !exists('b:ale_fixers') + let b:ale_fixers = ['eslint', 'prettier', 'prettier_standard'] + endif + + if !exists('b:ale_linter_aliases') + let b:ale_linter_aliases = ['css', 'javascript'] + endif + + if !exists('b:ale_linters') + let b:ale_linters = ['stylelint', 'eslint'] + endif +endif + +endif diff --git a/ftplugin/typescriptreact.vim b/ftplugin/typescriptreact.vim index 8a6bb9b5..6b8380f7 100644 --- a/ftplugin/typescriptreact.vim +++ b/ftplugin/typescriptreact.vim @@ -10,6 +10,10 @@ if exists("loaded_matchit") && !exists('b:tsx_match_words') \ : b:tsx_match_words endif +" Comment formatting +setlocal comments=s1:/*,mb:*,ex:*/,:// +setlocal formatoptions-=t formatoptions+=croql + set suffixesadd+=.tsx endif diff --git a/ftplugin/vala.vim b/ftplugin/vala.vim index ef433a26..00eefd1d 100644 --- a/ftplugin/vala.vim +++ b/ftplugin/vala.vim @@ -37,7 +37,7 @@ endfunction command! -buffer -bar CCode call CCode() command! -buffer -bar ValaCodingStyle call ValaCodingStyle() -if get(g:, 'vala_syntax_folding_enabled', 1) +if get(g:, 'vala_syntax_folding_enabled', 0) setlocal foldmethod=syntax endif diff --git a/indent/crystal.vim b/indent/crystal.vim index 74b5cc10..66eeef42 100644 --- a/indent/crystal.vim +++ b/indent/crystal.vim @@ -6,431 +6,78 @@ if exists('b:did_indent') endif let b:did_indent = 1 -if !exists('g:crystal_indent_access_modifier_style') - " Possible values: "normal", "indent", "outdent" - let g:crystal_indent_access_modifier_style = 'normal' -endif - setlocal nosmartindent " Now, set up our indentation expression and keys that trigger it. setlocal indentexpr=GetCrystalIndent(v:lnum) setlocal indentkeys=0{,0},0),0],!^F,o,O,e,:,. -setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end +setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue setlocal indentkeys+==private,=protected +let s:cpo_save = &cpo +set cpo&vim + " Only define the function once. if exists('*GetCrystalIndent') finish endif -let s:cpo_save = &cpo -set cpo&vim - -" 1. Variables {{{1 -" ============ - -" Regex of syntax group names that are or delimit strings/symbols or are comments. -let s:syng_strcom = '\' - -" Regex of syntax group names that are strings. -let s:syng_string = - \ '\' - -" Regex of syntax group names that are strings or documentation. -let s:syng_stringdoc = - \'\' - -" Expression used to check whether we should skip a match with searchpair(). -let s:skip_expr = - \ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" - -" Regex used for words that, at the start of a line, add a level of indent. -let s:crystal_indent_keywords = - \ '^\s*\zs\<\%(\%(\%(private\|protected\)\s\+\)\=\%(abstract\s\+\)\=\%(class\|struct\)' . - \ '\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\|union' . - \ '\|\%(private\|protected\)\=\s*\%(def\|class\|struct\|module\|macro\|lib\|enum\)\):\@!\>' . - \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . - \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' . - \ '\|{%\s*\<\%(if\|for\|while\|until\|case\|unless\|begin\|else\|elsif\|when\)' - -" Regex used for words that, at the start of a line, remove a level of indent. -let s:crystal_deindent_keywords = - \ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>' . - \ '\|{%\s*\<\%(ensure\|else\|rescue\|elsif\|when\|end\)\>' - -" Regex that defines the start-match for the 'end' keyword. -" TODO: the do here should be restricted somewhat (only at end of line)? -let s:end_start_regex = - \ '{%\s*\<\%(if\|for\|while\|until\|unless\|begin\)\>\|' . - \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . - \ '\<\%(\%(\%(private\|protected\)\s\+\)\=\%(abstract\s\+\)\=\%(class\|struct\)' . - \ '\|if\|for\|while\|until\|case\|unless\|begin\|union' . - \ '\|\%(private\|protected\)\=\s*\%(def\|lib\|enum\|macro\|module\)\):\@!\>' . - \ '\|\%(^\|[^.:@$]\)\@<=\' - -" Regex that defines the middle-match for the 'end' keyword. -let s:end_middle_regex = - \ '{%\s*\<\%(ensure\|else\|when\|elsif\)\>\s*%}\|' . - \ '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\\|when\|elsif\):\@!\>' - -" Regex that defines the end-match for the 'end' keyword. -let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\\|{%\s*\<\%(end\)\>' - -" Expression used for searchpair() call for finding match for 'end' keyword. -let s:end_skip_expr = s:skip_expr . - \ ' || (expand("") == "do"' . - \ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")' - -" Regex that defines continuation lines, not including (, {, or [. -let s:non_bracket_continuation_regex = '\%([\\.,:*/%+]\|\>\|:\s\)\s*\zs' . - \ '\<\%(if\|for\|while\|until\|unless\):\@!\>' - -" Regex that defines bracket continuations -let s:bracket_continuation_regex = '%\@\|%\@ 0 - " Go in and out of blocks comments as necessary. - " If the line isn't empty (with opt. comment) or in a string, end search. - let line = getline(lnum) - if line =~# '^=begin' - if in_block - let in_block = 0 - else - break - endif - elseif !in_block && line =~# '^=end' - let in_block = 1 - elseif !in_block && line !~# '^\s*#.*$' && !(s:IsInStringOrComment(lnum, 1) - \ && s:IsInStringOrComment(lnum, strlen(line))) - break - endif - let lnum = prevnonblank(lnum - 1) - endwhile - return lnum -endfunction - -" Find line above 'lnum' that started the continuation 'lnum' may be part of. -function s:GetMSL(lnum) - " Start on the line we're at and use its indent. - let msl = a:lnum - let msl_body = getline(msl) - let lnum = s:PrevNonBlankNonString(a:lnum - 1) - while lnum > 0 - " If we have a continuation line, or we're in a string, use line as MSL. - " Otherwise, terminate search as we have found our MSL already. - let line = getline(lnum) - - if s:Match(msl, s:leading_operator_regex) - " If the current line starts with a leading operator, keep its indent - " and keep looking for an MSL. - let msl = lnum - elseif s:Match(lnum, s:splat_regex) - " If the above line looks like the "*" of a splat, use the current one's - " indentation. - " - " Example: - " Hash[* - " method_call do - " something - " - return msl - elseif s:Match(lnum, s:non_bracket_continuation_regex) && - \ s:Match(msl, s:non_bracket_continuation_regex) - " If the current line is a non-bracket continuation and so is the - " previous one, keep its indent and continue looking for an MSL. - " - " Example: - " method_call one, - " two, - " three - " - let msl = lnum - elseif s:Match(lnum, s:non_bracket_continuation_regex) && - \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) - " If the current line is a bracket continuation or a block-starter, but - " the previous is a non-bracket one, respect the previous' indentation, - " and stop here. - " - " Example: - " method_call one, - " two { - " three - " - return lnum - elseif s:Match(lnum, s:bracket_continuation_regex) && - \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) - " If both lines are bracket continuations (the current may also be a - " block-starter), use the current one's and stop here - " - " Example: - " method_call( - " other_method_call( - " foo - return msl - elseif s:Match(lnum, s:block_regex) && - \ !s:Match(msl, s:continuation_regex) && - \ !s:Match(msl, s:block_continuation_regex) - " If the previous line is a block-starter and the current one is - " mostly ordinary, use the current one as the MSL. - " - " Example: - " method_call do - " something - " something_else - return msl - else - let col = match(line, s:continuation_regex) + 1 - if (col > 0 && !s:IsInStringOrComment(lnum, col)) - \ || s:IsInString(lnum, strlen(line)) - let msl = lnum - else - break - endif - endif - - let msl_body = getline(msl) - let lnum = s:PrevNonBlankNonString(lnum - 1) - endwhile - return msl -endfunction - -" Check if line 'lnum' has more opening brackets than closing ones. -function s:ExtraBrackets(lnum) - let opening = {'parentheses': [], 'braces': [], 'brackets': []} - let closing = {'parentheses': [], 'braces': [], 'brackets': []} - - let line = getline(a:lnum) - let pos = match(line, '[][(){}]', 0) - - " Save any encountered opening brackets, and remove them once a matching - " closing one has been found. If a closing bracket shows up that doesn't - " close anything, save it for later. - while pos != -1 - if !s:IsInStringOrComment(a:lnum, pos + 1) - if line[pos] ==# '(' - call add(opening.parentheses, {'type': '(', 'pos': pos}) - elseif line[pos] ==# ')' - if empty(opening.parentheses) - call add(closing.parentheses, {'type': ')', 'pos': pos}) - else - let opening.parentheses = opening.parentheses[0:-2] - endif - elseif line[pos] ==# '{' - call add(opening.braces, {'type': '{', 'pos': pos}) - elseif line[pos] ==# '}' - if empty(opening.braces) - call add(closing.braces, {'type': '}', 'pos': pos}) - else - let opening.braces = opening.braces[0:-2] - endif - elseif line[pos] ==# '[' - call add(opening.brackets, {'type': '[', 'pos': pos}) - elseif line[pos] ==# ']' - if empty(opening.brackets) - call add(closing.brackets, {'type': ']', 'pos': pos}) - else - let opening.brackets = opening.brackets[0:-2] - endif - endif - endif - - let pos = match(line, '[][(){}]', pos + 1) - endwhile - - " Find the rightmost brackets, since they're the ones that are important in - " both opening and closing cases - let rightmost_opening = {'type': '(', 'pos': -1} - let rightmost_closing = {'type': ')', 'pos': -1} - - for opening in opening.parentheses + opening.braces + opening.brackets - if opening.pos > rightmost_opening.pos - let rightmost_opening = opening - endif - endfor - - for closing in closing.parentheses + closing.braces + closing.brackets - if closing.pos > rightmost_closing.pos - let rightmost_closing = closing - endif - endfor - - return [rightmost_opening, rightmost_closing] -endfunction - -function s:Match(lnum, regex) - let line = getline(a:lnum) - let offset = match(line, '\C'.a:regex) - let col = offset + 1 - - while offset > -1 && s:IsInStringOrComment(a:lnum, col) - let offset = match(line, '\C'.a:regex, offset + 1) - let col = offset + 1 - endwhile - - if offset > -1 - return col - else - return 0 - endif -endfunction - -" Locates the containing class/module's definition line, ignoring nested classes -" along the way. -" -function! s:FindContainingClass() - let saved_position = getpos('.') - - while searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW', - \ s:end_skip_expr) > 0 - if expand('') =~# '\' - let found_lnum = line('.') - call setpos('.', saved_position) - return found_lnum - endif - endwhile - - call setpos('.', saved_position) - return 0 -endfunction +" Return the value of a single shift-width +if exists('*shiftwidth') + let s:sw = function('shiftwidth') +else + function s:sw() + return &shiftwidth + endfunction +endif -" 3. GetCrystalIndent Function {{{1 +" GetCrystalIndent Function {{{1 " ========================= function GetCrystalIndent(...) - " 3.1. Setup {{{2 - " ---------- - - " The value of a single shift-width - if exists('*shiftwidth') - let sw = shiftwidth() - else - let sw = &sw - endif + " Setup {{{2 + " ----- " For the current line, use the first argument if given, else v:lnum let clnum = a:0 ? a:1 : v:lnum - " Set up variables for restoring position in file. Could use clnum here. - let vcol = col('.') + " Set up variables for restoring position in file + let vcol = col(clnum) - " 3.2. Work on the current line {{{2 - " ----------------------------- + " Work on the current line {{{2 + " ------------------------ " Get the current line. let line = getline(clnum) let ind = -1 - " If this line is an access modifier keyword, align according to the closest - " class declaration. - if g:crystal_indent_access_modifier_style ==? 'indent' - if s:Match(clnum, s:access_modifier_regex) - let class_line = s:FindContainingClass() - if class_line > 0 - return indent(class_line) + sw - endif - endif - elseif g:crystal_indent_access_modifier_style ==? 'outdent' - if s:Match(clnum, s:access_modifier_regex) - let class_line = s:FindContainingClass() - if class_line > 0 - return indent(class_line) - endif - endif - endif - " If we got a closing bracket on an empty line, find its match and indent " according to it. For parentheses we indent to its column - 1, for the " others we indent to the containing line's MSL's level. Return -1 if fail. let col = matchend(line, '^\s*[]})]') - if col > 0 && !s:IsInStringOrComment(clnum, col) + if col > 0 && !crystal#indent#IsInStringOrComment(clnum, col) call cursor(clnum, col) let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2) - if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0 + if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', g:crystal#indent#skip_expr) if line[col-1] ==# ')' && col('.') != col('$') - 1 let ind = virtcol('.') - 1 else - let ind = indent(s:GetMSL(line('.'))) + let ind = indent(crystal#indent#GetMSL(line('.'))) endif endif return ind endif - " If we have a =begin or =end set indent to first column. - if match(line, '^\s*\%(=begin\|=end\)$') != -1 - return 0 - endif - " If we have a deindenting keyword, find its match and indent to its level. " TODO: this is messy - if s:Match(clnum, s:crystal_deindent_keywords) + if crystal#indent#Match(clnum, g:crystal#indent#crystal_deindent_keywords) call cursor(clnum, 1) - if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW', - \ s:end_skip_expr) > 0 - let msl = s:GetMSL(line('.')) + if searchpair( + \ g:crystal#indent#end_start_regex, + \ g:crystal#indent#end_middle_regex, + \ g:crystal#indent#end_end_regex, + \ 'bW', g:crystal#indent#skip_expr) + let msl = crystal#indent#GetMSL(line('.')) let line = getline(line('.')) if strpart(line, 0, col('.') - 1) =~# '=\s*$' && @@ -449,29 +96,29 @@ function GetCrystalIndent(...) return ind endif - " If we are in a multi-line string or line-comment, don't do anything to it. - if s:IsInStringOrDocumentation(clnum, matchend(line, '^\s*') + 1) + " If we are in a multi-line string, don't do anything to it. + if crystal#indent#IsInString(clnum, matchend(line, '^\s*') + 1) return indent('.') endif " If we are at the closing delimiter of a "<<" heredoc-style string, set the " indent to 0. if line =~# '^\k\+\s*$' - \ && s:IsInStringDelimiter(clnum, 1) - \ && search('\V<<'.line, 'nbW') > 0 + \ && crystal#indent#IsInStringDelimiter(clnum, 1) + \ && search('\V<<'.line, 'nbW') return 0 endif " If the current line starts with a leading operator, add a level of indent. - if s:Match(clnum, s:leading_operator_regex) - return indent(s:GetMSL(clnum)) + sw + if crystal#indent#Match(clnum, g:crystal#indent#leading_operator_regex) + return indent(crystal#indent#GetMSL(clnum)) + s:sw() endif - " 3.3. Work on the previous line. {{{2 - " ------------------------------- + " Work on the previous line. {{{2 + " -------------------------- " Find a non-blank, non-multi-line string line above the current line. - let lnum = s:PrevNonBlankNonString(clnum - 1) + let lnum = crystal#indent#PrevNonBlankNonString(clnum - 1) " If the line is empty and inside a string, use the previous line. if line =~# '^\s*$' && lnum != prevnonblank(clnum - 1) @@ -487,33 +134,34 @@ function GetCrystalIndent(...) let line = getline(lnum) let ind = indent(lnum) - if s:Match(lnum, s:continuable_regex) && s:Match(lnum, s:continuation_regex) - return indent(s:GetMSL(lnum)) + sw + sw + if crystal#indent#Match(lnum, g:crystal#indent#continuable_regex) && + \ crystal#indent#Match(lnum, g:crystal#indent#continuation_regex) + return indent(crystal#indent#GetMSL(lnum)) + s:sw() * 2 endif " If the previous line ended with a block opening, add a level of indent. - if s:Match(lnum, s:block_regex) - let msl = s:GetMSL(lnum) + if crystal#indent#Match(lnum, g:crystal#indent#block_regex) + let msl = crystal#indent#GetMSL(lnum) if getline(msl) =~# '=\s*\(#.*\)\=$' " in the case of assignment to the msl, align to the starting line, " not to the msl - let ind = indent(lnum) + sw + let ind = indent(lnum) + s:sw() else - let ind = indent(msl) + sw + let ind = indent(msl) + s:sw() endif return ind endif " If the previous line started with a leading operator, use its MSL's level " of indent - if s:Match(lnum, s:leading_operator_regex) - return indent(s:GetMSL(lnum)) + if crystal#indent#Match(lnum, g:crystal#indent#leading_operator_regex) + return indent(crystal#indent#GetMSL(lnum)) endif " If the previous line ended with the "*" of a splat, add a level of indent - if line =~ s:splat_regex - return indent(lnum) + sw + if line =~ g:crystal#indent#splat_regex + return indent(lnum) + s:sw() endif " If the previous line contained unclosed opening brackets and we are still @@ -523,25 +171,25 @@ function GetCrystalIndent(...) " If it contained hanging closing brackets, find the rightmost one, find its " match and indent according to that. if line =~# '[[({]' || line =~# '[])}]\s*\%(#.*\)\=$' - let [opening, closing] = s:ExtraBrackets(lnum) + let [opening, closing] = crystal#indent#ExtraBrackets(lnum) if opening.pos != -1 - if opening.type ==# '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 + if opening.type ==# '(' && searchpair('(', '', ')', 'bW', g:crystal#indent#skip_expr) if col('.') + 1 == col('$') - return ind + sw + return ind + s:sw() else return virtcol('.') endif else let nonspace = matchend(line, '\S', opening.pos + 1) - 1 - return nonspace > 0 ? nonspace : ind + sw + return nonspace > 0 ? nonspace : ind + s:sw() endif elseif closing.pos != -1 call cursor(lnum, closing.pos + 1) normal! % - if s:Match(line('.'), s:crystal_indent_keywords) - return indent('.') + sw + if crystal#indent#Match(line('.'), g:crystal#indent#crystal_indent_keywords) + return indent('.') + s:sw() else return indent('.') endif @@ -552,14 +200,18 @@ function GetCrystalIndent(...) " If the previous line ended with an "end", match that "end"s beginning's " indent. - let col = s:Match(lnum, '\%(^\|[^.:@$]\)\\s*\%(#.*\)\=$') - if col > 0 + let col = crystal#indent#Match(lnum, g:crystal#indent#end_end_regex) + if col call cursor(lnum, col) - if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW', - \ s:end_skip_expr) > 0 + if searchpair( + \ g:crystal#indent#end_start_regex, + \ g:crystal#indent#end_middle_regex, + \ g:crystal#indent#end_end_regex, + \ 'bW', + \ g:crystal#indent#skip_expr) let n = line('.') let ind = indent('.') - let msl = s:GetMSL(n) + let msl = crystal#indent#GetMSL(n) if msl != n let ind = indent(msl) end @@ -567,34 +219,35 @@ function GetCrystalIndent(...) endif end - let col = s:Match(lnum, s:crystal_indent_keywords) - if col > 0 + let col = crystal#indent#Match(lnum, g:crystal#indent#crystal_indent_keywords) + if col call cursor(lnum, col) - let ind = virtcol('.') - 1 + sw + let ind = virtcol('.') - 1 + s:sw() " TODO: make this better (we need to count them) (or, if a searchpair " fails, we know that something is lacking an end and thus we indent a " level - if s:Match(lnum, s:end_end_regex) + if crystal#indent#Match(lnum, g:crystal#indent#end_end_regex) let ind = indent('.') endif return ind endif - " 3.4. Work on the MSL line. {{{2 - " -------------------------- + " Work on the MSL line. {{{2 + " --------------------- " Set up variables to use and search for MSL to the previous line. let p_lnum = lnum - let lnum = s:GetMSL(lnum) + let lnum = crystal#indent#GetMSL(lnum) " If the previous line wasn't a MSL. if p_lnum != lnum " If previous line ends bracket and begins non-bracket continuation decrease indent by 1. - if s:Match(p_lnum, s:bracket_switch_continuation_regex) + if crystal#indent#Match(p_lnum, g:crystal#indent#bracket_switch_continuation_regex) return ind - 1 " If previous line is a continuation return its indent. - " TODO: the || s:IsInString() thing worries me a bit. - elseif s:Match(p_lnum, s:non_bracket_continuation_regex) || s:IsInString(p_lnum,strlen(line)) + " TODO: the || crystal#indent#IsInString() thing worries me a bit. + elseif crystal#indent#Match(p_lnum, g:crystal#indent#non_bracket_continuation_regex) || + \ crystal#indent#IsInString(p_lnum,strlen(line)) return ind endif endif @@ -606,19 +259,21 @@ function GetCrystalIndent(...) " If the MSL line had an indenting keyword in it, add a level of indent. " TODO: this does not take into account contrived things such as " module Foo; class Bar; end - if s:Match(lnum, s:crystal_indent_keywords) - let ind = msl_ind + sw - if s:Match(lnum, s:end_end_regex) - let ind = ind - sw + if crystal#indent#Match(lnum, g:crystal#indent#crystal_indent_keywords) + let ind = msl_ind + s:sw() + if crystal#indent#Match(lnum, g:crystal#indent#end_end_regex) + let ind = ind - s:sw() endif return ind endif - " If the previous line ended with [*+/.,-=], but wasn't a block ending or a - " closing bracket, indent one extra level. - if s:Match(lnum, s:non_bracket_continuation_regex) && !s:Match(lnum, '^\s*\([\])}]\|end\)') + " If the previous line ended with an operator -- but wasn't a block + " ending, closing bracket, or type declaration -- indent one extra + " level. + if crystal#indent#Match(lnum, g:crystal#indent#non_bracket_continuation_regex) && + \ !crystal#indent#Match(lnum, '^\s*\([\])}]\|end\)') if lnum == p_lnum - let ind = msl_ind + sw + let ind = msl_ind + s:sw() else let ind = msl_ind endif diff --git a/indent/cython.vim b/indent/cython.vim index 475bbf40..156833d4 100644 --- a/indent/cython.vim +++ b/indent/cython.vim @@ -160,8 +160,8 @@ function! s:find_start_of_block(lnum, types, skip, multiple) abort else let re_skip = '' endif - let lnum = a:lnum - let last_indent = indent(lnum) + 1 + let last_indent = indent(a:lnum) + 1 + let lnum = a:lnum - 1 while lnum > 0 && last_indent > 0 let indent = indent(lnum) if indent < last_indent @@ -262,7 +262,7 @@ function! s:indent_like_block(lnum) endif let [blocks, skip] = blocks_ignore - let indents = s:find_start_of_block(a:lnum - 1, blocks, skip, multiple) + let indents = s:find_start_of_block(a:lnum, blocks, skip, multiple) if empty(indents) return -1 endif diff --git a/indent/dart.vim b/indent/dart.vim index ea3bdcc3..7599de4d 100644 --- a/indent/dart.vim +++ b/indent/dart.vim @@ -12,7 +12,7 @@ setlocal indentexpr=DartIndent() let b:undo_indent = 'setl cin< cino<' -if exists("*DartIndent") +if exists('*DartIndent') finish endif diff --git a/indent/ecrystal.vim b/indent/ecrystal.vim new file mode 100644 index 00000000..adf64e89 --- /dev/null +++ b/indent/ecrystal.vim @@ -0,0 +1,489 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + +" Setup {{{1 +" ===== + +if exists('b:did_indent') + finish +endif + +call ecrystal#SetSubtype() + +if b:ecrystal_subtype !=# '' + exec 'runtime! indent/'.b:ecrystal_subtype.'.vim' + unlet! b:did_indent +endif + +if &l:indentexpr ==# '' + if &l:cindent + let &l:indentexpr = 'cindent(v:lnum)' + else + let &l:indentexpr = 'indent(prevnonblank(v:lnum - 1))' + endif +endif + +let b:ecrystal_subtype_indentexpr = &l:indentexpr + +" Should we use folding? +if has('folding') && get(g:, 'ecrystal_fold', 0) + setlocal foldmethod=expr + setlocal foldexpr=GetEcrystalFold() +endif + +" Should closing control tags be aligned with their corresponding +" opening tags? +if !exists('b:ecrystal_align_end') + if exists('g:ecrystal_align_end') + let b:ecrystal_align_end = g:ecrystal_align_end + else + let b:ecrystal_align_end = b:ecrystal_subtype !=# 'html' && b:ecrystal_subtype !=# 'xml' + endif +endif + +" Should multiline tags be indented? +if !exists('b:ecrystal_indent_multiline') + let b:ecrystal_indent_multiline = get(g:, 'ecrystal_indent_multiline', 1) +endif + +if b:ecrystal_indent_multiline + runtime! indent/crystal.vim + unlet! b:did_indent + setlocal indentexpr< +endif + +setlocal indentexpr=GetEcrystalIndent() +setlocal indentkeys+=<>>,=end,=else,=elsif,=rescue,=ensure,=when + +let b:did_indent = 1 + +" Only define the function once. +if exists('*GetEcrystalIndent') + finish +endif + +" Helper variables and functions {{{1 +" ============================== + +let s:ecr_open = '<%%\@!' +let s:ecr_close = '%>' + +let s:ecr_control_open = '<%%\@!-\=[=#]\@!' +let s:ecr_comment_open = '<%%\@!-\=#' + +let s:ecr_indent_regex = + \ '\<\%(if\|unless\|else\|elsif\|case\|for\|when\|while\|until\|begin\|do\|rescue\|ensure\|' . + \ 'class\|module\|struct\|lib\|enum\|union\)\>' + +let s:ecr_dedent_regex = + \ '\<\%(end\|else\|elsif\|when\|rescue\|ensure\)\>' + +" Return the value of a single shift-width +if exists('*shiftwidth') + let s:sw = function('shiftwidth') +else + function s:sw() + return &shiftwidth + endfunction +endif + +" Does the given pattern match at the cursor's position? +function s:MatchCursor(pattern) + return searchpos(a:pattern, 'cnz', line('.')) == [line('.'), col('.')] +endfunction + +" Does the given pattern match at the given position? +function s:MatchAt(lnum, col, pattern) + let pos = getcurpos() + + try + call cursor(a:lnum, a:col) + let result = s:MatchCursor(a:pattern) + finally + call setpos('.', pos) + endtry + + return result +endfunction + +" Is the cell at the given position part of a tag? If so, return the +" position of the opening delimiter. +function s:MatchECR(...) + if a:0 + let lnum = a:1 + let col = a:2 + + call cursor(lnum, col) + endif + + let pos = getcurpos() + + try + let flags = s:MatchCursor(s:ecr_open) ? 'bcWz' : 'bWz' + + let [open_lnum, open_col] = searchpairpos( + \ s:ecr_open, '', s:ecr_close, + \ flags, g:crystal#indent#skip_expr) + finally + call setpos('.', pos) + endtry + + return [open_lnum, open_col] +endfunction + +" If the cell at the given position is part of a control tag, return the +" respective positions of the opening and closing delimiters for that +" tag. +function s:MatchECRControl(...) + let pos = getcurpos() + + if a:0 + let lnum = a:1 + let col = a:2 + + call cursor(lnum, col) + else + let [lnum, col] = [line('.'), col('.')] + endif + + let open = { 'lnum': 0, 'col': 0 } + let close = { 'lnum': 0, 'col': 0 } + + let [open.lnum, open.col] = s:MatchECR(lnum, col) + + if !open.lnum + call setpos('.', pos) + return [open, close] + endif + + call cursor(open.lnum, open.col) + + if !s:MatchCursor(s:ecr_control_open) + let open.lnum = 0 + let open.col = 0 + + call setpos('.', pos) + return [open, close] + endif + + let [close.lnum, close.col] = searchpairpos( + \ s:ecr_control_open, '', s:ecr_close, + \ 'Wz', g:crystal#indent#skip_expr) + + call setpos('.', pos) + return [open, close] +endfunction + +" Determine whether or not the control tag at the given position starts +" an indent. +function s:ECRIndent(...) + if a:0 + if type(a:1) == 0 + let [open, close] = s:MatchECRControl(a:1, a:2) + elseif type(a:1) == 4 + let [open, close] = [a:1, a:2] + endif + else + let [open, close] = s:MatchECRControl() + endif + + let result = 0 + + if !open.lnum + return result + endif + + let pos = getcurpos() + + call cursor(open.lnum, open.col) + + " Find each Crystal keyword that starts an indent; if any of them do + " not have a corresponding ending keyword, then this tag starts an + " indent. + while search(s:ecr_indent_regex, 'z', close.lnum) + let [lnum, col] = [line('.'), col('.')] + + if lnum == close.lnum && col > close.col + break + endif + + if crystal#indent#IsInStringOrComment(lnum, col) + continue + endif + + let [end_lnum, end_col] = searchpairpos( + \ g:crystal#indent#end_start_regex, + \ g:crystal#indent#end_middle_regex, + \ g:crystal#indent#end_end_regex, + \ 'nz', + \ g:crystal#indent#skip_expr, + \ close.lnum) + + if end_lnum + if end_lnum == close.lnum && end_col > close.col + let result = 1 + endif + else + let result = 1 + endif + + if result + break + endif + endwhile + + call setpos('.', pos) + return result +endfunction + +" Determine if the control tag at the given position ends an indent or +" not. +function s:ECRDedent(...) + if a:0 + if type(a:1) == 0 + let [open, close] = s:MatchECRControl(a:1, a:2) + elseif type(a:1) == 4 + let [open, close] = [a:1, a:2] + endif + else + let [open, close] = s:MatchECRControl() + endif + + let result = 0 + + if !open.lnum + return result + endif + + let pos = getcurpos() + + call cursor(open.lnum, open.col) + + " Find each Crystal keyword that ends an indent; if any of them do not + " have a corresponding starting keyword, then this tag ends an indent + while search(s:ecr_dedent_regex, 'z', close.lnum) + let [lnum, col] = [line('.'), col('.')] + + if lnum == close.lnum && col > close.col + break + endif + + if crystal#indent#IsInStringOrComment(lnum, col) + continue + endif + + let [begin_lnum, begin_col] = searchpairpos( + \ g:crystal#indent#end_start_regex, + \ g:crystal#indent#end_middle_regex, + \ g:crystal#indent#end_end_regex, + \ 'bnz', + \ g:crystal#indent#skip_expr, + \ open.lnum) + + if begin_lnum + if begin_lnum == open.lnum && begin_col < open.col + let result = 1 + endif + else + let result = 1 + endif + + if result + break + endif + endwhile + + call setpos('.', pos) + return result +endfunction + +" Find and match a control tag in the given line, if one exists. +function s:FindECRControl(...) + let lnum = a:0 ? a:1 : line('.') + + let open = { 'lnum': 0, 'col': 0 } + let close = { 'lnum': 0, 'col': 0 } + + let pos = getcurpos() + + call cursor(lnum, 1) + + while search(s:ecr_control_open, 'cz', lnum) + let [open, close] = s:MatchECRControl() + + if open.lnum + break + endif + endwhile + + call setpos('.', pos) + return [open, close] +endfunction + +" Find and match the previous control tag. +" +" This takes two arguments: the first is the line to start searching +" from (exclusive); the second is the line to stop searching at +" (inclusive). +function s:FindPrevECRControl(...) + if a:0 == 0 + let start = line('.') + let stop = 1 + elseif a:0 == 1 + let start = a:1 + let stop = 1 + elseif a:0 == 2 + let start = a:1 + let stop = a:2 + endif + + let open = { 'lnum': 0, 'col': 0 } + let close = { 'lnum': 0, 'col': 0 } + + let pos = getcurpos() + + call cursor(start, 1) + + let [lnum, col] = searchpos(s:ecr_close, 'bWz', stop) + + if !lnum + call setpos('.', pos) + return [open, close] + endif + + let [open, close] = s:MatchECRControl() + + while !open.lnum + let [lnum, col] = searchpos(s:ecr_close, 'bWz', stop) + + if !lnum + break + endif + + let [open, close] = s:MatchECRControl() + endwhile + + call setpos('.', pos) + return [open, close] +endfunction + +" GetEcrystalIndent {{{1 +" ================= + +function GetEcrystalIndent() abort + let prev_lnum = prevnonblank(v:lnum - 1) + + if b:ecrystal_indent_multiline + let [open_tag_lnum, open_tag_col] = s:MatchECR() + else + let open_tag_lnum = 0 + endif + + if open_tag_lnum && open_tag_lnum < v:lnum + " If we are inside a multiline eCrystal tag... + + let ind = indent(open_tag_lnum) + + " If this line has a closing delimiter that isn't inside a string or + " comment, then we are done with this tag + if crystal#indent#Match(v:lnum, s:ecr_close) + return ind + endif + + " All tag contents will have at least one indent + let ind += s:sw() + + if open_tag_lnum == prev_lnum + " If this is the first line after the opening delimiter, then one + " indent is enough + return ind + elseif s:MatchAt(open_tag_lnum, open_tag_col, s:ecr_comment_open)[0] + " eCrystal comments shouldn't be indented any further + return ind + else + " Else, fall back to Crystal indentation... + let crystal_ind = GetCrystalIndent() + + " But only if it isn't less than the default indentation for this + " tag + return crystal_ind < ind ? ind : crystal_ind + endif + else + let [prev_ecr_open, prev_ecr_close] = s:FindPrevECRControl(v:lnum, prev_lnum) + let [curr_ecr_open, curr_ecr_close] = s:FindECRControl() + + let prev_is_ecr = prev_ecr_open.lnum != 0 + let curr_is_ecr = curr_ecr_open.lnum != 0 + + let shift = 0 + + if prev_is_ecr + if s:ECRIndent(prev_ecr_open, prev_ecr_close) + let shift = 1 + endif + endif + + if curr_is_ecr + if s:ECRDedent(curr_ecr_open, curr_ecr_close) + if !b:ecrystal_align_end + let shift = shift ? 0 : -1 + else + " Find the nearest previous control tag that starts an indent + " and align this one with that one + let end_tags = 0 + + let [open, close] = s:FindPrevECRControl() + + while open.lnum + if s:ECRIndent(open, close) + if end_tags + let end_tags -= 1 + else + return indent(open.lnum) + endif + elseif s:ECRDedent(open, close) + let end_tags += 1 + endif + + let [open, close] = s:FindPrevECRControl(open.lnum) + endwhile + endif + endif + endif + + if shift + return indent(prev_lnum) + s:sw() * shift + else + exec 'return ' . b:ecrystal_subtype_indentexpr + endif + endif +endfunction + +" GetEcrystalFold {{{1 +" =============== + +function GetEcrystalFold() abort + let fold = '=' + + let col = crystal#indent#Match(v:lnum, s:ecr_control_open) + + if col + let [open, close] = s:MatchECRControl(v:lnum, col) + + let starts_indent = s:ECRIndent(open, close) + let ends_indent = s:ECRDedent(open, close) + + if starts_indent && !ends_indent + let fold = 'a1' + elseif ends_indent && !starts_indent + let fold = 's1' + endif + endif + + return fold +endfunction + +" }}} + +" vim:fdm=marker + +endif diff --git a/indent/graphql.vim b/indent/graphql.vim index 48090bbd..3aae6acb 100644 --- a/indent/graphql.vim +++ b/indent/graphql.vim @@ -1,6 +1,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 -" Copyright (c) 2016-2019 Jon Parise +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to diff --git a/indent/julia.vim b/indent/julia.vim index 299bb3f6..97dd7bc6 100644 --- a/indent/julia.vim +++ b/indent/julia.vim @@ -316,11 +316,17 @@ function GetJuliaIndent() " Second scenario: some multiline bracketed expression was closed in the " previous line. But since we know we are still in a bracketed expression, " we need to find the line where the bracket was open - elseif last_closed_bracket != -1 " && exists("loaded_matchit") - " we use the % command to skip back (this is buggy without matchit, and - " is potentially a disaster if % got remapped) + elseif last_closed_bracket != -1 + " we use the % command to skip back (tries to ues matchit if possible, + " otherwise resorts to vim's default, which is buggy but better than + " nothing) call cursor(lnum, last_closed_bracket) - normal % + let percmap = maparg("%", "n") + if exists("g:loaded_matchit") && percmap =~# 'Match\%(it\|_wrapper\)' + normal % + else + normal! % + end if line(".") == lnum " something wrong here, give up let ind = indent(lnum) diff --git a/indent/plantuml.vim b/indent/plantuml.vim index d2d0aa99..0d17276e 100644 --- a/indent/plantuml.vim +++ b/indent/plantuml.vim @@ -77,7 +77,7 @@ endfunction function! s:getIncIndent() abort " Function to determine the s:incIndent pattern return - \ '^\s*\%(class\|object\|interface\|partition\|rectangle\|enum\|namespace\|package\)\>.*{\s*$\|' . + \ '^\s*\%(class\|entity\|object\|interface\|partition\|rectangle\|enum\|namespace\|package\)\>.*{\s*$\|' . \ '^\s*\%(loop\|alt\|opt\|group\|critical\|else\|legend\|box\|if\|while\|fork\|split\)\>\|' . \ '^\s*ref\>[^:]*$\|' . \ '^\s*[hr]\?note\>\%(\%("[^"]*" \\)\@![^:]\)*$\|' . diff --git a/indent/python.vim b/indent/python.vim index 475bbf40..156833d4 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -160,8 +160,8 @@ function! s:find_start_of_block(lnum, types, skip, multiple) abort else let re_skip = '' endif - let lnum = a:lnum - let last_indent = indent(lnum) + 1 + let last_indent = indent(a:lnum) + 1 + let lnum = a:lnum - 1 while lnum > 0 && last_indent > 0 let indent = indent(lnum) if indent < last_indent @@ -262,7 +262,7 @@ function! s:indent_like_block(lnum) endif let [blocks, skip] = blocks_ignore - let indents = s:find_start_of_block(a:lnum - 1, blocks, skip, multiple) + let indents = s:find_start_of_block(a:lnum, blocks, skip, multiple) if empty(indents) return -1 endif diff --git a/syntax/basic/function.vim b/syntax/basic/function.vim index 5acbb55c..d6cec847 100644 --- a/syntax/basic/function.vim +++ b/syntax/basic/function.vim @@ -21,7 +21,7 @@ syntax match typescriptFuncName contained /\K\k*/ \ skipwhite " destructuring ({ a: ee }) => -syntax match typescriptArrowFuncDef contained /({\_[^}]*}\(:\_[^)]\)\?)\s*=>/ +syntax match typescriptArrowFuncDef contained /(\(\s*\({\_[^}]*}\|\k\+\)\(:\_[^)]\)\?,\?\)\+)\s*=>/ \ contains=typescriptArrowFuncArg,typescriptArrowFunc \ nextgroup=@typescriptExpression,typescriptBlock \ skipwhite skipempty diff --git a/syntax/crystal.vim b/syntax/crystal.vim index d48d15ce..e4b5403a 100644 --- a/syntax/crystal.vim +++ b/syntax/crystal.vim @@ -63,8 +63,9 @@ endfunction com! -nargs=* SynFold call s:run_syntax_fold() -" Not-Top Cluster -syn cluster crystalNotTop contains=@crystalExtendedStringSpecial,@crystalRegexpSpecial,@crystalDeclaration,crystalConditional,crystalExceptional,crystalMethodExceptional,crystalTodo,crystalLinkAttr +" Top and Not-Top Clusters +syn cluster crystalTop contains=TOP +syn cluster crystalNotTop contains=CONTAINED " Whitespace Errors if exists('g:crystal_space_errors') @@ -78,16 +79,16 @@ endif " Operators if exists('g:crystal_operators') - syn match crystalOperator "[~!^&|*/%+-]\|\%(class\s*\)\@\|<=\|\%(<\|\>\|>=\|=\@\|\*\*\|\.\.\.\|\.\.\|::" + syn match crystalOperator "[~!^&|*/%+-]\|<=>\|<=\|\%(<\|\<\%(class\|struct\)\s\+\u\w*\s*\)\@>\|>=\|=\@1\|\*\*\|\.\.\.\|\.\.\|::" syn match crystalOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\|//" - syn region crystalBracketOperator matchgroup=crystalOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@crystalNotTop + syn region crystalBracketOperator matchgroup=crystalOperator start="\%(\w[?!]\=\|[]})]\)\@2<=\[" end="]" contains=TOP endif " Expression Substitution and Backslash Notation syn match crystalStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display syn match crystalStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display -syn region crystalInterpolation matchgroup=crystalInterpolationDelim start="#{" end="}" contained contains=ALLBUT,@crystalNotTop +syn region crystalInterpolation matchgroup=crystalInterpolationDelim start="#{" end="}" contained contains=TOP syn match crystalInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=crystalInterpolationDelim,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable,crystalPredefinedVariable syn match crystalInterpolationDelim "#\ze\%(\$\|@@\=\)\w\+" display contained syn match crystalInterpolation "#\$\%(-\w\|\W\)" display contained contains=crystalInterpolationDelim,crystalPredefinedVariable,crystalInvalidVariable @@ -127,7 +128,7 @@ syn cluster crystalExtendedStringSpecial contains=@crystalStringSpecial,crystalN syn cluster crystalRegexpSpecial contains=crystalInterpolation,crystalNoInterpolation,crystalStringEscape,crystalRegexpSpecial,crystalRegexpEscape,crystalRegexpBrackets,crystalRegexpCharClass,crystalRegexpDot,crystalRegexpQuantifier,crystalRegexpAnchor,crystalRegexpParens,crystalRegexpComment " Numbers and ASCII Codes -syn match crystalASCIICode "\%(\w\|[]})\"'/]\)\@" display syn match crystalInteger "\<0o[0-7_]\+\%([ui]\%(8\|16\|32\|64\|128\)\)\=\>" display syn match crystalInteger "\<0b[01_]\+\%([ui]\%(8\|16\|32\|64\|128\)\)\=\>" display @@ -135,33 +136,33 @@ syn match crystalInteger "\<\d[[:digit:]_]*\%([ui]\%(8\|16\|32\|64\|128\)\|f\% syn match crystalFloat "\<\d[[:digit:]_]*\.\d[[:digit:]_]*\%(f\%(32\|64\)\)\=\>" contains=crystalInvalidInteger display syn match crystalFloat "\<\d[[:digit:]_]*\%(\.\d[[:digit:]_]*\)\=\%([eE][-+]\=[[:digit:]_]\+\)\%(f\%(32\|64\)\)\=\>" contains=crystalInvalidInteger display " Note: 042 is invalid but 0, 0_, 0_u8 and 0_1 are valid (#73) -syn match crystalInvalidInteger "\.\@" contained containedin=crystalFloat,crystalInteger display +syn match crystalInvalidInteger "\%(\.\|[eE][+-]\)\@2" contained containedin=crystalFloat,crystalInteger display " Identifiers syn match crystalLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent syn match crystalBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent -syn match crystalTypeName "\%(\%([.@$]\@\|::\)\@=" contained -syn match crystalClassName "\%(\%([.@$]\@\|::\)\@=" contained -syn match crystalModuleName "\%(\%([.@$]\@\|::\)\@=" contained -syn match crystalStructName "\%(\%([.@$]\@\|::\)\@=" contained -syn match crystalLibName "\%(\%([.@$]\@\|::\)\@=" contained -syn match crystalEnumName "\%(\%([.@$]\@\|::\)\@=" contained -syn match crystalConstant "\%(\%([.@$]\@\|::\)\@=" +syn match crystalTypeName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalClassName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalModuleName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalStructName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalLibName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalEnumName "\%(\%([.@$]\@1\|::\)\@=" contained +syn match crystalConstant "\%(\%([.@$]\@1\|::\)\@=" syn match crystalClassVariable "@@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display syn match crystalInstanceVariable "@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display syn match crystalGlobalVariable "$\%(\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*\|-.\)" -syn match crystalFreshVariable "\%(\h\|[^\x00-\x7F]\)\@\|<=\|<\|===\|[=!]=\|[=!]\~\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[][=?]\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" -syn match crystalSymbol "[]})\"':]\@_,;:!?/.'"@$*\&+0]\)" -syn match crystalSymbol "[]})\"':]\@\@!\)\=" +syn match crystalFreshVariable "\%(\h\|[^\x00-\x7F]\)\@1\|<=\|<\|===\|[=!]=\|[=!]\~\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[][=?]\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" +syn match crystalSymbol "[]})\"':]\@1_,;:!?/.'"@$*\&+0]\)" +syn match crystalSymbol "[]})\"':]\@1\@!\)\=" syn match crystalSymbol "\%([{(,]\_s*\)\@<=\l\w*[!?]\=::\@!"he=e-1 -syn match crystalSymbol "[]})\"':]\@\|{\)\s*\)\@<=|" end="|" oneline display contains=crystalBlockParameter @@ -173,18 +174,18 @@ syn match crystalPredefinedVariable "$_\>" display syn match crystalPredefinedVariable "$-[0FIKadilpvw]\>" display syn match crystalPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display syn match crystalPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display -syn match crystalPredefinedConstant "\%(\%(\.\@\%(\s*(\)\@!" -syn match crystalPredefinedConstant "\%(\%(\.\@\%(\s*(\)\@!" -syn match crystalPredefinedConstant "\%(\%(\.\@\%(\s*(\)\@!" -syn match crystalPredefinedConstant "\%(\%(\.\@\%(\s*(\)\@!" +syn match crystalPredefinedConstant "\%(\%(\.\@1\%(\s*(\)\@!" +syn match crystalPredefinedConstant "\%(\%(\.\@1\%(\s*(\)\@!" +syn match crystalPredefinedConstant "\%(\%(\.\@1\%(\s*(\)\@!" +syn match crystalPredefinedConstant "\%(\%(\.\@1\%(\s*(\)\@!" " Normal Regular Expression SynFold '/' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|ifdef\|when\|not\|then\|else\)\|[;\~=!|&(,[<>?:*+-]\)\s*\)\@<=/" end="/[imx]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial SynFold '/' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=/]\@!" end="/[imx]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial " Generalized Regular Expression -SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r{" end="}[imx]*" skip="\\\\\|\\}" contains=@crystalRegexpSpecial -SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r<" end=">[imx]*" skip="\\\\\|\\>" contains=@crystalRegexpSpecial,crystalNestedAngleBrackets,crystalDelimEscape +SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r{" end="}[imx]*" skip="\\\\\|\\}" contains=@crystalRegexpSpecial,crystalNestedRawCurlyBraces +SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r<" end=">[imx]*" skip="\\\\\|\\>" contains=@crystalRegexpSpecial,crystalNestedRawAngleBrackets SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r\[" end="\][imx]*" skip="\\\\\|\\\]" contains=@crystalRegexpSpecial SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r(" end=")[imx]*" skip="\\\\\|\\)" contains=@crystalRegexpSpecial SynFold '%' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r|" end="|[imx]*" skip="\\\\\|\\|" contains=@crystalRegexpSpecial @@ -228,10 +229,10 @@ SynFold '%' syn region crystalString matchgroup=crystalStringDelimiter start="%[ SynFold '%' syn region crystalString matchgroup=crystalStringDelimiter start="%[Qx]\=|" end="|" skip="\\\\\|\\|" contains=@crystalStringSpecial,crystalDelimEscape " Here Document -syn region crystalHeredocStart matchgroup=crystalStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration +syn match crystalFunction "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2 +syn match crystalFunction "\%([[:space:].]\|^\)\@1<=\%(\[\][=?]\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration syn cluster crystalDeclaration contains=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration,crystalModuleDeclaration,crystalClassDeclaration,crystalStructDeclaration,crystalLibDeclaration,crystalMacroDeclaration,crystalFunction,crystalBlockParameter,crystalTypeDeclaration,crystalEnumDeclaration @@ -285,28 +286,28 @@ if !exists('b:crystal_no_expensive') && !exists('g:crystal_no_expensive') syn match crystalMacro "\" nextgroup=crystalMacroDeclaration skipwhite skipnl syn match crystalEnum "\" nextgroup=crystalEnumDeclaration skipwhite skipnl - SynFold 'def' syn region crystalMethodBlock start="\<\%(def\|macro\)\>" matchgroup=crystalDefine end="\%(\<\%(def\|macro\)\_s\+\)\@" contains=ALLBUT,@crystalNotTop - SynFold 'class' syn region crystalBlock start="\" matchgroup=crystalClass end="\" contains=ALLBUT,@crystalNotTop - SynFold 'module' syn region crystalBlock start="\" matchgroup=crystalModule end="\" contains=ALLBUT,@crystalNotTop - SynFold 'struct' syn region crystalBlock start="\" matchgroup=crystalStruct end="\" contains=ALLBUT,@crystalNotTop - SynFold 'lib' syn region crystalBlock start="\" matchgroup=crystalLib end="\" contains=ALLBUT,@crystalNotTop - SynFold 'enum' syn region crystalBlock start="\" matchgroup=crystalEnum end="\" contains=ALLBUT,@crystalNotTop + SynFold 'def' syn region crystalMethodBlock start="\<\%(def\|macro\)\>" matchgroup=crystalDefine end="\%(\<\%(def\|macro\)\_s\+\)\@" contains=TOP + SynFold 'class' syn region crystalBlock start="\" matchgroup=crystalClass end="\" contains=TOP + SynFold 'module' syn region crystalBlock start="\" matchgroup=crystalModule end="\" contains=TOP + SynFold 'struct' syn region crystalBlock start="\" matchgroup=crystalStruct end="\" contains=TOP + SynFold 'lib' syn region crystalBlock start="\" matchgroup=crystalLib end="\" contains=TOP + SynFold 'enum' syn region crystalBlock start="\" matchgroup=crystalEnum end="\" contains=TOP " modifiers syn match crystalConditionalModifier "\<\%(if\|unless\|ifdef\)\>" display - syn match crystalRepeatModifier "\<\%(while\|until\)\>" display - SynFold 'do' syn region crystalDoBlock matchgroup=crystalControl start="\" end="\" contains=ALLBUT,@crystalNotTop + SynFold 'do' syn region crystalDoBlock matchgroup=crystalControl start="\" end="\" contains=TOP " curly bracket block or hash literal - SynFold '{' syn region crystalCurlyBlock matchgroup=crystalCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@crystalNotTop - SynFold '[' syn region crystalArrayLiteral matchgroup=crystalArrayDelimiter start="\%(\w\|[\]})]\)\@" end="\" contains=ALLBUT,@crystalNotTop - SynFold 'case' syn region crystalCaseExpression matchgroup=crystalConditional start="\" end="\" contains=ALLBUT,@crystalNotTop - SynFold 'select' syn region crystalSelectExpression matchgroup=crystalConditional start="\" end="\" contains=ALLBUT,@crystalNotTop - SynFold 'if' syn region crystalConditionalExpression matchgroup=crystalConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" end="\%(\%(\%(\.\@" contains=ALLBUT,@crystalNotTop + SynFold 'begin' syn region crystalBlockExpression matchgroup=crystalControl start="\" end="\" contains=TOP + SynFold 'while' syn region crystalRepeatExpression matchgroup=crystalRepeat start="\<\%(while\|until\)\>" end="\" contains=TOP + SynFold 'case' syn region crystalCaseExpression matchgroup=crystalConditional start="\" end="\" contains=TOP + SynFold 'select' syn region crystalSelectExpression matchgroup=crystalConditional start="\" end="\" contains=TOP + SynFold 'if' syn region crystalConditionalExpression matchgroup=crystalConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" end="\%(\%(\%(\.\@1" contains=TOP syn match crystalConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=crystalCaseExpression syn match crystalConditional "\<\%(when\|else\)\>[?!]\@!" contained containedin=crystalSelectExpression @@ -336,10 +337,7 @@ else endif " Link attribute -syn region crystalLinkAttrRegion start="@\[" nextgroup=crystalLinkAttrRegionInner end="]" contains=crystalLinkAttr,crystalLinkAttrRegionInner transparent display oneline -syn region crystalLinkAttrRegionInner start="\%(@\[\)\@<=" end="]\@=" contained contains=ALLBUT,@crystalNotTop transparent display oneline -syn match crystalLinkAttr "@\[" contained containedin=crystalLinkAttrRegion display -syn match crystalLinkAttr "]" contained containedin=crystalLinkAttrRegion display +syn region crystalLinkAttr matchgroup=crystalLinkAttrDelim start="@\[" end="]" contains=TOP display oneline " Special Methods if !exists('g:crystal_no_special_methods') @@ -358,42 +356,56 @@ endif " Macro " Note: This definition must be put after crystalNestedCurlyBraces to give higher priority -syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={%" end="%}" oneline display contains=TOP,@crystalExpensive containedin=ALL -syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={{" end="}}" oneline display contains=TOP,@crystalExpensive containedin=ALL +syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={%" end="%}" oneline display contains=@crystalMacroGroup containedin=ALL +syn region crystalMacroRegion matchgroup=crystalMacroDelim start="\\\={{" end="}}" oneline display contains=@crystalMacroGroup containedin=ALL + +" Cluster for groups that can appear inside macro expressions +syn cluster crystalMacroGroup contains=@crystalTop " Cluster for Expensive Mode groups that can't appear inside macro " regions syn cluster crystalExpensive contains= - \ crystalMethodBlock,crystalBlock,crystalDoBlock,crystalBlockExpression,crystalCaseExpression, - \ crystalSelectExpression,crystalConditionalExpression + \ crystalMethodBlock,crystalBlock,crystalDoBlock,crystalBlockExpression,crystalRepeatExpression, + \ crystalCaseExpression,crystalSelectExpression,crystalConditionalExpression + +syn cluster crystalMacroGroup remove=@crystalExpensive " Some keywords will have to be redefined for them to be highlighted " properly -syn keyword crystalMacroKeyword contained containedin=crystalMacroRegion - \ if else elsif end for in begin do -syn cluster crystalNotTop add=crystalMacroKeyword +syn keyword crystalMacroKeyword contained + \ if else elsif end for in begin do case when while until loop + \ rescue ensure + +syn cluster crystalMacroGroup add=crystalMacroKeyword " Comments and Documentation syn match crystalSharpBang "\%^#!.*" display syn keyword crystalTodo FIXME NOTE TODO OPTIMIZE XXX todo contained -syn match crystalComment "#.*" contains=crystalSharpBang,crystalSpaceError,crystalTodo,@Spell + +if exists('g:main_syntax') && g:main_syntax ==# 'ecrystal' + " eCrystal tags can contain Crystal comments, so we need to modify the + " pattern for comments so that it does not consume delimiters + syn match crystalComment "#.*\ze\%($\|-\=%>\)" contains=crystalSharpBang,crystalSpaceError,crystalTodo,@Spell +else + syn match crystalComment "#.*" contains=crystalSharpBang,crystalSpaceError,crystalTodo,@Spell +endif SynFold '#' syn region crystalMultilineComment start="\%(\%(^\s*#.*\n\)\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE syn match crystalKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)[?!]" transparent contains=NONE syn match crystalKeywordAsMethod "\<\%(if\|ifdef\|module\|undef\|unless\|until\|while\)[?!]" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE -syn match crystalKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE +syn match crystalKeywordAsMethod "\%(\%(\.\@1" transparent contains=NONE hi def link crystalClass crystalDefine hi def link crystalModule crystalDefine @@ -407,7 +419,6 @@ hi def link crystalConditional Conditional hi def link crystalConditionalModifier crystalConditional hi def link crystalExceptional crystalConditional hi def link crystalRepeat Repeat -hi def link crystalRepeatModifier crystalRepeat hi def link crystalControl Statement hi def link crystalInclude Include hi def link crystalRecord Statement @@ -465,7 +476,7 @@ hi def link crystalRegexp crystalString hi def link crystalMacro PreProc hi def link crystalMacroDelim crystalMacro hi def link crystalMacroKeyword crystalKeyword -hi def link crystalLinkAttr crystalMacro +hi def link crystalLinkAttrDelim crystalMacro hi def link crystalError Error hi def link crystalInvalidVariable crystalError hi def link crystalSpaceError crystalError diff --git a/syntax/dart.vim b/syntax/dart.vim index 103b1da2..6c89e099 100644 --- a/syntax/dart.vim +++ b/syntax/dart.vim @@ -5,14 +5,14 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dart') == -1 " for details. 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("g:main_syntax") - if version < 600 +if !exists('g:main_syntax') + if v:version < 600 syntax clear - elseif exists("b:current_syntax") + elseif exists('b:current_syntax') finish endif let g:main_syntax = 'dart' - syntax region dartFold start="{" end="}" transparent fold + syntax region dartFold start='{' end='}' transparent fold endif " Ensure long multiline strings are highlighted. @@ -25,7 +25,7 @@ syntax keyword dartConditional if else switch syntax keyword dartRepeat do while for syntax keyword dartBoolean true false syntax keyword dartConstant null -syntax keyword dartTypedef this super class typedef enum mixin +syntax keyword dartTypedef this super class typedef enum mixin extension syntax keyword dartOperator new is as in syntax match dartOperator "+=\=\|-=\=\|*=\=\|/=\=\|%=\=\|\~/=\=\|<<=\=\|>>=\=\|[<>]=\=\|===\=\|\!==\=\|&=\=\|\^=\=\||=\=\|||\|&&\|\[\]=\=\|=>\|!\|\~\|?\|:" syntax keyword dartCoreType void var dynamic @@ -42,9 +42,9 @@ syntax match dartUserLabelRef "\k\+" contained syntax region dartLabelRegion transparent matchgroup=dartLabel start="\" matchgroup=NONE end=":" syntax keyword dartLabel default -syntax match dartLibrary "^\(import\|export\)\>" nextgroup=dartUri skipwhite -syntax region dartUri contained start=+r\=\z(["']\)+ end=+\z1+ nextgroup=dartCombinators skipwhite -syntax region dartCombinators contained start="" end=";" contains=dartCombinator +syntax match dartLibrary "^\(import\|export\)\>" nextgroup=dartUri skipwhite skipnl +syntax region dartUri contained start=+r\=\z(["']\)+ end=+\z1+ nextgroup=dartCombinators skipwhite skipnl +syntax region dartCombinators contained start="" end=";" contains=dartCombinator,dartComment,dartLineComment syntax keyword dartCombinator contained show hide deferred as syntax match dartLibrary "^\(library\|part of\|part\)\>" @@ -136,8 +136,8 @@ highlight default link dartUserType dartType highlight default link dartType Type highlight default link dartFunction Function -let b:current_syntax = "dart" -let b:spell_options = "contained" +let b:current_syntax = 'dart' +let b:spell_options = 'contained' if g:main_syntax is# 'dart' unlet g:main_syntax diff --git a/syntax/ecrystal.vim b/syntax/ecrystal.vim new file mode 100644 index 00000000..096990ff --- /dev/null +++ b/syntax/ecrystal.vim @@ -0,0 +1,37 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + +if &syntax !~# '\' || get(b:, 'current_syntax') =~# '\' + finish +endif + +if !exists('main_syntax') + let main_syntax = 'ecrystal' +endif + +call ecrystal#SetSubtype() + +if b:ecrystal_subtype !=# '' + exec 'runtime! syntax/'.b:ecrystal_subtype.'.vim' + unlet! b:current_syntax +endif + +syn include @crystalTop syntax/crystal.vim + +syn cluster ecrystalRegions contains=ecrystalControl,ecrystalRender,ecrystalComment + +syn region ecrystalControl matchgroup=ecrystalDelimiter start="<%%\@!-\=" end="-\=%>" display contains=@crystalTop containedin=ALLBUT,@ecrystalRegions +syn region ecrystalRender matchgroup=ecrystalDelimiter start="<%%\@!-\==" end="-\=%>" display contains=@crystalTop containedin=ALLBUT,@ecrystalRegions +syn region ecrystalComment matchgroup=ecrystalDelimiter start="<%%\@!-\=#" end="-\=%>" display contains=crystalTodo,@Spell containedin=ALLBUT,@ecrystalRegions + +" Define the default highlighting. + +hi def link ecrystalDelimiter PreProc +hi def link ecrystalComment crystalComment + +let b:current_syntax = 'ecrystal' + +if exists('main_syntax') && main_syntax ==# 'ecrystal' + unlet main_syntax +endif + +endif diff --git a/syntax/elixir.vim b/syntax/elixir.vim index 054ddd3e..ca057b3d 100644 --- a/syntax/elixir.vim +++ b/syntax/elixir.vim @@ -20,6 +20,10 @@ syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained syn match elixirId '\<[_a-zA-Z]\w*[!?]\?\>' contains=elixirUnusedVariable +syn match elixirFunctionCall '\<[a-z_]\w*[!?]\?\(\s*\.\?\s*(\|\s\+[a-zA-Z0-9@:\'\"\[]\)\@=' +syn match elixirFunctionCall '\(:\w\+\s*\.\s*\|[A-Z]\w*\s*\.\s*\)\@<=[a-z_]\w*[!?]\?' +syn match elixirFunctionCall '\(>\s+\)\<[a-z_]\w*[!?]\?' + syn match elixirKeyword '\(\.\)\@:\@!' syn keyword elixirInclude import require alias use @@ -40,6 +44,7 @@ syn match elixirOperator '|||\|||\||>\||' syn match elixirOperator '\.\.\|\.' syn match elixirOperator "\^\^\^\|\^" syn match elixirOperator '\\\\\|::\|\*\|/\|\~\~\~\|@' +syn match elixirOperator '\~>\|\~>>\|<\~\|<<\~\|<\~>' syn match elixirAlias '\([a-z]\)\@ +" Copyright (c) 2016-2020 Jon Parise " " Permission is hereby granted, free of charge, to any person obtaining a copy " of this software and associated documentation files (the "Software"), to @@ -24,7 +24,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1 " Maintainer: Jon Parise if exists('b:current_syntax') - finish + finish endif syn case match diff --git a/syntax/i3config.vim b/syntax/i3config.vim index 518cd93a..3b36d107 100644 --- a/syntax/i3config.vim +++ b/syntax/i3config.vim @@ -69,9 +69,9 @@ syn match i3ConfigModifier /\w\++\w\+\(\(+\w\+\)\+\)\?/ contained contains=i3Con syn match i3ConfigNumber /\s\d\+/ contained syn match i3ConfigUnit /\sp\(pt\|x\)/ contained syn match i3ConfigUnitOr /\sor/ contained -syn keyword i3ConfigBindKeyword bindsym bindcode exec gaps contained +syn keyword i3ConfigBindKeyword bindsym bindcode exec gaps border contained syn match i3ConfigBindArgument /--\w\+\(\(-\w\+\)\+\)\?\s/ contained -syn match i3ConfigBind /^\s*\(bindsym\|bindcode\)\s\+.*$/ contains=i3ConfigVariable,i3ConfigBindKeyword,i3ConfigVariableAndModifier,i3ConfigNumber,i3ConfigUnit,i3ConfigUnitOr,i3ConfigBindArgument,i3ConfigModifier,i3ConfigAction,i3ConfigString,i3ConfigGapStyleKeyword +syn match i3ConfigBind /^\s*\(bindsym\|bindcode\)\s\+.*$/ contains=i3ConfigVariable,i3ConfigBindKeyword,i3ConfigVariableAndModifier,i3ConfigNumber,i3ConfigUnit,i3ConfigUnitOr,i3ConfigBindArgument,i3ConfigModifier,i3ConfigAction,i3ConfigString,i3ConfigGapStyleKeyword,i3ConfigBorderStyleKeyword " Floating syn keyword i3ConfigSizeSpecial x contained @@ -90,7 +90,7 @@ syn match i3ConfigLayout /^\s*workspace_layout\s\+\(default\|stacking\|tabbed\)\ " Border style syn keyword i3ConfigBorderStyleKeyword none normal pixel contained -syn match i3ConfigBorderStyle /^\s*\(new_window\|new_float\|default_border\|default_floating_border\)\s\+\(none\|\(normal\|pixel\)\(\s\+\d\+\)\?\)\s\?$/ contains=i3ConfigBorderStyleKeyword,i3ConfigNumber +syn match i3ConfigBorderStyle /^\s*\(new_window\|new_float\|default_border\|default_floating_border\)\s\+\(none\|\(normal\|pixel\)\(\s\+\d\+\)\?\(\s\+\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?\)\?\)\s\?$/ contains=i3ConfigBorderStyleKeyword,i3ConfigNumber,i3ConfigVariable " Hide borders and edges syn keyword i3ConfigEdgeKeyword none vertical horizontal both smart smart_no_gaps contained diff --git a/syntax/javascript.vim b/syntax/javascript.vim index 0ffc5aa1..e2a25ceb 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -186,7 +186,7 @@ syntax match jsClassNoise contained /\./ syntax match jsClassFuncName contained /\<\K\k*\ze\s*[(<]/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowClassFunctionGroup syntax match jsClassMethodType contained /\<\%([gs]et\|static\)\ze\s\+\K\k*/ skipwhite skipempty nextgroup=jsAsyncKeyword,jsClassFuncName,jsClassProperty syntax region jsClassDefinition start=/\/ end=/\(\\s\+\)\@ " License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause) @@ -39,7 +39,7 @@ syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' " TODO: Figure out how escaping works inside of #(...) and #{...} blocks. syn region tmuxFormatString start=/#[#DFhHIPSTW]/ end=// contained keepend -syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ contained keepend +syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ keepend syn region tmuxFormatString start=/#(/ skip=/#(.\{-})/ end=/)/ contained keepend hi def link tmuxFormatString Identifier @@ -94,25 +94,26 @@ syn keyword tmuxCommands \ attach attach-session bind bind-key break-pane breakp capture-pane \ capturep choose-buffer choose-client choose-tree clear-history clearhist \ clock-mode command-prompt confirm confirm-before copy-mode detach -\ detach-client display display-menu display-message display-panes displayp -\ find-window findw if if-shell join-pane joinp kill-pane kill-server -\ kill-session kill-window killp has-session has killw link-window linkw -\ list-buffers list-clients list-commands list-keys list-panes list-sessions -\ list-windows load-buffer loadb lock lock-client lock-server lock-session -\ lockc last-pane lastp locks ls last-window last lsb lsc delete-buffer -\ deleteb lscm lsk lsp lsw menu move-pane move-window movep movew new -\ new-session new-window neww next next-layout next-window nextl -\ paste-buffer pasteb pipe-pane pipep prev previous-layout previous-window -\ prevl refresh refresh-client rename rename-session rename-window renamew -\ resize-pane resize-window resizep resizew respawn-pane respawn-window -\ respawnp respawnw rotate-window rotatew run run-shell save-buffer saveb -\ select-layout select-pane select-window selectl selectp selectw send -\ send-keys send-prefix set set-buffer set-environment set-hook set-option -\ set-window-option setb setenv setw show show-buffer show-environment -\ show-hooks show-messages show-options show-window-options showb showenv -\ showmsgs showw source source-file split-window splitw start start-server -\ suspend-client suspendc swap-pane swap-window swapp swapw switch-client -\ switchc unbind unbind-key unlink-window unlinkw wait wait-for +\ detach-client display display-menu display-message display-panes +\ display-popup displayp find-window findw if if-shell join-pane joinp +\ kill-pane kill-server kill-session kill-window killp has-session has killw +\ link-window linkw list-buffers list-clients list-commands list-keys +\ list-panes list-sessions list-windows load-buffer loadb lock lock-client +\ lock-server lock-session lockc last-pane lastp locks ls last-window last +\ lsb lsc delete-buffer deleteb lscm lsk lsp lsw menu move-pane move-window +\ movep movew new new-session new-window neww next next-layout next-window +\ nextl paste-buffer pasteb pipe-pane pipep popup prev previous-layout +\ previous-window prevl refresh refresh-client rename rename-session +\ rename-window renamew resize-pane resize-window resizep resizew +\ respawn-pane respawn-window respawnp respawnw rotate-window rotatew run +\ run-shell save-buffer saveb select-layout select-pane select-window +\ selectl selectp selectw send send-keys send-prefix set set-buffer +\ set-environment set-hook set-option set-window-option setb setenv setw +\ show show-buffer show-environment show-hooks show-messages show-options +\ show-window-options showb showenv showmsgs showw source source-file +\ split-window splitw start start-server suspend-client suspendc swap-pane +\ swap-window swapp swapw switch-client switchc unbind unbind-key +\ unlink-window unlinkw wait wait-for let &cpo = s:original_cpo unlet! s:original_cpo s:bg s:i diff --git a/syntax/vifm.vim b/syntax/vifm.vim index 68a20164..e8f9892f 100644 --- a/syntax/vifm.vim +++ b/syntax/vifm.vim @@ -2,7 +2,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1 " vifm syntax file " Maintainer: xaizek -" Last Change: July 12, 2019 +" Last Change: March 7, 2020 " Inspired By: Vim syntax file by Dr. Charles E. Campbell, Jr. if exists('b:current_syntax') @@ -23,8 +23,8 @@ syntax keyword vifmCommand contained \ mes[sages] mkdir m[ove] noh[lsearch] on[ly] popd pushd pu[t] pw[d] qa[ll] \ q[uit] redr[aw] reg[isters] regular rename restart restore rlink screen \ sh[ell] siblnext siblprev sor[t] sp[lit] s[ubstitute] tabc[lose] tabm[ove] - \ tabname tabnew tabn[ext] tabp[revious] touch tr trashes tree sync - \ undol[ist] ve[rsion] vie[w] vifm vs[plit] winc[md] w[rite] wq wqa[ll] + \ tabname tabnew tabn[ext] tabo[nly] tabp[revious] touch tr trashes tree + \ sync undol[ist] ve[rsion] vie[w] vifm vs[plit] winc[md] w[rite] wq wqa[ll] \ xa[ll] x[it] y[ank] \ nextgroup=vifmArgs syntax keyword vifmCommandCN contained diff --git a/syntax/zig.vim b/syntax/zig.vim index 2ee57a1b..9af783c6 100644 --- a/syntax/zig.vim +++ b/syntax/zig.vim @@ -29,21 +29,20 @@ syn match zigType "\v<[iu][1-9]\d*>" syn match zigOperator display "\%(+%\?\|-%\?\|/\|*%\?\|=\|\^\|&\|?\||\|!\|>\|<\|%\|<<%\?\|>>\)=\?" syn match zigArrowCharacter display "->" -syn match zigBuiltinFn "\v\@(addWithOverflow|ArgType|atomicLoad|atomicStore|bitCast|breakpoint)>" +syn match zigBuiltinFn "\v\@(addWithOverflow|as|atomicLoad|atomicStore|bitCast|breakpoint)>" syn match zigBuiltinFn "\v\@(alignCast|alignOf|cDefine|cImport|cInclude)>" syn match zigBuiltinFn "\v\@(cUndef|canImplicitCast|clz|cmpxchgWeak|cmpxchgStrong|compileError)>" syn match zigBuiltinFn "\v\@(compileLog|ctz|popCount|divExact|divFloor|divTrunc)>" syn match zigBuiltinFn "\v\@(embedFile|export|tagName|TagType|errorName|call)>" syn match zigBuiltinFn "\v\@(errorReturnTrace|fence|fieldParentPtr|field|unionInit)>" -syn match zigBuiltinFn "\v\@(frameAddress|import|newStackCall|asyncCall|intToPtr|IntType)>" -syn match zigBuiltinFn "\v\@(memberCount|memberName|memberType|as)>" +syn match zigBuiltinFn "\v\@(frameAddress|import|newStackCall|asyncCall|intToPtr)>" syn match zigBuiltinFn "\v\@(memcpy|memset|mod|mulWithOverflow|splat)>" syn match zigBuiltinFn "\v\@(bitOffsetOf|byteOffsetOf|OpaqueType|panic|ptrCast)>" 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|bitSizeOf|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|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|log|log2|log10|fabs|floor|ceil|trunc|round)>" -- cgit v1.2.3