-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
206 lines (160 loc) · 7.88 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
" ▄█ █▄ ▄█ ▄▄▄▄███▄▄▄▄
" ███ ███ ███ ▄██▀▀▀███▀▀▀██▄
" ███ ███ ███▌ ███ ███ ███
" ███ ███ ███▌ ███ ███ ███
" ███ ███ ███▌ ███ ███ ███
" ███ ███ ███ ███ ███ ███
" ███ ███ ███ ███ ███ ███
" ▀██████▀ █▀ ▀█ ███ █▀
" ==================================================================================================
" General settings
" ==================================================================================================
" base
set nocompatible " vim, not vi
syntax on " syntax highlighting
filetype plugin indent on " try to recognise filetype and load plugins and indent files
" set true colors and add vim specific fixes
set termguicolors
" set t_8f=[38;2;%lu;%lu;%lum
" set t_8b=[48;2;%lu;%lu;%lum
" interface
set background=dark " tell vim what the background color looks like
set colorcolumn=100 " show a column at 100 chars
set cursorline " highlight current line
set noshowmode " don't show mode
set ruler " show current position at bottom
set scrolloff=5 " keep at least 5 lines above/below
set shortmess+=aAIsT " disable welcome screen and other messages
set showcmd " show any commands
set sidescroll=1 " smoother horizontal scrolling
set sidescrolloff=5 " keep at least 5 lines left/right
set splitbelow " create new splits below
set splitright " create new splits to the right
set wildmenu " enable wildmenu
set wildmode=longest:full,full " configure wildmenu
set nohidden " close buffers instead of hiding them
set number " show line number
" whitespace
set nojoinspaces " use one space, not two, after punctuation
set shiftround " shift to next tabstop
set shiftwidth=4 " amount of space used for indentation
set softtabstop=4 " appearance of tabs
set tabstop=4 " use two spaces for tabs
" folding
set nofoldenable " disable folds
" text appearance
set list " show invisible characters
set synmaxcol=200 " stop syntax highlighting after 200 columns
set listchars=tab:>·,trail:·,nbsp:¬ " but only show useful chaaracters
set nowrap " disable line wrapping
" interaction
set backspace=2 " make backspace work like most other apps
set mouse=a " enable mouse support
set mousehide " hide the mouse cursor while typing
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap too
set backspace=indent,eol,start
" searching
set hlsearch " highlight search matches
set ignorecase " set case insensitive searching
set incsearch " find as you type search
set smartcase " case sensitive searching when not all lowercase
" background processes
set autoread " update file when changed outside of vim
set autoindent " copy indentation from the previous line for new line
set clipboard+=unnamed " use native clipboard
set history=200 " store last 200 commands as history
set nobackup " don't save backups
set noerrorbells " no error bells please
set noswapfile " no swapfiles
set nowritebackup " don't save a backup while editing
set lazyredraw " see if this fixes the slowness
set ttyfast " indicates a fast terminal connection
set undodir=~/.vim/undodir " set undofile location
set undofile " maintain undo history between sessions
set undolevels=1000 " store 1000 undos
" character encoding
if !&readonly && &modifiable
set fileencoding=utf-8 " the encoding written to file
endif
set encoding=utf-8 " the encoding displayed
" ==================================================================================================
" Change cursor shape based on mode
" ==================================================================================================
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
" ==================================================================================================
" Keys
" ==================================================================================================
" set leader to ;
let mapleader=";"
let g:mapleader=";"
let g:polyglot_disabled=['css']
" adjust window size with arrow keys
noremap <right> <C-w>5>
noremap <left> <C-w>5<
noremap <up> <C-w>5+
noremap <down> <C-w>5-
" keep selection after indent
vnoremap < <gv
vnoremap > >gv
" sort
vnoremap <leader>s :sort<CR>
" recalculate syntax highlighting
nnoremap <leader>s :syntax sync fromstart<CR>
" reload vim config
nnoremap <leader>r :source $MYVIMRC<CR>
" clear search
nnoremap <leader>c :let @/ = ""<CR>
" select all
nnoremap <leader>a ggVG<CR>
" copy all
nnoremap <leader>y ggVGy<CR>
" upper or lowercase the current word
nnoremap <leader>^ gUiW
nnoremap <leader>v guiW
" cycle through changelist
nnoremap <leader>- g;
nnoremap <leader>= g,
" cycle through jumplist
nnoremap <leader>, <C-o>
nnoremap <leader>. <C-i>
" cycle through quickfix list
noremap <leader>[ :cprev<CR>
noremap <leader>] :cnext<CR>
" ==================================================================================================
" Autocommands
" ==================================================================================================
augroup vimrcEx
autocmd!
" disable comment continuation
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" hide hidden characters in nerdtree buffer
autocmd FileType nerdtree setlocal nolist
augroup END
" ==================================================================================================
" Searching
" ==================================================================================================
if executable('ag')
" use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" define Ag command
command! -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
" bind \ to grep shortcut
nnoremap \ :Ag<SPACE>
endif
" ==================================================================================================
" Load plugins
" ==================================================================================================
source $HOME/.vimrc.plugins.vim
" ==================================================================================================
" Load configs
" ==================================================================================================
source $HOME/.vimrc.config-theme.vim
source $HOME/.vimrc.config-plugins.vim
" ==================================================================================================
" Load statusline
" ==================================================================================================
source $HOME/.vimrc.statusline.vim
highlight Comment cterm=italic
colorscheme dracula