-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.vimrc
213 lines (181 loc) · 5.33 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
" initialize plugins
call plug#begin()
" syntx highighting
Plug 'slim-template/vim-slim'
Plug 'fatih/vim-go'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'LnL7/vim-nix'
" make searching more convenient
Plug 'romainl/vim-cool'
" needed for yarn berry with immutable flag
Plug 'lbrayner/vim-rzip'
" language server protocol
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" testing at point etc.
Plug 'vim-test/vim-test'
Plug 'airblade/vim-gitgutter'
Plug 'zivyangll/git-blame.vim'
call plug#end()
set background=dark
set ai " auto indenting
set nowrap
set complete=.,b,u,]
let mapleader = ","
set history=100 " keep 100 lines of history
set ruler " show the cursor position
set hlsearch " highlight the last searched term
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
nnoremap <leader>! :History:<cr>
nnoremap <leader>f :grep!<Space>
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>T :TestFile<CR>
nmap <silent> <leader>a :TestSuite<CR>
nmap <silent> <leader>l :TestLast<CR>
nmap <silent> <leader>q :copen<CR>
nmap <silent> <leader>Q :ccl<CR>
nmap <silent> <leader>d :Vex<CR>
nmap <silent> <leader>s :<C-u>call gitblame#echo()<CR>
autocmd QuickFixCmdPost *grep* cwindow
" Due to internal representation, Vim has problems with long lines in general.
" https://github.com/mhinz/vim-galore#editing-small-files-is-slow
set synmaxcol=200
if (&tildeop)
nmap gcc guu~l
else
nmap gcc guu~h
endif
"tab complete map
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
"map esc to j k
:imap jk <Esc>
" remap capital Q to rerun last macro
:nmap Q @@
" imap <Tab>, <C-y>,
autocmd Filetype gitcommit setlocal spell textwidth=72
autocmd FileType markdown setlocal spell
set nocompatible
set ignorecase
set nobackup
set nowb
set noswapfile
set nowritebackup
set showcmd
set incsearch
set laststatus=2
set tabstop=2
"set relativenumber
set number
set shiftwidth=2
set expandtab
filetype plugin indent on
syntax enable
set splitbelow
set splitright
set termguicolors
set statusline=%F%m%r%h%w\ [%n]\%=\ [line\ %l\/%L]\ [%{&filetype}]
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
set complete=.,w,t
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
set mouse=
" Reset the listchars
set listchars=""
" make tabs visible
set listchars=tab:▸▸
" show trailing spaces as dots
set listchars+=trail:.
" The character to show in the last column when wrap is off and the line
" continues beyond the right of the screen
set listchars+=extends:>
" The character to show in the last column when wrap is off and the line
" continues beyond the right of the screen
set listchars+=precedes:<
set undodir=~/.vim/undodir
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
set guifont=Hack:h12
"project specific vim settings
set exrc
command! -nargs=* Wrap set wrap linebreak nolist
function! ToggleColumn()
let test = &g:colorcolumn
if test == 80
set colorcolumn&
echo "turning column off"
else
set cc=80
echo "turning colummn on"
endif
endfunction
nmap <silent><leader>l :call ToggleColumn()<CR>
"https://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
set backspace=2 " make backspace work like most other apps
"vim talk mods
set wildmenu
" If a file is changed outside of vim, automatically reload it without asking
set autoread
autocmd! FileType slim set sw=2 sts=2 et
" Compute syntax highlighting from beginning of file. (By default, vim only
" looks 200 lines back, which can make it highlight code incorrectly in some
" long files.)
autocmd BufEnter * :syntax sync fromstart
nnoremap <silent><cr> :<c-u>update<cr>
augroup QuickFix
au FileType qf noremap <buffer> <cr> <cr>
au FileType qf noremap <buffer> <c-v> <C-w><Enter><C-w>L
augroup END
" automatically make quickfix window span the entire bottom split
autocmd FileType qf wincmd J
set clipboard=unnamedplus
let g:coc_global_extensions = [
\ 'coc-tsserver',
\ 'coc-go',
\ 'coc-json',
\ 'coc-css'
\ ]
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gr <Plug>(coc-references)
nnoremap <silent> K :call CocAction('doHover')<CR>
"colors for completion
hi Pmenu ctermbg=0 guibg=black
hi PmenuSel ctermbg=0
hi CocFloating ctermbg=0
"clear out the signcolumn and gitgutter bgs
hi clear SignColumn
hi clear GitGutterAdd
hi clear GitGutterChange
hi clear GitGutterDelete
hi clear LineNr
hi LineNr ctermfg=248
"list buffers via fzf
nnoremap <silent><c-b> :<c-u>Buffers<cr>
"set C-P to open fzf
nnoremap <silent><c-p> :<c-u>FZF<cr>
nnoremap <silent><c-x> :<c-u>q!<cr>
nnoremap <leader>p :let @+ = expand("%")<cr>
let g:test#javascript#jest#executable = 'yarn jest'
let g:test#javascript#runner = 'jest'
let g:gitgutter_show_msg_on_hunk_jumping = 0
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading\ --hidden
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
let g:coc_disable_transparent_cursor = 1
nnoremap <leader>p :set paste<CR>"+p:set nopaste<CR>