From 6ef84fa6d76caeba16a9fa8e138376896aa4a197 Mon Sep 17 00:00:00 2001 From: tdro Date: Thu, 4 Mar 2021 02:00:18 -0500 Subject: .vimrc: Move linting function bodies directly to auto commands --- .vimrc | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/.vimrc b/.vimrc index 52fcb0c..c30eab2 100644 --- a/.vimrc +++ b/.vimrc @@ -104,23 +104,6 @@ function! AnsibleCheck() :redraw! endfunction -" Shell Check -function! ShellCheck() - :silent exe '!' . expand(g:notify) . ' ' . '"$(shellcheck -x --exclude=SC1090,SC1091 % 2>&1 && echo ''Shellcheck OK: %'')" > /dev/null 2>&1 &' -endfunction - -" Nix Check -function! NixCheck() - :silent exe '!' . expand(g:notify) . ' ' . '"$(nix-linter % 2>&1 && echo ''Nix Lint OK: %'' && nixfmt % 2>&1)" > /dev/null 2>&1' - :redraw! -endfunction - -" Elixir Format -function! ElixirFormat() - :silent exe '!' . expand(g:notify) . ' ' . '"$(mix format % 2>&1 && echo ''Elixir Format OK: %'')" > /dev/null 2>&1' - :redraw! -endfunction - " Typography Format function! TypographyFormat() :silent! %s/\(^\|\s\|\w\)\zs--\ze\($\|\s\|\w\)/–/g | silent! %s/\(^\|\s\|\w\)\zs---\ze\($\|\s\|\w\)/—/g @@ -309,21 +292,21 @@ augroup AutoCommands autocmd BufWritePost *.txt,*.md :only | :term ++rows=10 vale-wrapper % " Linting file type post write commands. - autocmd FileType bash,sh autocmd! BufWritePost :call ShellCheck() - autocmd FileType nix autocmd! BufWritePost silent call NixCheck() - autocmd FileType elixir autocmd! BufWritePost :call ElixirFormat() autocmd FileType haskell autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(hlint % 2>&1)"' - autocmd FileType json autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(jsonlint -i % 2>&1 && echo ''json OK: %'')"' autocmd FileType css autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(prettier --write --parser css % 2>&1)"' autocmd FileType rust autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(rustfmt % 2>&1 && echo ''rustfmt OK: %'')"' + autocmd FileType json autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(jsonlint -i % 2>&1 && echo ''json OK: %'')"' autocmd FileType c autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(clang-format -i % 2>&1 && echo ''clang-format OK: %'')"' autocmd FileType go autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(gofmt -w -s -e % 2>&1 && go vet % 2>&1 && echo ''gofmt OK: %'')"' autocmd FileType awk autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(awk -g -f % 2>&1 && awk -o- -f % | sponge % && echo ''awk OK: %'')"' + autocmd FileType elixir autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(mix format % 2>&1 && echo ''Elixir Format OK: %'')" > /dev/null 2>&1' + autocmd FileType nix autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(nix-linter % 2>&1 && echo ''Nix Lint OK: %'' && nixfmt % 2>&1)" > /dev/null 2>&1' autocmd FileType yaml autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(yaml round-trip --indent 2 --save % 2>&1 && yamllint -s % 2>&1 && echo ''yaml OK: %'')"' + autocmd FileType bash,sh autocmd! BufWritePost silent exe '!' . expand(g:notify) . ' ' . '"$(shellcheck -x --exclude=SC1090,SC1091 % 2>&1 && echo ''Shellcheck OK: %'')" > /dev/null 2>&1 &' " File type function under cursor lookups. - autocmd FileType go noremap df :exe ':term ++rows=10 go doc ' . expand('') - autocmd FileType nix noremap df :exe ':term ++rows=10 nixos-option ' . expand('') + autocmd FileType go noremap df :exe ':term ++rows=10 go doc ' . expand('') + autocmd FileType nix noremap df :exe ':term ++rows=10 nixos-option ' . expand('') autocmd FileType elixir noremap df :exe ':term ++rows=10 sh -c "echo ''h(' . expand('') . ')'' \| iex"' " REPL commands. -- cgit v1.2.3