forked from geerlingguy/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
236 lines (189 loc) · 7.61 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
"""
" Run :PlugInstall after dropping this in place to install plugins with vim-plug
"""
set nocompatible " be iMproved, required
"" nastily install 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 --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible' "sensible vim defaults
" assorted plugins
Plug 'scrooloose/syntastic' " syntax checking for various filetypes
Plug 'altercation/vim-colors-solarized' " the best colorscheme
Plug 'tpope/vim-abolish' " case-smart substitution with :S///, among other things
"NVIM INCOMPATIBLE
if !has('nvim')
Plug 'tpope/vim-fugitive' " git wrapper
" autocomplete - https://github.com/ycm-core/YouCompleteMe/issues/1751
" requires cmake, golang, etc
function! BuildYCM(info)
if a:info.status == 'installed' || a:info.force
!./install.py --clang-completer --go-completer --ts-completer
endif
endfunction
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
"" Clipboard
" :version must have +clipboard. Use vim, not vi, on osx homebrew. vim 7.4+
"" Linux apt-get install vim-gtk; alias vi=vim
set clipboard=autoselect,unnamedplus
" allow yy, etc. to interact with OS X clipboard
"fix scrolling in iterm
set mouse=a
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
endif
"END NVIM INCOMPATIBLE
"NVIM ONLY
if has('nvim')
Plug 'github/copilot.vim'
let g:copilot_filetypes = {
\ 'yaml': v:true,
\ }
set mouse=a
set clipboard=unnamedplus " autoselect waiting for https://github.com/neovim/neovim/issues/2325
source ~/.vim/scripts/partial_accept.vim
endif
"END NVIM ONLY
"typescript
autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
" post install (yarn install | npm install) then load plugin only for editing supported files
Plug 'prettier/vim-prettier', {
\ 'do': 'npm install',
\ 'for': ['javascript', 'typescript', 'css'] }
"ruby
Plug 'tpope/vim-rails', { 'for': 'ruby' }
Plug 'thoughtbot/vim-rspec', { 'for': 'ruby' }
Plug 'tpope/vim-bundler', { 'for': 'ruby' }
"golang
Plug 'fatih/vim-go', { 'for': 'go'}
Plug 'mdempsky/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh', 'for': 'go' }
let g:go_addtags_transform="camelcase" " json tags in camelCase instead of snake_case, required for kube
"Plug 'jgdavey/tslime.vim' " send commands to tmux
" Folding, comments, and formatting plugins
" Plug 'avakhov/vim-yaml', { 'for': 'yaml' } " autoformat yaml
let g:syntastic_yaml_checkers = [ "yamllint" ] " pip package
let g:syntastic_quiet_messages = { "type": "style", "file:e": "yaml" }
Plug 'tmhedberg/SimpylFold' "folding
Plug 'scrooloose/nerdcommenter' " Comment blocks: \c<space> to toggle
let g:NERDSpaceDelims = 1
" Markdown
" Enable spellcheck
" ]s for next word
" zg to add word to spellfile
" zx for suggestions
" :h spell
autocmd FileType markdown setlocal spell spelllang=en_us
Plug 'godlygeek/tabular', { 'for': 'markdown' }
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
let g:vim_markdown_new_list_item_indent = 0 " don't indent list items
let g:vim_markdown_folding_disabled=1 " disable markdown auto folding
"Plug 'nathanaelkane/vim-indent-guides' " shows indent guides in colors
let g:indent_guides_enable_on_vim_startup = 0 " Turn off indent guides
" Elixir
Plug 'elixir-lang/vim-elixir', { 'for': 'elixir' }
Plug 'mattreduce/vim-mix', { 'for': 'elixir' }
" Terraform
" Plug 'hashivim/vim-terraform'
call plug#end()
" Regular config resumes here
" Colorscheme
" let g:solarized_termcolors=256 " mediocre colors - use if termcolors are terrible
if (has("termguicolors"))
" term pallete must be solarized for this to look ok
" set termguicolors "i prefer the plugin's solarized palette over gnome's
let g:solarized_termtrans=1
let g:foo=1
endif
" workaround for tmux https://github.com/tmux/tmux/pull/2343 - relies on gtk theme name
let s:bg = system('gsettings get org.gnome.desktop.interface gtk-theme | grep -iq dark && echo -n dark')
if s:bg == "dark"
set background=dark
else
"set background=dark "TODO force dark until installed numix
set background=light
endif
colorscheme solarized
highlight CursorLineNr cterm=standout term=standout
"" File handling
set encoding=utf-8
autocmd CursorHold * checktime
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
set modeline " allow modelines to override things, typically filetype
"" Appearance
set cursorcolumn " highlight the current column
set cursorline " highlight the current line
set laststatus=2 " always show status line
set number " show line numbers
set ruler " show cursor position in status line
set scrolloff=5 " show at least 5 lines above/below
set showcmd " show selection metadata
set showmode " show INSERT, VISUAL, etc. mode
set splitright " put splits to right with :vsp
" Wrapping
set wrap " wrap long lines (on display)
set lbr " break at a sensible character (on display)
"set textwidth=80 " actually break
" Folding
set foldmethod=syntax
set foldcolumn=0
set foldnestmax=1
"set foldlevelstart=20
let g:go_fmt_experimental = 1 " fix folds reverting on every write due to go_fmt
"" Tabs and indenting
Plug 'vim-scripts/Smart-Tabs' " Smart tabs - tabs at line start, spaces for variable alignment
"to use: :RetabIndent[!]
set listchars=tab:▻\ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨
set list " since we have sensible tab displays now
syntax on " enable syntax highlighting
filetype on " enable filetype detection
filetype indent on " enable filetype-specific indenting
filetype plugin on " enable filetype-specific plugins
autocmd Filetype php setlocal noexpandtab tabstop=4 shiftwidth=4
autocmd Filetype go setlocal nolist " gofmt takes care of any issues so let's make it pretty
set autoindent " auto indenting
set smartindent " smart indenting
set expandtab " spaces instead of tabs " generally overridden
set smarttab " better backspace and tab functionality
set backspace=2 " more powerful backspacing
set shiftwidth=2 " front of line
set tabstop=2
set softtabstop=2 " midline, even if no text after (with smarttab)
let g:html_indent_inctags = "html,body,head,tbody" "indent includes for html
"" Bells
set vb t_vb= " disable all error bells and flashing
"" Search
" Fuzzy finding (\t)
map <leader>t :FZF<CR>
set rtp+=~/.fzf "add fuzzy finding if installed with git
set rtp+=/usr/local/opt/fzf "or if installed with homebrew
set hlsearch " highlighted search results
" map space to turn off search highlighting in normal mode
nnoremap <Space> :noh<cr><Space>
set showmatch " show matching bracket
set ignorecase
set smartcase " ignore case unless UC in search
" ignore annoying obviously bad paths for matching
set wildignore+=*.o,*.obj,*.swp,.git,.svn,tmp,log,.sass-cache,public,coverage,tests,content,node_modules
"" Other
set nobackup " don't create pointless backup files; Use VCS instead
"" Mappings
" easier window movement
nmap <leader>h :wincmd h<CR>
nmap <leader>j :wincmd j<CR>
nmap <leader>k :wincmd k<CR>
nmap <leader>l :wincmd l<CR>
"map <F2> :NERDTreeToggle<CR>
"" Remappings
"let mapleader= "," " change leader to something easier if desired
" auto insert close brackets
"inoremap { {}<Left>
"inoremap {<CR> {<CR>}<Esc>O
"inoremap {{ {
"inoremap {} {}