Skip to content

Instantly share code, notes, and snippets.

@ldelelis

ldelelis/init.vim

Last active Nov 9, 2020
Embed
What would you like to do?
" Configure the editor itself
set background=dark
set title
set ignorecase
set smartcase
set wrap
set autoindent
set copyindent
set smartindent
set number
set relativenumber
set noswapfile
set noshowmode
set equalalways
set lazyredraw
set splitbelow
" This is only necessary if you use "set termguicolors".
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" fixes glitch? in colors when using vim with tmux
set t_Co=256
" set termguicolors
syntax on
filetype on
filetype plugin on
filetype plugin indent on
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType c setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType cpp setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType javascript setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType typescript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType Jenkinsfile setlocal ts=4 sts=4 sw=4 expandtab
au BufNewFile,BufRead /*.rasi setf css
au BufNewFile,BufRead *.nix set ft=nix
autocmd FileType python let b:coc_root_patterns = ['manage.py']
autocmd BufNewFile,BufRead *.py
\ setlocal tabstop=4 |
\ setlocal softtabstop=4 |
\ setlocal shiftwidth=4 |
\ setlocal textwidth=99 |
\ setlocal expandtab |
\ set fileformat=unix
autocmd FileType sh
\ setlocal tabstop=4 |
\ setlocal softtabstop=4 |
\ setlocal shiftwidth=4 |
\ setlocal expandtab
" Trim trailing whitespace on save
autocmd BufWritePre * %s/\s\+$//e
" Automatically enter insert mode on terminals
autocmd BufEnter term://* startinsert
" Load plugins
call plug#begin()
Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'taigacute/gruvbox9'
Plug 'chriskempson/base16-vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'hashivim/vim-terraform', { 'for': 'terraform' }
Plug 'Shougo/deoplete.nvim', { 'for': 'go', 'do': ':UpdateRemotePlugins' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'tpope/vim-surround'
Plug 'Yggdroot/indentLine'
Plug 'Raimondi/delimitMate'
Plug 'yuttie/comfortable-motion.vim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'mgedmin/python-imports.vim', { 'for': 'python' }
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
Plug 'MaxMEllon/vim-jsx-pretty', { 'for': 'javascript' }
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'martinda/Jenkinsfile-vim-syntax'
Plug 'SirVer/ultisnips'
Plug 'vim-scripts/indentpython.vim'
Plug 'liuchengxu/graphviz.vim'
Plug 'LnL7/vim-nix'
Plug 'elixir-editors/vim-elixir', { 'for': 'elixir' }
call plug#end()
" Set up keybinds
let mapleader = "\<Space>"
let maplocalleader = ","
inoremap jk <esc>
nnoremap H gT
nnoremap L gt
" Disable ex mode
nnoremap Q <nop>
" Handy disable highlight bind
nnoremap <silent> <F12> :noh<CR>
" Open a small terminal
nnoremap <silent> <leader>` :10sp term://zsh<CR>
" Improve pane naviation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Navigate between wrapped lines
noremap <silent> k gk
noremap <silent> j gj
noremap <silent> 0 g0
noremap <silent> $ g$
" Search visual mode selection
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
" Inline encode/decode base64
vnoremap <silent> <Leader>be y:let @"=system('base64 -w0', @")<CR>gvP
vnoremap <silent> <Leader>bd y:let @"=system('base64 --decode', @")<CR>gvP
" DEFX
map <silent> <leader>e :Defx -show-ignored-files<CR>
call defx#custom#option('_', {
\ 'columns': 'indent:git:icons:filename',
\ 'winwidth': 28,
\ 'split': 'vertical',
\ 'direction': 'topleft',
\ 'show_ignored_files': 0,
\ })
autocmd WinEnter * if &ft == 'defx' && winnr('$') == 1 | q | endif
autocmd TabLeave * if &ft == 'defx' | wincmd w | endif
autocmd FileType defx do WinEnter | call s:defx_my_settings()
function! s:defx_my_settings() abort
nnoremap <silent><buffer><expr> q defx#do_action('quit')
nnoremap <silent><buffer><expr> <CR> defx#do_action('drop')
nnoremap <silent><buffer><expr> N defx#do_action('new_multiple_files')
nnoremap <silent><buffer><expr> o defx#do_action('new_directory')
nnoremap <silent><buffer><expr><nowait> m defx#do_action('move')
nnoremap <silent><buffer><expr><nowait> p defx#do_action('paste')
nnoremap <silent><buffer><expr> l <sid>defx_toggle_tree()
nnoremap <silent><buffer><expr> h defx#do_action('cd', ['..'])
endfunction
function! s:defx_toggle_tree() abort
if defx#is_directory()
return defx#do_action('open_or_close_tree')
endif
return defx#do_action('drop')
endfunction
" AIRLINE
let g:airline_theme='bubblegum'
let g:airline_powerline_fonts=0
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
" HASHIVIM
let g:terraform_align = 1
let g:terraform_fmt_on_save = 1
" INDENTLINE
let g:indentLine_enabled = 1
let g:indentLine_char = ''
" DELIMITMATE
let g:delimitMate_expand_cr = 2
" FZF
"" Open fuzzy tag finder
nnoremap <silent> <C-t> :Tags<CR>
"" Open fuzzy file searching similar to vscode
nnoremap <silent> <C-p> :Files<CR>
"" Floating window
let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
function! FloatingFZF()
let buf = nvim_create_buf(v:false, v:true)
call setbufvar(buf, '&signcolumn', 'no')
let height = &lines - 45
let width = float2nr(&columns - (&columns * 2 / 4))
let col = float2nr((&columns - width) / 2)
let opts = {
\ 'relative': 'editor',
\ 'row': 1,
\ 'col': col,
\ 'width': width,
\ 'height': height
\ }
call nvim_open_win(buf, v:true, opts)
endfunction
nmap <leader>1 <Plug>BuffetSwitch(1)
nmap <leader>2 <Plug>BuffetSwitch(2)
nmap <leader>3 <Plug>BuffetSwitch(3)
nmap <leader>4 <Plug>BuffetSwitch(4)
nmap <leader>5 <Plug>BuffetSwitch(5)
nmap <leader>6 <Plug>BuffetSwitch(6)
nmap <leader>7 <Plug>BuffetSwitch(7)
nmap <leader>8 <Plug>BuffetSwitch(8)
nmap <leader>9 <Plug>BuffetSwitch(9)
nmap <leader>0 <Plug>BuffetSwitch(10)
" SNIPPETS
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<C-d>"
let g:UltiSnipsJumpBackwardTrigger = "<C-u>"
" GRAPHVIZ
nnoremap <silent> <localleader><localleader> :silent Graphviz! png<CR> <BAR> :silent !rm %:r.png<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment