" 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; fast 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 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 tn :tabe
" Navigate Tabs
nnoremap tl :tabn
nnoremap th :tabp
" Close Tabs
nnoremap tc :q
"
" New window
nnoremap wn :vertical new
" Navigate windows
nnoremap wk k
nnoremap wj j
nnoremap wh h
nnoremap wl l
"Close window
nnoremap wc :q
"
" Open Defx
nnoremap ff :Defx `escape(expand('%:p:h'), ' :')` -search=`expand('%:p')`
"
" keycombo to remove highlight as soon as pressed enter
nnoremap :nohlsearch
"
" Enforce muscle memory from emacs
nnoremap :
" 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")
" 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
\ defx#do_action('open')
nnoremap c
\ defx#do_action('copy')
nnoremap m
\ defx#do_action('move')
nnoremap p
\ defx#do_action('paste')
nnoremap l
\ defx#do_action('open')
nnoremap E
\ defx#do_action('open', 'vsplit')
nnoremap P
\ defx#do_action('preview')
nnoremap o
\ defx#do_action('open_tree', 'toggle')
nnoremap K
\ defx#do_action('new_directory')
nnoremap N
\ defx#do_action('new_file')
nnoremap M
\ defx#do_action('new_multiple_files')
nnoremap C
\ defx#do_action('toggle_columns',
\ 'mark:indent:icon:filename:type:size:time')
nnoremap S
\ defx#do_action('toggle_sort', 'time')
nnoremap d
\ defx#do_action('remove')
nnoremap r
\ defx#do_action('rename')
nnoremap !
\ defx#do_action('execute_command')
nnoremap x
\ defx#do_action('execute_system')
nnoremap yy
\ defx#do_action('yank_path')
nnoremap .
\ defx#do_action('toggle_ignored_files')
nnoremap ;
\ defx#do_action('repeat')
nnoremap h
\ defx#do_action('cd', ['..'])
nnoremap ~
\ defx#do_action('cd')
nnoremap q
\ defx#do_action('quit')
nnoremap
\ defx#do_action('toggle_select') . 'j'
nnoremap *
\ defx#do_action('toggle_select_all')
nnoremap j
\ line('.') == line('$') ? 'gg' : 'j'
nnoremap k
\ line('.') == 1 ? 'G' : 'k'
nnoremap
\ defx#do_action('redraw')
nnoremap
\ defx#do_action('print')
nnoremap 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 bi :Denite buffer
nnoremap . :DeniteBufferDir file
nnoremap fr :Denite file/old
nnoremap ht :Denite colorscheme
" Theme
colorscheme iceberg
"
" Airline
let g:airline_theme = 'iceberg'
let g:airline_powerline_fonts = 1
syntax on
filetype plugin indent on