dotfiles/.vimrc

147 lines
5.2 KiB
VimL
Raw Normal View History

2024-01-10 08:20:32 -06:00
"execute pathogen#infect()
2020-01-01 20:10:00 -06:00
set autochdir
2016-01-19 15:10:51 -06:00
set autoindent
set expandtab
set hlsearch
set incsearch
2020-01-01 20:10:00 -06:00
set number
set ruler
set shiftwidth=2
set tabstop=2
2024-01-10 08:20:32 -06:00
set softtabstop=0
2016-01-19 15:10:51 -06:00
set textwidth=79
2024-01-10 08:20:32 -06:00
set signcolumn=yes
2020-01-01 20:10:00 -06:00
set cursorline
syntax enable
2016-01-19 15:10:51 -06:00
2024-01-10 08:20:32 -06:00
packadd matchit
2016-01-19 15:10:51 -06:00
filetype plugin on
filetype indent on
let mapleader=" "
2024-01-10 08:20:32 -06:00
let g:markdown_recommended_style=0
autocmd BufRead,BufNewFile *.md setlocal filetype=markdown fo-=l fo+=ro
autocmd BufRead,BufNewFile *.pco setlocal filetype=chordpro
autocmd BufRead,BufNewFile *.yaml setlocal fo=croqt
autocmd BufRead,BufNewFile *.nim setlocal fo=croqt
autocmd BufRead,BufNewFile *.ts setlocal fo=croqt
2020-01-01 20:10:00 -06:00
" Set/load the view when switching buffers. Used to use to preserve folding.
" Stopped because weirder things were happening.
2024-01-10 08:20:32 -06:00
" autocmd BufEnter *.* silent loadview
" autocmd BufLeave *.* mkview!
2016-01-19 15:10:51 -06:00
autocmd BufRead *.java set foldnestmax=2
autocmd BufRead *.java set foldmethod=syntax
inoremap <Nul> <C-x><C-o>
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
let g:solarized_contrast="high"
2024-01-10 08:20:32 -06:00
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['deno', 'eslint'],
\ 'typescript': ['deno', 'eslint', 'prettier'],
\ 'vue': ['prettier'],
\}
" Disable linters on markdown. I personally don't find any of these useful
" enough to includ in my general authorship. However, ALE performs the check
" for the presence of the executables every time vim enters normal mode. This
" can introduce a noticeable (>1s) lag when running in balanced power mode. So
" I manually disable all of them.
let g:ale_linters = {
\ 'markdown': [],
\ 'html': ['HTMLHint', 'proselint', 'write-good'],
\ 'rst': [],
\ 'python': ['pylint'],
\ 'typescript': ['deno', 'eslint'],
\}
" default (as of time of writing) was:
" \ 'markdown': ['alex', 'cspell', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood'],
",
let g:ale_fix_on_save = 1
"let g:ale_linters_explicit = 1
2016-01-19 15:10:51 -06:00
let g:ctrlp_max_files = 0
let g:ctrlp_custom_ignore = {
2020-01-01 20:10:00 -06:00
\ 'dir': '\v\.git$|\.hg$|\.svn$|\.worktrees$|build$|target$|node_modules$|nimcache$|dist$',
2016-01-19 15:10:51 -06:00
\ 'file': '\v\.(class|exe|so|dll|sw.)$'
\ }
2024-01-10 08:20:32 -06:00
let g:ale_virtualtext_cursor = 0
2016-01-19 15:10:51 -06:00
let groovy_space_errors = 1
let groovy_allow_cpp_keywords = 1
2020-01-01 20:10:00 -06:00
cmap w!! w !sudo tee > /dev/null %
2020-01-01 20:26:52 -06:00
let g:tsuquyomi_disable_quickfix = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
2016-01-19 15:10:51 -06:00
" Generate Java Getter and Setter for one property.
" Expects property lines to match /private \w\+ \w\+/
" Requires mark A to be set at the current property line start and mark B to
" be set where the getter and setter should be inserted. The marks are updated
" so that the command can be immediately invoked again for a subsequent
" property.
" nmap <Leader>gs wve"tywve"py'bo public void set "ppbvUhxA("tpA "ppA) { this."ppA = "ppA; } public "tpA get "ppbvUhxA() { return this."ppA; }mb'a/private \w+\+ \w\+; ma
nmap <Leader>jgs :let @t=''<CR>:let @n=''<CR>'a0v$:s/\v^\s*(private\|public\|protected)? ?(\w+(\<[^>]+\>)?) (\w+);/\=setreg('T', submatch(2))/n<CR>0v$:s/\v^\s*(private\|public\|protected)? ?(\w+(\<[^>]+\>)?) (\w+);/\=setreg('N', submatch(4))/n<CR>'bo<CR>public <ESC>"tpA get <ESC>"npbvUhxA() {<CR> return this.<ESC>"npA;<CR>}<ESC><<o<CR>public void set <ESC>"npbvUhxA(<ESC>"tpA <ESC>"npA) {<CR> this.<ESC>"npA = <ESC>"npA;<CR>}<ESC><<mb'anma
" Clean un-used Java imports.
nmap <Leader>jci :UnusedImportsRemove<CR>
2016-01-19 15:10:51 -06:00
" Format the file using java-file-formatter. java-file-formatter should be a
" command that takes a file path as the first argument and either alters the
" file in place or prints out the altered file on STDOUT.
nmap <Leader>jsf :!java-file-formatter %:p<CR>
nmap <Leader>wo :vsplit /home/jdbernard/projects/worklog/worklog.txt<CR><C-w>L200<C-w><43<C-w>>
nmap <Leader>ws :w<CR>:silent !git add %<CR>:!git commit<CR>
nmap <Leader>b :CtrlPBuffer<CR>
2024-01-10 08:20:32 -06:00
" Format Biblical quotations in Markdown
vmap <Leader>qb :s/\v\s+(\d+)(\s+\|$)/ **\1**\2/g<CR>
" remove trailing whitespace from all lines
nmap <Leader>ss :%s/\s\+$//<CR>
2020-01-01 20:10:00 -06:00
2024-01-10 08:20:32 -06:00
" check spelling
nmap <Leader>sp :!aspell -c %<CR>
2020-01-01 20:10:00 -06:00
" Execute the current line (stripping leading `$`s)
2024-01-10 08:20:32 -06:00
nmap <Leader>r :.w !sed s/^\\s*[\\$\\#]\\s*//\|bash<CR>
2020-01-01 20:10:00 -06:00
" Execute the current line (stripping leading `$`s) and paste the output into
" the buffer underneath.
2024-01-10 08:20:32 -06:00
nmap <Leader>R yyp!!sed s/^\\s*[\\$\\#]\\s*//\|bash<CR><Esc>
2020-01-01 20:10:00 -06:00
2024-01-10 08:20:32 -06:00
" Execute the selected text as a vim command.
vmap <Leader>e "zy@z<CR>
2020-01-01 20:10:00 -06:00
highlight Folded term=standout ctermfg=3 ctermbg=256
" Use a dark gray for highlighting 'spelling' errors (ALE uses this class for
" highlighting linting errors). Original value was 224
2024-01-10 08:20:32 -06:00
"highlight SpellBad ctermbg=236
2020-01-01 20:10:00 -06:00
"
" Actually, just diable ALE in-line error highlighting and just rely on the
" markers in the gutter.
2024-01-10 08:20:32 -06:00
" highlight clear ALEError
" highlight link ALEError NONE