-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
235 lines (234 loc) · 6.95 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
" Load plugins
call plug#begin()
" Statusline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Opening files and buffers
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Word and character motions
Plug 'easymotion/vim-easymotion'
" Show git changes in gutter
Plug 'airblade/vim-gitgutter'
" Git integration
Plug 'tpope/vim-fugitive'
" Github integration
Plug 'tpope/vim-rhubarb'
" Extend . command
Plug 'tpope/vim-repeat'
" Surround text with delimeters
Plug 'tpope/vim-surround'
" " Motions for adding/removing comments
Plug 'tomtom/tcomment_vim'
" Auto-close parens
Plug 'jiangmiao/auto-pairs'
" Duplicate lines and visual selection
Plug 'timkendrick/vim-duplicate'
" Motions for function arguments
Plug 'b4winckler/vim-angry'
" Open file at last edit position
Plug 'farmergreg/vim-lastplace'
" Recent files (overrides start screen)
Plug 'mhinz/vim-startify'
" File commands
Plug 'tpope/vim-eunuch'
" Extend % matching
Plug 'vim-scripts/matchit.zip', {'for': ['html', 'xml', 'sh', 'vim']}
" JSX
Plug 'yuezk/vim-js'
Plug 'maxmellon/vim-jsx-pretty'
" Clojure
Plug 'tpope/vim-fireplace', {'for': 'clojure'}
" Clojure formatting
Plug 'venantius/vim-cljfmt', {'for': 'clojure'}
" Autocompletion
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Prettier
Plug 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
" Codeowners
Plug 'rhysd/vim-syntax-codeowners'
" Handlebars/Mustache templates
Plug 'mustache/vim-mustache-handlebars', {'for': 'hbs'}
" Svelte
Plug 'leafOfTree/vim-svelte-plugin'
call plug#end()
" Color theme
colorscheme tir_black
" Yank
nmap Y y$
" Don't show mode
set noshowmode
" set termguicolors
" Allow navigation away from modified buffers
set hidden
" Disable tabline
set showtabline=0
" Turn off beeping
set visualbell
" Highlight current line
set cursorline
" " Set the terminal's title
" set title
" Tabs and spaces
set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
set smarttab
" Allow backspace in insert mode
set backspace=indent,eol,start
" Use OS clipboard
set clipboard=unnamed
" Use undo file to maintain undo state per buffer
set undofile
" Enable line numbers
set number
" Searching
set incsearch
set ignorecase smartcase
set nohls
" Better? completion on command line
set wildmenu
" Don't offer to open certain files/directories
set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png,*.ico
set wildignore+=*.pdf,*.psd
set wildignore+=node_modules/*
" Enable mouse in all modes
set mouse=a
" " Omnicomplete
" " set completeopt=longest,menuone,preview
" " IMPORTANT: :help Ncm2PopupOpen for more information
" set completeopt=noinsert,menuone,noselect
" set omnifunc=syntaxcomplete#Complete
" List
set listchars+=space:.
" Change default split behavior
set splitbelow
set splitright
" <Leader>
let mapleader=','
let maplocalleader=','
" Enable edn filetype detection
au BufNewFile,BufRead *.edn setlocal filetype=clojure
" Enable .babelrc filetype detection
au BufNewFile,BufRead .babelrc setlocal filetype=json
" " HTML autocompletion
" au FileType html set omnifunc=htmlcomplete#CompleteTags
" vim-airline
set laststatus=2
let g:airline_theme='murmur'
let g:airline_left_sep=''
let g:airline_right_sep=''
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.readonly='RO'
let g:airline_symbols.linenr = ''
let g:airline_symbols.maxlinenr = ''
" " Horizontal split
" nmap _ :sp<CR>
" Backspace closes buffer
nmap <BS> :bd<CR>
" Last buffer
map <C-l> :e#<CR>
" Move lines up/down
nmap <C-j> :m +1<CR>
nmap <C-k> :m -2<CR>
vmap <C-j> :m '>+1<CR> gv
vmap <C-k> :m '<-2<CR> gv
" Duplicate line/selection
nmap <Leader>d <Plug>Duplicate
vmap <Leader>d <Plug>Duplicate gv
" Emacs keybindings (insert mode)
imap <C-f> <Right>
imap <C-b> <Left>
" " Stay in visual mode when indenting
" vnoremap < <gv
" vnoremap > >gv
" Entire file
onoremap af :<C-u>normal! ggVG<CR>
" Easy Motion
map <Leader>c <Plug>(easymotion-s)
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
map <Leader>W <Plug>(easymotion-bd-W)
" FZF
nmap <Leader>f :Files<CR>
nmap <Leader>b :Buffers<CR>
nmap <Leader>h :History/<CR>
" Search
function s:Search(term)
execute 'terminal rg --fixed-strings --max-columns 125 --pretty --smart-case --no-ignore-vcs ' . a:term
endfunction
command -nargs=1 Search call s:Search(<f-args>)
nmap <Leader>s :Search<Space>
" Search (with quickfix)
function s:SearchWithQuickfix(term)
cgetexpr system('rg --vimgrep --fixed-strings --smart-case --no-ignore-vcs ' . a:term)
copen
endfunction
command -nargs=1 SearchWithQuickfix call s:SearchWithQuickfix(<f-args>)
nmap <Leader>/ :SearchWithQuickfix<Space>
" Set grep program to rg
set grepprg=rg\ --vimgrep
set grepformat^=%f:%l:%c:%m
" Git
nmap <Leader>gh :Gbrowse<CR>
vmap <Leader>gh :Gbrowse<CR>
nmap <Leader>gs :Git<CR>
nmap <Leader>gb :Git blame<CR>
nmap <Leader>gc :Git commit<CR>
nmap <Leader>gd :terminal git diff<CR>
nmap <Leader>gl :BCommits!<CR>
nmap <Leader>gf :Git fetch<CR>
nmap <Leader>gp :Git push<CR>
nmap <Leader>gP :Git pull<CR>
nmap <Leader>gup :!git push -u origin $(git rev-parse --abbrev-ref HEAD)<CR>
nmap <Leader>gn :GitGutterNextHunk<CR>
" Open lines without changing to Insert mode
nmap <Leader>o o<Esc>
nmap <Leader>O O<Esc>
" netrw
let g:netrw_liststyle = 3
" Display full path of current file
nmap <Leader>n :echo expand('%:p')<CR>
" Javascript
au FileType javascript,typescript nmap <silent> <Leader>j <Plug>(coc-definition)
au FileType javascript,typescript nmap <silent> gd <Plug>(coc-definition)
au FileType javascript,typescript nmap <silent> gr <Plug>(coc-references)
au FileType javascript,typescript nmap <silent> gy <Plug>(coc-type-definition)
au FileType javascript,typescript nmap <silent> gi <Plug>(coc-implementation)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Symbol renaming.
nmap <Leader>rn <Plug>(coc-rename)
" Startify (start screen)
nmap <Leader>r :Startify<CR>
let g:startify_list_order = ['dir']
let g:startify_change_to_dir = 0
let g:startify_custom_header = []
" MJML
autocmd BufEnter *.mjml setlocal filetype=xml
au FileType clojure nmap <buffer> <silent> <Leader>j <Plug>FireplaceDjump
" Yank history
nnoremap <silent> <Leader>y :<C-u>CocList -A --normal yank<cr>
" COC
nmap <silent> <C-p> <Plug>(coc-diagnostic-prev)
nmap <silent> <C-n> <Plug>(coc-diagnostic-next)
let g:coc_global_extensions = ['coc-json', 'coc-sql', 'coc-css', 'coc-html', 'coc-eslint', 'coc-conjure', 'coc-sh', 'coc-yank', 'coc-vimlsp', 'coc-xml', 'coc-yaml', 'coc-tsserver' ]
command! -nargs=0 Format :call CocActionAsync('format')
" Prettier
let g:prettier#config#semi = 'false'
let g:prettier#config#single_quote = 'true'
nmap <leader>p :Prettier<CR>