forked from neovim/neovim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vim-patch:86b4816766d9 (neovim#21314)
Update runtime files vim/vim@86b4816 vim-patch:9.0.1029: autoload directory missing from distribution Problem: Autoload directory missing from distribution. Solution: Add the autoload/zig directory to the list of distributed files. vim/vim@84dbf85 Co-authored-by: Bram Moolenaar <Bram@vim.org>
- Loading branch information
Showing
23 changed files
with
1,096 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
" Adapted from fatih/vim-go: autoload/go/fmt.vim | ||
" | ||
" Copyright 2011 The Go Authors. All rights reserved. | ||
" Use of this source code is governed by a BSD-style | ||
" license that can be found in the LICENSE file. | ||
" | ||
" Upstream: https://github.com/ziglang/zig.vim | ||
|
||
function! zig#fmt#Format() abort | ||
" Save cursor position and many other things. | ||
let view = winsaveview() | ||
|
||
if !executable('zig') | ||
echohl Error | echomsg "no zig binary found in PATH" | echohl None | ||
return | ||
endif | ||
|
||
let cmdline = 'zig fmt --stdin --ast-check' | ||
let current_buf = bufnr('') | ||
|
||
" The formatted code is output on stdout, the errors go on stderr. | ||
if exists('*systemlist') | ||
silent let out = systemlist(cmdline, current_buf) | ||
else | ||
silent let out = split(system(cmdline, current_buf)) | ||
endif | ||
if len(out) == 1 | ||
if out[0] == "error: unrecognized parameter: '--ast-check'" | ||
let cmdline = 'zig fmt --stdin' | ||
if exists('*systemlist') | ||
silent let out = systemlist(cmdline, current_buf) | ||
else | ||
silent let out = split(system(cmdline, current_buf)) | ||
endif | ||
endif | ||
endif | ||
let err = v:shell_error | ||
|
||
|
||
if err == 0 | ||
" remove undo point caused via BufWritePre. | ||
try | silent undojoin | catch | endtry | ||
|
||
" Replace the file content with the formatted version. | ||
if exists('*deletebufline') | ||
call deletebufline(current_buf, len(out), line('$')) | ||
else | ||
silent execute ':' . len(out) . ',' . line('$') . ' delete _' | ||
endif | ||
call setline(1, out) | ||
|
||
" No errors detected, close the loclist. | ||
call setloclist(0, [], 'r') | ||
lclose | ||
elseif get(g:, 'zig_fmt_parse_errors', 1) | ||
let errors = s:parse_errors(expand('%'), out) | ||
|
||
call setloclist(0, [], 'r', { | ||
\ 'title': 'Errors', | ||
\ 'items': errors, | ||
\ }) | ||
|
||
let max_win_height = get(g:, 'zig_fmt_max_window_height', 5) | ||
" Prevent the loclist from becoming too long. | ||
let win_height = min([max_win_height, len(errors)]) | ||
" Open the loclist, but only if there's at least one error to show. | ||
execute 'silent! lwindow ' . win_height | ||
endif | ||
|
||
call winrestview(view) | ||
|
||
if err != 0 | ||
echohl Error | echomsg "zig fmt returned error" | echohl None | ||
return | ||
endif | ||
|
||
" Run the syntax highlighter on the updated content and recompute the folds if | ||
" needed. | ||
syntax sync fromstart | ||
endfunction | ||
|
||
" parse_errors parses the given errors and returns a list of parsed errors | ||
function! s:parse_errors(filename, lines) abort | ||
" list of errors to be put into location list | ||
let errors = [] | ||
for line in a:lines | ||
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)') | ||
if !empty(tokens) | ||
call add(errors,{ | ||
\"filename": a:filename, | ||
\"lnum": tokens[2], | ||
\"col": tokens[3], | ||
\"text": tokens[4], | ||
\ }) | ||
endif | ||
endfor | ||
|
||
return errors | ||
endfunction | ||
" vim: sw=2 ts=2 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
" Vim compiler file | ||
" Compiler: dotnet build (.NET CLI) | ||
" Maintainer: Nick Jensen <nickspoon@gmail.com> | ||
" Last Change: 2022-12-06 | ||
" License: Vim (see :h license) | ||
" Repository: https://github.com/nickspoons/vim-cs | ||
|
||
if exists("current_compiler") | ||
finish | ||
endif | ||
let current_compiler = "dotnet" | ||
|
||
if exists(":CompilerSet") != 2 " older Vim always used :setlocal | ||
command -nargs=* CompilerSet setlocal <args> | ||
endif | ||
|
||
let s:cpo_save = &cpo | ||
set cpo&vim | ||
|
||
if get(g:, "dotnet_errors_only", v:false) | ||
CompilerSet makeprg=dotnet\ build\ -nologo | ||
\\ -consoleloggerparameters:NoSummary | ||
\\ -consoleloggerparameters:ErrorsOnly | ||
else | ||
CompilerSet makeprg=dotnet\ build\ -nologo\ -consoleloggerparameters:NoSummary | ||
endif | ||
|
||
if get(g:, "dotnet_show_project_file", v:true) | ||
CompilerSet errorformat=%E%f(%l\\,%c):\ %trror\ %m, | ||
\%W%f(%l\\,%c):\ %tarning\ %m, | ||
\%-G%.%# | ||
else | ||
CompilerSet errorformat=%E%f(%l\\,%c):\ %trror\ %m\ [%.%#], | ||
\%W%f(%l\\,%c):\ %tarning\ %m\ [%.%#], | ||
\%-G%.%# | ||
endif | ||
|
||
let &cpo = s:cpo_save | ||
unlet s:cpo_save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
" Vim compiler file | ||
" Compiler: Zig Compiler | ||
" Upstream: https://github.com/ziglang/zig.vim | ||
|
||
if exists("current_compiler") | ||
finish | ||
endif | ||
let current_compiler = "zig" | ||
|
||
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
if exists(":CompilerSet") != 2 | ||
command -nargs=* CompilerSet setlocal <args> | ||
endif | ||
|
||
" a subcommand must be provided for the this compiler (test, build-exe, etc) | ||
if has('patch-7.4.191') | ||
CompilerSet makeprg=zig\ \$*\ \%:S | ||
else | ||
CompilerSet makeprg=zig\ \$*\ \"%\" | ||
endif | ||
|
||
" TODO: improve errorformat as needed. | ||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
" Vim compiler file | ||
" Compiler: Zig Compiler (zig build) | ||
" Upstream: https://github.com/ziglang/zig.vim | ||
|
||
if exists('current_compiler') | ||
finish | ||
endif | ||
runtime compiler/zig.vim | ||
let current_compiler = 'zig_build' | ||
|
||
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
|
||
if exists(':CompilerSet') != 2 | ||
command -nargs=* CompilerSet setlocal <args> | ||
endif | ||
|
||
if exists('g:zig_build_makeprg_params') | ||
execute 'CompilerSet makeprg=zig\ build\ '.escape(g:zig_build_makeprg_params, ' \|"').'\ $*' | ||
else | ||
CompilerSet makeprg=zig\ build\ $* | ||
endif | ||
|
||
" TODO: anything to add to errorformat for zig build specifically? | ||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
" Vim compiler file | ||
" Compiler: Zig Compiler (zig build-exe) | ||
" Upstream: https://github.com/ziglang/zig.vim | ||
|
||
if exists('current_compiler') | ||
finish | ||
endif | ||
runtime compiler/zig.vim | ||
let current_compiler = 'zig_build_exe' | ||
|
||
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
|
||
if exists(':CompilerSet') != 2 | ||
command -nargs=* CompilerSet setlocal <args> | ||
endif | ||
|
||
if has('patch-7.4.191') | ||
CompilerSet makeprg=zig\ build-exe\ \%:S\ \$* | ||
else | ||
CompilerSet makeprg=zig\ build-exe\ \"%\"\ \$* | ||
endif | ||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
" Vim compiler file | ||
" Compiler: Zig Compiler (zig test) | ||
" Upstream: https://github.com/ziglang/zig.vim | ||
|
||
if exists('current_compiler') | ||
finish | ||
endif | ||
runtime compiler/zig.vim | ||
let current_compiler = 'zig_test' | ||
|
||
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
|
||
if exists(':CompilerSet') != 2 | ||
command -nargs=* CompilerSet setlocal <args> | ||
endif | ||
|
||
if has('patch-7.4.191') | ||
CompilerSet makeprg=zig\ test\ \%:S\ \$* | ||
else | ||
CompilerSet makeprg=zig\ test\ \"%\"\ \$* | ||
endif | ||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
" vim: tabstop=8 shiftwidth=4 softtabstop=4 expandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.