update vimrc

This commit is contained in:
James Dixon 2020-10-20 16:10:06 -04:00
parent 2e334edaa0
commit dd683a1a7f
2 changed files with 180 additions and 131 deletions

View File

@ -3,12 +3,121 @@
" \ V /| | | | | | | | | (__ " \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___| " \_/ |_|_| |_| |_|_| \___|
"sources defaults if available "source system defaults
if filereadable(expand('$VIMRUNTIME/defaults.vim')) if filereadable(expand('$VIMRUNTIME/defaults.vim'))
unlet! g:skip_defaults_vim unlet! g:skip_defaults_vim
source $VIMRUNTIME/defaults.vim source $VIMRUNTIME/defaults.vim
endif endif
"os settings
"-----------
if has('win32')
let &runtimepath.=",$HOME/.vim"
endif
"gui settings
"------------
if has("gui_running")
set guioptions -=m
set guioptions -=T
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
" set guifont=Consolas:h10
set guifont=Cascadia\ Code:h10
endif
endif
"general settings
"----------------
"encoding/format
set encoding=utf-8
set fileformats=unix,dos,mac
"file/buffer
set autoread
set autowrite
set confirm
"display
set background=light
set number
set wrap
set foldmethod=marker
set listchars=tab:→\ ,extends:,precedes:,nbsp,space,trail,eol
" set list
"drawing
set lazyredraw
set regexpengine=1
set redrawtime=10000
"tab/indent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
"status bar
set showcmd
set wildmenu
set ruler
set laststatus=2
"search
set incsearch
set hlsearch
set ignorecase
set smartcase
"cursor behaviour
set virtualedit=block
set backspace=indent,eol,start
set showmatch
set scrolloff=2
set sidescrolloff=4
"input/timeout
set esckeys
set timeoutlen=1000 "for mappings
set ttimeoutlen=20 "for keycodes
"window behaviour (ltr)
set splitbelow
set splitright
"cleanup files created by vim
"swap
let mySwapDir = expand("$HOME/.vim/.swap")
if !isdirectory(mySwapDir)
silent! call mkdir(mySwapDir, "p")
endif
let &directory=mySwapDir
"undo
if has('persistent_undo')
let myUndoDir = expand("$HOME/.vim/.undo")
if !isdirectory(myUndoDir)
silent! call mkdir(myUndoDir, "p")
endif
let &undodir=myUndoDir
set undofile
endif
"backup
if has('writebackup')
let myBackupDir = expand("$HOME/.vim/.backup")
if !isdirectory(myBackupDir)
silent! call mkdir(myBackupDir, "p")
endif
let &backupdir=myBackupDir
set backup
endif
"plugins (vim-plug) "plugins (vim-plug)
"------------------ "------------------
"vim-plug paths "vim-plug paths
@ -41,6 +150,7 @@ call plug#begin(pluginDir)
Plug 'flazz/vim-colorschemes' Plug 'flazz/vim-colorschemes'
"linting "linting
Plug 'w0rp/ale' Plug 'w0rp/ale'
"javascript/css/html "javascript/css/html
Plug 'pangloss/vim-javascript' Plug 'pangloss/vim-javascript'
Plug 'mattn/emmet-vim' Plug 'mattn/emmet-vim'
@ -55,6 +165,12 @@ call plug#begin(pluginDir)
Plug 'cespare/vim-toml' Plug 'cespare/vim-toml'
call plug#end() call plug#end()
"syntax/filetype settings
"---------------
" syntax on
" filetype plugin indent on
" runtime macros/matchit.vim
"plugin settings "plugin settings
"--------------- "---------------
"netrw "netrw
@ -111,100 +227,11 @@ let g:vim_markdown_toc_autofit = 1
" colorscheme monokai-phoenix " colorscheme monokai-phoenix
" }}} " }}}
"general settings
"----------------
"encoding/format
set encoding=utf-8
set fileformats=unix,dos,mac
"file/buffer
set autoread
set autowrite
set confirm
"display
set background=dark
set number
set wrap
set foldmethod=marker
set listchars=tab:→\ ,extends:,precedes:,nbsp,space,trail,eol
" set list
"drawing
set lazyredraw
set regexpengine=1
set redrawtime=10000
"tab/indent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
"status bar
set showcmd
set wildmenu
set ruler
set laststatus=2
"search
set incsearch
set hlsearch
set ignorecase
set smartcase
"cursor behaviour
set virtualedit=block
set backspace=indent,eol,start
set showmatch
set scrolloff=2
set sidescrolloff=4
"input/timeout
set esckeys
set timeoutlen=1000 "for mappings
set ttimeoutlen=20 "for keycodes
"window behaviour (ltr)
set splitbelow
set splitright
"vim feature cleanup
"-------------------
"swap
let mySwapDir = expand("$HOME/.vim/.swap")
if !isdirectory(mySwapDir)
silent! call mkdir(mySwapDir, "p")
endif
let &directory=mySwapDir
"undo
if has('persistent_undo')
let myUndoDir = expand("$HOME/.vim/.undo")
if !isdirectory(myUndoDir)
silent! call mkdir(myUndoDir, "p")
endif
let &undodir=myUndoDir
set undofile
endif
"backup
if has('writebackup')
let myBackupDir = expand("$HOME/.vim/.backup")
if !isdirectory(myBackupDir)
silent! call mkdir(myBackupDir, "p")
endif
let &backupdir=myBackupDir
set backup
endif
"normal/visual mode keybinds
"---------------------------
"leader key "leader key
let mapleader=' ' let mapleader=' '
"normal/visual mode keybinds
"---------------------------
"paste and search "paste and search
nnoremap <silent><leader><space> :let @/ = ""<CR> nnoremap <silent><leader><space> :let @/ = ""<CR>
nnoremap <leader>p :set invpaste<CR> nnoremap <leader>p :set invpaste<CR>
@ -291,25 +318,36 @@ function! ToggleNetrw() "make netrw toggleable <https://vi.stackexchange.com/que
endif endif
endfunction endfunction
"syntax/filetype "autogroup filetype functions
"--------------- "------------------
syntax on function BashSettings()
filetype plugin indent on set syntax=sh
runtime macros/matchit.vim endfunction
"gui settings function PythonSettings()
"------------ xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
if has("gui_running") endfunction
set guioptions -=m
set guioptions -=T function GoSettings()
if has("gui_gtk2") set noexpandtab
set guifont=Inconsolata\ 12 let g:go_auto_type_info = 1
elseif has("gui_macvim") let g:go_imports_autosave = 1
set guifont=Menlo\ Regular:h14 endfunction
elseif has("gui_win32")
set guifont=Consolas:h10 function HtmlSettings()
endif syntax sync fromstart
endif endfunction
"autogroup group functions
"-------------------------
function SpellSettings()
setlocal spell
endfunction
function HalftabSettings()
setlocal ts=2 sts=2 sw=2 expandtab
endfunction
"auto commands "auto commands
"------------- "-------------
@ -324,18 +362,27 @@ if has("autocmd")
\ <= line("$") | exe "normal! g'\"" | endif \ <= line("$") | exe "normal! g'\"" | endif
augroup END augroup END
"language/filetype augroup filetype_bash
augroup languages autocmd! BufNewFile,BufRead *.bash call BashSettings()
autocmd! augroup END
autocmd BufNewFile,BufRead *bash* set syntax=sh
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR> augroup filetype_python
autocmd FileType go set noexpandtab | autocmd! FileType python call PythonSettings()
\ let g:go_auto_type_info = 1 | augroup END
\ let g:go_imports_autosave = 1
autocmd FileType html :syntax sync fromstart augroup filetype_go
autocmd FileType html,javascript,css,json,yaml,markdown autocmd! FileType go call GoSettings()
\ setlocal ts=2 sts=2 sw=2 expandtab | augroup END
\ nnoremap <leader>f :%!prettier %<CR>
autocmd Filetype markdown setlocal spell augroup filetype_html
autocmd! FileType html call HtmlSettings()
augroup END
augroup filetype_spell
autocmd! FileType markdown call SpellSettings()
augroup END
augroup filetype_halftab
autocmd! FileType html,javascript,css,json,yaml,sh call HalftabSettings()
augroup END augroup END
endif endif

View File

@ -2,12 +2,14 @@
" minimal vimrc with no (extra) plugins " minimal vimrc with no (extra) plugins
" "
"load defaults if available "load system defaults
if filereadable(expand('$VIMRUNTIME/defaults.vim')) if filereadable(expand('$VIMRUNTIME/defaults.vim'))
unlet! g:skip_defaults_vim unlet! g:skip_defaults_vim
source $VIMRUNTIME/defaults.vim source $VIMRUNTIME/defaults.vim
endif endif
"regular settings
"----------------
" ui " ui
set number set number
set ruler set ruler
@ -31,18 +33,18 @@ set tabstop=4
set softtabstop=4 set softtabstop=4
set autoindent set autoindent
" allow syntax and filetype plugins
syntax enable
filetype plugin indent on
runtime macros/matchit.vim
" key timeout values " key timeout values
set esckeys set esckeys
set ttimeoutlen=20 set ttimeoutlen=20
set timeoutlen=1000 set timeoutlen=1000
" autocmds " allow syntax and filetype plugins
syntax enable
filetype plugin indent on
runtime macros/matchit.vim
" autocmds
"---------
augroup general augroup general
autocmd! autocmd!
"keep equal proportions when windows resized "keep equal proportions when windows resized
@ -54,7 +56,7 @@ augroup END
augroup languages augroup languages
autocmd! autocmd!
autocmd BufNewFile,BufRead *bash* set syntax=sh autocmd BufNewFile,BufRead *.bash set syntax=sh
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR> autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
autocmd FileType go set noexpandtab autocmd FileType go set noexpandtab
autocmd FileType html :syntax sync fromstart autocmd FileType html :syntax sync fromstart