-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
296 lines (246 loc) · 6.89 KB
/
init.vim
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
set encoding=utf8
set nocompatible
set nu
set nobackup
set nocursorline
set nocursorcolumn
set nowritebackup
set noswapfile
set hlsearch
set ruler
set laststatus=2
set tabstop=2
set shiftwidth=2
set scrolljump=5
set expandtab
set hidden
set lazyredraw
set ttyfast
set cursorline!
setlocal autoindent
setlocal cindent
setlocal smartindent
" Disable syntax higlighting after 128 columns
set synmaxcol=128
syntax sync minlines=256
" Plugins
call plug#begin('~/.vim/plugged')
" Tools
Plug 'nvim-tree/nvim-web-devicons'
Plug 'nvim-tree/nvim-tree.lua'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rhubarb'
Plug 'raghur/fruzzy'
Plug 'tomtom/tcomment_vim'
Plug 'mileszs/ack.vim'
Plug 'benmills/vimux'
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzy-native.nvim'
Plug 'ojroques/vim-oscyank'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" Github tool
Plug 'mattn/webapi-vim'
Plug 'mattn/gist-vim'
" HTML
Plug 'othree/html5.vim'
" Colorscheme and UI
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
" Go
Plug 'fatih/vim-go'
" GraphQL
Plug 'jparise/vim-graphql'
" LSP Support
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
" Autocompletion
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'saadparwaiz1/cmp_luasnip'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-nvim-lua'
" Snippets
Plug 'L3MON4D3/LuaSnip'
Plug 'rafamadriz/friendly-snippets'
Plug 'VonHeikemen/lsp-zero.nvim'
" Autocomplete
function! DoRemote(arg)
UpdateRemotePlugins
endfunction
call plug#end()
if (has("termguicolors"))
set termguicolors
endif
syntax enable
let g:tokyonight_style = "storm"
colorscheme tokyonight
highlight Comment cterm=italic gui=italic
" Set up leader key to <,>
let mapleader = ","
" Hide bookmarks and help text
let g:NERDTreeMinimalUI = 1
" Map Keys for Managing Buffers
map <C-J> :bnext<CR>
map <C-K> :bprev<CR>
map <C-L> :tabn<CR>
map <C-H> :tabp<CR>
" Map CTRL+S to save file
map <C-s> :w<cr>
imap <C-s> <ESC>:w<cr>a
" Map CTRL+Q to close buffer
map <C-q> :bp\|bd #<cr>
imap <C-q> <ESC>:bd #<cr>
" Create new buffer
nnoremap <leader>B :enew<cr>
" Close all buffers
nnoremap <leader>ba :bufdo bd!<cr>
" Map semicolon to colon
map ; :
" Key mapping for tab
map <C-t> <esc>:tabnew<CR>
" Key mapping for window management
map <C-x> <C-w>c
map <Leader>w <C-w>w
" Edit Vimrc
command! Vimrc :vs $MYVIMRC
" Enable jsx syntax
let g:jsx_ext_required = 0
" Highlight ruby code when the line is more than 80 characters
augroup vimrc_autocmds
autocmd BufEnter *.rb highlight OverLength ctermbg=red ctermfg=white guibg=#592929
autocmd BufEnter *.rb match OverLength /\%81v.\+/
augroup END
" Clean trailing whitespace
nnoremap <leader>ww mz:%s/\s\+$//<cr>:let @/=''<cr>`z
" Prettify JSON
nnoremap <leader>pp :%!python -m json.tool<cr>
" Enable 256 color support in tmux <http://superuser.com/questions/399296/256-color-support-for-vim-background-in-tmux>
set t_ut=
" OSCYank
noremap <Leader>y :OSCYank<CR>
let g:oscyank_max_length = 1000000
" Gist
let g:gist_post_private = 1
" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LSP
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
lua << EOF
local lsp = require('lsp-zero')
lsp.preset('recommended')
lsp.ensure_installed({
'tsserver',
'solargraph',
})
lsp.setup()
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vimux
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Run current test file inside tmux pane
nnoremap <leader>r :call VimuxRunCommand("bundle exec rspec " . bufname("%"))<CR>
nnoremap <leader>rf :call VimuxRunCommand("bundle exec rspec " . bufname("%") . " --tag focus")<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NvimTree
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>n :NvimTreeToggle<cr>
nmap <leader>nf :NvimTreeFindFile<CR>
lua <<EOF
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
adaptive_size = true,
mappings = {
list = {
{ key = "u", action = "dir_up" },
},
},
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Treesitter
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
lua <<EOF
require'nvim-treesitter.configs'.setup {
indent = {
enable = true
}
}
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Telescope
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
lua << EOF
require('telescope').load_extension('fzy_native')
local actions = require('telescope.actions')
require('telescope').setup{
defaults = {
file_sorter = require('telescope.sorters').get_fzy_sorter,
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<esc>"] = actions.close,
["<c-d>"] = actions.delete_buffer,
},
n = {
["<esc>"] = actions.close,
},
},
extensions = {
fzy_native = {
override_generic_sorter = false,
override_file_sorter = true,
}
},
file_ignore_patterns = {"doc/.*", "docs/.*"}
}
}
EOF
nnoremap <C-p> :lua require('telescope.builtin').find_files()<CR>
nnoremap <leader>s <cmd>lua require('telescope.builtin').buffers()<cr>
nnoremap <leader>g <cmd>lua require('telescope.builtin').git_status()<cr>
nnoremap <leader>f <cmd>lua require('telescope.builtin').treesitter()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ack
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if executable('rg')
" Use rg over grep
set grepprg=rg\ --nogroup\ --nocolor
let g:ackprg = 'rg --vimgrep -g "!doc/*" -g "!docs/*"'
endif
" bind K to grep word under cursor
nnoremap K :Ack! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
command! -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ack<SPACE>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Go
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" run goimports on save
let g:go_fmt_command = "goimports"
" Speed up syntax highlighting
" https://vim.fandom.com/wiki/Speed_up_Syntax_Highlighting
augroup vimrc
autocmd!
autocmd BufWinEnter,Syntax * syn sync minlines=500 maxlines=500
augroup END