vim/vimrc

167 lines
4.3 KiB
VimL
Raw Normal View History

" Default Vim options. Some have been modified.
2022-08-03 10:51:44 -07:00
source ~/.vim/defaults.vim
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
2022-08-03 10:51:44 -07:00
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
2022-08-03 10:51:44 -07:00
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
set undofile " keep an undo file (undo changes after closing)
endif
endif
2022-08-03 10:51:44 -07:00
" Don't clutter directories with swap files.
" Save them in /tmp instead.
set backupdir=/tmp//,.
set directory=/tmp//,.
set undodir=/tmp//,.
if &t_Co > 2 || has("gui_running")
2022-08-03 10:51:44 -07:00
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" Put these in an autocmd group, so that we can delete them easily.
"augroup vimrcEx
" au!
" For all text files set 'textwidth' to 78 characters.
" autocmd FileType text setlocal textwidth=78
"augroup END
" Enable syntax highlighting if the terminal supports color
if &t_Co > 1
syntax enable
colorscheme atom-dark
" Clear 'background color erase' value to prevent
" terminal background bleed.
set t_ut=
endif
" Enable line numbers in the left margin
set number
set numberwidth=4
" Enable relative line numbers
" set relativenumber
" Display invisible characters.
2022-08-03 10:51:44 -07:00
" Here's a helpful list of chars:
" ␠ ⎵ ⏎ ·
set list
set listchars=tab:\ \ \|,trail,nbsp:⎵
2022-08-03 10:51:44 -07:00
" Configure and load conceal chars
"
"set conceallevel=0 " Nothing is hidden
"set conceallevel=1 " Hide stuff as concealchar, or as listchar.
"set conceallevel=2 " Hide stuff as concealchar, or completely.
"set conceallevel=3 " Hide completely.
"
"syntax keyword ConcealedX kw_hide_x conceal concealchar=x
"syntax keyword ConcealedY kw_hide_y conceal concealchar=y
"syntax keyword ConcealedMe kw_hide_me conceal
"syntax keyword NoConceal kw_normal
"
"highlight ConcealedX ctermfg=2
"highlight ConcealedY ctermfg=3
"highlight ConcealedMe ctermfg=4
"highlight NoConceal ctermfg=5
"
:set conceallevel=2
highlight Conceal ctermbg=NONE ctermfg=green guibg=NONE guifg=NONE
source ~/.vim/conceal.vim
2022-08-03 10:51:44 -07:00
" jh to escape in insert mode, esc is hard to reach.
"inoremap jh <Esc>
2022-08-03 10:51:44 -07:00
" Clears trailing whitespace while preserving cursor.
function StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
2022-08-03 10:51:44 -07:00
augroup clearwhitespace_gp
autocmd!
autocmd BufWritePre * :call StripTrailingWhitespaces()
augroup END
2022-08-03 10:51:44 -07:00
" Toggle invisibles in normal mode
nnoremap <F3> :set list! <CR>
" Tab size shortcuts
" TODO: VSCode-like tab menu
nnoremap <C-p> :set tabstop=4 shiftwidth=4 noexpandtab<CR>
nnoremap <C-o> :set tabstop=8 shiftwidth=8 noexpandtab<CR>
" Autodetect filetypes and set proper indentation
2022-08-03 10:51:44 -07:00
" Default: 4, with tabs.
set tabstop=4 shiftwidth=4 noexpandtab
augroup tabsize_gp
autocmd!
autocmd Filetype py setlocal tabstop=4 shiftwidth=4 noexpandtab
autocmd Filetype lua setlocal tabstop=4 shiftwidth=4 noexpandtab
augroup END
2022-08-03 10:51:44 -07:00
" Plugins
call plug#begin()
2022-08-03 10:51:44 -07:00
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-goyo.git'
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-gitgutter.git'
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-nerdtree.git'
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-hexHighlight.git'
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-pencil.git'
"Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-wordchipper.git'
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-boxdraw.git'
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-fish.git'
call plug#end()
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
packadd! matchit
endif
nmap <F2> <Plug>ToggleHexHighlight
2021-04-09 14:28:18 -07:00
let g:pencil#textwidth = 70
augroup pencil
autocmd!
autocmd FileType markdown,mkd call pencil#init({'wrap': 'soft'})
autocmd FileType text call pencil#init()
autocmd FileType text setlocal list
2021-04-09 14:28:18 -07:00
augroup END
2022-07-17 14:08:06 -07:00