dotfiles/slackware/home/vim/.vim/vimrc
2022-07-31 12:57:46 -04:00

334 lines
10 KiB
VimL
Executable file

" vim-plug {{{
" Automatic installation
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugins')
packloadall
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin --all' }
" Plug 'https://gitlab.com/lstwn/broot.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'dense-analysis/ale'
Plug 'airblade/vim-gitgutter'
Plug 'itchyny/lightline.vim'
Plug 'tpope/vim-repeat'
Plug 'haya14busa/incsearch.vim'
Plug 'sheerun/vim-polyglot'
Plug 'nvie/vim-flake8'
Plug 'wolf-dog/lightline-sceaduhelm.vim'
Plug 'tpope/vim-fugitive'
Plug 'justinmk/vim-sneak'
Plug 'jgdavey/tslime.vim'
Plug 'vimwiki/vimwiki'
Plug 'simnalamburt/vim-mundo'
Plug 'tpope/vim-dadbod'
Plug 'junegunn/gv.vim'
Plug 'rbong/vim-flog'
Plug 'tpope/vim-unimpaired'
Plug 'guns/vim-clojure-static' " syntax
Plug 'tpope/vim-fireplace'
Plug 'guns/vim-sexp'
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'alvan/vim-closetag'
Plug 'mattn/emmet-vim'
Plug 'chrisbra/colorizer'
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-rhubarb'
Plug 'zhaozg/vim-diagram'
Plug 'fatih/vim-go'
Plug 'diepm/vim-rest-console'
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'peitalin/vim-jsx-typescript'
Plug 'jremmen/vim-ripgrep'
Plug 'francoiscabrol/ranger.vim'
Plug 'https://github.com/moll/vim-bbye'
Plug 'jlanzarotta/bufexplorer'
Plug 'chriskempson/base16-vim'
Plug 'HiPhish/guile.vim'
call plug#end()
"}}}
" appearance {{{
syntax on " Enable syntax
colorscheme base16-oceanicnext
" set termguicolors?
" set t_Co=16?
set encoding=utf-8 " Keep utf-8 encoding
set scrolloff=2 " Keep at least 3 lines above and below cursor
set showmode " Something something buffers
set showcmd " Show command in bottom bar
set wildmenu " Visual autocomplete for command menu
set wildmode=list:longest " Show all completions on tab
set laststatus=2 " Last window will always have statusline
set showmatch " Highlight matching [{()}]
set cursorline " Highlight current line
highlight GitGutterAdd ctermbg=black guibg=black
highlight SignColumn guibg=black ctermbg=black
let g:ctrlsf_default_root="project"
" remove underline on current line number
hi CursorLineNr cterm=NONE
" Lightline
let g:lightline = { 'colorscheme': 'sceaduhelm' }
set fillchars+=vert:│
command! LightlineReload call LightlineReload()
function! LightlineReload()
call lightline#init()
call lightline#colorscheme()
call lightline#update()
endfunction
" Invisible characters
set list
set listchars=tab:▸\ ,eol
" }}}
" Folding {{{
set foldenable " Enable folding
set foldmethod=manual " Fold sections by marker
" set foldlevel=0 " Fold by default
" set modelines=1 " Check final line of file for modeline
" }}}
" behavior {{{
set nocompatible " Turn off vi compatability nonsense
set hidden " Hide buffer when opening new file
set visualbell " Use visual bell instead of beeping
set ttyfast " Improves smoothness and drawing
set backspace=indent,eol,start " Always allow backspacing
set undofile " Make .un file for persistent undo
set number
set lazyredraw " Redraw only when necessary
set updatetime=100 " Make updates happen faster (gitgutter)
set splitright " Make split to right by default
set splitbelow
set winheight=30 " Soft minimum window height (active)
set winminheight=6 " Hard minimum window height (inactive)
set winwidth=90 " Window width for current window
set winminwidth=30 " Hard minimum for window width
set t_vb= " No visual bell ever
let g:sneak#use_ic_scs=1
set virtualedit=block
set noswapfile
set undodir=~/.vim/undo
let g:markdown_folding=1
au FileType markdown setlocal foldlevel=99
let g:bufExplorerSplitHorzSize=8 " New split window is n rows high.
let g:bufExplorerDefaultHelp=0 " Do not show default help.
set nobackup
"}}}
" searching {{{
set gdefault " Remove default g flag on search
set ignorecase " Ignore case for searches
set smartcase " Case-specific only when uppercase
set hlsearch " Don't continue to highlight searched phrases.
set incsearch " But do search as characters are entered
"}}}
" tab settings {{{
set tabstop=4 " Number of visual spaces per tab
set softtabstop=4 " Should always = tabstop
set shiftwidth=4 " Indent/outdent by 4 columns
set expandtab " Tabs are spaces
set shiftround " Always indent/outdent to the nearest tabstop
" Make search terms more visible
highlight Visual ctermbg=DarkGreen ctermfg=Black
set autoindent " Auto indentation
"}}}
" hjkl {{{
" Disable arrow keys in normal and visual mode
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" Make j and k move by screen line, not file line
nnoremap j gj
nnoremap k gk
"}}}
" {{{ web dev
autocmd FileType html,css,javascript,typescript,typescriptreact
\ set expandtab smarttab softtabstop=2 shiftwidth=2 tabstop=2
" Emmet tab size
let g:user_emmet_settings = {
\ 'indentation' : ' '
\}
" }}}
" split pane navigation {{{
" nnoremap <C-h> <C-w>h
" nnoremap <C-j> <C-w>j
" nnoremap <C-k> <C-w>k
" nnoremap <C-l> <C-w>l
nnoremap <C-c> :close <cr>
nnoremap <C-n> :bn <cr>
nnoremap <C-p> :bp <cr>
let g:tmux_navigator_disable_when_zoomed = 1
"}}}
" git commands {{{
nmap ghv <Plug>(GitGutterPreviewHunk)
nmap ghn <Plug>(GitGutterNextHunk)
nmap ghp <Plug>(GitGutterPrevHunk)
nmap ghf <Plug>(GitGutterFold)
nmap ghs <Plug>(GitGutterStageHunk)
" Controls fugitive diff split direction
set diffopt=vertical
"}}}
" plugin modification {{{
" FZF
map <C-s> :FZF<cr>
" map <C-s> :tabNext<cr>
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~30%' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': [ 'fg', 'Normal'],
\ 'bg': [ 'bg', 'Normal'],
\ 'hl': [ 'fg', 'Comment'],
\ 'fg+': [ 'fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': [ 'bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': [ 'fg', 'Statement'],
\ 'info': [ 'fg', 'PreProc'],
\ 'border': [ 'fg', 'Ignore'],
\ 'prompt': [ 'fg', 'Conditional'],
\ 'pointer': [ 'fg', 'Exception'],
\ 'marker': [ 'fg', 'Keyword'],
\ 'spinner': [ 'fg', 'Label'],
\ 'header': [ 'fg', 'Comment'] }
" EasyAlign
"" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
"}}}
" vimwiki {{{
let g:vimwiki_list = [
\ {'name': 'work', 'path': '~/.vim/work'},
\ {'name': 'home', 'path': '~/.vim/home'},
\ {'name': 'blog', 'path': '~/.vim/blog'},
\ {'name': 'vim', 'path': '~/.vim/vim'},
\ ]
let g:vimwiki_syntax = 'markdown'
let g:vimwiki_ext = '.md'
let g:vimwiki_automatic_nested_syntaxes = 1
let g:vimwiki_links_space_char = '_'
"}}}
" diffs {{{
hi DiffAdd cterm=none ctermfg=DarkGray ctermbg=Green
hi DiffChange cterm=none ctermfg=DarkGray ctermbg=Yellow
hi DiffDelete cterm=bold ctermfg=DarkGray ctermbg=Red
hi DiffText cterm=none ctermfg=DarkGray ctermbg=LightBlue
" better diffs
set diffopt+=internal,algorithm:patience
" }}}
" buffers {{{
let g:bufExplorerDisableDefaultKeyMapping=1 " Disable mapping.
"}}}
" broot {{{
let g:broot_default_conf_path=expand('~/.config/broot/conf.hjson')
let g:broot_replace_netrw=1
let g:loaded_netrwPlugin=1 " use broot for :E/T/V/Hexplore
"}}}
" ALE {{{
let g:ale_linters = {'javascript': ['tsserver'],
\ 'typescript': ['tsserver'],
\ 'typescriptreact': ['tsserver'],
\ 'python': ['flake8'],
\ 'css': ['csslint'],
\ 'dockerfile': ['hadolint'],
\ 'yaml': ['yamllint'] }
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'] }
" let g:ale_set_loclist = 0
" let g:ale_set_quickfix = 1
let g:ale_set_quickfix = 0
let g:ale_set_loclist = 0
let g:ale_fix_on_save = 1
"}}}
" leaders {{{
:let mapleader = ","
" Underline with line of the same length
nnoremap <leader>- yypv$r-
" Insert date on current line
nnoremap <leader>d k :r !date <cr>
nnoremap <leader>se :Explore<cr>
nnoremap <leader>st :Texplore<cr>
nnoremap <leader>sv :Vexplore<cr>
nnoremap <leader>sh :Hexplore<cr>
nmap <leader>h :map <leader><cr>
nnoremap <leader>ad :ALEDetail<cr>
nnoremap <leader>ag :ALEGoToDefinition<cr>
nnoremap <leader>al :ALEPopulateQuickfix<cr>
nnoremap <leader>an :ALENext<cr>
nnoremap <leader>ap :ALEPrevious<cr>
nnoremap <leader>ar :ALERename<cr>
nnoremap <leader>b :BufExplorerHorizontalSplit<cr>
"}}}
" folding options {{{
" folding options, this must be last in file
" vim:foldmethod=marker:foldlevel=0
" }}}