Permalink
Switch branches/tags
Nothing to show
Find file Copy path
e9e492c May 13, 2018
1 contributor

Users who have contributed to this file

344 lines (292 sloc) 9.4 KB
" vim:foldmethod=marker:foldlevel=0
" zo + zc to open / close folds in case I forgot :P
" PLUG {{{
call plug#begin('~/.config/nvim/plugged')
function! DoRemote(arg)
UpdateRemotePlugins
endfunction
Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') }
Plug 'scrooloose/nerdtree'
Plug 'bling/vim-airline'
Plug 'tomtom/tcomment_vim' " gc comments
Plug 'tpope/vim-surround'
Plug 'milkypostman/vim-togglelist'
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
Plug 'neomake/neomake', { 'for': ['rust', 'haskell', 'typescript'] }
Plug 'airblade/vim-gitgutter'
Plug 'w0rp/ale'
" FZF / Ctrlp for file navigation
if executable('fzf')
" OSX vs Linux loading (depending on where fzf is)
let s:uname = system("echo -n \"$(uname)\"")
if !v:shell_error && s:uname == "Darwin"
Plug '/usr/local/opt/fzf'
else
Plug 'junegunn/fzf', {'dir': '~/.local/src/fzf', 'do': './install --all' }
endif
Plug 'junegunn/fzf.vim'
else
Plug 'ctrlpvim/ctrlp.vim'
endif
" Language plugins
" Scala plugins
if executable('scalac')
Plug 'derekwyatt/vim-scala', { 'for': 'scala' }
endif
" Haskell Plugins
if executable('ghc')
Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' }
Plug 'owickstrom/neovim-ghci', { 'for': 'haskell' }
endif
" Rust Plugins
if executable('rustc')
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
Plug 'racer-rust/vim-racer', { 'for': 'rust' }
endif
" Plug 'vim-ruby/vim-ruby'
call plug#end()
" }}}
" LOOK AND SYNTAX HILIGHTING {{{
set t_Co=256
syntax on
set background=dark
colorscheme nnkd
" whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd Syntax * syn match ExtraWhitespace /\s\+$/ containedin=ALL
" Undefined Marks
highlight UndefinedMarks ctermfg=yellow
autocmd Syntax * syn match UndefinedMarks /???/ containedin=ALL
" Automatic syntax highlighting for files
au BufRead,BufNewFile *.sbt set filetype=scala
au BufRead,BufNewFile *.conf set filetype=dosini
au BufRead,BufNewFile *.bash* set filetype=sh
au BufRead,BufNewFile *.jsonnet* set filetype=c
au BufRead,BufNewFile *.libsonnet* set filetype=c
au BufRead,BufNewFile todo* set filetype=todo
au BufRead,BufNewFile *.txt set filetype=todo
" Better split character
" Override color scheme to make split them black
" set fillchars=vert:\|
set fillchars=vert:│
set colorcolumn=101
set cursorline
" }}}
" KEYMAPPINGS {{{
" Leader key
let mapleader = ","
" arrow keys disable
nnoremap <right> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <up> <nop>
vnoremap <right> <nop>
vnoremap <down> <nop>
vnoremap <left> <nop>
vnoremap <up> <nop>
" j/k move virtual lines, gj/jk move physical lines
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" Remap increment and decrement numbers to something that works on macs/linux
nnoremap <A-a> <C-a>
nnoremap <A-x> <C-x>
" panes
nnoremap <leader>d :vsp<cr>
set splitright
nnoremap <leader>s :split<cr>
set splitbelow
" map <C-w>w (switch buffer focus) to something nicer
nnoremap <leader>w <C-w>w
" tabs
nnoremap <leader>] :tabn<cr>
nnoremap <leader>[ :tabp<cr>
nnoremap <leader>T :tabe<cr>
" Insert date
nnoremap <leader>fd "=strftime("%m-%d-%y")<CR>p
" Edit vimrc
nnoremap <leader>ev :edit $MYVIMRC<cr>
nnoremap <leader>evs :source $MYVIMRC<cr>
" Toggle paste with F2
set pastetoggle=<F2>
" Terminal Mode
" Use escape to go back to normal mode
tnoremap <Esc> <C-\><C-n>
" }}}
" BRACE COMPLETION {{{
set showmatch
" inoremap { {}<Left>
" inoremap {<CR> {<CR>}<Esc>O
" inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : "}"
" inoremap {} {}
"
" inoremap ( ()<Left>
" inoremap (<CR> (<CR>)<Esc>O
" inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
" inoremap () ()
"
" inoremap [ []<Left>
" inoremap [<CR> [<CR>]<Esc>O
" inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
" inoremap [] []
" }}}
" GENERAL/TOGGLEABLE SETTINGS {{{
" horizontal split splits below
set splitbelow
" indentation
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
filetype indent off
au BufNewFile,BufRead *.py
\ setlocal tabstop=2
\ shiftwidth=2
\ softtabstop=2
\ autoindent
\ expandtab
" line numbers
set number
set relativenumber
" show title
set title
" mouse
set mouse-=a
" utf-8 ftw
" nvim sets utf8 by default, wrap in if because prevents reloading vimrc
if !has('nvim')
set encoding=utf-8
endif
" Ignore case unless use a capital in search (smartcase needs ignore set)
set ignorecase
set smartcase
" Textwidth for folding
set textwidth=100
" Disable cursor styling in new neovim version
set guicursor=
" }}}
" PLUGINS + CUSTOM FUNCTIONS {{{
" Custom
source ~/.config/nvim/custom/functions.vim
nnoremap <leader>t :call ToggleTodo()<cr>
vnoremap <leader>t :call ToggleTodo()<cr>
" deoplete
let g:deoplete#enable_at_startup=1
inoremap <silent><expr> <Tab> pumvisible() ? "\<C-n>" : "\<C-i>"
" NERDTree
" Open NERDTree in the directory of the current file (or /home if no file is open)
function! NERDTreeToggleFind()
if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1)
execute ":NERDTreeClose"
else
execute ":NERDTreeFind"
endif
endfunction
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nnoremap <leader>c :call NERDTreeToggleFind()<cr>
" sarsi
let sarsivim = 'sarsi-nvim'
if (executable(sarsivim))
call rpcstart(sarsivim)
" nnoremap <leader>l :cfirst<cr>
nnoremap <leader>f :cnext<cr>
nnoremap <leader>g :cprevious<cr>
endif
" Ripgrep for search
if executable('rg')
set grepprg=rg\ -i\ --vimgrep
" Ripgrep on /
command! -nargs=+ -complete=file -bar Rg silent! grep! <args>|cwindow|redraw!
nnoremap <leader>/ :Rg<SPACE>
endif
" airline
set laststatus=2
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#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#show_tab_nr = 1
let g:airline#extensions#tabline#tab_nr_type = 1 " show tab number not number of split panes
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#show_buffers = 0
" let g:airline#extensions#hunks#enabled = 0
" let g:airline_section_z = ""
if get(g:, 'airline_theme', 'notloaded') == 'notloaded'
source ~/.config/nvim/custom/customairline.vim
let g:airline_theme="customairline"
endif
" FZF
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --no-messages "" .'
set grepprg=rg\ --vimgrep
endif
let g:fzf_command_prefix = 'Fzf'
if executable('fzf')
nnoremap <leader>v :FzfFiles<cr>
nnoremap <leader>u :FzfTags<cr>
nnoremap <leader>j :call fzf#vim#tags("'".expand('<cword>'))<cr>
if executable('rg')
" :Find <term> runs `rg <term>` and passes it to fzf
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
nnoremap <leader>/ :Find
nnoremap <leader>' :execute "Find " . expand("<cword>")<cr>
endif
else
nnoremap <leader>v :CtrlP<Space><cr>
endif
" Racer
set hidden
let g:racer_cmd = "/home/seena/.cargo/bin/racer"
let g:racer_experimental_completer = 1
au FileType rust nmap <leader>rx <Plug>(rust-doc)
au FileType rust nmap <leader>rd <Plug>(rust-def)
au FileType rust nmap <leader>rs <Plug>(rust-def-split)
" Neomake
" Gross hack to stop Neomake running when exitting because it creates a zombie cargo check process
" which holds the lock and never exits. But then, if you only have QuitPre, closing one pane will
" disable neomake, so BufEnter reenables when you enter another buffer.
let s:quitting = 0
au QuitPre *.rs let s:quitting = 1
au BufEnter *.rs let s:quitting = 0
au BufWritePost *.rs if ! s:quitting | Neomake | else | echom "Neomake disabled"| endif
au QuitPre *.ts let s:quitting = 1
au BufEnter *.ts let s:quitting = 0
au BufWritePost *.ts if ! s:quitting | Neomake | else | echom "Neomake disabled"| endif
let g:neomake_warning_sign = {'text': '?'}
" Haskell
" Changes highlighting links to use Type/Structure
let g:haskell_classic_highlighting = 1
augroup ghciMaps
au!
" Background process and window management
au FileType haskell nnoremap <silent> <leader>gs :GhciStart<CR>
au FileType haskell nnoremap <silent> <leader>gk :GhciKill<CR>
" Open GHCi split horizontally
au FileType haskell nnoremap <silent> <leader>go :GhciOpen<CR>
au FileType haskell nnoremap <silent> <leader>gh :GhciHide<CR>
" Automatically reload on save
au BufWritePost *.hs GhciReload
" Load individual modules
au FileType haskell nnoremap <silent> <leader>gl :GhciLoadCurrentModule<CR>
au FileType haskell nnoremap <silent> <leader>gf :GhciLoadCurrentFile<CR>
augroup END
" GHCi starts automatically. Set this if you'd like to prevent that.
let g:ghci_start_immediately = 1
" GHCi Settings
" Check if shell.nix exists in root, use nix shell if so
if !empty(glob('shell.nix'))
let g:ghci_command = 'nix-shell --command "cabal repl"'
let g:ghci_command_line_options = ''
else
let g:ghci_command = 'ghci'
let g:ghci_command_line_options = '-fobject-code'
endif
" ALE
let g:airline#extensions#ale#enabled = 1
let g:ale_linters = {'go': ['golint', 'gofmt']}
let g:ale_lint_delay = 800
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" }}}