Skip to content

Instantly share code, notes, and snippets.

@fdidron
Last active December 24, 2020 08:39
Show Gist options
  • Save fdidron/7436b62220a137cec8f8f633b40dac88 to your computer and use it in GitHub Desktop.
Save fdidron/7436b62220a137cec8f8f633b40dac88 to your computer and use it in GitHub Desktop.
Init vim
" Space as leader key
let mapleader = " "
" Sensible defaults
set nocompatible
set autoread
" Swap directory
set directory=$HOME/.vim/swp/
" Undo directory
set undodir=$HOME/.vim/undo/
" No arrows
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" Window management
nnoremap <silent> <Leader>- :sp<CR>
nnoremap <silent> <Leader>\ :vsp<CR>
nnoremap <Leader>j <C-W><C-J>
nnoremap <Leader>k <C-W><C-K>
nnoremap <Leader>l <C-W><C-L>
nnoremap <Leader>h <C-W><C-H>
nnoremap <silent> <Leader>d :Vifm<CR>
nnoremap <silent> <Leader>a :Startify<CR>
nnoremap <Leader>f :Files<CR>
nnoremap <Leader>b :Buffers<CR>
nmap <Leader>i <Plug>(Prettier)
map <Leader> <Plug>(easymotion-prefix)
" Alt Tab
nnoremap <Leader><Tab> <C-^>
" Blank chars rendering
set list listchars=tab:\ \ ,trail:·
" Indentation
filetype plugin indent on
set expandtab
set tabstop=2
set shiftwidth=2
" Line numbers
set number
" Hidden buffers
set hidden
"--- VimPlug
call plug#begin()
" UI / Styles
Plug 'danilamihailov/beacon.nvim'
Plug 'chrisbra/Colorizer'
Plug 'psliwka/vim-smoothie'
Plug 'chuling/ci_dark'
Plug 'vim-airline/vim-airline'
" File Navigation
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'airblade/vim-rooter'
Plug 'mhinz/vim-startify'
Plug 'ryanoasis/vim-devicons'
Plug 'vifm/vifm.vim'
" Task runners
Plug 'w0rp/ale'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'neomake/neomake'
Plug 'coddingtonbear/neomake-platformio'
" Search
Plug 'easymotion/vim-easymotion'
" Git
Plug 'tpope/vim-fugitive'
" Languages
Plug 'sheerun/vim-polyglot'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Autocomplete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'mattn/emmet-vim'
call plug#end()
" Autocomplete
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" UI / Color scheme
colorscheme ci_dark
let g:airline_theme = 'ci_dark'
set background=dark
syntax enable
set termguicolors
set wildmenu
set mouse=a
set cursorline
" Prettier
let g:prettier#autoformat_require_pragma = 0
" Autocommands
if has("autocmd")
" Automatically clean trailing whitespace
autocmd BufWritePre * :%s/\s\+$//e
autocmd FileType go setlocal shiftwidth=4 tabstop=4
augroup autoindent
au!
autocmd BufWritePre *.rb,*.go :normal migg=G`i
augroup End
endif
let g:localvimrc_sandbox = 0
" Update session automatically as you exit vim
let g:startify_session_persistence = 1
let g:startify_bookmarks = [
\ '~/dev/zsa/oryx-frontend',
\ '~/dev/zsa/oryx-backend',
\ '~/dev/zsa/qmk_zsa',
\ '~/dev/zsa/yardstick',
\ '~/dev/zsa/zsa_io_store',
\ '~/dev/memdev',
\ '~/dev/go/src/github.com/zsa/wally',
\ '~/.config/nvim/init.vim',
\ ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment