-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·272 lines (222 loc) · 6.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
"*****************************************************************************
"" Vim-Plug core
"*****************************************************************************
"
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
let curl_exists=expand('curl')
if !filereadable(vimplug_exists)
if !executable(curl_exists)
echoerr "Install Curl you doughnut."
execute "q!"
endif
echo "Installing Vim-Plug..."
echo ""
silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
let g:not_finish_vimplug = "yes"
autocmd VimEnter * PlugInstall
endif
if !isdirectory($HOME."/.vim/undo-dir")
call mkdir($HOME."/.vim/undo-dir", "", 0700)
endif
call plug#begin(expand('~/.vim/plugged'))
"*****************************************************************************
"" Plug install packages
"*****************************************************************************
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-sleuth'
Plug 'itchyny/lightline.vim'
Plug 'Raimondi/delimitMate'
Plug 'Yggdroot/indentLine'
Plug 'statox/FYT.vim'
Plug 'roxma/vim-tmux-clipboard'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
Plug 'cocopon/iceberg.vim', { 'as': 'iceberg' }
Plug 'christoomey/vim-tmux-navigator'
call plug#end()
" Required:
filetype plugin indent on
"*****************************************************************************
"" Basic Setup
"*****************************************************************************"
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
syntax on
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set ttyfast
set undodir=~/.vim/undo-dir
set undofile
set backspace=indent,eol,start
set lazyredraw
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
set hidden
set hlsearch
set incsearch
set ignorecase
set smartcase
set ruler
set relativenumber
set number
set wildmenu
set gcr=a:blinkon0
set scrolloff=3
set cul
set laststatus=2
set showtabline=2
set guioptions-=e
set showmatch
set matchtime=3
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set mouse=a
set mousemodel=popup
set t_Co=256
set shortmess+=I
set cursorline
set splitbelow
" change cursor in insert mode
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = ''
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
if &term =~ '256color'
set t_ut=
endif
let no_buffers_menu=1
if has('termguicolors')
set termguicolors
endif
set background=dark
let g:lightline = {'colorscheme': 'iceberg'}
colorscheme iceberg
highlight LineNr term=bold cterm=NONE ctermbg=NONE gui=NONE guibg=NONE
let g:FYT_flash_time = 200
"*****************************************************************************
"" Commands
"*****************************************************************************
" remove blank lines
command Nobl :g/^\s*$/d
" remove trailing white space
command Nows :%s/\s\+$//
" make current buffer executable
command Chmodx :!chmod a+x %
"*****************************************************************************
"" Functions
"*****************************************************************************
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=79
endfunction
endif
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"" Copy/Paste/Cut
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
"" Copy over ssh
function! Osc52Yank()
let buffer=system('base64 -w0', @0)
let buffer=substitute(buffer, "\n$", "", "")
let buffer='\e]52;c;'.buffer.'\x07'
silent exe "!echo -ne ".shellescape(buffer)." > ".shellescape("/dev/tty")
endfunction
command! Osc52CopyYank call Osc52Yank()
augroup Example
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call Osc52Yank() | endif
augroup END
augroup CloseHelpWithQ
autocmd!
autocmd FileType help nnoremap <buffer> q :close<CR>
augroup END
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
set autoread
"*****************************************************************************
"" Mappings
"*****************************************************************************
nnoremap <SPACE> <Nop>
let mapleader=' '
" search will center on line
nnoremap n nzzzv
nnoremap N Nzzzv
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>
"" Git
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Git commit --verbose<CR>
noremap <Leader>gsh :Git push<CR>
noremap <Leader>gll :Git pull<CR>
noremap <Leader>gs :Git<CR>
noremap <Leader>gb :Git blame<CR>
noremap <Leader>gd :Gvdiffsplit<CR>
noremap <Leader>gr :GRemove<CR>
"" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>
"" Opens an edit command with the path of the currently edited file filled in
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
noremap <Leader>xx :Chmodx<CR>
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
" noremap p "_dP<CR>
"" Buffer nav
noremap <c-n> :bn<cr>
noremap <c-p> :bp<cr>
noremap <c-x> :bd<cr>
noremap <Tab> :b#<CR>
"" map <leader>o & <leader>O to newline without insert mode
noremap <silent> <leader>o :<C-u>call append(line("."), repeat([""], v:count1))<CR>
noremap <silent> <leader>O :<C-u>call append(line(".")-1, repeat([""], v:count1))<CR>
"" Clean search (highlight)
nnoremap <silent> <Esc><Esc> :noh<cr>
"" Switching windows
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv