diff options
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/crystal_lang.vim | 9 | ||||
| -rw-r--r-- | autoload/dart.vim | 87 | ||||
| -rw-r--r-- | autoload/go/config.vim | 5 | ||||
| -rw-r--r-- | autoload/jsx_pretty/comment.vim | 4 | ||||
| -rw-r--r-- | autoload/puppet/format.vim | 17 | ||||
| -rw-r--r-- | autoload/terraform.vim | 3 | 
6 files changed, 72 insertions, 53 deletions
| diff --git a/autoload/crystal_lang.vim b/autoload/crystal_lang.vim index a04d456b..99d0ca2c 100644 --- a/autoload/crystal_lang.vim +++ b/autoload/crystal_lang.vim @@ -77,10 +77,17 @@ function! crystal_lang#entrypoint_for(file_path) abort          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 "./spec/**"', +                \   'require "' . require_spec_str . '"',                  \   printf('require "./%s"', fnamemodify(a:file_path, ':p')[strlen(root_dir)+1 : ])                  \ ] diff --git a/autoload/dart.vim b/autoload/dart.vim index de67efe3..3776da4e 100644 --- a/autoload/dart.vim +++ b/autoload/dart.vim @@ -28,61 +28,56 @@ function! s:clearQfList(reason) abort  endfunction  function! dart#fmt(q_args) abort -  if executable('dartfmt') -    let buffer_content = join(getline(1, '$'), "\n") -    let args = '--stdin-name '.expand('%').' '.a:q_args -    let joined_lines = system(printf('dartfmt %s', args), buffer_content) -    if buffer_content ==# joined_lines[:-2] -      call s:clearQfList('dartfmt') -      return -    endif -    if 0 == v:shell_error -      let win_view = winsaveview() -      let lines = split(joined_lines, "\n") -      silent keepjumps call setline(1, lines) -      if line('$') > len(lines) -        silent keepjumps execute string(len(lines)+1).',$ delete' -      endif -      call winrestview(win_view) -      call s:clearQfList('dartfmt') -    else -      let errors = split(joined_lines, "\n")[2:] -      let error_format = '%Aline %l\, column %c of %f: %m,%C%.%#' -      call s:cexpr(error_format, errors, 'dartfmt') +  let cmd = s:FindDartFmt() +  if type(cmd) != type('') | return | endif +  let buffer_content = getline(1, '$') +  let args = '--stdin-name '.expand('%').' '.a:q_args +  let lines = systemlist(printf('%s %s', cmd, args), join(buffer_content, "\n")) +  " TODO(https://github.com/dart-lang/sdk/issues/38507) - Remove once the +  " tool no longer emits this line on SDK upgrades. +  if lines[-1] ==# 'Isolate creation failed' +    let lines = lines[:-2] +  endif +  if buffer_content == lines +    call s:clearQfList('dartfmt') +    return +  endif +  if 0 == v:shell_error +    let win_view = winsaveview() +    silent keepjumps call setline(1, lines) +    if line('$') > len(lines) +      silent keepjumps execute string(len(lines)+1).',$ delete'      endif +    call winrestview(win_view) +    call s:clearQfList('dartfmt')    else -    call s:error('cannot execute binary file: dartfmt') +    let errors = lines[2:] +    let error_format = '%Aline %l\, column %c of %f: %m,%C%.%#' +    call s:cexpr(error_format, errors, 'dartfmt')    endif  endfunction -function! dart#analyzer(q_args) abort -  if executable('dartanalyzer') -    let path = expand('%:p:gs:\:/:') -    if filereadable(path) -      let command = printf('dartanalyzer %s %s', a:q_args, shellescape(path)) -      let lines = systemlist(command) -      call s:cexpr('%m (%f\, line %l\, col %c)', lines, 'dartanalyzer') -    else -      call s:error(printf('cannot read a file: "%s"', path)) -    endif -  else -    call s:error('cannot execute binary file: dartanalyzer') +function! s:FindDartFmt() abort +  if executable('dartfmt') | return 'dartfmt' | endif +  if executable('flutter') +    let l:flutter_cmd = resolve(exepath('flutter')) +    let l:bin = fnamemodify(l:flutter_cmd, ':h') +    let l:dartfmt = l:bin.'/cache/dart-sdk/bin/dartfmt' +    if executable(l:dartfmt) | return l:dartfmt | endif    endif +  call s:error('Cannot find a `dartfmt` command') +endfunction + +function! dart#analyzer(q_args) abort +  call s:error('DartAnalyzer support has been removed. '. +      \'If this broke your workflow please comment on '. +      \'https://github.com/dart-lang/dart-vim-plugin/issues/89')  endfunction  function! dart#tojs(q_args) abort -  if executable('dart2js') -    let path = expand('%:p:gs:\:/:') -    if filereadable(path) -      let command = printf('dart2js %s %s', a:q_args, shellescape(path)) -      let lines = systemlist(command) -      call s:cexpr('%m (%f\, line %l\, col %c)', lines, 'dart2js') -    else -      call s:error(printf('cannot read a file: "%s"', path)) -    endif -  else -    call s:error('cannot execute binary file: dartanalyzer') -  endif +  call s:error('Dart2JS support has been removed. '. +      \'If this broke your workflow please comment on '. +      \'https://github.com/dart-lang/dart-vim-plugin/issues/89')  endfunction  " Finds the path to `uri`. diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 3301edae..055d3d6a 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -207,9 +207,10 @@ endfunction  function! go#config#DebugWindows() abort    return get(g:, 'go_debug_windows', { -            \ 'stack': 'leftabove 20vnew', -            \ 'out':   'botright 10new',              \ 'vars':  'leftabove 30vnew', +            \ 'stack': 'leftabove 20new', +            \ 'goroutines': 'botright 10new', +            \ 'out':        'botright 5new',              \ }           \ ) diff --git a/autoload/jsx_pretty/comment.vim b/autoload/jsx_pretty/comment.vim index 1569cd82..c202ebf4 100644 --- a/autoload/jsx_pretty/comment.vim +++ b/autoload/jsx_pretty/comment.vim @@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || !(index(g:polyglot_disabled, 'typescript')  function! jsx_pretty#comment#update_commentstring(original)    let syn_current = s:syn_name(line('.'), col('.'))    let syn_start = s:syn_name(line('.'), 1) -  let save_view = winsaveview() +  let save_cursor = getcurpos()    if syn_start =~? '^jsx'      let line = getline(".") @@ -24,7 +24,7 @@ function! jsx_pretty#comment#update_commentstring(original)    endif    " Restore the cursor position -  call winrestview(save_view) +  call setpos('.', save_cursor)  endfunction  function! s:syn_name(lnum, cnum) diff --git a/autoload/puppet/format.vim b/autoload/puppet/format.vim index cfd48155..519fcc71 100644 --- a/autoload/puppet/format.vim +++ b/autoload/puppet/format.vim @@ -5,9 +5,16 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'puppet') == -1  function! puppet#format#Format() abort    let l:start_lnum = v:lnum    let l:end_lnum = v:lnum + v:count - 1 -  call puppet#format#Indention(l:start_lnum, l:end_lnum) -  call puppet#format#Hashrocket(l:start_lnum, l:end_lnum) +  " Don't modify indentation or alignment if called by textwidth. We'll only +  " let the fallback function do its thing in this case so that textwidth +  " still performs the expected feature. +  if mode() !~# '[iR]' +    call puppet#format#Indention(l:start_lnum, l:end_lnum) +    call puppet#format#Hashrocket(l:start_lnum, l:end_lnum) +  endif    call puppet#format#Fallback(l:start_lnum, l:end_lnum) +  " explicitly avoid falling back to default formatting +  return 0  endfunction  "" @@ -37,10 +44,16 @@ endfunction  " lines which exeed &widthline are formated  "  function! puppet#format#Fallback(start_lnum, end_lnum) abort +  " We shouldn't wrap lines based on textwidth if it is disabled +  if &textwidth == 0 +    return +  endif +    " I'm using it to check if autoformat expand range    let l:eof_lnum = line('$')    let l:lnum = a:start_lnum    let l:end_lnum = a:end_lnum +    while l:lnum <= l:end_lnum      if strlen(getline(l:lnum)) > &textwidth        call cursor(l:lnum) diff --git a/autoload/terraform.vim b/autoload/terraform.vim index 8372b004..da36751e 100644 --- a/autoload/terraform.vim +++ b/autoload/terraform.vim @@ -1,5 +1,8 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1 +" Ensure no conflict with arguments from the environment +let $TF_CLI_ARGS_fmt='' +  function! terraform#fmt()    if !filereadable(expand('%:p'))      return | 
