diff --git a/vim/vimrc b/vim/vimrc index 7be1db0..c9f18b1 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -48,6 +48,24 @@ let _agw.colors=[ \ 'base16-unikitty-dark', \] +let _agw.languages=[ +\ "c", +\ "cpp", +\ "cs", +\ "go", +\ "html", +\ "java", +\ "json", +\ "lisp", +\ "php", +\ "python", +\ "racket", +\ "ruby", +\ "rust", +\ "scheme", +\ "zscript", +\] + let _agw.cr_scheme=-2 " color from s:colors, -1=random, -2=default let _agw.g_columns=80 " GUI columns let _agw.g_rows=24 " GUI rows @@ -64,6 +82,10 @@ runtime! vconf " Functions ------------------------------------------------------------------| +fu _agw.is_lang(lang) + return index(g:_agw.languages, a:lang) >= 0 +endfu + fu _agw.fill_line() if g:_agw.use_ruby ruby<< @@ -268,7 +290,8 @@ let twitvim_browser_cmd='palemoon' let vim_markdown_folding_disabled=1 " rainbow -let rainbow_active=0 +let rainbow_active=1 +let lisp_rainbow=1 " netrw let netrw_banner=0 @@ -444,62 +467,68 @@ com W execute 'w !sudo tee > /dev/null %' | edit! " Autocommands ---------------------------------------------------------------| -" Strip whitespace -au FileType c,cpp,cs,java,php,ruby,rust,python,go,zscript,markdown au BufWritePre call _agw.strip_white() +augroup AGW + " enable tagbar + if _agw.use_tagbar == 1 + au VimEnter * nested :TagbarOpen + endif -" Enable rainbow braces -if _agw.use_rainbow != 0 - au FileType c,cpp,cs,java,php,ruby,rust,python,go,zscript,html,scheme,racket,lisp,json au BufEnter RainbowToggleOn -endif + " vertical split on enter + if _agw.use_vsp == 1 + au VimEnter * vsplit + endif -" markdown sucks -au FileType markdown set comments+=fb:- comments-=b:- indentexpr= + " markdown sucks + au FileType markdown set comments+=fb:- comments-=b:- indentexpr= -" Racket options -au FileType racket call _agw.setup_rkt() + " Racket options + au FileType racket call _agw.setup_rkt() -" ASM options -au BufEnter *\.asm,*\.s,*\.inc,*\.i call _agw.setup_asm() + " ASM options + au FileType asm call _agw.setup_asm() -" close empty buffers automatically -au BufEnter * call _agw.close_empty() + " Strip whitespace + au BufWritePre * if _agw.is_lang(&ft) | call _agw.strip_white() | endif -" set color randomly on buffer enter -if _agw.cr_scheme == -1 - au BufEnter * call _agw.set_color(localtime() % len(_agw.colors)) -endif + " fix file detection for fish + au BufRead * + \ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' | + \ setlocal filetype=fish | + \ endif -" .rkt → Racket -au BufRead,BufNewFile *.rkt set syntax=racket + " .rkt → Racket + au BufRead,BufNewFile *.rkt set syntax=racket -" .edf → conf -au BufRead,BufNewFile *.edf set syntax=conf + " .edf → conf + au BufRead,BufNewFile *.edf set syntax=conf -" disable most ftplugins -au BufReadPre * let b:did_ftplugin=1 -au BufReadPre *.rkt unlet b:did_ftplugin + " disable most ftplugins + au BufReadPre * let b:did_ftplugin=1 + au BufReadPre *.rkt unlet b:did_ftplugin -" enable tagbar -if _agw.use_tagbar == 1 - au VimEnter * nested :TagbarOpen -endif + " rust.vim sets Cargo.toml to use filetype `cfg` even though it shouldn't, + " to fix this we simply do the same thing before it has a chance to + au BufRead,BufNewFile Cargo.toml + \ if &filetype == "" | + \ set filetype=toml | + \ endif -" rust.vim sets Cargo.toml to use filetype `cfg` even though it shouldn't, to -" fix this we simply do the same thing before it has a chance to -au BufRead,BufNewFile Cargo.toml if &filetype == "" | set filetype=toml | endif + " close empty buffers automatically + au BufEnter * call _agw.close_empty() -" vertical split on enter -if _agw.use_vsp == 1 - au VimEnter * vsplit -endif + " set color randomly on buffer enter + if _agw.cr_scheme == -1 + au BufEnter * call _agw.set_color(localtime() % len(_agw.colors)) + endif -" suppress readonly warnings -au BufEnter * set noreadonly + " Enable rainbow braces + if _agw.use_rainbow != 0 + au BufEnter * if _agw.is_lang(&ft) | exec 'RainbowToggleOn' | endif + endif -autocmd BufRead * -\ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' | -\ setlocal filetype=fish | -\ endif + " suppress readonly warnings + au BufEnter * set noreadonly +augroup end " Mapping --------------------------------------------------------------------|