-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
207 lines (157 loc) · 5.5 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
" ==========================================================================================
" Neovim Config File von Awesome
" ==========================================================================================
" -----------------------------------------------------------
" Colors/Color Schemes
" -----------------------------------------------------------
set termguicolors
let g:codedark_conservative = 1
colorscheme codedark
" Set indent character for indent-blankline.nvim plugin
let g:indent_blankline_char = "⦙"
" Syntax Highlighting
syntax on
" Search Path
set path+=**
" Ignore tags file in searches like vimgrep
set wildignore+=tags
" Set Leader Key
let mapleader = " "
nnoremap <space> <nop>
" Browse Window Properties
let g:netrw_preview = 1
let g:netrw_banner = 0
let g:netrw_liststyle = 0
let g:netrw_browse_split = 4
" netrw Tweak until the fix for the bug at adds a phantom <space> to
" the minus (-) key gets merged up stream: https://stackoverflow.com/a/58409216
nmap - <Plug>NetrwBrowseUpDir
" Buffer Settings
set hidden
" Automatically change to the directory of the open file
" set autochdir
" Sign Column Settings
set signcolumn=yes
" Show Line Number settings
"set number norelativenumber "Setting absolute line numbers
set number relativenumber "Setting relative line numbers
" Show line under cursor
set cursorline
" Tab Options
set tabstop=2 softtabstop=2
set shiftwidth=2
set expandtab
set smartindent
" Search Options
" set nohlsearch
set ignorecase
set smartcase "If your search has an upper case character in it, then search will be case sensitive, else case insensitive
set inccommand=nosplit "Show substitutions incrementally
" File History Settings
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
" Scrolling Options
set scrolloff=10 "Start scrolling the screen up or down when the cursor is 10 rows from the top or bottom
" Window Options
set splitbelow "Put horizontally split new windows below
" ----------------------------------------------------------
" Custom Key Bindings
" ----------------------------------------------------------
" Quick reload of init.vim file
nnoremap <Leader><CR> :so ~/.config/nvim/init.vim<CR>
" Navigate between windows easier
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader><tab> <c-^>
" Move lines or blocks of lines at once
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Shortcut for :noh
nnoremap <leader>nh :noh<CR>
" Open tree view for current file directory
nnoremap <leader>tv :wincmd v<bar> Ex <bar> vertical resize 35<CR>
nnoremap <leader>th :wincmd s<bar> Ex <bar> resize 25<CR>
" Return to Normal mode whilst in Insert mode using the Terminal
tnoremap <Esc> <C-\><C-n>
" Still need to be able to send <Esc> whilst using Terminal
tnoremap <A-[> <Esc>
" I keep typing Q
nnoremap Q <nop>
" Generate Graphviz custom key binding (TODO: How do I detect a dot file, and
" only allow this to run against a dot file?)
nnoremap <leader>ggv :w<CR>:!dot -T png % -o %:r.png<CR>
nnoremap <leader>vgv :!display %:r.png &<CR>
" Copy & Paste to/from system clipboard
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap <leader>Y gg"+yG
nnoremap <leader>p "+p
vnoremap <leader>p "+p
" Copy relative path
nnoremap <leader>cf :let @+=expand("%")<CR>
" Copy absolute path
nnoremap <leader>cF :let @+=expand("%:p")<CR>
" Window Controls
nnoremap <A-Up> :vert resize +4<CR>
nnoremap <A-Down> :vert resize -4<CR>
nnoremap <C-Up> :resize +4<CR>
nnoremap <C-Down> :resize -4<CR>
" Spell Check
nnoremap <leader>ss :set spell<CR>
nnoremap <leader>sns :set nospell<CR>
" Find next spelling mistake
nnoremap <leader>sl ]s
" Find previous spelling mistake
nnoremap <leader>sh [s
" z= - Replace misspelled word
" zg - Good word: Add the word under the cursor to the dictionary
" zw - Woops! Undo and remove the word from the dictionary
" Word Wrap
set nowrap
nnoremap <leader>snw :set nowrap<CR>
nnoremap <leader>sw :set wrap<CR>
" Quickfix List Navigation
nnoremap <C-j> :cnext<CR>
nnoremap <C-k> :cprev<CR>
" -----------------------------------------------------------
" Status Bar
" -----------------------------------------------------------
" Left Side
set statusline=
set statusline+=\ %M
set statusline+=\ %y
set statusline+=\ %r
set statusline+=\ %F
" Right side
set statusline+=%=
set statusline+=\ %c:%l/%L
set statusline+=\ %p%%
set statusline+=\ [%n]
" -----------------------------------------------------------
" Markdown Composer Options
" -----------------------------------------------------------
let g:markdown_composer_autostart = 0
" -----------------------------------------------------------
" Telescope
" -----------------------------------------------------------
" Find files using Telescope
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>
" -----------------------------------------------------------
" Magical Auto Commands
" -----------------------------------------------------------
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
augroup VON_AWESOME
autocmd!
autocmd BufWritePre * :call TrimWhitespace()
augroup END