Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Feb 6, 2018
1 parent bfc6ed9 commit 18efda3
Show file tree
Hide file tree
Showing 25 changed files with 656 additions and 118 deletions.
4 changes: 2 additions & 2 deletions after/syntax/c.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1
" Highlight function names.
" -----------------------------------------------------------------------------
if !exists('g:cpp_no_function_highlight')
syn match cCustomParen "(" contains=cParen contains=cCppParen
syn match cCustomParen transparent "(" contains=cParen contains=cCppParen
syn match cCustomFunc "\w\+\s*(\@=" contains=cCustomParen
hi def link cCustomFunc Function
endif
Expand All @@ -32,7 +32,7 @@ endif
if exists('g:cpp_member_variable_highlight') && g:cpp_member_variable_highlight
syn match cCustomDot "\." contained
syn match cCustomPtr "->" contained
syn match cCustomMemVar "\(\.\|->\)\w\+" contains=cCustomDot,cCustomPtr
syn match cCustomMemVar "\(\.\|->\)\h\w*" contains=cCustomDot,cCustomPtr
hi def link cCustomMemVar Function
endif

Expand Down
69 changes: 66 additions & 3 deletions after/syntax/cpp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1
" Language: C++ Additions
" Maintainer: Jon Haggblad <[email protected]>
" URL: http://www.haeggblad.com
" Last Change: 12 Oct 2016
" Last Change: 1 Feb 2018
" Version: 0.6
" Changelog:
" 0.1 - initial version.
Expand Down Expand Up @@ -37,7 +37,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1

" Functions
if !exists('g:cpp_no_function_highlight')
syn match cCustomParen "(" contains=cParen contains=cCppParen
syn match cCustomParen transparent "(" contains=cParen contains=cCppParen
syn match cCustomFunc "\w\+\s*(\@="
hi def link cCustomFunc Function
endif
Expand Down Expand Up @@ -855,6 +855,37 @@ syntax keyword cppSTLconstant WEOF
syntax keyword cppSTLconstant WCHAR_MIN
syntax keyword cppSTLconstant WCHAR_MAX

" locale
syntax keyword cppSTLtype locale
syntax keyword cppSTLtype ctype_base
syntax keyword cppSTLtype codecvt_base
syntax keyword cppSTLtype messages_base
syntax keyword cppSTLtype time_base
syntax keyword cppSTLtype money_base
syntax keyword cppSTLtype ctype
syntax keyword cppSTLtype codecvt
syntax keyword cppSTLtype collate
syntax keyword cppSTLtype messages
syntax keyword cppSTLtype time_get
syntax keyword cppSTLtype time_put
syntax keyword cppSTLtype num_get
syntax keyword cppSTLtype num_put
syntax keyword cppSTLtype numpunct
syntax keyword cppSTLtype money_get
syntax keyword cppSTLtype money_put
syntax keyword cppSTLtype moneypunct
syntax keyword cppSTLtype ctype_byname
syntax keyword cppSTLtype codecvt_byname
syntax keyword cppSTLtype messages_byname
syntax keyword cppSTLtype collate_byname
syntax keyword cppSTLtype time_get_byname
syntax keyword cppSTLtype time_put_byname
syntax keyword cppSTLtype numpunct_byname
syntax keyword cppSTLtype moneypunct_byname
syntax keyword cppSTLfunction use_facet
syntax keyword cppSTLfunction has_facet
syntax keyword cppSTLfunction isspace isblank iscntrl isupper islower isalpha
syntax keyword cppSTLfunction isdigit ispunct isxdigit isalnum isprint isgraph

if !exists("cpp_no_cpp11")
syntax keyword cppSTLconstant nullptr
Expand Down Expand Up @@ -1766,6 +1797,9 @@ if !exists("cpp_no_cpp17")
syntax keyword cppSTLfunction do_deallocate
syntax keyword cppSTLfunction do_is_equal

" mutex
syntax keyword cppSTLtype scoped_lock

" new
syntax keyword cppSTLconstant hardware_destructive_interference_size
syntax keyword cppSTLconstant hardware_constructive_interference_size
Expand Down Expand Up @@ -1804,7 +1838,7 @@ if !exists("cpp_no_cpp17")
syntax keyword cppSTLbool is_error_code_enum_v
syntax keyword cppSTLbool is_error_condition_enum_v

" thread
" shared_mutex
syntax keyword cppSTLtype shared_mutex

" tuple
Expand Down Expand Up @@ -1879,6 +1913,16 @@ if !exists("cpp_no_cpp17")
syntax keyword cppSTLbool conjunction_v
syntax keyword cppSTLbool disjunction_v
syntax keyword cppSTLbool negation_v
syntax keyword cppSTLbool has_unique_object_representations_v
syntax keyword cppSTLbool is_swappable_v
syntax keyword cppSTLbool is_swappable_with_v
syntax keyword cppSTLbool is_nothrow_swappable_v
syntax keyword cppSTLbool is_nothrow_swappable_with_v
syntax keyword cppSTLbool is_invocable_v
syntax keyword cppSTLbool is_invocable_r_v
syntax keyword cppSTLbool is_nothrow_invocable_v
syntax keyword cppSTLbool is_nothrow_invocable_r_v
syntax keyword cppSTLbool is_aggregate_v
syntax keyword cppSTLconstant alignment_of_v
syntax keyword cppSTLconstant rank_v
syntax keyword cppSTLconstant extent_v
Expand All @@ -1888,6 +1932,19 @@ if !exists("cpp_no_cpp17")
syntax keyword cppSTLtype conjunction
syntax keyword cppSTLtype disjunction
syntax keyword cppSTLtype negation
syntax keyword cppSTLtype void_t
syntax keyword cppSTLtype has_unique_object_representations
syntax keyword cppSTLtype is_swappable
syntax keyword cppSTLtype is_swappable_with
syntax keyword cppSTLtype is_nothrow_swappable
syntax keyword cppSTLtype is_nothrow_swappable_with
syntax keyword cppSTLtype is_invocable
syntax keyword cppSTLtype is_invocable_r
syntax keyword cppSTLtype is_nothrow_invocable
syntax keyword cppSTLtype is_nothrow_invocable_r
syntax keyword cppSTLtype invoke_result
syntax keyword cppSTLtype invoke_result_t
syntax keyword cppSTLtype is_aggregate

" unordered_map, unordered_set, unordered_multimap, unordered_multiset
syntax keyword cppSTLtype node_type
Expand Down Expand Up @@ -1921,6 +1978,12 @@ if !exists("cpp_no_cpp17")
endif " C++17


if !exists("cpp_no_cpp20")
" type_traits
syntax keyword cppSTLtype remove_cvref remove_cvref_t
endif


if exists('g:cpp_concepts_highlight') && g:cpp_concepts_highlight
syntax keyword cppStatement concept
syntax keyword cppStorageClass requires
Expand Down
2 changes: 1 addition & 1 deletion after/syntax/yaml.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ syn match yamlBlock "[\[\]\{\}\|\>]"
syn region yamlComment start="\#" end="$"
syn match yamlIndicator "#YAML:\S\+"

syn region yamlString start="\%(^\| \)\zs'" end="'\ze\%( \|$\)" skip="\\'"
syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)'" end="'" skip="\\'"
syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape
syn match yamlEscape +\\[abfnrtv'"\\]+ contained
syn match yamlEscape "\\\o\o\=\o\=" contained
Expand Down
89 changes: 89 additions & 0 deletions autoload/cargo.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1

function! cargo#cmd(args)
silent! clear
if !a:args
execute "!" . "cargo ". a:args
else
echom "Missing arguments"
endif
endfunction

function! cargo#build(args)
silent! clear
if !a:args
execute "!" . "cargo build " . a:args
else
execute "!" . "cargo build"
endif
silent! clear
execute "!" . "cargo build"
endfunction

function! cargo#clean(args)
silent! clear
if !a:args
execute "!" . "cargo clean " . a:args
else
execute "!" . "cargo clean"
endif
silent! clear
execute "!" . "cargo clean"
endfunction

function! cargo#doc(args)
silent! clear
if !a:args
execute "!" . "cargo doc " . a:args
else
execute "!" . "cargo doc"
endif
endfunction

function! cargo#new(args)
silent! clear
if !a:args
execute "!cargo new " . a:args
:cd `=a:args`
else
echom "Missing arguments"
endif
endfunction

function! cargo#init(args)
silent! clear
if !a:args
execute "!" . "cargo init " . a:args
else
execute "!" . "cargo init"
endif
endfunction

function! cargo#run(args)
silent! clear
if !a:args
execute "!" . "cargo run " . a:args
else
execute "!" . "cargo run"
endif
endfunction

function! cargo#test(args)
silent! clear
if !a:args
execute "!" . "cargo test " . a:args
else
execute "!" . "cargo test"
endif
endfunction

function! cargo#bench(args)
silent! clear
if !a:args
execute "!" . "cargo bench " . a:args
else
execute "!" . "cargo bench"
endif
endfunction

endif
67 changes: 21 additions & 46 deletions autoload/crystal_lang.vim
Original file line number Diff line number Diff line change
Expand Up @@ -280,59 +280,34 @@ function! crystal_lang#format_string(code, ...) abort
return output
endfunction

function! s:get_saved_states() abort
let result = {}
let fname = bufname('%')
let current_winnr = winnr()
for i in range(1, winnr('$'))
let bufnr = winbufnr(i)
if bufnr == -1
continue
endif
if bufname(bufnr) ==# fname
execute i 'wincmd w'
let result[i] = {
\ 'pos': getpos('.'),
\ 'screen': winsaveview()
\ }
endif
endfor
execute current_winnr 'wincmd w'
return result
endfunction

function! crystal_lang#format(option_str) abort
" crystal_lang#format(option_str [, on_save])
function! crystal_lang#format(option_str, ...) abort
if !executable(g:crystal_compiler_command)
" Finish command silently
return
endif

let formatted = crystal_lang#format_string(join(getline(1, '$'), "\n"), a:option_str)
let formatted = substitute(formatted, '\n$', '', '')
let on_save = a:0 > 0 ? a:1 : 0

let sel_save = &l:selection
let ve_save = &virtualedit
let &l:selection = 'inclusive'
let &virtualedit = ''
let [save_g_reg, save_g_regtype] = [getreg('g'), getregtype('g')]
let windows_save = s:get_saved_states()
let before = join(getline(1, '$'), "\n")
let formatted = crystal_lang#format_string(before, a:option_str)
if !on_save
let after = substitute(formatted, '\n$', '', '')
if before ==# after
return
endif
endif

try
call setreg('g', formatted, 'v')
silent normal! gg0vG$"gp
finally
call setreg('g', save_g_reg, save_g_regtype)
let &l:selection = sel_save
let &virtualedit = ve_save
let winnr = winnr()
for winnr in keys(windows_save)
let w = windows_save[winnr]
execute winnr 'wincmd w'
call setpos('.', w.pos)
call winrestview(w.screen)
endfor
execute winnr 'wincmd w'
endtry
let view_save = winsaveview()
let pos_save = getpos('.')
let lines = split(formatted, '\n')
silent! undojoin
if line('$') > len(lines)
execute len(lines) . ',$delete' '_'
endif
call setline(1, lines)
call winrestview(view_save)
call setpos('.', pos_save)
endfunction

let &cpo = s:save_cpo
Expand Down
17 changes: 15 additions & 2 deletions autoload/elixir/indent.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ function! elixir#indent#indent(lnum)
call s:debug("==> Indenting line " . lnum)
call s:debug("text = '" . text . "'")

let [_, curs_lnum, curs_col, _] = getpos('.')
call cursor(lnum, 0)

let handlers = [
\'top_of_file',
\'starts_with_end',
\'starts_with_mid_or_end_block_keyword',
\'following_trailing_do',
\'following_trailing_rocket',
\'following_trailing_binary_operator',
\'starts_with_pipe',
\'starts_with_close_bracket',
Expand All @@ -37,11 +41,13 @@ function! elixir#indent#indent(lnum)
let indent = function('elixir#indent#handle_'.handler)(lnum, text, prev_nb_lnum, prev_nb_text)
if indent != -1
call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned '.indent)
call cursor(curs_lnum, curs_col)
return indent
endif
endfor

call s:debug("defaulting")
call cursor(curs_lnum, curs_col)
return 0
endfunction

Expand Down Expand Up @@ -166,7 +172,7 @@ function! s:get_base_indent(lnum, text)
elseif s:ends_with(a:text, data_structure_close, a:lnum)
let data_structure_open = '\%(\[\|{\|(\)'
let close_match_idx = match(a:text, data_structure_close . '\s*$')
let _move = cursor(a:lnum, close_match_idx + 1)
call cursor(a:lnum, close_match_idx + 1)
let [open_match_lnum, open_match_col] = searchpairpos(data_structure_open, '', data_structure_close, 'bnW')
let open_match_text = getline(open_match_lnum)
return s:get_base_indent(open_match_lnum, open_match_text)
Expand All @@ -175,7 +181,6 @@ function! s:get_base_indent(lnum, text)
endif
endfunction

" TODO: @jbodah 2017-03-31: remove
function! elixir#indent#handle_following_trailing_do(lnum, text, prev_nb_lnum, prev_nb_text)
if s:ends_with(a:prev_nb_text, s:keyword('do'), a:prev_nb_lnum)
if s:starts_with(a:text, s:keyword('end'), a:lnum)
Expand All @@ -188,6 +193,14 @@ function! elixir#indent#handle_following_trailing_do(lnum, text, prev_nb_lnum, p
endif
endfunction

function! elixir#indent#handle_following_trailing_rocket(lnum, text, prev_nb_lnum, prev_nb_text)
if s:ends_with(a:prev_nb_text, '->', a:prev_nb_lnum)
return indent(a:prev_nb_lnum) + s:sw()
else
return -1
endif
endfunction

function! elixir#indent#handle_following_trailing_binary_operator(lnum, text, prev_nb_lnum, prev_nb_text)
let binary_operator = '\%(=\|<>\|>>>\|<=\|||\|+\|\~\~\~\|-\|&&\|<<<\|/\|\^\^\^\|\*\)'

Expand Down
Loading

0 comments on commit 18efda3

Please sign in to comment.