-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
283 lines (215 loc) · 7.75 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
" Additional configs and scripts are in .vim/plugins folder
autocmd!
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-plug
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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
endif
call plug#begin('~/.vim/plugged')
Plug 'dracula/vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'https://github.com/mawaldne/BufOnly.vim'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-commentary', { 'on': '<Plug>Commentary' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-eunuch'
Plug 'justinmk/vim-dirvish'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-git'
Plug 'keith/tmux.vim'
" JS
Plug 'leafgarland/typescript-vim'
" Ruby
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-rails', { 'for': [] }
" zig
Plug 'ziglang/zig.vim'
" Go
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Plug 'prabirshrestha/vim-lsp'
" JSON
" Plug 'sheerun/vim-json'
" HTML CSS
" Plug 'othree/html5.vim'
" Mermaid
Plug 'mracos/mermaid.vim'
" Odin
Plug 'https://github.com/Tetralux/odin.vim'
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Color
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:dracula_italic = 0
let g:dracula_colorterm = 0
colorscheme dracula
if has("gui_macvim")
set guifont=Monaco:h16
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set nocompatible
" This allows buffers to be hidden if you've modified a buffer.
" This is almost a must if you wish to use buffers in this way.
set hidden
" remember more commands and search history
set history=10000
set expandtab
set tabstop=8
set shiftwidth=4
set softtabstop=0 noexpandtab
set autoindent
set laststatus=2
set showmatch
set incsearch
set hlsearch
" Natural split changes
set splitbelow " Splitting a window will put the new window below the current
set splitright
" make searches case-sensitive only if they contain upper-case characters
set ignorecase smartcase
set cmdheight=1
set switchbuf=useopen
set showtabline=1
set winwidth=79
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" keep more context when scrolling off the end of a buffer
set scrolloff=3
" Don't make backups at all
set nobackup
set nowritebackup
set backspace=indent,eol,start
" display incomplete commands
set showcmd
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" use emacs-style tab completion when selecting files, etc
set wildmode=longest,list
" make tab completion for files/buffers act like bash
set wildmenu
" Fix slow O inserts
set timeout timeoutlen=1000 ttimeoutlen=100
" Normally, Vim messes with iskeyword when you open a shell file. This can
" leak out, polluting other file types even after a 'set ft=' change. This
" variable prevents the iskeyword change so it can't hurt anyone.
let g:sh_noisk=1
" Modelines (comments that set vim options on a per-file basis)
set modeline
set modelines=3
" Turn folding off for real, hopefully
set foldmethod=manual
set nofoldenable
" Insert only one space when joining lines that contain sentence-terminating
" punctuation like `.`.
set nojoinspaces
" If a file is changed outside of vim, automatically reload it without asking
set autoread
" Enable highlighting for syntax
syntax on
set noswapfile
set backupdir=$HOME/.vim/backup
set directory=$HOME/.vim/tmp
set nofixendofline
" Space works better on my kenesis keyboard. Kenesis for life!
let mapleader = "\<Space>"
" Copy everything to the system clipboard
set clipboard=unnamed
" NVIM Only feature - show a %s change as you write it in the file
if has('nvim')"
set inccommand=split
endif
" Preserve indentation while pasting text from the OS X clipboard
noremap <leader>p :set paste<CR>:put *<CR>:set nopaste<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Undo folder. undo changes after closing and opening files
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set undofile
if has('nvim')
" New format in https://github.com/neovim/neovim/pull/13973 (f42e932,
" 2021-04-13).
set undodir=~/.vim/undodir
else
set undodir=~/.vim/undodir_old
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" STATUS LINE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set statusline=[%02n]\ %f\ %(\[%M%R%H]%)%=\ %4l,%02c%2V\ %P%*
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Repeat last ex command using F2
map <F2> @:
" Repeat last macro using F3
map <F3> @@
" Show invisible characters
nmap <leader>i :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
if &encoding == 'utf-8'
set listchars=tab:▸\ ,eol:¬,trail:·
endif
" Pretty print a json file
command! -nargs=0 Jqfile %!jq '.'
" Pretty print a sql file
command! -nargs=0 Sqlfile %!pg_format -B '-'
" Turn off highlighting
nnoremap <leader>\ :noh<return> " Turn off highlighting
" Turn off ex mode.
map q: <Nop>
nnoremap Q <Nop>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Buffers
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To open a new empty buffer
" This replaces :tabnew which I used to bind to this mapping
nmap <leader>T :enew<cr>
" Close the current buffer and move to the previous one
" This replicates the idea of closing a tab
" nmap <leader>w :bp <BAR> bd #<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Editing files
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a vertical split command with the path of the currently edited file filled in
" Normal mode: <Leader>t
map <Leader>v :vsplit <C-R>=expand("%:p:h") . "/" <CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" for ruby, autoindent with two spaces, always expand tabs
autocmd FileType text,ruby,haml,eruby,yaml,html,javascript,sass,scss,cucumber,terraform,nasm set ai sw=2 sts=2 et
autocmd BufNewFile,BufRead *.p8 set filetype=lua
autocmd BufNewFile,BufRead *.s set filetype=nasm
" make python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
autocmd FileType python set sw=4 sts=4 et
autocmd FileType odin set sw=4 sts=4 et
autocmd BufNewFile,BufRead *.j2 set filetype=python
au InsertEnter,InsertChange * silent redraw!
au VimEnter,InsertLeave * silent redraw!
source $HOME/.vim/conf.d/dirvish.vim
source $HOME/.vim/conf.d/fzf_config.vim
source $HOME/.vim/conf.d/commentary_config.vim
source $HOME/.vim/conf.d/strip_whitespace.vim
source $HOME/.vim/conf.d/reload_files.vim
" source $HOME/.vim/conf.d/vim-go.vim
"source $HOME/.vim/conf.d/vim-lsp.vim