guest@dotshare [~/groups/vim/rc] $ ls my-initvim/ | cat

my init.vim (raw, dl)

idm Jan 30, 2021 (vim/rc)
  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
" Tab size
set expandtab
set tabstop=4
" Line Numbering
set number
" Show command bar
set showcmd
" Cursor line Highlight (commented until I think it could be useful
" set cursorline
" Autocomplete menu
set wildmenu
"lazy redraw; <i>fast</i> macros
set lazyredraw
" highlight matching brackets; i.e. (bruh)
set showmatch
" search stuff
set incsearch
set hlsearch

"Code folding + keybind
set foldenable
set foldlevelstart=10
nnoremap <space> za

" fold based on indentation if filetype python
autocmd Filetype python set foldmethod=indent

" Navigate visually
nnoremap j gj
nnoremap k gk

" Keybindings
"
" New Tab
nnoremap <Space>tn :tabe<CR>
" Navigate Tabs
nnoremap <Space>tl :tabn<CR> 
nnoremap <Space>th :tabp<CR> 
" Close Tabs
nnoremap <Space>tc :q<CR>
"
" New window
nnoremap <Space>wn :vertical new<CR>
" Navigate windows
nnoremap <Space>wk <C-w>k
nnoremap <Space>wj <C-w>j
nnoremap <Space>wh <C-w>h
nnoremap <Space>wl <C-w>l
"Close window
nnoremap <Space>wc :q<CR>
"
" Open Defx
nnoremap <Space>ff :Defx `escape(expand('%:p:h'), ' :')` -search=`expand('%:p')`<CR>
"
" keycombo to remove highlight as soon as pressed enter
nnoremap <silent> <Space><Return> :nohlsearch<CR>
"
" Enforce muscle memory from emacs
nnoremap <M-x> :

" Make splits *better*
cabbrev split vsplit
cabbrev h vertical help
cabbrev hsplit split
cabbrev sta vertical sta
cabbrev help vertical help
cabbrev new vertical new
" A more heavyweight solution for ^W^]
function! ToggleSplit (dir)
  let currFname = bufname ("%")
  let old = winnr ()
  " Window navigation to ensure the correct window is 'last'.
  if (a:dir == "u")
    wincmd k
    let back="j"
  elseif (a:dir == "d")
    wincmd j
    let back="k"
  elseif (a:dir == "l")
    wincmd h
    let back="l"
  elseif (a:dir == "r")
    wincmd l
    let back="h"
  endif
  if (winnr () == old)
    echo "Ouch"
    return
  endif
  exec "wincmd " . back
  quit
  if (back == "j" || back == "k")
    let orientation = "vsplit"
  else
    let orientation = "split"
  endif
  if (back == "j" || back == "l")
    let dir = "below"
  else
    let dir = "above"
  endif
  exec dir . " " . orientation " " . currFname
endfunction
noremap ^W^] ^W^]:silent call ToggleSplit ("d")<CR>

" Plugins & dein
if &compatible
		set nocompatible
endif
" add the dein installation dir into runtimepath
set runtimepath+=~/.local/share/dein/repos/github.com/Shougo/dein.vim

if dein#load_state('~/.local/share/dein')
		call dein#begin('~/.local/share/dein')

		" Plugins
        "
        " Dein itself
		call dein#add('~/.local/share/dein/repos/github.com/Shougo/dein.vim')
        " Some of Shougo's 'Dark' plugins (Generally work best with neovim)
		call dein#add('Shougo/deoplete.nvim')
		call dein#add('Shougo/denite.nvim')
		call dein#add('Shougo/defx.nvim')
		call dein#add('Shougo/deol.nvim')
		call dein#add('Shougo/deorise.nvim')
        " Statusbar
		call dein#add('vim-airline/vim-airline')
		call dein#add('vim-airline/vim-airline-themes')
        " Themes
		call dein#add('cocopon/iceberg.vim')
        " Utilities
        call dein#add('tpope/vim-fugitive')
        call dein#add('w0rp/ale')
        " Syntax
        call dein#add('lervag/vimtex')
        call dein#add('dag/vim-fish')

		" Plugins specific to Vim8 (For compatibility reasons)
		if !has('nvim')
				call dein#add('roxma/nvim-yarp')
				call dein#add('roxma/vim-hug-neovim-rpc')
		endif

		call dein#end()
		call dein#save_state()
endif

" Defx
"
" Icons
" Directory icons
"call defx#custom#column('icon', {
"						\ 'directory': '',
"						\ 'opened_icon': '',
"						\ 'root_icon': ''
"						\ })
"" Filename length
"call defx#custom#column('filename', {
"						\ 'min_width': 40,
"						\ 'max_width': 40
"						\ })
"" Readonly icon (& others?)
"call defx#custom#column('mark', {
"						\ 'readonly_icon': '',
"						\ 'selected_icon': ''
"						\ })
""
"" Keybindings
""
"" Navigation
"nnoremap 
""
"" Functions
autocmd FileType defx call s:defx_my_settings()
function! s:defx_my_settings() abort
        " Define mappings
        nnoremap <silent><buffer><expr> <CR>
        \ defx#do_action('open')
        nnoremap <silent><buffer><expr> c
        \ defx#do_action('copy')
        nnoremap <silent><buffer><expr> m
        \ defx#do_action('move')
        nnoremap <silent><buffer><expr> p
        \ defx#do_action('paste')
        nnoremap <silent><buffer><expr> l
        \ defx#do_action('open')
        nnoremap <silent><buffer><expr> E
        \ defx#do_action('open', 'vsplit')
        nnoremap <silent><buffer><expr> P
        \ defx#do_action('preview')
        nnoremap <silent><buffer><expr> o
        \ defx#do_action('open_tree', 'toggle')
        nnoremap <silent><buffer><expr> K
        \ defx#do_action('new_directory')
        nnoremap <silent><buffer><expr> N
        \ defx#do_action('new_file')
        nnoremap <silent><buffer><expr> M
        \ defx#do_action('new_multiple_files')
        nnoremap <silent><buffer><expr> C
        \ defx#do_action('toggle_columns',
        \                'mark:indent:icon:filename:type:size:time')
        nnoremap <silent><buffer><expr> S
        \ defx#do_action('toggle_sort', 'time')
        nnoremap <silent><buffer><expr> d
        \ defx#do_action('remove')
        nnoremap <silent><buffer><expr> r
        \ defx#do_action('rename')
        nnoremap <silent><buffer><expr> !
        \ defx#do_action('execute_command')
        nnoremap <silent><buffer><expr> x
        \ defx#do_action('execute_system')
        nnoremap <silent><buffer><expr> yy
        \ defx#do_action('yank_path')
        nnoremap <silent><buffer><expr> .
        \ defx#do_action('toggle_ignored_files')
        nnoremap <silent><buffer><expr> ;
        \ defx#do_action('repeat')
        nnoremap <silent><buffer><expr> h
        \ defx#do_action('cd', ['..'])
        nnoremap <silent><buffer><expr> ~
        \ defx#do_action('cd')
        nnoremap <silent><buffer><expr> q
        \ defx#do_action('quit')
        nnoremap <silent><buffer><expr> <Space>
        \ defx#do_action('toggle_select') . 'j'
        nnoremap <silent><buffer><expr> *
        \ defx#do_action('toggle_select_all')
        nnoremap <silent><buffer><expr> j
        \ line('.') == line('$') ? 'gg' : 'j'
        nnoremap <silent><buffer><expr> k
        \ line('.') == 1 ? 'G' : 'k'
        nnoremap <silent><buffer><expr> <C-l>
        \ defx#do_action('redraw')
        nnoremap <silent><buffer><expr> <C-g>
        \ defx#do_action('print')
        nnoremap <silent><buffer><expr> cd
        \ defx#do_action('change_vim_cwd')
endfunction

" Denite
"
" TODO: make some kind of helm-like keybinding (or something) for Denite that
" shows the available keybindings after starting a keychain.
" Keybindings
nnoremap <silent><Space>bi :Denite buffer<CR>
nnoremap <silent><Space>. :DeniteBufferDir file<CR>
nnoremap <silent><Space>fr :Denite file/old<CR>
nnoremap <silent><Space>ht :Denite colorscheme<CR>

" Theme
colorscheme iceberg
"
" Airline
let g:airline_theme = 'iceberg'
let g:airline_powerline_fonts = 1

syntax on
filetype plugin indent on

CLICK TO VIEW

x

Notes

Requirements

  • dein
  • and the dependencies of the plugins included