dotfiles/vim/.vimrc

197 lines
6 KiB
VimL
Raw Permalink Normal View History

" file stuff
2022-10-26 12:05:56 -06:00
filetype plugin on
syntax enable
" Plug plugins
call plug#begin()
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'itchyny/lightline.vim'
Plug 'jceb/vim-orgmode'
2023-04-02 22:20:09 -06:00
" Plug 'tpope/vim-speeddating'
Plug 'ryanoasis/vim-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'lervag/vimtex'
Plug 'preservim/nerdtree'
Plug 'itchyny/vim-gitbranch'
2022-11-12 18:20:45 -07:00
Plug 'tpope/vim-commentary'
2023-01-25 10:47:00 -07:00
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
2023-04-02 22:20:09 -06:00
" Plug 'Yggdroot/indentLine'
Plug 'junegunn/fzf.vim'
call plug#end()
" sets
2021-11-16 16:40:58 -07:00
set nocompatible
set ttymouse=sgr
set number
2022-12-11 01:03:47 -07:00
set relativenumber
2022-03-11 00:20:49 -07:00
set bg:dark
2021-11-16 16:40:58 -07:00
set mouse=a
2022-03-11 00:20:49 -07:00
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
2023-04-02 22:20:09 -06:00
set formatoptions-=t
2021-11-16 16:40:58 -07:00
set linebreak
set cursorline
2023-04-02 22:20:09 -06:00
" set cursorcolumn
2021-11-16 16:40:58 -07:00
set backspace=indent,eol,start
set laststatus=2
set wildmenu
set scrolloff=5
2022-03-03 22:13:34 -07:00
set incsearch
2022-03-11 00:20:49 -07:00
set ttimeout ttimeoutlen=25
2023-04-02 22:20:09 -06:00
" set showtabline=2
2022-10-26 12:05:56 -06:00
set undodir=~/.vim/undo-dir
set undofile
set backupdir=$HOME/.vim/backups
set noshowmode
2022-11-12 18:20:45 -07:00
set showcmd
2023-04-02 22:20:09 -06:00
" set termguicolors
2022-11-12 18:20:45 -07:00
" set clipboard=unnamedplus
" lets
let g:vimtex_compiler_method = 'arara'
let mapleader = " "
let g:gruvbox_contrast_dark = 'soft'
let g:gruvbox_termcolors = '16'
let g:python_recommended_style = 0
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
2023-04-02 22:20:09 -06:00
let g:NERDTreeWinPos = 'right'
2023-01-25 10:47:00 -07:00
let g:org_heading_shade_leading_stars = 0
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_new_list_item_indent = 2
" colorscheme stuff
colorscheme gruvbox
2023-04-02 22:20:09 -06:00
" set specific colors
hi Normal ctermbg=NONE
2023-04-02 22:20:09 -06:00
hi Normal guibg=NONE
hi CocUnderline gui=undercurl cterm=underline
hi CocInfoHighlight cterm=underline
hi CocErrorHighlight ctermfg=red gui=underline cterm=underline
hi CocWarningHighlight ctermfg=yellow gui=underline cterm=underline
hi MatchParen cterm=bold ctermfg=cyan
" Custom commands
command Fixtabs :%s/ / /g | echo 'tabs replaced with spaces (like a good programmer)'
command Clipboard :yank + | echo 'Yanked line into system clipboard'
" remaps
nnoremap <SPACE> <Nop>
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>! :q!<CR>
nnoremap <leader>x :wq<CR>
2022-11-16 19:01:14 -07:00
nnoremap <leader>b :e#<CR>
2022-12-11 01:03:47 -07:00
nnoremap <leader>e :e<CR>
2022-12-31 18:36:08 -07:00
nnoremap <leader>c gcc<CR>
2023-04-02 22:20:09 -06:00
nnoremap <leader>y :noh<CR>
2022-12-11 01:03:47 -07:00
nnoremap <leader>u :tabp<CR>
nnoremap <leader>o :tabn<CR>
2023-04-02 22:20:09 -06:00
nnoremap <leader>r :Clipboard<CR>
2022-11-12 18:20:45 -07:00
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <leader>t :NERDTreeToggle<CR>
2023-04-02 22:20:09 -06:00
nnoremap <leader>f :Files .<CR>
nnoremap <leader>p :wincmd p<CR>
2022-12-11 01:03:47 -07:00
nnoremap <leader>v :set paste! number! relativenumber!<CR>
2022-11-12 18:20:45 -07:00
nnoremap <leader>i :CocCommand clangd.switchSourceHeader<CR>
" nerdtree stuff
" Start NERDTree. If a file is specified, move the cursor to its window.
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Open the existing NERDTree on each new tab.
2023-04-02 22:20:09 -06:00
" autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
2021-11-16 16:40:58 -07:00
2023-01-25 10:47:00 -07:00
" turn on spell checker for certain files
2022-02-19 16:05:54 -07:00
autocmd FileType markdown setlocal spell
2023-01-25 10:47:00 -07:00
autocmd FileType org setlocal spell
2022-10-26 12:05:56 -06:00
hi clear SpellBad
2023-04-02 22:20:09 -06:00
hi SpellBad cterm=underline ctermfg=red
2022-10-26 12:05:56 -06:00
hi clear SpellRare
hi SpellRare cterm=underline
hi clear SpellCap
hi SpellCap cterm=underline
hi clear SpellLocal
hi SpellLocal cterm=underline
2022-03-11 00:20:49 -07:00
" Coc remaps
inoremap <silent><expr> <TAB>
2023-01-25 10:47:00 -07:00
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
2023-01-25 10:47:00 -07:00
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
2023-01-25 10:47:00 -07:00
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
2023-04-02 22:20:09 -06:00
function! HumanSize() abort
let l:bytes = line2byte('$') + len(getline('$'))
let l:sizes = ['B', 'KB', 'MB', 'GB']
let l:i = 0
while l:bytes >= 1024
let l:bytes = l:bytes / 1024.0
let l:i += 1
endwhile
return printf('%.0f%s', l:bytes, l:sizes[l:i])
endfunction
2022-11-12 18:20:45 -07:00
" lightline config
2022-12-11 01:03:47 -07:00
if expand('$UID') == 0
let g:lightline = {
\ 'colorscheme': 'molokai',
\ 'active': {
\ 'left': [ [ 'root', 'mode', 'paste' ],
\ [ 'filename', 'readonly', 'modified' ],
\ [ 'gitbranch'] ],
\ 'right': [ [ 'lineinfo' ],
2023-04-02 22:20:09 -06:00
\ [ 'filesize', 'fileformat', 'filetype' ],
2022-12-11 01:03:47 -07:00
\ [ 'percent' ] ]
\ },
\ 'component_function': {
2023-04-02 22:20:09 -06:00
\ 'gitbranch': 'gitbranch#name',
\ 'filesize': 'HumanSize'
2022-12-11 01:03:47 -07:00
\ },
\ }
let g:lightline.component = {
\ 'close': ' %n | X ',
\ 'root': '!!root!!', }
else
let g:lightline = {
\ 'colorscheme': 'gruvbox',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'filename', 'readonly', 'modified' ],
\ [ 'gitbranch'] ],
\ 'right': [ [ 'lineinfo' ],
2023-04-02 22:20:09 -06:00
\ [ 'filesize', 'fileformat', 'filetype' ],
2022-12-11 01:03:47 -07:00
\ [ 'percent' ] ]
\ },
\ 'component_function': {
2023-04-02 22:20:09 -06:00
\ 'gitbranch': 'gitbranch#name',
\ 'filesize': 'HumanSize'
2022-12-11 01:03:47 -07:00
\ },
\ }
let g:lightline.component = {
\ 'close': ' %n | X ', }
endif