diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:03:34 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:03:34 +0200 |
commit | 68b2748af117b56208f25678c4b465af00dc64c5 (patch) | |
tree | f9038064b78513b3f99edb574cdd2943bd2fd633 | |
parent | 14dc82fc4e6c0c08078f97a24a6c1639c1cc5113 (diff) | |
download | vim-polyglot-68b2748af117b56208f25678c4b465af00dc64c5.tar.gz vim-polyglot-68b2748af117b56208f25678c4b465af00dc64c5.zip |
Update
-rw-r--r-- | autoload/crystal/indent.vim | 28 | ||||
-rw-r--r-- | autoload/crystal_lang.vim | 546 | ||||
-rw-r--r-- | autoload/ecrystal.vim | 2 | ||||
-rw-r--r-- | autoload/go/config.vim | 2 | ||||
-rw-r--r-- | autoload/rust.vim | 4 | ||||
-rw-r--r-- | ftplugin/crystal.vim | 12 | ||||
-rw-r--r-- | ftplugin/julia.vim | 2 | ||||
-rw-r--r-- | indent/crystal.vim | 6 | ||||
-rw-r--r-- | indent/julia.vim | 18 | ||||
-rw-r--r-- | syntax/basic/doc.vim | 3 | ||||
-rw-r--r-- | syntax/common.vim | 1 | ||||
-rw-r--r-- | syntax/crystal.vim | 2 | ||||
-rw-r--r-- | syntax/julia.vim | 2 | ||||
-rw-r--r-- | syntax/python.vim | 2 | ||||
-rw-r--r-- | syntax/ruby.vim | 2 |
15 files changed, 312 insertions, 320 deletions
diff --git a/autoload/crystal/indent.vim b/autoload/crystal/indent.vim index dbf4c141..63908254 100644 --- a/autoload/crystal/indent.vim +++ b/autoload/crystal/indent.vim @@ -31,6 +31,11 @@ lockvar g:crystal#indent#sol let g:crystal#indent#eol = '\s*\%(%}\)\=\ze\s*\%(#.*\)\=$' lockvar g:crystal#indent#eol +" Regex that defines blocks. +let g:crystal#indent#block_regex = + \ '\%(\<do\>\|%\@1<!{\)\s*\%(|[^|]*|\)\='.g:crystal#indent#eol +lockvar g:crystal#indent#block_regex + " Regex that defines the start-match for the 'end' keyword. " NOTE: This *should* properly match the 'do' only at the end of the " line @@ -43,7 +48,7 @@ let g:crystal#indent#end_start_regex = \ '\<\%(if\|unless\|while\|until\|case\|begin\|for\|union\)\>' . \ '\)' . \ '\|' . - \ '.\{-}\zs\<do\s*\%(|.*|\)\='.g:crystal#indent#eol + \ g:crystal#indent#block_regex lockvar g:crystal#indent#end_start_regex " Regex that defines the middle-match for the 'end' keyword. @@ -80,13 +85,15 @@ lockvar g:crystal#indent#crystal_type_declaration " Regex that defines continuation lines, not including (, {, or [. let g:crystal#indent#non_bracket_continuation_regex = \ '\%(' . - \ '[\\.,:/%+\-=~<>|&^]' . + \ '[\\.,:/%+\-=~<>&^]' . + \ '\|' . + \ '\%(\%(\<do\>\|%\@1<!{\)\s*|[^|]*\)\@<!|' . \ '\|' . \ '\W?' . \ '\|' . \ '\<\%(if\|unless\)\>' . \ '\|' . - \ '\%('.g:crystal#indent#sol.g:crystal#indent#crystal_type_declaration.'\h\k*\)\@<!\*' . + \ '\%('.g:crystal#indent#crystal_type_declaration.'\h\k*\)\@<!\*' . \ '\)' . \ g:crystal#indent#eol lockvar g:crystal#indent#non_bracket_continuation_regex @@ -117,19 +124,6 @@ lockvar g:crystal#indent#continuable_regex 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 = - \ '\%(\<do:\@!\>\|%\@1<!{\)\s*\%(|\s*(*\s*\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(*\s*[*@&]\=\h\w*\s*)*\s*\)*|\)\=\s*\%(%}\)\=\s*\%(#.*\)\=$' -lockvar g:crystal#indent#block_regex - let g:crystal#indent#block_continuation_regex = '^\s*[^])}\t ].*'.g:crystal#indent#block_regex lockvar g:crystal#indent#block_continuation_regex @@ -368,4 +362,6 @@ function! crystal#indent#FindContainingClass() abort return 0 endfunction +" vim: sw=2 sts=2 et: + endif diff --git a/autoload/crystal_lang.vim b/autoload/crystal_lang.vim index 98359a4b..a697a943 100644 --- a/autoload/crystal_lang.vim +++ b/autoload/crystal_lang.vim @@ -10,41 +10,41 @@ let s:C = s:V.import('ColorEcho') let s:IS_WINDOWS = has('win32') if exists('*json_decode') - function! s:decode_json(text) abort - return json_decode(a:text) - endfunction + function! s:decode_json(text) abort + return json_decode(a:text) + endfunction else - let s:J = s:V.import('Web.JSON') - function! s:decode_json(text) abort - return s:J.decode(a:text) - endfunction + let s:J = s:V.import('Web.JSON') + function! s:decode_json(text) abort + return s:J.decode(a:text) + endfunction endif function! s:echo_error(msg, ...) abort - echohl ErrorMsg - if a:0 == 0 - echomsg a:msg - else - echomsg call('printf', [a:msg] + a:000) - endif - echohl None + echohl ErrorMsg + if a:0 == 0 + echomsg a:msg + else + echomsg call('printf', [a:msg] + a:000) + endif + echohl None endfunction function! s:run_cmd(cmd) abort - if !executable(g:crystal_compiler_command) - throw "vim-crystal: Error: '" . g:crystal_compiler_command . "' command is not found." - endif - return s:P.system(a:cmd) + if !executable(g:crystal_compiler_command) + throw "vim-crystal: Error: '" . g:crystal_compiler_command . "' command is not found." + endif + return s:P.system(a:cmd) endfunction function! s:find_root_by(search_dir, d) abort - let found_dir = finddir(a:search_dir, a:d . ';') - if found_dir ==# '' - return '' - endif + let found_dir = finddir(a:search_dir, a:d . ';') + if found_dir ==# '' + return '' + endif - " Note: ':h:h' for {root}/{search_dir}/ -> {root}/{search_dir} -> {root} - return fnamemodify(found_dir, ':p:h:h') + " Note: ':h:h' for {root}/{search_dir}/ -> {root}/{search_dir} -> {root} + return fnamemodify(found_dir, ':p:h:h') endfunction " Search the root directory containing a 'spec/' and a 'src/' directories. @@ -53,319 +53,321 @@ endfunction " compiler has a 'cr_sources/src/spec/' directory that would otherwise give the root " directory as 'cr_source/src/' instead of 'cr_sources/'. function! s:find_root_by_spec_and_src(d) abort - " Search for 'spec/' - let root = s:find_root_by('spec', a:d) - " Check that 'src/' is also there - if root !=# '' && isdirectory(root . '/src') - return root - endif - - " Search for 'src/' - let root = s:find_root_by('src', a:d) - " Check that 'spec/' is also there - if root !=# '' && isdirectory(root . '/spec') - return root - endif - - " Cannot find a directory containing both 'src/' and 'spec/' - return '' + " Search for 'spec/' + let root = s:find_root_by('spec', a:d) + " Check that 'src/' is also there + if root !=# '' && isdirectory(root . '/src') + return root + endif + + " Search for 'src/' + let root = s:find_root_by('src', a:d) + " Check that 'spec/' is also there + if root !=# '' && isdirectory(root . '/spec') + return root + endif + + " Cannot find a directory containing both 'src/' and 'spec/' + return '' endfunction function! crystal_lang#entrypoint_for(file_path) abort - let parent_dir = fnamemodify(a:file_path, ':p:h') - let root_dir = s:find_root_by_spec_and_src(parent_dir) - if root_dir ==# '' - " No spec directory found. No need to make temporary file - return a:file_path - endif - - let required_spec_path = get(b:, 'crystal_required_spec_path', get(g:, 'crystal_required_spec_path', '')) - if required_spec_path !=# '' - let require_spec_str = './' . required_spec_path - else - let require_spec_str = './spec/**' - endif - - let temp_name = root_dir . '/__vim-crystal-temporary-entrypoint-' . fnamemodify(a:file_path, ':t') - let contents = [ - \ 'require "spec"', - \ 'require "' . require_spec_str . '"', - \ printf('require "./%s"', fnamemodify(a:file_path, ':p')[strlen(root_dir)+1 : ]) - \ ] - - let result = writefile(contents, temp_name) - if result == -1 - " Note: When writefile() failed - return a:file_path - endif - - return temp_name + let parent_dir = fnamemodify(a:file_path, ':p:h') + let root_dir = s:find_root_by_spec_and_src(parent_dir) + if root_dir ==# '' + " No spec directory found. No need to make temporary file + return a:file_path + endif + + let required_spec_path = get(b:, 'crystal_required_spec_path', get(g:, 'crystal_required_spec_path', '')) + if required_spec_path !=# '' + let require_spec_str = './' . required_spec_path + else + let require_spec_str = './spec/**' + endif + + let temp_name = root_dir . '/__vim-crystal-temporary-entrypoint-' . fnamemodify(a:file_path, ':t') + let contents = [ + \ 'require "spec"', + \ 'require "' . require_spec_str . '"', + \ printf('require "./%s"', fnamemodify(a:file_path, ':p')[strlen(root_dir)+1 : ]) + \ ] + + let result = writefile(contents, temp_name) + if result == -1 + " Note: When writefile() failed + return a:file_path + endif + + return temp_name endfunction function! crystal_lang#tool(name, file, pos, option_str) abort - let entrypoint = crystal_lang#entrypoint_for(a:file) - let cmd = printf( - \ '%s tool %s --no-color %s --cursor %s:%d:%d %s', - \ g:crystal_compiler_command, - \ a:name, - \ a:option_str, - \ a:file, - \ a:pos[1], - \ a:pos[2], - \ entrypoint - \ ) - - try - let output = s:run_cmd(cmd) - return {'failed': s:P.get_last_status(), 'output': output} - finally - " Note: - " If the entry point is temporary file, delete it finally. - if a:file !=# entrypoint - call delete(entrypoint) - endif - endtry + let entrypoint = crystal_lang#entrypoint_for(a:file) + let cmd = printf( + \ '%s tool %s --no-color %s --cursor %s:%d:%d %s', + \ g:crystal_compiler_command, + \ a:name, + \ a:option_str, + \ a:file, + \ a:pos[1], + \ a:pos[2], + \ entrypoint + \ ) + + try + let output = s:run_cmd(cmd) + return {'failed': s:P.get_last_status(), 'output': output} + finally + " Note: + " If the entry point is temporary file, delete it finally. + if a:file !=# entrypoint + call delete(entrypoint) + endif + endtry endfunction " `pos` is assumed a returned value from getpos() function! crystal_lang#impl(file, pos, option_str) abort - return crystal_lang#tool('implementations', a:file, a:pos, a:option_str) + return crystal_lang#tool('implementations', a:file, a:pos, a:option_str) endfunction function! s:jump_to_impl(impl) abort - execute 'edit' a:impl.filename - call cursor(a:impl.line, a:impl.column) + execute 'edit' a:impl.filename + call cursor(a:impl.line, a:impl.column) endfunction function! crystal_lang#jump_to_definition(file, pos) abort - echo 'analyzing definitions under cursor...' - - let cmd_result = crystal_lang#impl(a:file, a:pos, '--format json') - if cmd_result.failed - return s:echo_error(cmd_result.output) - endif - - let impl = s:decode_json(cmd_result.output) - if impl.status !=# 'ok' - return s:echo_error(impl.message) - endif - - if len(impl.implementations) == 1 - call s:jump_to_impl(impl.implementations[0]) - return - endif - - let message = "Multiple definitions detected. Choose a number\n\n" - for idx in range(len(impl.implementations)) - let i = impl.implementations[idx] - let message .= printf("[%d] %s:%d:%d\n", idx, i.filename, i.line, i.column) - endfor - let message .= "\n" - let idx = str2nr(input(message, "\n> ")) - call s:jump_to_impl(impl.implementations[idx]) + echo 'analyzing definitions under cursor...' + + let cmd_result = crystal_lang#impl(a:file, a:pos, '--format json') + if cmd_result.failed + return s:echo_error(cmd_result.output) + endif + + let impl = s:decode_json(cmd_result.output) + if impl.status !=# 'ok' + return s:echo_error(impl.message) + endif + + if len(impl.implementations) == 1 + call s:jump_to_impl(impl.implementations[0]) + return + endif + + let message = "Multiple definitions detected. Choose a number\n\n" + for idx in range(len(impl.implementations)) + let i = impl.implementations[idx] + let message .= printf("[%d] %s:%d:%d\n", idx, i.filename, i.line, i.column) + endfor + let message .= "\n" + let idx = str2nr(input(message, "\n> ")) + call s:jump_to_impl(impl.implementations[idx]) endfunction function! crystal_lang#context(file, pos, option_str) abort - return crystal_lang#tool('context', a:file, a:pos, a:option_str) + return crystal_lang#tool('context', a:file, a:pos, a:option_str) endfunction function! crystal_lang#type_hierarchy(file, option_str) abort - let cmd = printf( - \ '%s tool hierarchy --no-color %s %s', - \ g:crystal_compiler_command, - \ a:option_str, - \ a:file - \ ) - - return s:run_cmd(cmd) + let cmd = printf( + \ '%s tool hierarchy --no-color %s %s', + \ g:crystal_compiler_command, + \ a:option_str, + \ a:file + \ ) + + return s:run_cmd(cmd) endfunction function! s:find_completion_start() abort - let c = col('.') - if c <= 1 - return -1 - endif + let c = col('.') + if c <= 1 + return -1 + endif - let line = getline('.')[:c-2] - return match(line, '\w\+$') + let line = getline('.')[:c-2] + return match(line, '\w\+$') endfunction function! crystal_lang#complete(findstart, base) abort - if a:findstart - return s:find_completion_start() - endif - - let cmd_result = crystal_lang#context(expand('%'), getpos('.'), '--format json') - if cmd_result.failed - return - endif - - let contexts = s:decode_json(cmd_result.output) - if contexts.status !=# 'ok' - return - endif - - let candidates = [] - - for c in contexts.contexts - for [name, desc] in items(c) - let candidates += [{ - \ 'word': name, - \ 'menu': ': ' . desc . ' [var]', - \ }] - endfor + if a:findstart + return s:find_completion_start() + endif + + let cmd_result = crystal_lang#context(expand('%'), getpos('.'), '--format json') + if cmd_result.failed + return + endif + + let contexts = s:decode_json(cmd_result.output) + if contexts.status !=# 'ok' + return + endif + + let candidates = [] + + for c in contexts.contexts + for [name, desc] in items(c) + let candidates += [{ + \ 'word': name, + \ 'menu': ': ' . desc . ' [var]', + \ }] endfor + endfor - return candidates + return candidates endfunction function! crystal_lang#get_spec_switched_path(absolute_path) abort - let base = fnamemodify(a:absolute_path, ':t:r') - - " TODO: Make cleverer - if base =~# '_spec$' - let parent = fnamemodify(substitute(a:absolute_path, '/spec/', '/src/', ''), ':h') - return parent . '/' . matchstr(base, '.\+\ze_spec$') . '.cr' - else - let parent = fnamemodify(substitute(a:absolute_path, '/src/', '/spec/', ''), ':h') - return parent . '/' . base . '_spec.cr' - endif + let base = fnamemodify(a:absolute_path, ':t:r') + + " TODO: Make cleverer + if base =~# '_spec$' + let parent = fnamemodify(substitute(a:absolute_path, '/spec/', '/src/', ''), ':h') + return parent . '/' . matchstr(base, '.\+\ze_spec$') . '.cr' + else + let parent = fnamemodify(substitute(a:absolute_path, '/src/', '/spec/', ''), ':h') + return parent . '/' . base . '_spec.cr' + endif endfunction function! crystal_lang#switch_spec_file(...) abort - let path = a:0 == 0 ? expand('%:p') : fnamemodify(a:1, ':p') - if path !~# '.cr$' - return s:echo_error('Not crystal source file: ' . path) - endif + let path = a:0 == 0 ? expand('%:p') : fnamemodify(a:1, ':p') + if path !~# '.cr$' + return s:echo_error('Not crystal source file: ' . path) + endif - execute 'edit!' crystal_lang#get_spec_switched_path(path) + execute 'edit!' crystal_lang#get_spec_switched_path(path) endfunction function! s:run_spec(root, path, ...) abort - " Note: - " `crystal spec` can't understand absolute path. - let cmd = printf( - \ '%s spec %s%s', - \ g:crystal_compiler_command, - \ a:path, - \ a:0 == 0 ? '' : (':' . a:1) - \ ) - - let saved_cwd = getcwd() - let cd = haslocaldir() ? 'lcd' : 'cd' - try - execute cd a:root - call s:C.echo(s:run_cmd(cmd)) - finally - execute cd saved_cwd - endtry + " Note: + " `crystal spec` can't understand absolute path. + let cmd = printf( + \ '%s spec %s%s', + \ g:crystal_compiler_command, + \ a:path, + \ a:0 == 0 ? '' : (':' . a:1) + \ ) + + let saved_cwd = getcwd() + let cd = haslocaldir() ? 'lcd' : 'cd' + try + execute cd a:root + call s:C.echo(s:run_cmd(cmd)) + finally + execute cd saved_cwd + endtry endfunction function! crystal_lang#run_all_spec(...) abort - let path = a:0 == 0 ? expand('%:p:h') : a:1 - let root_path = s:find_root_by_spec_and_src(path) - if root_path ==# '' - return s:echo_error("'spec' directory is not found") - endif - call s:run_spec(root_path, 'spec') + let path = a:0 == 0 ? expand('%:p:h') : a:1 + let root_path = s:find_root_by_spec_and_src(path) + if root_path ==# '' + return s:echo_error("'spec' directory is not found") + endif + call s:run_spec(root_path, 'spec') endfunction function! crystal_lang#run_current_spec(...) abort - " /foo/bar/src/poyo.cr - let path = a:0 == 0 ? expand('%:p') : fnamemodify(a:1, ':p') - if path !~# '.cr$' - return s:echo_error('Not crystal source file: ' . path) - endif - - " /foo/bar/src - let source_dir = fnamemodify(path, ':h') - - " /foo/bar - let root_dir = s:find_root_by_spec_and_src(source_dir) - if root_dir ==# '' - return s:echo_error("Root directory with 'src/' and 'spec/' not found") - endif - - " src - let rel_path = source_dir[strlen(root_dir)+1 : ] - - if path =~# '_spec.cr$' - call s:run_spec(root_dir, path[strlen(root_dir)+1 : ], line('.')) - else - let spec_path = substitute(rel_path, '^src', 'spec', '') . '/' . fnamemodify(path, ':t:r') . '_spec.cr' - if !filereadable(root_dir . '/' . spec_path) - return s:echo_error('Error: Could not find a spec source corresponding to ' . path) - endif - call s:run_spec(root_dir, spec_path) + " /foo/bar/src/poyo.cr + let path = a:0 == 0 ? expand('%:p') : fnamemodify(a:1, ':p') + if path !~# '.cr$' + return s:echo_error('Not crystal source file: ' . path) + endif + + " /foo/bar/src + let source_dir = fnamemodify(path, ':h') + + " /foo/bar + let root_dir = s:find_root_by_spec_and_src(source_dir) + if root_dir ==# '' + return s:echo_error("Root directory with 'src/' and 'spec/' not found") + endif + + " src + let rel_path = source_dir[strlen(root_dir)+1 : ] + + if path =~# '_spec.cr$' + call s:run_spec(root_dir, path[strlen(root_dir)+1 : ], line('.')) + else + let spec_path = substitute(rel_path, '^src', 'spec', '') . '/' . fnamemodify(path, ':t:r') . '_spec.cr' + if !filereadable(root_dir . '/' . spec_path) + return s:echo_error('Error: Could not find a spec source corresponding to ' . path) endif + call s:run_spec(root_dir, spec_path) + endif endfunction function! crystal_lang#format_string(code, ...) abort - if s:IS_WINDOWS - let redirect = '2> nul' - else - let redirect = '2>/dev/null' - endif - let cmd = printf( - \ '%s tool format --no-color %s - %s', - \ g:crystal_compiler_command, - \ get(a:, 1, ''), - \ redirect, - \ ) - let output = s:P.system(cmd, a:code) - if s:P.get_last_status() - throw 'vim-crystal: Error on formatting with command: ' . cmd - endif - return output + if s:IS_WINDOWS + let redirect = '2> nul' + else + let redirect = '2>/dev/null' + endif + let cmd = printf( + \ '%s tool format --no-color %s - %s', + \ g:crystal_compiler_command, + \ get(a:, 1, ''), + \ redirect, + \ ) + let output = s:P.system(cmd, a:code) + if s:P.get_last_status() + throw 'vim-crystal: Error on formatting with command: ' . cmd + endif + return output endfunction " crystal_lang#format(option_str [, on_save]) function! crystal_lang#format(option_str, ...) abort - let on_save = a:0 > 0 ? a:1 : 0 - - if !executable(g:crystal_compiler_command) - if on_save - " Finish command silently on save - return - else - throw 'vim-crystal: Command for formatting is not executable: ' . g:crystal_compiler_command - endif - endif + let on_save = a:0 > 0 ? a:1 : 0 - let before = join(getline(1, '$'), "\n") - try - let formatted = crystal_lang#format_string(before, a:option_str) - catch /^vim-crystal: / - echohl ErrorMsg - echomsg v:exception . ': Your code was not formatted. Exception was thrown at ' . v:throwpoint - echohl None - return - endtry - - if !on_save - let after = substitute(formatted, '\n$', '', '') - if before ==# after - return - endif + if !executable(g:crystal_compiler_command) + if on_save + " Finish command silently on save + return + else + throw 'vim-crystal: Command for formatting is not executable: ' . g:crystal_compiler_command endif + endif - let view_save = winsaveview() - let pos_save = getpos('.') - let lines = split(formatted, '\n') - silent! undojoin - if line('$') > len(lines) - execute len(lines) . ',$delete' '_' + let before = join(getline(1, '$'), "\n") + try + let formatted = crystal_lang#format_string(before, a:option_str) + catch /^vim-crystal: / + echohl ErrorMsg + echomsg v:exception . ': Your code was not formatted. Exception was thrown at ' . v:throwpoint + echohl None + return + endtry + + if !on_save + let after = substitute(formatted, '\n$', '', '') + if before ==# after + return endif - call setline(1, lines) - call winrestview(view_save) - call setpos('.', pos_save) + endif + + 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 function! crystal_lang#expand(file, pos, ...) abort - return crystal_lang#tool('expand', a:file, a:pos, get(a:, 1, '')) + return crystal_lang#tool('expand', a:file, a:pos, get(a:, 1, '')) endfunction let &cpo = s:save_cpo unlet s:save_cpo +" vim: sw=2 sts=2 et: + endif diff --git a/autoload/ecrystal.vim b/autoload/ecrystal.vim index 1a00b894..20f3151f 100644 --- a/autoload/ecrystal.vim +++ b/autoload/ecrystal.vim @@ -31,4 +31,6 @@ function! ecrystal#SetSubtype() abort endif endfunction +" vim: sw=2 sts=2 et: + endif diff --git a/autoload/go/config.vim b/autoload/go/config.vim index a2df286f..a7fd29f9 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -310,7 +310,7 @@ function! go#config#FmtAutosave() abort endfunction function! go#config#ImportsAutosave() abort - return get(g:, 'go_imports_autosave', 1) + return get(g:, 'go_imports_autosave', 0) endfunction function! go#config#SetFmtAutosave(value) abort diff --git a/autoload/rust.vim b/autoload/rust.vim index 373be590..34dd1673 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -502,13 +502,13 @@ function! s:SearchTestFunctionNameUnderCursor() abort " Search the end of test function (closing brace) to ensure that the " cursor position is within function definition if maparg('<Plug>(MatchitNormalForward)') ==# '' - normal! % + keepjumps 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' "\<Plug>(MatchitNormalForward)" + execute 'keepjumps' 'normal' "\<Plug>(MatchitNormalForward)" endif if line('.') < cursor_line return '' diff --git a/ftplugin/crystal.vim b/ftplugin/crystal.vim index 441e069f..1a2b5970 100644 --- a/ftplugin/crystal.vim +++ b/ftplugin/crystal.vim @@ -39,11 +39,11 @@ setlocal suffixesadd=.cr " Set format for quickfix window setlocal errorformat= - \%ESyntax\ error\ in\ line\ %l:\ %m, - \%ESyntax\ error\ in\ %f:%l:\ %m, - \%EError\ in\ %f:%l:\ %m, - \%C%p^, - \%-C%.%# + \%ESyntax\ error\ in\ line\ %l:\ %m, + \%ESyntax\ error\ in\ %f:%l:\ %m, + \%EError\ in\ %f:%l:\ %m, + \%C%p^, + \%-C%.%# let g:crystal_compiler_command = get(g:, 'crystal_compiler_command', 'crystal') let g:crystal_auto_format = get(g:, 'crystal_auto_format', 0) @@ -89,6 +89,6 @@ endif let &cpo = s:save_cpo unlet s:save_cpo -" vim: nowrap sw=2 sts=2 ts=8: +" vim: sw=2 sts=2 et: endif diff --git a/ftplugin/julia.vim b/ftplugin/julia.vim index 90cc49e3..9b787512 100644 --- a/ftplugin/julia.vim +++ b/ftplugin/julia.vim @@ -33,7 +33,7 @@ if exists("loaded_matchit") " note: begin_keywords must contain all blocks, in order " for nested-structures-skipping to work properly - " note: 'mutable struct' and 'strcut' are defined separately because + " note: 'mutable struct' and 'struct' are defined separately because " using \? puts the cursor on 'struct' instead of 'mutable' for some reason let b:julia_begin_keywords = '\%(\%(\.\s*\)\@<!\|\%(@\s*.\s*\)\@<=\)\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\>' " note: the following regex not only recognizes macros, but also local/global keywords. diff --git a/indent/crystal.vim b/indent/crystal.vim index 66eeef42..96cdd586 100644 --- a/indent/crystal.vim +++ b/indent/crystal.vim @@ -42,7 +42,7 @@ function GetCrystalIndent(...) let clnum = a:0 ? a:1 : v:lnum " Set up variables for restoring position in file - let vcol = col(clnum) + let vcol = col('.') " Work on the current line {{{2 " ------------------------ @@ -170,7 +170,7 @@ function GetCrystalIndent(...) " " If it contained hanging closing brackets, find the rightmost one, find its " match and indent according to that. - if line =~# '[[({]' || line =~# '[])}]\s*\%(#.*\)\=$' + if line =~# '[[({]' || line =~# '[])]\s*\%(#.*\)\=$' let [opening, closing] = crystal#indent#ExtraBrackets(lnum) if opening.pos != -1 @@ -186,7 +186,7 @@ function GetCrystalIndent(...) endif elseif closing.pos != -1 call cursor(lnum, closing.pos + 1) - normal! % + keepjumps normal! % if crystal#indent#Match(line('.'), g:crystal#indent#crystal_indent_keywords) return indent('.') + s:sw() diff --git a/indent/julia.vim b/indent/julia.vim index 97dd7bc6..59cd7d80 100644 --- a/indent/julia.vim +++ b/indent/julia.vim @@ -370,23 +370,13 @@ function GetJuliaIndent() " Analyse the reference line let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum, st, lim) - - " Increase indentation for each newly opened block - " in the reference line - while num_open_blocks > 0 - let ind += &sw - let num_open_blocks -= 1 - endwhile + " Increase indentation for each newly opened block in the reference line + let ind += shiftwidth() * num_open_blocks " Analyse the current line let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum) - - " Decrease indentation for each closed block - " in the current line - while num_closed_blocks > 0 - let ind -= &sw - let num_closed_blocks -= 1 - endwhile + " Decrease indentation for each closed block in the current line + let ind -= shiftwidth() * num_closed_blocks return ind endfunction diff --git a/syntax/basic/doc.vim b/syntax/basic/doc.vim index 44c94ef6..50f03e29 100644 --- a/syntax/basic/doc.vim +++ b/syntax/basic/doc.vim @@ -7,8 +7,9 @@ syntax match shellbang "^#!.*iojs\>" "JavaScript comments syntax keyword typescriptCommentTodo TODO FIXME XXX TBD +syntax match typescriptMagicComment "@ts-\%(ignore\|expect-error\)\>" syntax match typescriptLineComment "//.*" - \ contains=@Spell,typescriptCommentTodo,typescriptRef + \ contains=@Spell,typescriptCommentTodo,typescriptRef,typescriptMagicComment syntax region typescriptComment \ start="/\*" end="\*/" \ contains=@Spell,typescriptCommentTodo extend diff --git a/syntax/common.vim b/syntax/common.vim index fed39cf6..51900080 100644 --- a/syntax/common.vim +++ b/syntax/common.vim @@ -57,6 +57,7 @@ if exists("did_typescript_hilink") HiLink typescriptLineComment Comment HiLink typescriptDocComment Comment HiLink typescriptCommentTodo Todo + HiLink typescriptMagicComment SpecialComment HiLink typescriptRef Include HiLink typescriptDocNotation SpecialComment HiLink typescriptDocTags SpecialComment diff --git a/syntax/crystal.vim b/syntax/crystal.vim index e4b5403a..937361a8 100644 --- a/syntax/crystal.vim +++ b/syntax/crystal.vim @@ -486,6 +486,6 @@ let b:current_syntax = 'crystal' delc SynFold -" vim: nowrap sw=2 sts=2: +" vim: sw=2 sts=2 et: endif diff --git a/syntax/julia.vim b/syntax/julia.vim index 8727bde1..2dea6175 100644 --- a/syntax/julia.vim +++ b/syntax/julia.vim @@ -197,7 +197,7 @@ syntax match juliaConstGeneric display "\<\%(nothing\|Main\|undef\|missing\)\> syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro exec 'syntax match juliaMacro contained "@' . s:idregex . '\%(\.' . s:idregex . '\)*"' -syntax match juliaMacro contained "@\.\ze[^0-9]" +syntax match juliaMacro contained "@[!.~$%^*/\\|<>+-]\ze[^0-9]" exec 'syntax region juliaMacroCall contained transparent start="\(@' . s:idregex . '\%(\.' . s:idregex . '\)*\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS' exec 'syntax region juliaMacroCall contained transparent start="\(@.\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS' exec 'syntax region juliaMacroCallP contained transparent start="@' . s:idregex . '\%(\.' . s:idregex . '\)*(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock' diff --git a/syntax/python.vim b/syntax/python.vim index 101dbc2f..b6ea6529 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -58,8 +58,8 @@ endif if s:Enabled('g:python_highlight_builtins') call s:EnableByDefault('g:python_highlight_builtin_objs') - call s:EnableByDefault('g:python_highlight_builtin_funcs') call s:EnableByDefault('g:python_highlight_builtin_types') + call s:EnableByDefault('g:python_highlight_builtin_funcs') endif " diff --git a/syntax/ruby.vim b/syntax/ruby.vim index 5821749c..0a38ad8e 100644 --- a/syntax/ruby.vim +++ b/syntax/ruby.vim @@ -463,7 +463,7 @@ endif syn match rubyDefinedOperator "\%#=1\<defined?" display " 1.9-style Hash Keys and Keyword Parameters {{{1 -syn match rubySymbol "\%([{(|,]\_s*\)\@<=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[?!]\=::\@!"he=e-1 +syn match rubySymbol "\%(\w\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[?!]\=::\@!"he=e-1 contained containedin=rubyBlockParameterList,rubyCurlyBlock syn match rubySymbol "[]})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="he=e-1 syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="hs=s+1,he=e-1 |