From a61d45f4244866e12ded168fc8e224c3685a4a36 Mon Sep 17 00:00:00 2001 From: katherine Date: Tue, 27 Nov 2018 04:33:48 -0700 Subject: add vader testing function also clean up vimrc for syntactic consistency --- .vimrc | 214 ++++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 126 insertions(+), 88 deletions(-) diff --git a/.vimrc b/.vimrc index cc1089d..1df8c05 100644 --- a/.vimrc +++ b/.vimrc @@ -1,6 +1,6 @@ if !has('gui_running') set t_Co=256 -endif +end set nocompatible @@ -10,7 +10,7 @@ set nocompatible " VUNDLE " """""""""""" -execute 'set rtp+=' . split(&rtp, ',')[0] . '/bundle/Vundle.vim' +exec 'set rtp+=' . split(&rtp, ',')[0] . '/bundle/Vundle.vim' call vundle#begin() Plugin 'gmarik/Vundle.vim' @@ -74,12 +74,12 @@ set ttimeoutlen=100 nnoremap u :GundoToggle "snippet bindings -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" +let g:UltiSnipsExpandTrigger='' +let g:UltiSnipsJumpForwardTrigger='' +let g:UltiSnipsJumpBackwardTrigger='' "lightline colours. modded from 16color -function! s:Lightline_palette_init() +fun! s:Lightline_palette_init() let l:black = [ '#000000', 0 ] let l:lblack = [ '#808080', 8 ] let l:red = [ '#800000', 1 ] @@ -121,7 +121,7 @@ function! s:Lightline_palette_init() \ [ 'percent' ], \ [ 'filetype' ] ] \ }, 'colorscheme': 'shmibs' } -endfunction +endfun call s:Lightline_palette_init() @@ -130,38 +130,38 @@ let g:easytags_async = 1 let g:easytags_always_enabled = 1 "opam stuff -if executable("opam") - let s:opam_share_dir = system("opam config var share") +if executable('opam') + let s:opam_share_dir = system('opam config var share') let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '') let s:opam_configuration = {} - function! OpamConfOcpIndent() - execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim" - endfunction + fun! OpamConfOcpIndent() + exec 'set rtp^=' . s:opam_share_dir . '/ocp-indent/vim' + endfun let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent') - function! OpamConfOcpIndex() - execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim" - endfunction + fun! OpamConfOcpIndex() + exec 'set rtp+=' . s:opam_share_dir . '/ocp-index/vim' + endfun let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex') - function! OpamConfMerlin() - let l:dir = s:opam_share_dir . "/merlin/vim" - execute "set rtp+=" . l:dir - endfunction + fun! OpamConfMerlin() + let l:dir = s:opam_share_dir . '/merlin/vim' + exec 'set rtp+=' . l:dir + endfun let s:opam_configuration['merlin'] = function('OpamConfMerlin') - let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"] - let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages + let s:opam_packages = ['ocp-indent', 'ocp-index', 'merlin'] + let s:opam_check_cmdline = ['opam list --installed --short --safe --color=never'] + s:opam_packages let s:opam_available_tools = split(system(join(s:opam_check_cmdline))) for tool in s:opam_packages - " Respect package order (merlin should be after ocp-index) + "respect package order (merlin should be after ocp-index) if count(s:opam_available_tools, tool) > 0 call s:opam_configuration[tool]() - endif + end endfor -endif +end """""""""""""""""""""" @@ -250,7 +250,7 @@ inoremap pumvisible() ? "\" : matchstr(getline(line('.')-1), ' inoremap pumvisible() ? "\" : matchstr(getline(line('.')+1), '\%' . virtcol('.') . 'v\%(\k\+\\|.\)') "use the X clipboard for things when running in a virtual terminal, because yes -if &term != "linux" && has('clipboard') +if &term != 'linux' && has('clipboard') nnoremap y (v:register ==# '"' ? '"+' : '') . 'y' nnoremap Y (v:register ==# '"' ? '"+' : '') . 'Y' xnoremap y (v:register ==# '"' ? '"+' : '') . 'y' @@ -284,7 +284,7 @@ let g:c_no_if0_fold = 1 let g:sh_fold_enabled = 1 -if has("autocmd") +if has('autocmd') "set various filetype-specific settings. augroup filetypesettings @@ -333,10 +333,14 @@ if has("autocmd") au FileType * call Settings_skel_read() augroup END -endif "autocmd +end "autocmd + +" +" Settings Subroutines +" "command for reading filetype skeletons -function! Settings_skel_read() +fun! Settings_skel_read() "is the buffer not empty? if line('$') != 1 || col('$') != 1 return 1 @@ -345,39 +349,72 @@ function! Settings_skel_read() if filereadable(split(&rtp, ',')[0] . "/skel/" . &ft) == 0 return 1 end - execute 'silent! r ' . split(&rtp, ',')[0] . "/skel/" . &ft + exec 'silent! r ' . split(&rtp, ',')[0] . "/skel/" . &ft "read the date into %DATE% - execute '%s/%DATE%/' . system("date '+%a, %B %d, %Y'|tr -d '\n'") . '/ge' + exec '%s/%DATE%/' . system("date '+%a, %B %d, %Y'|tr -d '\n'") . '/ge' "move cursor to %START% - execute "silent! normal! ggJ/%START%\:s/%START%//\" -endfunction + exec 'silent! normal! ggJ/%START%\:s/%START%//\' +endfun "a 'writing mode' for prose-y formats -function! s:goyo_enter() +fun! s:goyo_enter() setlocal formatoptions+=a -endfunction +endfun -function! s:goyo_leave() +fun! s:goyo_leave() setlocal formatoptions+=a -endfunction +endfun -function! Settings_sub_wmodetoggle() +fun! Settings_sub_wmodetoggle() if &fo =~ 'a' Goyo! else Goyo end -endfunction +endfun + +"run vader tests on the current file +fun! Settings_sub_test_vim() + "check first if curbuf is a file + if @% != '' && filereadable(@%) + let l:real = '' + + "test first for file in project test dir + silent let l:base = systemlist('git rev-parse --show-toplevel')[0] + if !v:shell_error + let l:check = l:base . '/test/' . expand('%:t:r') . '.vader' + if filereadable(l:check) + let l:real = l:check + end + end + + "or else test for one in the same dir + let l:check = expand('%:t:r') . '.vader' + if l:real == '' && filereadable(l:check) + let l:real = l:check + end + + "if a vader file was found, run the test + if l:real != '' + silent source % + silent exec 'Vader' l:real + end + end +endfun + +" +" Settings Functions +" -function! Settings_asm() +fun! Settings_asm() "settings setlocal foldmethod=syntax "mappings nnoremap -- A; nnoremap -_ O; -endfunction +endfun -function! Settings_c() +fun! Settings_c() "settings setlocal foldmethod=syntax setlocal shiftwidth=4 @@ -387,47 +424,47 @@ function! Settings_c() "note: these mappings are in weird reverse order to avoid opening folds nnoremap -- O*/hhi/* inoremap { }i{O -endfunction +endfun -function! Settings_coffee() +fun! Settings_coffee() call Settings_script2() setlocal foldmethod=syntax nnoremap -_ O######O -endfunction +endfun -function! Settings_conf() +fun! Settings_conf() call Settings_script() setlocal expandtab -endfunction +endfun -function! Settings_crystal() +fun! Settings_crystal() call Settings_script2() setlocal expandtab -endfunction +endfun -function! Settings_css() +fun! Settings_css() call Settings_c() "settings setlocal shiftwidth=2 setlocal tabstop=2 setlocal softtabstop=2 "mappings -endfunction +endfun -function! Settings_elixir() +fun! Settings_elixir() call Settings_script2() inoremap do endhhidoO -endfunction +endfun -function! Settings_ia64() +fun! Settings_ia64() "settings setlocal foldmethod=syntax "mappings nnoremap -- A*/hhi/* nnoremap -_ O*/hhi/* -endfunction +endfun -function! Settings_haskell() +fun! Settings_haskell() "settings setlocal shiftwidth=4 setlocal tabstop=4 @@ -435,9 +472,9 @@ function! Settings_haskell() setlocal expandtab "mappings nnoremap -- O-- -endfunction +endfun -function! Settings_html() +fun! Settings_html() "settings setlocal foldmethod=syntax setlocal shiftwidth=4 @@ -445,9 +482,9 @@ function! Settings_html() setlocal softtabstop=4 "mappings nnoremap -- O-->3hi3hi