Last active
April 17, 2019 14:20
-
-
Save kiyui/44cbe439736de6897867 to your computer and use it in GitHub Desktop.
neovim configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" File: `~/.config/nvim/init.vim` | |
filetype off | |
" Required for Python on MacOS | |
" | |
" brew install python | |
" brew install python3 | |
" pip2 install neovim --upgrade | |
" pip3 install neovim --upgrade | |
" | |
" brew install neovim/neovim/neovim | |
let g:python2_host_prog = '/usr/bin/python' | |
let g:python3_host_prog = '/usr/bin/python3' | |
" SECTION DEIN | |
" https://github.com/Shougo/dein.vim | |
" Installed to ~/.config/nvim/bundle | |
if &compatible | |
set nocompatible " Be iMproved | |
endif | |
" Required: | |
let dein_path = $HOME . '/.config/nvim/bundle' | |
set runtimepath+=~/.config/nvim/./bundle/repos/github.com/Shougo/dein.vim | |
" Required: | |
if dein#load_state(dein_path) | |
call dein#begin(dein_path) | |
" Let dein manage dein | |
" Required: | |
call dein#add(dein_path) | |
" Add or remove your plugins here: | |
call dein#add('Shougo/neosnippet.vim') | |
call dein#add('Shougo/neosnippet-snippets') | |
call dein#add('Shougo/deoplete.nvim') | |
call dein#add('scrooloose/nerdtree') " NERD Tree file browser | |
call dein#add('Xuyuanp/nerdtree-git-plugin') " Git support in NERD Tree | |
call dein#add('vim-airline/vim-airline') " Status bar | |
call dein#add('vim-airline/vim-airline-themes') " Status bar themes | |
call dein#add('tpope/vim-surround') " Vim bracket/parentheses wrapping | |
call dein#add('tpope/vim-repeat') " Make . powerful! | |
call dein#add('morhetz/gruvbox') " gruvbox theme | |
call dein#add('cloudhead/neovim-fuzzy') " Fuzzy search with fzy | |
call dein#add('numkil/ag.nvim') " the_silver_searcher | |
call dein#add('tpope/vim-fugitive') " Git stuff | |
call dein#add('airblade/vim-gitgutter') " Git annotations | |
call dein#add('Valloric/MatchTagAlways') " HTML tag highlight and jumping | |
call dein#add('w0rp/ale') " Asynchronous Lint Engine | |
call dein#add('luochen1990/rainbow') " Flower power | |
call dein#add('sheerun/vim-polyglot') " Syntax support | |
call dein#add('mhartington/nvim-typescript', {'build': './install.sh'}) | |
call dein#add('reasonml-editor/vim-reason-plus') " Reason | |
" Required: | |
call dein#end() | |
call dein#save_state() | |
endif | |
" Required: | |
filetype plugin indent on | |
syntax on | |
" Automatically install new plugins | |
if dein#check_install() | |
call dein#install() | |
endif | |
" ENDSECTION DEIN | |
" Theming options | |
set background=dark | |
color gruvbox | |
let g:airline_theme='dark' | |
" Settings | |
set nowrap | |
set number | |
set clipboard=unnamedplus | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab " Insert spaces | |
set mouse=a " Mouse mode | |
set autoread | |
" section: Functions { | |
function NERDTreeToggleInCurDir() | |
" Stolen from https://github.com/scrooloose/nerdtree/issues/480 | |
if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1) | |
exe ":NERDTreeClose" | |
else | |
if (expand("%:t") != '') | |
exe ":NERDTreeFind" | |
else | |
exe ":NERDTreeToggle" | |
endif | |
endif | |
endfunction | |
" Set filetype based on name of a template file that follows the syntax: | |
" $name.$format.template | |
" | |
" name: file name | |
function SetTemplateType(name) | |
let l:extensions = split(a:name, "\\.") | |
let l:template_type = l:extensions[len(l:extensions) - 2] | |
let &filetype = l:template_type | |
endfunction | |
function JSOptions() | |
" Additional word matching | |
set isk+=- | |
set isk+=$ | |
endfunction | |
function VueOptions() | |
syntax sync fromstart | |
endfunction | |
function SetFourSpaces() | |
setlocal tabstop=4 shiftwidth=4 softtabstop=4 | |
endfunction | |
" endsection: Functions } | |
" section: autocmd { | |
autocmd FileType javascript call JSOptions() | |
autocmd FileType typescript call JSOptions() | |
autocmd FileType vue call VueOptions() | |
autocmd FileType sh call SetFourSpaces() | |
autocmd FileType python call SetFourSpaces() | |
" Filetype aliases | |
autocmd FileType yml set ft=yaml | |
autocmd FileType ts set ft=typescript | |
autocmd FileType js set ft=javascript | |
" Close vim if NERDTree is the only open buffer | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" Set file type for template files | |
autocmd bufenter *.template call SetTemplateType(expand( '%:t' )) | |
" endsection: autocmd } | |
" # Remaps & shortcuts | |
" Ctrl + S to search | |
nnoremap <C-s> :Ag <Space> | |
" Ctrl + T to open a new tab | |
nnoremap <C-t> :tabnew <Enter> | |
" Ctrl + ] to switch to next tab | |
nnoremap <C-]> :tabnext<CR> | |
" Ctrl + [ to switch to previous tab | |
nnoremap <C-[> :tabprevious<CR> | |
" Ctrl + E to open file-search pane | |
nnoremap <C-e> :call NERDTreeToggleInCurDir() <Enter> | |
" Ctrl + X to close a window | |
nnoremap <C-x> :q <Enter> | |
" Open terminal | |
nnoremap <C-M-t> :terminal <Enter> | |
" When you're literally like wtf is this code | |
nnoremap ` :Gblame <Enter> | |
" # Split Controls | |
" Ctrl + Left to move to split left | |
nnoremap <C-h> <C-W>h | |
nnoremap <C-Left> <C-W>h | |
" Ctrl + Down to move to split below | |
nnoremap <C-j> <C-W>j | |
nnoremap <C-Down> <C-W>j | |
" Ctrl + Up to move to split above | |
nnoremap <C-k> <C-W>k | |
nnoremap <C-Up> <C-W>k | |
" Ctrl + Right to move to split right | |
nnoremap <C-l> <C-W>l | |
nnoremap <C-Right> <C-W>l | |
" Change split size | |
nnoremap sh :vertical resize -5 <Enter> | |
nnoremap sl :vertical resize +5 <Enter> | |
" # Moving Around | |
" Disable shift jumping for people with RSI | |
" map <S-j> j | |
nnoremap <S-k> k | |
nnoremap <S-Down> j | |
nnoremap <S-Up> k | |
" Easy word Jumping | |
nnoremap <S-h> B | |
nnoremap <S-l> W | |
nnoremap <S-Left> B | |
nnoremap <S-Right> W | |
" Easily jump to first word | |
nnoremap <Space> ^ | |
" Make % jump to closing tag | |
runtime macros/matchit.vim | |
" # Paste Powers | |
" nnoremap i :put<CR> | |
" nnoremap I :put!<CR> | |
" # Move lines up and down | |
nnoremap - ddkP | |
nnoremap _ ddp | |
" # Searching | |
" Double click to highlight word | |
nnoremap <2-LeftMouse> * | |
" Double / in visual mode searches selection | |
vmap // y/<C-R>"<CR> | |
nnoremap <C-p> :FuzzyOpen<CR> | |
nnoremap <C-i> :FuzzyGrep<Space> | |
" # Insert Mode Remaps | |
" In insert mode jj is Esc | |
imap jj <Esc> | |
" For when Churchill uses my Vim | |
imap jk <Esc> | |
" ALE Errors | |
nnoremap <silent> <C-k> <Plug>(ale_previous_wrap) | |
nnoremap <silent> <C-j> <Plug>(ale_next_wrap) | |
" Tab completion | |
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
" Plugin key-mappings. | |
" Note: It must be "imap" and "smap". It uses <Plug> mappings. | |
imap <C-k> <Plug>(neosnippet_expand_or_jump) | |
smap <C-k> <Plug>(neosnippet_expand_or_jump) | |
xmap <C-k> <Plug>(neosnippet_expand_target) | |
" SuperTab like snippets behavior. | |
" Note: It must be "imap" and "smap". It uses <Plug> mappings. | |
"imap <expr><TAB> | |
" \ pumvisible() ? "\<C-n>" : | |
" \ neosnippet#expandable_or_jumpable() ? | |
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" | |
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? | |
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" | |
" Set background transparent | |
hi Normal ctermbg=none | |
" Shougo/deoplete.nvim | |
let g:deoplete#enable_at_startup = 1 | |
" vim-airline/vim-airline | |
let g:airline_powerline_fonts = 1 | |
" numkil/ag.nvim | |
let g:ag_working_path_mode="r" | |
" Valloric/MatchTagAlways | |
let g:mta_filetypes = { | |
\'xml' : 1, | |
\'vue' : 1, | |
\'html' : 1, | |
\'xhtml' : 1, | |
\'eruby' : 1, | |
\'javascript.jsx' : 1} | |
" w0rp/ale | |
let g:ale_completion_enabled = 0 | |
let g:ale_linters = { | |
\'sh': ['shellcheck'], | |
\'javascript': ['eslint'], | |
\'typescript': ['tslint', 'tsserver'], | |
\'vue': ['eslint'], | |
\'python': ['flake8'], | |
\'xml': ['xmllint'], | |
\'svg': ['xmllint'], | |
\'json': ['prettier'], | |
\'html': ['eslint', 'prettier']} | |
let g:ale_fixers = { | |
\'sh': ['shellcheck'], | |
\'javascript': ['eslint'], | |
\'typescript': ['tslint'], | |
\'vue': ['eslint'], | |
\'python': ['autopep8'], | |
\'xml': ['xmllint'], | |
\'svg': ['xmllint'], | |
\'json': ['prettier'], | |
\'html': ['prettier']} | |
" luochen1990/rainbow | |
let g:rainbow_active = 1 | |
" pangloss/vim-javascript | |
let g:javascript_plugin_jsdoc = 1 | |
" mxw/vim-jsx | |
let g:jsx_ext_required = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment