-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
241 lines (195 loc) · 6.19 KB
/
vimrc
File metadata and controls
241 lines (195 loc) · 6.19 KB
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
" °|██╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╰═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Copy to clipboard
set clipboard+=unnamedplus
" Add line numbers
set number
" Highlight cursor horizontally
set cursorline
" Set shift width to 2
set shiftwidth=2
" Set tab width to 2
set tabstop=2
" Use space characters instead of tabs
set expandtab
" Do not save backup files
set nobackup
" Do not wrap lines
set nowrap
" Highlight search matches as you type
set incsearch
" Show matching words during a search
set showmatch
" Use highlighting when doing a search
set hlsearch
" Ignore capital letters during search
set ignorecase
" Override the ignorecase option if searching for capital letters
set smartcase
" Show partial command you type in the last line of the screen
set showcmd
" Don't show mode in command line (shown in statusline instead)
set noshowmode
" Set command history
set history=1000
" More natural split with vsp and sp
set splitbelow
set splitright
" Auto save when switching buffers
:set autowriteall
:au FocusLost * silent! wa
" When insetting comments, align them to the left
let g:NERDDefaultAlign = 'left'
" PLUGINS ---------------------------------------------------------------- {{{
" ALE linting settings
let g:ale_linters = {
\ 'json': ['jq'],
\ 'javascript': ['eslint'],
\ 'javascriptreact': ['eslint'],
\ 'typescript': ['eslint'],
\ 'typescriptreact': ['eslint'],
\}
let g:ale_json_jq_executable = 'jq'
let g:ale_json_jq_options = '.'
let g:ale_fixers = {
\ 'javascript': ['prettier', 'eslint'],
\ 'javascriptreact': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'eslint'],
\ 'typescriptreact': ['prettier', 'eslint'],
\ 'css': ['prettier'],
\ 'json': ['prettier'],
\ 'yaml': ['prettier'],
\ 'markdown': ['prettier'],
\ 'html': ['prettier'],
\}
" Auto fix on save
let g:ale_fix_on_save = 1
" vim-go: let ALE handle linting and formatting
let g:go_fmt_autosave = 0
let g:go_diagnostics_enabled = 0
let g:go_metalinter_enabled = []
" Install Plug if it's not already
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
call plug#begin('~/.vim/plugged')
" Linting while you type
Plug 'dense-analysis/ale'
" Better syntax highlighting
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" Auto close/rename JSX and HTML tags
Plug 'windwp/nvim-ts-autotag'
" Lua functions and required for telescoep.nvim to work
Plug 'nvim-lua/plenary.nvim'
" Fuzzy finder
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-live-grep-args.nvim'
" Nvim tree with icons
Plug 'nvim-tree/nvim-web-devicons' " for file icons
Plug 'nvim-tree/nvim-tree.lua'
" Jump to any part of the file
Plug 'smoka7/hop.nvim'
" Go plugin
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Mason, portalbe package manager for NVIM
Plug 'williamboman/mason.nvim'
" Mason Nvim Dap bridge
Plug 'mfussenegger/nvim-dap'
Plug 'jay-babu/mason-nvim-dap.nvim'
" Nice debugging UI
Plug 'rcarriga/nvim-dap-ui'
" Notify, a nice tool to send notifications in Nvim
Plug 'rcarriga/nvim-notify'
" NERD Comment
Plug 'preservim/nerdcommenter'
" Copilot
Plug 'github/copilot.vim'
" Color
Plug 'folke/tokyonight.nvim'
Plug 'rebelot/kanagawa.nvim'
" Neotest
Plug 'nvim-neotest/nvim-nio'
Plug 'nvim-neotest/neotest'
" Neotest-jest
Plug 'nvim-neotest/neotest-jest'
" Which-key for keymap discovery
Plug 'folke/which-key.nvim'
" Auto-completion
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
" Snippet engine (required by nvim-cmp)
Plug 'L3MON4D3/LuaSnip'
Plug 'saadparwaiz1/cmp_luasnip'
" LSP config
Plug 'neovim/nvim-lspconfig'
call plug#end()
" }}}
" MAPPINGS --------------------------------------------------------------- {{{
" Set comma as the leader key.
let mapleader = ","
" Split mapping
nnoremap <leader>sv <cmd>vsp<cr>
nnoremap <leader>sh <cmd>sp<cr>
" Panel navigation mappings
nnoremap <leader>j <C-W><C-J>
nnoremap <leader>k <C-W><C-K>
nnoremap <leader>l <C-W><C-L>
nnoremap <leader>h <C-W><C-H>
" Type jj quickly to exit insert mode
inoremap jj <Esc>
" Pres the space bare to type the : character in command mode
nnoremap <space> :
" Center the cursor vertically when moving to the next word during search
nnoremap n nzz
nnoremap N Nzz
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
" nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fr <cmd>Telescope resume<cr>
" Nvim tree mappings
nnoremap <leader>tt :NvimTreeToggle<CR>
nnoremap <leader>r :NvimTreeRefresh<CR>
nnoremap <leader>n :NvimTreeFindFile<CR>
" Terminal
nnoremap <leader>tm :terminal<CR>
:tnoremap <Esc> <C-\><C-n>
" Hop mappings
nnoremap <leader>ja :HopAnywhere<CR>
nnoremap <leader>jw :HopWord<CR>
" Buffer mappings
nnoremap <leader>bk :bp\|bd! #<CR>
nnoremap <leader>bh :hide<CR>
" Tabs
nnoremap <leader>tc :tabnew<CR>
nnoremap <leader>tn :tabnext<CR>
nnoremap <leader>tp :tabprev<CR>
" }}}
" ALE Linting
nnoremap <leader>en :ALENextWrap<CR>zz
nnoremap <leader>ep :ALEPreviousWrap<CR>zz
nnoremap <leader>ed :ALEDetail<CR>
" ALE code
nnoremap <leader>cr :ALEFindReferences -relative<CR>
nnoremap <leader>cd :ALEGoToDefinition<CR>
nnoremap <leader>cv :ALEGoToDefinition -vsplit<CR>
nnoremap <leader>ch :ALEGoToDefinition -split<CR>
nnoremap <leader>ct :ALEGoToTypeDefinition<CR>
nnoremap <leader>fn :let @+ = expand('%:t')<CR>
"Remove all trailing whitespace by pressing F5
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" VIMSCRIPT -------------------------------------------------------------- {{{
" This will enable code folding.
" Use the marker method of folding.
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}