-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
336 lines (270 loc) · 10.8 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
"
" =====================================================================
" ======== .-----. ========
" ======== .----------------------. | === | ========
" ======== |.-""""""""""""""""""-.| |-----| ========
" ======== || || | === | ========
" ======== || KICKSTART.VIM || |-----| ========
" ======== || || | === | ========
" ======== || || |-----| ========
" ======== ||:Tutor || |:::::| ========
" ======== |'-..................-'| |____o| ========
" ======== `"")----------------(""` ___________ ========
" ======== /::::::::::| |::::::::::\ \ no mouse \ ========
" ======== /:::========| |==hjkl==:::\ \ required \ ========
" ======== '""""""""""""' '""""""""""""' '""""""""""' ========
" ======== ========
" =====================================================================
"
" Kickstart.vim is a starting point for your Vim configuration,
" heavily inspired by Kickstart.nvim.
"
" If you are using Neovim, you should use Kickstart.nvim instead:
" https://github.com/nvim-lua/kickstart.nvim
" (use `gx` keybinding to open the link)
"
" If you have any question while reading the .vimrc,
" you should use Vim's built-in help, triggered by `:help X`.
" We also provide a keymap "<space>sh" [s]earch [h]elp documentation.
"
" Set <space> as the leader key
" See `:help mapleader`
let mapleader=' '
let maplocalleader = ' '
" [[ Setting Neovim default options ]]
" These are some of the options enabled by default in Neovim
" These are options believed by many Vim users to be essential.
" For more information, see `:h vim_diff.txt` in Neovim
" I will skip the
filetype on
syntax on
set autoindent autoread background=dark
set backspace=indent,eol,start belloff=all
set display=lastline encoding=utf-8 hidden
set history=10000 hlsearch incsearch
set nojoinspaces laststatus=2 ruler
set showcmd smarttab nostartofline
set switchbuf=uselast wildmenu "wildoptions=pum,tagfile
" [[ Settings other options ]]
" See `:help :set`
" NOTE: You can change these options as you wish!
" For more options, you can see `:help option-list`
" Make line numbers default
set number
" You can also add relative line numbers, to help with jumping.
" Experiment for yourself to see if you like it!
"set relativenumber
" Enable mouse mode, can be useful for resizing splits for example!
set mouse=a
" Don't show the mode, since it's already in the status line
set noshowmode
" Sync clipboard between OS and Neovim.
" Remove this option if you want your OS clipboard to remain independent.
" See `:help 'clipboard'`
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//
"set 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
" Decrease mapped sequence wait time
" Displays vim-which-key sooner
set timeoutlen=300
" Configure how new splits should be opened
set splitright
set splitbelow
" Sets how vim will display certain whitespace characters in the editor.
set list
set listchars=tab:»\ ,trail:·,nbsp:␣
" Use the following settings if you do not want unicode characters
"set listchars=tab:>\ ,trail:-,nbsp:+
" Show which line your cursor is on
set cursorline
" Minimal number of screen lines to keep above and below the cursor
set scrolloff=10
" [[ Basic Keymaps ]]
" Set highlight on search, but clear on pressing <Esc> in normal mode
set hlsearch
nnoremap <Esc> :nohlsearch<CR>
" Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
" for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
" is not what someone will guess without a bit more experience.
"
" NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
" or just use <C-\><C-n> to exit terminal mode
tnoremap <Esc><Esc> <C-\><C-n>
" Remap for dealing with word wrap
nnoremap <expr> <silent> k v:count == 0 ? 'gk' : 'k'
nnoremap <expr> <silent> j v:count == 0 ? 'gj' : 'j'
" TIP: Disable arrow keys in normal mode
nnoremap <left> :echo "Use h to move!!"<CR>
nnoremap <right> :echo "Use l to move!!"<CR>
nnoremap <up> :echo "Use k to move!!"<CR>
nnoremap <down> :echo "Use j to move!!"<CR>
" Keybinds to make split navigation easier.
" Use CTRL+<hjkl> to switch between windows
"
" See `:help wincmd` for a list of all window commands
nnoremap <C-h> <C-w><C-h>
nnoremap <C-l> <C-w><C-l>
nnoremap <C-j> <C-w><C-j>
nnoremap <C-k> <C-w><C-k>
" [[ Install `vim-plug` plugin manager ]]
" See https://github.com/junegunn/vim-plug/ for more info
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
" [[ Install plugins ]]
" To check the current status of your plugins, run
" :PlugStatus
"
" To update plugins you can run
" :PlugUpdate
"
" Note: Here is where you install your plugins.
call plug#begin()
" Detect tabstop and shiftwidth automatically
Plug 'tpope/vim-sleuth'
" "gc" to comment visual regions/lines
Plug 'tpope/vim-commentary'
" Adds git related signs to the gutter
Plug 'airblade/vim-gitgutter'
" Useful plugin to show you pending keybinds.
Plug 'liuchengxu/vim-which-key'
" Fuzzy Finder
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Enable LSP
Plug 'prabirshrestha/vim-lsp'
" Install language servers and configure them for vim-lsp
Plug 'mattn/vim-lsp-settings'
" Autocompletion
"Plug 'prabirshrestha/asyncomplete.vim'
" Use <Tab> to auto complete
Plug 'ervandew/supertab'
" Colorscheme
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
Plug 'ghifarit53/tokyonight-vim'
" Set airline as statusline
Plug 'vim-airline/vim-airline'
call plug#end()
" [[ Configure plugins ]]
" Set colorscheme
set termguicolors
" Tokyonight colorscheme
" let g:tokyonight_style = 'storm' " available: night, storm
" let g:tokyonight_enable_italic = 0
" colorscheme tokyonight
"Catppuccin colorscheme
let g:catppuccin_flavour = "mocha" " latte, frappe, macchiato, mocha
colorscheme catppuccin_mocha
" [[ 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 existing 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.r = { 'name' : '[R]ename' }
let g:which_key_map.s = { 'name' : '[S]earch' }
let g:which_key_map.f = { 'name' : '[S]earch' }
let g:which_key_map.w = { 'name' : '[W]orkspace' }
let g:which_key_map.t = { 'name' : '[T]oggle' }
let g:which_key_map.h = { 'name' : 'Git [H]unk' }
" [[ Configure fzf.vim ]]
" See `:help fzf-vim`
nmap <leader>fh :Helptags<CR>
let g:which_key_map.f.h = '[S]earch [H]elp'
nmap <leader>fk :Maps<CR>
let g:which_key_map.f.k = '[S]earch [K]eymaps'
nmap <leader>ff :Files<CR>
let g:which_key_map.f.f = '[S]earch [F]iles'
nmap <leader>fg :Rg<CR>
let g:which_key_map.f.g = '[S]earch by [G]rep'
nmap <leader>f. :History<CR>
let g:which_key_map.f['.'] = '[S]earch Recent Files ("." for repeat)'
nmap <leader><leader> :Buffers<CR>
let g:which_key_map[' '] = '[ ] Find existing buffers'
nmap <leader>/ :BLines<CR>
let g:which_key_map['/'] = '[/] Fuzzily search in current buffer'
" [[ 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
" [[ 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"
" The line beneath this is called `modeline`. See `:help modeline`
" vim: ts=2 sts=2 sw=2 et