-
Notifications
You must be signed in to change notification settings - Fork 8
/
.vimrc
164 lines (133 loc) · 3.91 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
" turn off mouse mode
set mouse=c
" turn on spell checking
set spell
let mapleader = ","
" tabs to 2 spaces
set expandtab
set shiftwidth=2
set softtabstop=2
filetype plugin indent on
" Add a line at col 80
set colorcolumn=80
" language specific tabbing
autocmd Filetype html setlocal ts=2 sts=2 sw=2
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2
autocmd Filetype qf nnoremap <buffer> q :q<CR>
" set default dispatch commands per file
autocmd FileType sh let b:dispatch = './%'
" live reload files if it changes on disk
set autoread
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * checktime
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
" word wrap more excellently
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'
" relative line numbers
set relativenumber
set number
" search options
set incsearch
set hlsearch
set ignorecase
set smartcase
set gdefault " replace option
" fzf file fuzzy search that respects .gitignore
" If in git directory, show only files that are committed, staged, or unstaged
" else use regular :Files
nnoremap <expr> <C-p> (len(system('git rev-parse')) ? ':Files' : ':GFiles --exclude-standard --others --cached')."\<cr>"
" TODO: Directory edit for file creation (maybe even inc mkdir -p)
" nnoremap <expr> <C-S-p> (len(system('git rev-parse')) ? ':Files' : ':GFiles --exclude-standard --others --cached')."\<cr>"
" ctags file setup
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" use control s to save and exit insert mode
noremap <silent> <C-s> :update<CR>:noh<CR>:set nopaste<CR>
inoremap <silent> <C-s> <C-c>:update<CR>:noh<CR>:set nopaste<CR>
" additional escapes
imap jk <esc>
imap kj <esc>
" open panes same location as tmux
set splitbelow
set splitright
" stop using arrow keys, dammit
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
inoremap <Up> <nop>
inoremap <Down> <nop>
inoremap <Left> <nop>
inoremap <Right> <nop>
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'terraform': ['terraform'],
\ 'crystal': ['crystal'],
\ }
call plug#begin('~/.vim/plugged')
" Fuzzy searching
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Background processes made easy
Plug 'tpope/vim-dispatch'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rails'
Plug 'sheerun/vim-polyglot'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" Themes
Plug 'blueshirts/darcula'
Plug 'dracula/vim', { 'as': 'dracula' }
" Colorize hex color strings
Plug 'chrisbra/Colorizer'
Plug 'tpope/vim-surround'
" Plug 'tmhedberg/matchit'
Plug 'tpope/vim-commentary'
Plug 'mhinz/vim-mix-format'
" ejs support
Plug 'nikvdp/ejs-syntax'
" HTML support
Plug 'mattn/emmet-vim'
call plug#end()
" Theme
packadd! dracula_pro
" syntax enable
let g:dracula_colorterm = 0
colorscheme dracula_pro_buffy
" set background=dark
" colorscheme darcula
highlight Normal ctermbg=None
let g:splitjoin_ruby_hanging_args = 0
" custom leader commands
" source vimrc
map <leader>so :source $MYVIMRC<CR>
map <Leader>vi :tabe ~/.vimrc<CR>
map <Leader>vl :tabe ~/.config/nvim/init.lua<CR>
map <Leader>vn :tabe notes.md<CR>
map <leader>r :!resize<CR><CR>
map <leader>co mmgg"+yG`m
map <leader>' cs"'
map <leader>" cs'"
map <Leader>o :Dispatch<cr>
map <Leader>q @q
map <Leader>t :Tags<cr>
map <Leader>a :Ag<cr>
map <leader>g :Git
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <Leader>n :call RenameFile()<cr>