forked from theopn/kickstart.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
312 lines (249 loc) · 9.39 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
" Set <space> as the leader key
" See `:help mapleader`
" NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
let mapleader=' '
let maplocalleader = ' '
set relativenumber
set rnu
" Install package manager
" https://github.com/junegunn/vim-plug/
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" NOTE: Here is where you install your plugins.
call plug#begin()
" Detect tabstop and shiftwidth automatically
" Plug 'tpope/vim-sleuth'
" NOTE: This is where your plugins related to LSP can be installed.
" The configuration is done below. Search for lsp to find it below.
" Enable LSP
Plug 'prabirshrestha/vim-lsp'
" Install language servers and configure them for vim-lsp
Plug 'mattn/vim-lsp-settings'
" Use <Tab> to auto complete
Plug 'ervandew/supertab'
" Useful plugin to show you pending keybinds.
Plug 'liuchengxu/vim-which-key'
" Adds git related signs to the gutter
Plug 'airblade/vim-gitgutter'
" Set airline as statusline
Plug 'vim-airline/vim-airline'
" Add indentation guides even on blank lines
Plug 'Yggdroot/indentLine'
" "gc" to comment visual regions/lines
Plug 'tpope/vim-commentary'
" Fuzzy Finder
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'sonph/onehalf', { 'rtp': 'vim' }
Plug 'tpope/vim-surround'
call plug#end()
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" [[ Setting sensible default options ]]
" These are some of the settings enabled by default in Neovim.
" These are options believed by many Vim users to be essential.
" Find the list of the options using: `:options` and/or `:h option-list`
" switch on file type detection, without syntax highlighting
filetype on
" start using syntax highlighting
syntax on
" automatically set the indent of a new line
set autoindent
" automatically read a file when it was modified outside of Vim
set autoread
" "dark" or "light"; the background color brightness
set background=dark
" specifies what <BS>, CTRL-W, etc. can do in Insert mode
set backspace=indent,eol,start
" do not ring the bell for these reasons
set belloff=all
" include "lastline" to show the last line even if it doesn't fit
" include "uhex" to show unprintable characters as a hex number
set display=lastline
" character encoding used in Vim: "latin1", "utf-8",
set encoding=utf-8
" don't unload a buffer when no longer shown in a window
" (Allow opening other files w/o saving current buffer)
set hidden
" how many command lines are remembered
set history=10000
" highlight all matches for the last used search pattern
set hlsearch
" show match for partly typed search command
set incsearch
" use two spaces after '.' when joining a line
set nojoinspaces
" 0, 1 or 2; when to use a status line for the last window
set laststatus=2
" list of strings used for list mode
set listchars=tab:>\ ,trail:-,nbsp:+
" show cursor position below each window
set ruler
" show (partial) command keys in location given by 'showcmdloc'
set showcmd
" a <Tab> in an indent inserts 'shiftwidth' spaces
" NOTE: See `:help tabstop` to learn how tabs in Vim work
set smarttab
" many jump commands move the cursor to the first non-blank
set nostartofline
" "useopen" and/or "split"; which window to use when jumping to a buffer
set switchbuf=uselast
" use menu for command line completion
set wildmenu
" specifies how command line completion is done
set wildoptions=pum,tagfile
" [[ Settings other options ]]
" NOTE: You can change these options as you wish!
" Make line numbers default
set number
" Enable mouse mode
set mouse=a
" Sync clipboard between OS and Neovim.
" Remove this option if you want your OS clipboard to remain independent.
" See `:help 'clipboard'`
if has('unnamedplus')
set clipboard^=unnamed
set clipboard^=unnamedplus
endif
" set clipboard=unnamedplus
" Enable break indent
set breakindent
" Save undo history
" By default, undo files (.file.txt.un~) are saved in the current directory.
" This makes the file system very messy, so undofile is disabled by default.
"
" If would like to enable undofile, I recommend you to change undodir:
" 1. Create the undo directory: `:! mkdir -p ~/.local/state/vim/undo`
" 2. Uncomment the following line starting with "set undodir" and save the file
" 3. Source the .vimrc: `:source ~/.vimrc`
" 4. Now undo history will persist between Vim sessions
"
" NOTE: See `:help undofile` and `:help undodir` for more information
" You may change the undodir to another directory you prefer
"set undodir=~/.local/state/vim/undo// undofile
" Case-insensitive searching UNLESS \C or capital in search
set ignorecase
set smartcase
" Keep signcolumn on by default
set signcolumn=yes
" Decrease update time
set updatetime=250
set timeoutlen=300
" Set completeopt to have a better completion experience
set completeopt=menuone,noselect
" NOTE: You should make sure your terminal supports this
set termguicolors
" [[ Basic Keymaps ]]
" Keymaps for better default experience
nnoremap <silent> <Space> <Nop>
xnoremap <silent> <Space> <Nop>
" Remap for dealing with word wrap
nnoremap <expr> <silent> k v:count == 0 ? 'gk' : 'k'
nnoremap <expr> <silent> j v:count == 0 ? 'gj' : 'j'
" [[ Configure plugins ]]
" Set colorscheme
colorscheme onehalflight
" Characters to render for indentation guide
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
" [[ Configure vim-which-key ]]
call which_key#register('<Space>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey '<Space>'<CR>
" document key chains
let g:which_key_map = {}
let g:which_key_map.c = { 'name' : '[C]ode' }
let g:which_key_map.d = { 'name' : '[D]ocument' }
let g:which_key_map.g = { 'name' : '[G]it' }
" See `:help gitgutter-mappings`
let g:which_key_map.h = {
\ 'name' : 'More git',
\ 'p' : 'Preview git hunk',
\}
let g:which_key_map.r = { 'name' : '[R]ename' }
let g:which_key_map.s = { 'name' : '[S]earch' }
let g:which_key_map.w = { 'name' : '[W]orkspace' }
" [[ Configure fzf.vim ]]
" See `:help fzf-vim`
nmap <leader>? :History<CR>
let g:which_key_map['?'] = '[?] Find recently opened files'
nmap <leader><space> :Buffers<CR>
let g:which_key_map[' '] = '[ ] Find existing buffers'
nmap <leader>/ :BLines<CR>
let g:which_key_map['/'] = '[/] Fuzzily search in current buffer'
nmap <leader>gf :GFiles<CR>
let g:which_key_map.g.f = 'Search [G]it [F]iles'
nmap <leader>sf :Files<CR>
let g:which_key_map.s.f = '[S]earch [F]iles'
nmap <leader>sh :Helptags<CR>
let g:which_key_map.s.h = '[S]earch [H]elp'
" [[ Configure completion ]]
" Set Omni Completion
" See `:help compl-omni` and `:help omnifunc`
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" Enter key confirms the current selection when completion is open
inoremap <expr> <CR> pumvisible() ? '<C-y>' : '<CR>'
" <Tab> triggers Omni completion (<C-x><C-o>) in a coding context
let g:SuperTabDefaultCompletionType = "context"
" [[ Configure LSP ]]
" NOTE: Install new language server using `:LspInstallServer` in the filetype
" you are trying to install LSP for.
" For example, if you want LSP server for C/C++, type
" `:LspInstallServer clangd` in a C/C++ buffer.
" Performance related settings, requires Vim 8.2+
let g:lsp_use_native_client = 1
let g:lsp_semantic_enabled = 0
let g:lsp_format_sync_timeout = 1000
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
" Keymaps
" Go to previous diagnostic message
nmap <buffer> [d <plug>(lsp-previous-diagnostic)
" Go to next diagnostic message
nmap <buffer> ]d <plug>(lsp-next-diagnostic)
nmap <buffer> <leader>rn <plug>(lsp-rename)
let g:which_key_map.r.n = '[R]e[n]ame'
nmap <buffer> <leader>ca <plug>(lsp-code-action-float)
let g:which_key_map.c.a = '[C]ode [A]ction'
" [G]oto [D]efinition
nmap <buffer> gd <plug>(lsp-definition)
" [G]oto [R]eferences
nmap <buffer> gr <plug>(lsp-references)
" [G]oto [I]mplementation
nmap <buffer> gI <plug>(lsp-implementation)
nmap <buffer> <leader>D <plug>(lsp-peek-type-definition)
let g:which_key_map.D = 'Type [D]efinition'
nmap <buffer> <leader>ds <plug>(lsp-document-symbol-search)
let g:which_key_map.d.s = '[D]ocument [S]ymbols'
nmap <buffer> <leader>ws <plug>(lsp-workspace-symbol-search)
let g:which_key_map.w.s = '[W]orkspace [S]ymbols'
" See `:help K` for why this keymap
" Hover Documentation
nmap <buffer> K <plug>(lsp-hover)
" Signature Documentation
nmap <buffer> <C-k> <plug>(lsp-signature-help)
" Lesser used LSP functionality
" [G]oto [D]eclaration
nmap <buffer> gD <plug>(lsp-declaration)
" Create a command `:Format` local to the LSP buffer
command Format LspDocumentFormatSync
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
" Adding my own stuff below
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
set nobackup
set nowritebackup
set noswapfile
" The line beneath this is called `modeline`. See `:help modeline`
" vim: ts=2 sts=2 sw=2 et