reorganize, remove plugins, add colors
This commit is contained in:
parent
387d44c489
commit
b627c4d0dd
398
vim/vimrc
398
vim/vimrc
@ -3,25 +3,98 @@
|
|||||||
" \ V /| | | | | | | | | (__
|
" \ V /| | | | | | | | | (__
|
||||||
" \_/ |_|_| |_| |_|_| \___|
|
" \_/ |_|_| |_| |_|_| \___|
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
"sources defaults if available
|
||||||
"general settings
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
"load defaults if available
|
|
||||||
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
|
||||||
|
|
||||||
|
"plugins (vim-plug)
|
||||||
|
"------------------
|
||||||
|
"ensure vim-plug is installed on VimEnter
|
||||||
|
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
|
||||||
|
|
||||||
|
"filetype *may* interfere with certain plugins
|
||||||
|
filetype off
|
||||||
|
|
||||||
|
call plug#begin('~/.vim/plugged')
|
||||||
|
Plug 'junegunn/vim-plug'
|
||||||
|
|
||||||
|
"general
|
||||||
|
"-------
|
||||||
|
"quality of life
|
||||||
|
Plug 'tpope/vim-surround'
|
||||||
|
Plug 'tpope/vim-commentary'
|
||||||
|
Plug 'tpope/vim-unimpaired'
|
||||||
|
Plug 'tpope/vim-rsi'
|
||||||
|
Plug 'tpope/vim-eunuch'
|
||||||
|
Plug 'tpope/vim-repeat'
|
||||||
|
Plug 'editorconfig/editorconfig-vim'
|
||||||
|
"git
|
||||||
|
Plug 'tpope/vim-fugitive'
|
||||||
|
"visual
|
||||||
|
Plug 'flazz/vim-colorschemes'
|
||||||
|
"linting
|
||||||
|
Plug 'w0rp/ale'
|
||||||
|
|
||||||
|
"language/ft specific
|
||||||
|
"--------------------
|
||||||
|
"javascript/css/html
|
||||||
|
Plug 'pangloss/vim-javascript'
|
||||||
|
Plug 'mattn/emmet-vim'
|
||||||
|
"go
|
||||||
|
Plug 'fatih/vim-go'
|
||||||
|
call plug#end()
|
||||||
|
|
||||||
|
"plugin settings
|
||||||
|
"---------------
|
||||||
|
"this function gets called with the VimEnter autocommand to set plugin
|
||||||
|
"options
|
||||||
|
function! SetPluginSettings()
|
||||||
|
"netrw
|
||||||
|
let g:netrw_banner = 0
|
||||||
|
let g:netrw_winsize = 24
|
||||||
|
let g:netrw_liststyle = 3
|
||||||
|
let g:netrw_preview = 1
|
||||||
|
let g:netrw_alto = 0
|
||||||
|
let g:netrw_usetab = 1
|
||||||
|
let g:NetrwIsOpen = 0 "for toggle function
|
||||||
|
|
||||||
|
"ale
|
||||||
|
if exists(':ALEToggle')
|
||||||
|
let g:ale_fixers = {
|
||||||
|
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||||
|
\ 'javascript': ['eslint'],
|
||||||
|
\}
|
||||||
|
let g:ale_sign_error = '->'
|
||||||
|
let g:ale_sign_warning = '--'
|
||||||
|
endif
|
||||||
|
|
||||||
|
"colors
|
||||||
|
"set background=dark
|
||||||
|
|
||||||
|
"colorscheme 1989
|
||||||
|
"colorscheme PaperColor
|
||||||
|
"colorscheme dracula
|
||||||
|
"colorscheme gruvbox
|
||||||
|
colorscheme jellybeans
|
||||||
|
"colorscheme molokai
|
||||||
|
"colorscheme badwolf
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"general settings
|
||||||
|
"----------------
|
||||||
"encoding/format
|
"encoding/format
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
set fileformats=unix,dos,mac
|
set fileformats=unix,dos,mac
|
||||||
|
|
||||||
"file/buffer
|
"file/buffer
|
||||||
set autoread
|
set autoread
|
||||||
set autowrite
|
set autowrite
|
||||||
set confirm
|
set confirm
|
||||||
|
|
||||||
"display
|
"display
|
||||||
set background=dark
|
set background=dark
|
||||||
set number
|
set number
|
||||||
@ -32,88 +105,71 @@ set foldmethod=marker
|
|||||||
set lazyredraw
|
set lazyredraw
|
||||||
set regexpengine=1
|
set regexpengine=1
|
||||||
set redrawtime=10000
|
set redrawtime=10000
|
||||||
|
|
||||||
"tab/indent
|
"tab/indent
|
||||||
set tabstop=4
|
set tabstop=4
|
||||||
set softtabstop=4
|
set softtabstop=4
|
||||||
set shiftwidth=4
|
set shiftwidth=4
|
||||||
set expandtab
|
set expandtab
|
||||||
set autoindent
|
set autoindent
|
||||||
|
|
||||||
"status bar
|
"status bar
|
||||||
set showcmd
|
set showcmd
|
||||||
set wildmenu
|
set wildmenu
|
||||||
set ruler
|
set ruler
|
||||||
set laststatus=2
|
set laststatus=2
|
||||||
|
|
||||||
"search
|
"search
|
||||||
set incsearch
|
set incsearch
|
||||||
set hlsearch
|
set hlsearch
|
||||||
set ignorecase
|
set ignorecase
|
||||||
set smartcase
|
set smartcase
|
||||||
|
|
||||||
"cursor behaviour
|
"cursor behaviour
|
||||||
set virtualedit=block
|
set virtualedit=block
|
||||||
set backspace=indent,eol,start
|
set backspace=indent,eol,start
|
||||||
set showmatch
|
set showmatch
|
||||||
set scrolloff=2
|
set scrolloff=2
|
||||||
set sidescrolloff=8
|
set sidescrolloff=8
|
||||||
|
|
||||||
"input/timeout
|
"input/timeout
|
||||||
set esckeys
|
set esckeys
|
||||||
set timeoutlen=1000 "for mappings
|
set timeoutlen=1000 "for mappings
|
||||||
set ttimeoutlen=20 "for keycodes
|
set ttimeoutlen=20 "for keycodes
|
||||||
|
|
||||||
"window behaviour (ltr)
|
"window behaviour (ltr)
|
||||||
set splitbelow
|
set splitbelow
|
||||||
set splitright
|
set splitright
|
||||||
|
|
||||||
"undo/bkup dirs
|
"undo/bkup dirs
|
||||||
set undofile
|
set undofile
|
||||||
set undodir=~/.vim/.undo//,/tmp//
|
set undodir=~/.vim/.undo//,/tmp//
|
||||||
set backupdir=~/.vim/.backup//,/tmp//
|
set backupdir=~/.vim/.backup//,/tmp//
|
||||||
set directory=~/.vim/.swap//,/tmp//
|
set directory=~/.vim/.swap//,/tmp//
|
||||||
|
|
||||||
"leader key
|
"leader key
|
||||||
let mapleader=' '
|
let mapleader=' '
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"normal/visual mode keybinds
|
"normal/visual mode keybinds
|
||||||
"------------------------------------------------------------------------------
|
"---------------------------
|
||||||
|
"paste and search
|
||||||
"normal keybinds
|
|
||||||
nnoremap <silent><leader><space> :let @/ = ""<CR>
|
nnoremap <silent><leader><space> :let @/ = ""<CR>
|
||||||
nnoremap <leader>p :set invpaste<CR>
|
nnoremap <leader>p :set invpaste<CR>
|
||||||
|
"toggles
|
||||||
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
|
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
|
||||||
nnoremap <silent><leader>wr :call ToggleWrap()<CR>
|
nnoremap <silent><leader>wr :call ToggleWrap()<CR>
|
||||||
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
|
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
|
||||||
|
"dates
|
||||||
nnoremap <leader>ts "=strftime("%F %T%z")<CR>
|
nnoremap <leader>ts "=strftime("%F %T%z")<CR>
|
||||||
nnoremap <leader>dt :r !date<CR>
|
nnoremap <leader>dt :r !date<CR>
|
||||||
|
"rc files
|
||||||
nnoremap <leader>rc :vsplit $MYVIMRC<CR>
|
nnoremap <leader>rc :vsplit $MYVIMRC<CR>
|
||||||
nnoremap <leader>so :source $MYVIMRC<CR>
|
nnoremap <leader>so :source $MYVIMRC<CR>
|
||||||
|
"formatting tools
|
||||||
nnoremap =j :%!python -m json.tool<CR>
|
nnoremap =j :%!python -m json.tool<CR>
|
||||||
|
|
||||||
"plugin keybinds
|
"plugin keybinds
|
||||||
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
|
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
|
||||||
nnoremap <leader>at :ALEToggle<CR>
|
nnoremap <leader>at :ALEToggle<CR>
|
||||||
if !exists('##TextYankPost')
|
|
||||||
map y <Plug>(highlightedyank)
|
|
||||||
endif
|
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"insert mode keybinds and abbreviations
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
"insert mode keybinds/abbreviations
|
||||||
|
"--------------------
|
||||||
inoreabbrev <expr> #!! "#!/usr/bin/env"
|
inoreabbrev <expr> #!! "#!/usr/bin/env"
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"custom commands
|
"custom commands
|
||||||
"------------------------------------------------------------------------------
|
"---------------
|
||||||
|
|
||||||
"common typos and abbreviations
|
"common typos and abbreviations
|
||||||
cnoremap w!! w !sudo tee % > /dev/null
|
cnoremap w!! w !sudo tee % > /dev/null
|
||||||
command! W w !sudo tee % > /dev/null
|
command! W w !sudo tee % > /dev/null
|
||||||
@ -125,233 +181,115 @@ command! Q1 q!
|
|||||||
"function calls
|
"function calls
|
||||||
command! -nargs=+ SearchGoogle call SearchGoogle(join([<f-args>]))
|
command! -nargs=+ SearchGoogle call SearchGoogle(join([<f-args>]))
|
||||||
|
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"plugins (vim-plug)
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
"ensure vim-plug is installed on VimEnter
|
|
||||||
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
|
|
||||||
|
|
||||||
"filetype *may* interfere with certain plugins
|
|
||||||
filetype off
|
|
||||||
|
|
||||||
"entry function
|
|
||||||
call plug#begin('~/.vim/plugged')
|
|
||||||
|
|
||||||
"## vim plug ##
|
|
||||||
Plug 'junegunn/vim-plug'
|
|
||||||
|
|
||||||
"-------------
|
|
||||||
"== general ==
|
|
||||||
"-------------
|
|
||||||
|
|
||||||
"## quality of life ##
|
|
||||||
Plug 'tpope/vim-surround'
|
|
||||||
Plug 'tpope/vim-commentary'
|
|
||||||
Plug 'tpope/vim-unimpaired'
|
|
||||||
Plug 'tpope/vim-rsi'
|
|
||||||
Plug 'tpope/vim-eunuch'
|
|
||||||
Plug 'tpope/vim-repeat'
|
|
||||||
Plug 'editorconfig/editorconfig-vim'
|
|
||||||
|
|
||||||
"## git ##
|
|
||||||
Plug 'tpope/vim-fugitive'
|
|
||||||
Plug 'airblade/vim-gitgutter'
|
|
||||||
|
|
||||||
"## visual ##
|
|
||||||
Plug 'machakann/vim-highlightedyank'
|
|
||||||
|
|
||||||
"-----------------------
|
|
||||||
"== language specific ==
|
|
||||||
"-----------------------
|
|
||||||
|
|
||||||
"javascript/css/html
|
|
||||||
Plug 'pangloss/vim-javascript'
|
|
||||||
Plug 'mattn/emmet-vim'
|
|
||||||
|
|
||||||
"go
|
|
||||||
Plug 'fatih/vim-go'
|
|
||||||
|
|
||||||
"## linting ##
|
|
||||||
Plug 'w0rp/ale'
|
|
||||||
|
|
||||||
call plug#end()
|
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"plugin settings
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
" this function gets called with the VimEnter autocommand to set plugin
|
|
||||||
" options
|
|
||||||
function! SetPluginSettings()
|
|
||||||
|
|
||||||
"netrw
|
|
||||||
let g:netrw_banner = 0
|
|
||||||
let g:netrw_winsize = 24
|
|
||||||
let g:netrw_liststyle = 3
|
|
||||||
let g:netrw_preview = 1
|
|
||||||
let g:netrw_alto = 0
|
|
||||||
let g:netrw_usetab = 1
|
|
||||||
let g:netrw_browsex_viewer = "xdg-open"
|
|
||||||
let g:NetrwIsOpen = 0 "for toggle function
|
|
||||||
|
|
||||||
"git gutter
|
|
||||||
augroup git_gutter
|
|
||||||
if exists(':GitGutter')
|
|
||||||
autocmd!
|
|
||||||
let g:gitgutter_map_keys = 0 "don't use mapped keys
|
|
||||||
autocmd BufWritePost * GitGutter "update GitGutter after writing
|
|
||||||
endif
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"ale
|
|
||||||
if exists(':ALEToggle')
|
|
||||||
let g:ale_fixers = {
|
|
||||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
|
||||||
\ 'javascript': ['eslint'],
|
|
||||||
\}
|
|
||||||
let g:ale_sign_error = '->'
|
|
||||||
let g:ale_sign_warning = '--'
|
|
||||||
endif
|
|
||||||
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"general functions
|
"general functions
|
||||||
"------------------------------------------------------------------------------
|
"-----------------
|
||||||
|
|
||||||
"----------------
|
|
||||||
"toggle functions
|
"toggle functions
|
||||||
"----------------
|
|
||||||
|
|
||||||
function! ToggleColorColumn()
|
function! ToggleColorColumn()
|
||||||
if &cc == ''
|
if &cc == ''
|
||||||
set cc=80
|
set cc=80
|
||||||
else
|
else
|
||||||
set cc=
|
set cc=
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ToggleLineBreak()
|
function! ToggleLineBreak()
|
||||||
if &lbr == ''
|
if &lbr == ''
|
||||||
set fo+=t "Autowraps text with textwidth
|
set fo+=t "Autowraps text with textwidth
|
||||||
set fo-=l "Wraps long lines in --insert-- mode
|
set fo-=l "Wraps long lines in --insert-- mode
|
||||||
set lbr
|
set lbr
|
||||||
else
|
else
|
||||||
set fo-=t
|
set fo-=t
|
||||||
set fo+=l
|
set fo+=l
|
||||||
set lbr!
|
set lbr!
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ToggleWrap()
|
function! ToggleWrap()
|
||||||
if &wrap == ''
|
if &wrap == ''
|
||||||
set wrap
|
set wrap
|
||||||
else
|
else
|
||||||
set nowrap
|
set nowrap
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ToggleNetrw() "make netrw toggleable
|
function! ToggleNetrw() "make netrw toggleable
|
||||||
"https://vi.stackexchange.com/questions/10988/toggle-explorer-window
|
"https://vi.stackexchange.com/questions/10988/toggle-explorer-window
|
||||||
if g:NetrwIsOpen
|
if g:NetrwIsOpen
|
||||||
let i = bufnr("$")
|
let i = bufnr("$")
|
||||||
while (i >= 1)
|
while (i >= 1)
|
||||||
if (getbufvar(i, "&filetype") == "netrw")
|
if (getbufvar(i, "&filetype") == "netrw")
|
||||||
silent exe "bwipeout " . i
|
silent exe "bwipeout " . i
|
||||||
endif
|
endif
|
||||||
let i-=1
|
let i-=1
|
||||||
endwhile
|
endwhile
|
||||||
let g:NetrwIsOpen=0
|
let g:NetrwIsOpen=0
|
||||||
else
|
else
|
||||||
let g:NetrwIsOpen=1
|
let g:NetrwIsOpen=1
|
||||||
silent Lexplore
|
silent Lexplore
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"----------------
|
|
||||||
"search functions
|
"search functions
|
||||||
"----------------
|
|
||||||
|
|
||||||
function! SearchGoogle(string)
|
function! SearchGoogle(string)
|
||||||
let l:google = "https://www.google.com/search?q="
|
let l:google = "https://www.google.com/search?q="
|
||||||
let l:browser = "xdg-open >/dev/null 2>/dev/null"
|
let l:browser = "xdg-open >/dev/null 2>/dev/null"
|
||||||
let l:query = substitute(join(split(a:string),"+"),'"',"","g")
|
let l:query = substitute(join(split(a:string),"+"),'"',"","g")
|
||||||
execute "!" l:browser . "\ " . l:google . l:query
|
execute "!" l:browser . "\ " . l:google . l:query
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"syntax/filetype
|
"syntax/filetype
|
||||||
"------------------------------------------------------------------------------
|
"---------------
|
||||||
|
|
||||||
syntax enable
|
syntax enable
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
runtime macros/matchit.vim
|
runtime macros/matchit.vim
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"gui settings
|
"gui settings
|
||||||
"------------------------------------------------------------------------------
|
"------------
|
||||||
|
|
||||||
if has("gui_running")
|
if has("gui_running")
|
||||||
set guioptions -=m
|
set guioptions -=m
|
||||||
set guioptions -=T
|
set guioptions -=T
|
||||||
if has("gui_gtk2")
|
if has("gui_gtk2")
|
||||||
set guifont=Inconsolata\ 12
|
set guifont=Inconsolata\ 12
|
||||||
elseif has("gui_macvim")
|
elseif has("gui_macvim")
|
||||||
set guifont=Menlo\ Regular:h14
|
set guifont=Menlo\ Regular:h14
|
||||||
elseif has("gui_win32")
|
elseif has("gui_win32")
|
||||||
set guifont=Consolas:h10
|
set guifont=Consolas:h10
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"win32 settings
|
"win32 settings
|
||||||
"------------------------------------------------------------------------------
|
"--------------
|
||||||
|
|
||||||
if has('win32')
|
if has('win32')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"------------------------------------------------------------------------------
|
|
||||||
"auto commands
|
"auto commands
|
||||||
"------------------------------------------------------------------------------
|
"-------------
|
||||||
|
|
||||||
if has("autocmd")
|
if has("autocmd")
|
||||||
|
"global
|
||||||
|
augroup global
|
||||||
|
autocmd!
|
||||||
|
"set plugin settings on VimEnter
|
||||||
|
autocmd VimEnter * call SetPluginSettings()
|
||||||
|
"keep equal proportions when windows resized
|
||||||
|
autocmd VimResized * wincmd =
|
||||||
|
"save cursor position in a file
|
||||||
|
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
|
||||||
|
\ <= line("$") | exe "normal! g'\"" | endif
|
||||||
|
augroup END
|
||||||
|
|
||||||
"------------
|
"language/filetype
|
||||||
"## global ##
|
augroup languages
|
||||||
"------------
|
autocmd!
|
||||||
augroup general
|
"shell
|
||||||
autocmd!
|
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
||||||
"set plugin settings on VimEnter
|
"python
|
||||||
autocmd VimEnter * call SetPluginSettings()
|
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
||||||
"keep equal proportions when windows resized
|
"go
|
||||||
autocmd VimResized * wincmd =
|
autocmd FileType go set expandtab! "go uses real tabs
|
||||||
"save cursor position in a file
|
"html
|
||||||
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
|
autocmd FileType html :syntax sync fromstart
|
||||||
\ <= line("$") | exe "normal! g'\"" | endif
|
"filestypes where tabs should = 2 spaces
|
||||||
augroup END
|
autocmd FileType html,javascript,css,json,yaml,sh
|
||||||
|
\ setlocal ts=2 sts=2 sw=2 expandtab
|
||||||
"--------------------------------
|
augroup END
|
||||||
"## language/filetype specific ##
|
|
||||||
"--------------------------------
|
|
||||||
augroup languages
|
|
||||||
autocmd!
|
|
||||||
"shell
|
|
||||||
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
|
||||||
"python
|
|
||||||
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
|
||||||
"go
|
|
||||||
autocmd FileType go set expandtab! "go uses real tabs
|
|
||||||
"html
|
|
||||||
autocmd FileType html :syntax sync fromstart
|
|
||||||
"filestypes where tabs should = 2 spaces
|
|
||||||
autocmd FileType html,javascript,css,json,yaml,sh
|
|
||||||
\ setlocal ts=2 sts=2 sw=2 expandtab
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user