Skip to content

Instantly share code, notes, and snippets.

@g-dormoy
Created February 23, 2019 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g-dormoy/b596b13a7678cc260ff97ef78b4662e6 to your computer and use it in GitHub Desktop.
Save g-dormoy/b596b13a7678cc260ff97ef78b4662e6 to your computer and use it in GitHub Desktop.
.config/nvim/init.vim
" Specift a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" ====================
" | Language support |
" ====================
Plug 'sheerun/vim-polyglot' " Multilanguage
Plug 'posva/vim-vue' " VueJs
Plug 'leafgarland/typescript-vim' " Typescript
Plug 'pangloss/vim-javascript' " Javascript
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " Golang
" ==========================
" | File system navigation |
" ==========================
Plug 'scrooloose/nerdtree' " NerdTree
Plug 'Xuyuanp/nerdtree-git-plugin' " Git Plugin
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " fuzzyfinder
" =========
" | Theme |
" =========
Plug 'rakr/vim-one' " One
Plug 'mhartington/oceanic-next' " Oceanic
Plug 'vim-airline/vim-airline' " Airline
" ==========
" | TagBar |
" ==========
Plug 'majutsushi/tagbar' " Tagbar
Plug 'ludovicchabant/vim-gutentags' " Tag File Generation
" ================
" | Autocomplete |
" ================
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " Deoplete
" ========
" | Misc |
" ========
Plug 'powerman/vim-plugin-AnsiEsc' " Documentation lookup
call plug#end()
filetype plugin indent on
" =========
" | Theme |
" =========
if (has("termguicolors"))
set termguicolors
endif
" Theme
syntax enable
colorscheme one
set background=dark
let g:airline_theme='one'
let g:one_allow_italics = 1
" air-line
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" airline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
" Make comment on italic
highlight Comment cterm=italic
" ===============
" | Text editor |
" ===============
let mapleader = "," " Leader configuration
set tabstop=2 " Show existing tab with 2 spaces width
set shiftwidth=2 " When indenting with '>', uses 2 spaces width
set expandtab " On pressing tab, insert 2 spaces
set nu " Display line numbers
set autowrite " Autowrite on :make
set nobackup noswapfile " Disable backup files
set encoding=utf-8 " Encoding
set hlsearch " Highlight search results
set incsearch " Incremental search, search as you type
set ignorecase " Ignore case when searching
set smartcase " Ignore case when searching lowercase
set cursorline " Highlight cursor line
set cursorcolumn " Highlight cursor column
set title " Set the title of the iterm tab
" Stop highlighting on Enter
map <CR> :noh<CR>
" =========
" | Ctags |
" =========
let g:gutentags_cache_dir = '~/.tags_cache'
" Build ctags on save
au BufWritePost *.go silent! !ctags -R --exclude=.git --exclude=log &
au BufWritePost *.php silent! !ctags -R --exclude=.git --exclude=log &
au BufWritePost *.yml silent! !ctags -R --exclude=node_modules --exclude=.git --exclude=log &
au BufWritePost *.js silent! !ctags -R --exclude=node_modules --exclude=.git --exclude=log &
au BufWritePost *.ts silent! !ctags -R --exclude=node_modules --exclude=.git --exclude=log &
au BufWritePost *.vue silent! !ctags -R --exclude=node_modules --exclude=.git --exclude=log &
" ============
" | Terminal |
" ============
" split the screen verticaly and open a new term
nmap <leader>vt :vsplit term://zsh<CR>
" escape the insert mode on escape
:tnoremap <Esc> <C-\><C-n>
" ==========
" | GoLang |
" ==========
let g:go_fmt_command = "goimports" " Auto imports
" Error navigation
map <C-n> :cnext<CR>
map <C-m> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
"run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
" Synthaxe highlight for go
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
" Metalinter support
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
let g:go_metalinter_autosave = 1
" ============
" | NERDTREE |
" ============
" Open at startup
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
autocmd VimEnter * wincmd w
" Open NERDTree on crtl-n
map <C-n> :NERDTreeToggle<CR>
" Close NerdTree if the only windows left is nerdtree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" ============
" | Deoplete |
" ============
let g:deoplete#enable_at_startup = 1 " start deoplete.
" ==========
" | TagBar |
" ==========
" Open at startup
autocmd vimenter * Tagbar
" Open on f4
nmap <F4> :TagbarToggle<CR>
" ===============
" | FUZZYFINDER |
" ===============
" bind fuzzy finder
map <C-f> :FZF<CR>
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" =======
" | TAB |
" =======
" bind tab control
" Open new tab
map <C-t> :tab split<CR>
map <C-l> :+tabnext<CR>
map <C-h> :-tabnext<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment