Simplify vim config

main
Buddy Sandidge 1 year ago
parent 004de0eb1f
commit 340fe01281

@ -0,0 +1,105 @@
" Mappings
let mapleader=","
let g:mapleader=","
map <leader>rl :source $MYVIMRC<CR>
map <leader>ss :setlocal spell!<CR>
map <leader>ts :%s/\s\s*$//g<CR>
nnoremap <leader>rc :split $MYVIMRC<cr>
nnoremap <leader>p :set paste<cr>
nnoremap <leader>np :set nopaste<cr>
nnoremap <leader>nn :set nonumber norelativenumber<cr>
nnoremap <leader>rn :set number relativenumber<cr>
" commands
command! W write
command! Q qall!
" Vim Tabs
map <leader>tt :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>to :tabonly<cr>
map <leader>tn :tabNext<cr>
map <leader>tp :tabprevious<cr>
map <leader>tf :tabfirst<cr>
map <leader>tl :tablast<cr>
map <leader>tm :tabmove
" Basics
set encoding=utf-8
" General
" setlocal spell spelllang=en_us
set fileformats=unix,dos,mac
set nostartofline
set autochdir
set colorcolumn=81
" Have tab complete work more like bash
set wildmode=list:longest
set whichwrap+=<,>,[,]
set magic
" Turn on omni completion. Must have `filetype plugin on` to use.
" To use, in insert mode press ctrl+x ctrl+o
set omnifunc=syntaxcomplete#Complete
set completeopt=menu,longest,preview
" Indent
set smartindent
set copyindent
set preserveindent
set shiftround
" Text Formatting/Layout
set nowrap
set ignorecase
set smartcase
set list
" UI
set showcmd
set number relativenumber
set numberwidth=4
set hidden
" Cues
set showmatch
set matchtime=2
set hlsearch
set noerrorbells
set novisualbell
set t_vb=
set timeoutlen=500
" Tabs
set complete-=i
set autoindent
set backspace=indent,eol,start
set smarttab
set noexpandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
set autoread
" Status
" ~/file [type] [line,column] [number of lines]
"set statusline=%F%m%r%h%w\ [%Y]\ [%03l,%03v]\ [%L]
set laststatus=2
set ruler
set wildmenu
set nrformats-=octal
set incsearch
set sessionoptions-=options
set viewoptions-=options
augroup COMMIT_EDITMSG
autocmd!
autocmd BufRead,BufNewFile COMMIT_EDITMSG set filetype=gitcommit
augroup END

@ -3,9 +3,9 @@
"{{- if lookPath "go" -}}
set noexpandtab
"{{ if lookPath "goimports" -}}
"{{ if lookPath "gofumpt" -}}
" use goimports for formatting
let g:go_fmt_command = "goimports"
let g:go_fmt_command = "gofumpt"
"{{- end }}
" turn highlighting on

@ -1,23 +0,0 @@
" Mappings
let mapleader=","
let g:mapleader=","
map <leader>rl :source $MYVIMRC<CR>
map <leader>ss :setlocal spell!<CR>
map <leader>ts :%s/\s\s*$//g<CR>
nnoremap <leader>rc :split $MYVIMRC<cr>
nnoremap <leader>p :set paste<cr>
nnoremap <leader>np :set nopaste<cr>
nnoremap <leader>nn :set nonumber norelativenumber<cr>
nnoremap <leader>rn :set number relativenumber<cr>
" Vim Tabs
map <leader>tt :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>to :tabonly<cr>
map <leader>tn :tabNext<cr>
map <leader>tp :tabprevious<cr>
map <leader>tf :tabfirst<cr>
map <leader>tl :tablast<cr>
map <leader>tm :tabmove

@ -1,4 +0,0 @@
Plug 'bfrg/vim-jq'
Plug 'cespare/vim-toml', { 'for': 'toml' }
Plug 'editorconfig/editorconfig-vim', { 'tag': 'v1.1.1' }
Plug 'tpope/vim-surround', { 'tag': 'v2.2' }

@ -1,9 +0,0 @@
" chezmoi:template:left-delimiter="{{
"{{- /* vim: set filetype=vim: */ -}}
"{{- if lookPath "fzf" -}}
Plug 'junegunn/fzf', { 'tag': '0.40.0' }
Plug 'junegunn/fzf.vim'
map <leader>fz :GFiles<CR>
map <leader>rg :Rg<CR>
"{{- end }}

@ -1,5 +0,0 @@
" chezmoi:template:left-delimiter="{{
"{{- /* vim: set filetype=vim: */ -}}
"{{- if lookPath "go" -}}
Plug 'fatih/vim-go'
"{{- end }}

@ -1,30 +0,0 @@
Plug 'preservim/nerdtree', { 'tag': '6.10.16' }
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let NERDTreeDirArrows=1
map <leader>nt :NERDTreeToggle<CR>
" Close nerdtree if it's the last buffer
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree()
\ | quit
\ | endif
" Mirror nerdtree in each tab
autocmd BufWinEnter * silent NERDTreeMirror
" check if reading from stdin
autocmd StdinReadPre * let s:std_in=1
" open nerdtree if no args in passed to vim
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif
" open nerdtree if vim opens to a directory
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in')
\ | execute 'NERDTree' argv()[0]
\ | wincmd p
\ | enew
\ | execute 'cd '.argv()[0]
\ | endif

@ -1,5 +0,0 @@
" chezmoi:template:left-delimiter="{{
"{{- /* vim: set filetype=vim: */ -}}
"{{- if lookPath "rustc" -}}
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
"{{- end }}

@ -1,14 +0,0 @@
Plug 'NLKNguyen/papercolor-theme'
Plug 'joshdick/onedark.vim'
Plug 'morhetz/gruvbox'
Plug 'nanotech/jellybeans.vim', { 'tag': 'v1.7' }
Plug 'romainl/Apprentice'
Plug 'sheerun/vim-wombat-scheme'
Plug 'tomasr/molokai'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline_powerline_fonts = 0
let g:molokai_original = 1
let g:onedark_hide_endofbuffer = 1
let g:onedark_terminal_italics = 1

@ -1,12 +1,38 @@
" chezmoi:template:left-delimiter="{{
"{{- /* vim: set filetype=vim: */ -}}
Plug 'bfrg/vim-jq'
Plug 'editorconfig/editorconfig-vim', { 'tag': 'v1.1.1' }
Plug 'tpope/vim-surround', { 'tag': 'v2.2' }
Plug 'preservim/nerdtree', { 'tag': '6.10.16' }
Plug 'cespare/vim-toml', { 'for': 'toml' }
Plug 'SirVer/ultisnips', { 'tag': '3.2' }
let g:UltiSnipsSnippetDirectories = [ 'UltiSnips', 'snips' ]
"{{ if .development -}}
Plug 'lifepillar/pgsql.vim', { 'for': [ 'sql' ] }
let g:sql_type_default = 'pgsql'
" Themes
Plug 'NLKNguyen/papercolor-theme'
Plug 'joshdick/onedark.vim'
Plug 'morhetz/gruvbox'
Plug 'nanotech/jellybeans.vim', { 'tag': 'v1.7' }
Plug 'romainl/Apprentice'
Plug 'sheerun/vim-wombat-scheme'
Plug 'tomasr/molokai'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"{{ if lookPath "fzf" -}}
Plug 'junegunn/fzf', { 'tag': '0.40.0' }
Plug 'junegunn/fzf.vim'
"{{ end -}}
"{{ if lookPath "go" }}
Plug 'fatih/vim-go'
"{{ end }}
"{{ if lookPath "rustc" }}
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
"{{ end }}
"{{ if .development }}
Plug 'dense-analysis/ale', {
\ 'tag': 'v3.3.0',
\ 'for': [
@ -38,6 +64,7 @@ Plug 'dense-analysis/ale', {
\ ]
\ }
"{{ if lookPath "node" }}
Plug 'prettier/vim-prettier', {
\ 'branch': 'master',
\ 'do': 'npm install',
@ -64,4 +91,5 @@ Plug 'prettier/vim-prettier', {
\ 'yaml'
\ ]
\ }
"{{- end }}
"{{ end }}
"{{ end }}

@ -1,4 +0,0 @@
augroup COMMIT_EDITMSG
autocmd!
autocmd BufRead,BufNewFile COMMIT_EDITMSG set filetype=gitcommit
augroup END

@ -1,2 +0,0 @@
command! W write
command! Q qall!

@ -1,10 +0,0 @@
let g:ale_sign_error = '→'
let g:ale_sign_warning = '‽'
let g:ale_echo_msg_format = '%s [%severity%] [%linter%]'
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
augroup linters
autocmd!
autocmd FileType javascript let g:ale_linters['javascript'] = ['eslint']
augroup END

@ -1,19 +0,0 @@
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^Eterm'
set t_Co=16
else
set t_Co=256
endif
if (has("nvim"))
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
if (has("termguicolors"))
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
colorscheme gruvbox
set background=dark

@ -0,0 +1,69 @@
" chezmoi:template:left-delimiter="{{
"{{- /* vim: set filetype=vim: */ -}}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" fzf
"{{ if lookPath "fzf" }}
Plug 'junegunn/fzf', { 'tag': '0.40.0' }
Plug 'junegunn/fzf.vim'
map <leader>fz :GFiles<CR>
map <leader>rg :Rg<CR>
"{{ end }}
colorscheme gruvbox
set background=dark
let g:airline_powerline_fonts = 0
let g:molokai_original = 1
let g:onedark_hide_endofbuffer = 1
let g:onedark_terminal_italics = 1
let g:UltiSnipsSnippetDirectories = [ 'UltiSnips', 'snips' ]
"{{ if .development }}
let g:sql_type_default = 'pgsql'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ALE
let g:ale_sign_error = '→'
let g:ale_sign_warning = '‽'
let g:ale_echo_msg_format = '%s [%severity%] [%linter%]'
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
augroup linters
autocmd!
autocmd FileType javascript let g:ale_linters['javascript'] = ['eslint']
augroup END
"{{ end }}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let NERDTreeDirArrows=1
map <leader>nt :NERDTreeToggle<CR>
" Close nerdtree if it's the last buffer
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree()
\ | quit
\ | endif
" Mirror nerdtree in each tab
autocmd BufWinEnter * silent NERDTreeMirror
" check if reading from stdin
autocmd StdinReadPre * let s:std_in=1
" open nerdtree if no args in passed to vim
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif
" open nerdtree if vim opens to a directory
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in')
\ | execute 'NERDTree' argv()[0]
\ | wincmd p
\ | enew
\ | execute 'cd '.argv()[0]
\ | endif

@ -2,18 +2,12 @@
" The vim help suggests this as the first setting because of the side effects.
set nocompatible
" Load from init.d instead of plugin directory. This is done so a leader key
" can be set before loading plugin settings. This allows the plugin setting
" files to set mappings with leader keys
for f in split(glob($XDG_CONFIG_HOME.'/vim/init.d/*.vim'), '\n')
execute 'source '.fnameescape(f)
endfor
source $XDG_CONFIG_HOME/vim/xdg.vim
source $XDG_CONFIG_HOME/vim/config.vim
source $XDG_CONFIG_HOME/vim/workarounds.vim
" The plugged plugin manager function calls need to be called between the
" plug#begin and plug#end. Because of that, using the normal plugin directory
" loading won't work.
call plug#begin($XDG_DATA_HOME.'/vim/plugged')
for f in split(glob($XDG_CONFIG_HOME.'/vim/plug.d/*.vim'), '\n')
execute 'source '.fnameescape(f)
endfor
source $XDG_CONFIG_HOME/vim/plug.vim
call plug#end()
source $XDG_CONFIG_HOME/vim/settings.vim

@ -1,3 +1,13 @@
if (has("nvim"))
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
if (has("termguicolors"))
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
@ -7,44 +17,50 @@ if has('autocmd')
filetype indent on
endif
" Tabs
set complete-=i
set autoindent
set backspace=indent,eol,start
set smarttab
set noexpandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
set nrformats-=octal
if !has('nvim') && &ttimeoutlen == -1
set ttimeout
set ttimeoutlen=100
endif
set incsearch
if has('path_extra')
setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
set laststatus=2
set ruler
set wildmenu
if !empty(&viminfo)
set viminfo^=!
endif
" Status
" ~/file [type] [line,column] [number of lines]
"set statusline=%F%m%r%h%w\ [%Y]\ [%03l,%03v]\ [%L]
if empty(mapcheck('<C-U>', 'i'))
inoremap <C-U> <C-G>u<C-U>
endif
if empty(mapcheck('<C-W>', 'i'))
inoremap <C-W> <C-G>u<C-W>
endif
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^Eterm'
set t_Co=16
else
set t_Co=256
endif
if !&scrolloff
set scrolloff=1
endif
if !&sidescrolloff
set sidescrolloff=5
endif
set display+=lastline
if &encoding ==# 'latin1' && has('gui_running')
set encoding=utf-8
@ -54,79 +70,10 @@ if &listchars ==# 'eol:$'
set listchars=tab:\⇥\ ,trail:…,extends:→,precedes:←,nbsp:+
endif
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
if has('path_extra')
setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif
set autoread
if &history < 10000
set history=10000
endif
if &tabpagemax < 50
set tabpagemax=50
endif
if !empty(&viminfo)
set viminfo^=!
endif
set sessionoptions-=options
set viewoptions-=options
if empty(mapcheck('<C-U>', 'i'))
inoremap <C-U> <C-G>u<C-U>
endif
if empty(mapcheck('<C-W>', 'i'))
inoremap <C-W> <C-G>u<C-W>
endif
" Basics
set encoding=utf-8
" General
" setlocal spell spelllang=en_us
set fileformats=unix,dos,mac
set nostartofline
set autochdir
set colorcolumn=81
" Have tab complete work more like bash
set wildmode=list:longest
set whichwrap+=<,>,[,]
set magic
" Turn on omni completion. Must have `filetype plugin on` to use.
" To use, in insert mode press ctrl+x ctrl+o
set omnifunc=syntaxcomplete#Complete
set completeopt=menu,longest,preview
" Indent
set smartindent
set copyindent
set preserveindent
set shiftround
" Text Formatting/Layout
set nowrap
set ignorecase
set smartcase
set list
" UI
set showcmd
set number relativenumber
set numberwidth=4
set hidden
" Cues
set showmatch
set matchtime=2
set hlsearch
set noerrorbells
set novisualbell
set t_vb=
set timeoutlen=500

@ -1,3 +1,4 @@
" use XDG
if empty($MYVIMRC) | let $MYVIMRC = expand('%:p') | endif
if empty($XDG_CACHE_HOME) | let $XDG_CACHE_HOME = $HOME.'/.cache' | endif
Loading…
Cancel
Save