Skip to content

Instantly share code, notes, and snippets.

@timgremore
Created November 20, 2017 14:22
Show Gist options
  • Save timgremore/b465dfb0fb08021f115e7d589b2956c3 to your computer and use it in GitHub Desktop.
Save timgremore/b465dfb0fb08021f115e7d589b2956c3 to your computer and use it in GitHub Desktop.
neovim config
if &compatible
set nocompatible
endif
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
if dein#load_state(expand('~/.cache'))
call dein#begin(expand('~/.cache'))
call dein#add(expand('~/.cache'))
" call dein#add('Shougo/deoplete.nvim') " Auto-completion
call dein#add('ElmCast/elm-vim') " Elm
call dein#add('w0rp/ale') " Linter
call dein#add('vim-airline/vim-airline') " Status line
call dein#add('kassio/neoterm') " Neovim terminals
call dein#add('janko-m/vim-test') " Test runner
call dein#add('tpope/vim-projectionist')
" Elixir and Phoenix
" call dein#add('slashmili/alchemist.vim') " Elixir
call dein#add('elixir-editors/vim-elixir') " Elixir
call dein#add('c-brenn/phoenix.vim') " Phoenix
call dein#add('junegunn/fzf') " Fuzzy finder
call dein#add('iCyMind/NeoSolarized') " Color scheme
" Git
call dein#add('airblade/vim-gitgutter')
call dein#add('tpope/vim-fugitive')
call dein#add('scrooloose/nerdtree')
" Ruby and Rails
call dein#add('tpope/vim-rails')
call dein#end()
call dein#save_state()
endif
filetype plugin indent on
syntax enable
let mapleader=","
" Auto-completion with deoplete.vim
let g:deoplete#enable_at_startup = 1
let g:python_host_prog = expand('~/.pyenv/versions/neovim2/bin/python')
let g:python3_host_prog = expand('~/.pyenv/versions/neovim3/bin/python')
set mouse=a
set showmatch " Show matching brackets
set number " Show the line numbers
set expandtab " Insert spaces when tab is pressed
set tabstop=2 " Render tabs using this many spaces
set shiftwidth=2 " Indentation amount for < and > commands
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set gdefault " Use 'g' flag by default with :s/foo/bar/.
" Open NERDTree with [<leader>d]
map <Leader>d :NERDTreeToggle<CR>
" Show current file in the NERDTree hierarchy
map <Leader>D :NERDTreeFind<CR>
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDTreeWinSize = 51
let NERDTreeShowLineNumbers=1
let g:nerdtree_tabs_focus_on_files=0
let g:nerdtree_tabs_open_on_console_startup=0
let g:nerdtree_tabs_smart_startup_focus=2
" NeoSolarized
set termguicolors
set background=dark
colorscheme NeoSolarized
" Relative numbering
function! NumberToggle()
if(&relativenumber == 1)
set nornu
set number
else
set rnu
endif
endfunc
set rnu
" Toggle between normal and relative numbering.
nnoremap <leader>l :call NumberToggle()<cr>
" Make Q useful and avoid the confusing Ex mode.
" Pressing Q with this mapping does nothing intentionally
noremap Q <nop>
" Close window.
noremap QQ :q<CR>
" close and write
noremap WQ :wq<CR>
" Close all.
noremap QA :qa<CR>
" Close!
noremap Q! :q!<CR>
noremap SS :w<CR>
" Load up all buffers into tabs
nmap <localleader>bt :tab sball<CR>
" previous tab(shift-9), next tab (shift-0)
nnoremap ( :tabp<CR>
nnoremap ) :tabn<CR>
" ,q to toggle quickfix window (where you have stuff like GitGrep)
" ,oq to open it back up (rare)
nmap <silent> ,cq :cclose<CR>
nmap <silent> ,co :copen<CR>
" To map <Esc> to exit terminal-mode: >
tnoremap <Esc> <C-\><C-n>
" To use `CTRL+{h,j,k,l}` to navigate windows from any mode: >
tnoremap <C-h> <C-\><C-N><C-w>h
tnoremap <C-j> <C-\><C-N><C-w>j
tnoremap <C-k> <C-\><C-N><C-w>k
tnoremap <C-l> <C-\><C-N><C-w>l
inoremap <C-h> <C-\><C-N><C-w>h
inoremap <C-j> <C-\><C-N><C-w>j
inoremap <C-k> <C-\><C-N><C-w>k
inoremap <C-l> <C-\><C-N><C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" vim-test maps
map <silent> <leader>t :TestNearest<CR>
map <silent> <leader>f :TestFile<CR>
map <silent> <leader>T :TestSuite<CR>
map <silent> <leader>r :TestLast<CR>
map <silent> <leader>g :TestVisit<CR>
" neovim config
if has("nvim")
" run tests with :T
let test#strategy = "neoterm"
" vertical split instead of the default horizontal
let g:neoterm_position = "vertical"
" pretty much essential: by default in terminal mode, you have to press ctrl-\-n to get into normal mode
" ain't nobody got time for that
tnoremap <Esc> <C-\><C-n>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment