-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
170 lines (148 loc) · 3.61 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
" general options
filetype plugin indent on
syntax on
set encoding=utf-8
set termencoding=utf-8
set fileencodings=ucs-bom,utf-8,default,shift-jis,latin1
set fileformat=unix
set undofile
set undodir=~/.vim/undo
set noswapfile
set backspace=indent,eol,start
let mapleader=" "
set autochdir
set wildmenu
set wildignore=*.pyc,*.jpg,*.gif,*.png
set autoread
set hidden
set laststatus=2
set nojoinspaces
" timeout on keybindings can be low
set ttimeout
set ttimeoutlen=50
set mouse=n
" graphical options
set background=dark
set termguicolors
set scrolloff=5
set showmode
set showcmd
set ttyfast
set number
set relativenumber
set noruler
set lazyredraw
set list
set listchars=tab:▸\ ,trail:←,nbsp:¬
" search options
set incsearch
set hlsearch
set showmatch
set smartcase
set ignorecase
set wrapscan
set gdefault
set matchtime=3
set magic
" tab options
set autoindent
set smartindent
set smarttab
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
nnoremap <up> <c-y>
nnoremap <down> <c-e>
nnoremap <silent> <left> :bprev<cr>
nnoremap <silent> <right> :bnext<cr>
nnoremap <silent> ZZ :xa<cr>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
inoremap <f1> <esc>
nnoremap <f1> <esc>
vnoremap <f1> <esc>
" ex mode is useless, map it to something useful
map Q @q
nnoremap Y y$
nnoremap U <c-r>
nmap S i<cr><esc>d^==kg_lD
" leader shortcuts
nmap <silent> <leader>h :noh<cr>
nmap <leader>ev :edit ~/.vimrc<cr>
nmap <leader>ez :edit ~/.zshrc<cr>
nmap <leader>w :w<cr>
nmap <leader><leader> V
nmap <silent> <leader>s :set spell!<cr>
nmap <silent> <leader>l :set nu!<cr>:set rnu!<cr>:set list!<cr>:set signcolumn=no<cr>
nmap <silent> <leader>u :UndotreeToggle<cr>
" fast system clipboard pastes
vmap <cs-C> "+y
vmap <leader>y "+y
vmap <leader>d "+d
vmap <leader>p "+p
vmap <leader>P "+P
nmap <leader>p "+p
nmap <leader>P "+P
nmap <leader>Y "+Y
nmap <leader>yy "+yy
nmap <leader>dd "+dd
" Find files using Telescope command-line sugar.
nnoremap <leader>f <cmd>Telescope find_files<cr>
nnoremap <leader>g <cmd>Telescope live_grep<cr>
nnoremap <C-p> <cmd>Telescope git_files<cr>
nnoremap <leader>ds <cmd>Gdiff<cr>
nnoremap <leader>gc <cmd>Git commit --quiet<cr>
nnoremap <leader>gp <cmd>Git push --quiet<cr>
nnoremap <leader>gb <cmd>.GBrowse<cr>
" autocmds
augroup reloadvimrc
au!
au BufWritePost .vimrc source $MYVIMRC
au BufWritePost vimrc source $MYVIMRC
au BufWritePost init.vim source $MYVIMRC
au BufWritePost init.nvim source $MYVIMRC
augroup END
augroup notmpundos
au!
au BufReadPre /tmp/* set noundofile
" sudo -e makes random file names in /var/tmp, tracking undo state is useless
au BufReadPre /var/tmp/* set noundofile
" pass edits files in /dev/shm
au BufReadPre /dev/shm/* set noundofile
augroup END
" bypass annoying "X files left to read" warning by rewriting :q to :qa
:au QuitPre * qa
" change xterm cursor style depending on mode
" insert mode, blinking thin line cursor
let &t_SI = "\e[5 q"
" normal mode, block cursor
let &t_EI = "\e[2 q"
function! IsWSL()
if has("linux")
let lines = readfile("/proc/version")
if lines[0] =~ "Microsoft"
return 1
endif
endif
endfunction
if IsWSL()
let g:netrw_browsex_viewer = "firefox.exe"
endif
" gui settings
if has('gui_running')
set guicursor+=a:blinkon0 " cursor doesn't blink
" remove menu bar, toolbar and scrollbar (in order)
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions-=l
set guioptions-=L
set guifont=Liberation\ Mono\ for\ Powerline\ 11
set cursorline
endif
if has("nvim")
lua require('plugins')
endif