Guest User

Untitled

a guest
Jul 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. " ~/.config/nvim/init.vim
  2. " Author: Max Lay
  3. if &compatible
  4. set nocompatible
  5. endif
  6.  
  7. " Plugins
  8. " Add the dein installation directory into runtimepath
  9. set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
  10. call dein#begin(expand('~/.vim/dein')) " plugins' root path
  11.  
  12. call dein#add('Shougo/dein.vim')
  13.  
  14. " File navigation and manipulation
  15. call dein#add('scrooloose/nerdtree', {'on_map': '<F2>'})
  16. " More precise, faster matcher than CtrlP
  17. call dein#add('junegunn/fzf')
  18. call dein#add('junegunn/fzf.vim', {'dir': '~/.fzf', 'do': './install --all'})
  19. call dein#add('pbogut/fzf-mru.vim')
  20.  
  21. " Find (and replace)
  22. call dein#add('rking/ag.vim', {'on_cmd': ['Ag']})
  23. call dein#add('tpope/vim-abolish', {'on_cmd': ['Abolish', 'Subvert']})
  24.  
  25. " Git
  26. call dein#add('mattn/webapi-vim')
  27. call dein#add('mattn/gist-vim', {'on_cmd': ['Gist'], 'depends': 'webapi-vim'})
  28. call dein#add('tpope/vim-fugitive')
  29.  
  30. " Tmux
  31. call dein#add('christoomey/vim-tmux-navigator')
  32. call dein#add('tmux-plugins/vim-tmux-focus-events')
  33.  
  34. " Theme
  35. call dein#add('morhetz/gruvbox')
  36. set background=dark
  37. set t_Co=256
  38. colorscheme gruvbox
  39.  
  40. " Autocomplete
  41. call dein#add('Shougo/deoplete.nvim', {'depends': ['nvim-yarp', 'delimitMate']})
  42. if !has('nvim')
  43. call dein#add('roxma/nvim-yarp')
  44. call dein#add('roxma/vim-hug-neovim-rpc')
  45. endif
  46. let g:deoplete#enable_at_startup = 1
  47. call dein#add('Raimondi/delimitMate', {'on_map': { 'i' : ['(', '[', '{', '<']}})
  48.  
  49. " Actions
  50. call dein#add('scrooloose/nerdcommenter', {'on_map': ['<Leader>cc', '<Leader>cu', '<Leader>c<Space>']})
  51. call dein#add('FooSoft/vim-argwrap')
  52.  
  53. " Allows repeat to be used with some plugins
  54. call dein#add('tpope/vim-repeat', {'on_map': '.'})
  55. " Fixes increment and decrement for dates/times
  56. call dein#add('tpope/vim-speeddating', {'on_map': ['<c-a>', '<c-x>']})
  57.  
  58. " Motions
  59. call dein#add('tpope/vim-surround', {'on_map': {'n': ['cs', 'ds', 'ys'], 'x': 'S'}, 'depends': 'vim-repeat'})
  60. call dein#add('easymotion/vim-easymotion')
  61. call dein#add('godlygeek/tabular', {'on_cmd': ['Tab', 'Tabularize'] , 'augroup': 'tabular'})
  62.  
  63. " Text objects
  64. " Adds function/list/tuple argument object support
  65. call dein#add('b4winckler/vim-angry')
  66. " Adds a huge number of text objects
  67. call dein#add('wellle/targets.vim')
  68. " Allows simple selection of text objects (eg. viv)
  69. call dein#add('gorkunov/smartpairs.vim')
  70.  
  71. " Syntax checking/linting
  72. call dein#add('w0rp/ale')
  73.  
  74. " Snippets
  75. call dein#add('SirVer/ultisnips', {'on_map': ['<c-k>', '<c-l>', '<c-h>'], 'depends': 'vim-snippets'})
  76. let g:UltiSnipsEditSplit="vertical"
  77. let g:UltiSnipsExpandTrigger="<c-k>"
  78. let g:UltiSnipsJumpForwardTrigger="<c-l>"
  79. let g:UltiSnipsJumpBackwardTrigger="<c-h>"
  80. call dein#add('honza/vim-snippets')
  81.  
  82. " Filetypes
  83. " Guess indents based on file and containing directory
  84. call dein#add('tpope/vim-sleuth')
  85.  
  86. " Erlang
  87. call dein#add('vim-erlang/vim-erlang-tags')
  88. call dein#add('vim-erlang/vim-erlang-compiler')
  89. call dein#add('vim-erlang/vim-erlang-omnicomplete')
  90. call dein#add('vim-erlang/vim-erlang-runtime')
  91. call dein#add('vim-erlang/erlang-motions.vim')
  92. call dein#add('vim-erlang/vim-dialyzer')
  93. call dein#add('vim-erlang/vim-rebar')
  94.  
  95. " Traverse the undo/redo tree
  96. call dein#add('sjl/gundo.vim')
  97.  
  98. call dein#end()
  99.  
  100. " Improve startup time
  101. set guioptions=M
  102.  
  103. filetype on
  104. filetype plugin on
  105. filetype indent on
  106.  
  107. syntax on
  108. set shell=/bin/bash
  109.  
  110. "Easy ways of getting into normal mode
  111. inoremap kk <ESC>
  112. inoremap jj <ESC>
  113. let mapleader = "\<Space>"
  114.  
  115. " General
  116. "Uncomment for mouse support
  117. "set mouse=a
  118. " Fix backspace
  119. set backspace=indent,eol,start
  120. "Disable ex mode
  121. map q: <Nop>
  122. nnoremap Q <nop>
  123. " Increase command history
  124. set history=200
  125. "Use ; as :
  126. nnoremap ; :
  127. "Removes error message when navigating away from unsaved buffer
  128. set hidden
  129. "cd
  130. map <Leader>cd :cd %:p:h<cr>:pwd<cr>
  131. "Saving
  132. nmap <Leader>w :w!<cr>
  133. "Sudo write
  134. cmap w!! w !sudo tee % >/dev/null
  135. "Reload file if edits happen somewhere else
  136. set autoread
  137. "Auto resize panes on terminal resize
  138. autocmd VimResized * wincmd =
  139.  
  140. "Terminal setup
  141. set termencoding=utf-8
  142. set fileencodings=utf8,cp1251
  143. set encoding=utf8
  144. "fixes terminal draw bug in Tmux
  145. set t_ut=
  146. "Beeps off, not that I ever use a terminal that does
  147. set noerrorbells visualbell t_vb=
  148. if has('autocmd')
  149. autocmd GUIEnter * set visualbell t_vb=
  150. endif
  151.  
  152. " Indentation
  153. function UseTabs(...)
  154. if a:0 > 0
  155. let width = a:1
  156. else
  157. let width = 4
  158. end
  159. set noexpandtab
  160. let &tabstop=width
  161. endfunction
  162. command UseTabs call UseTabs()
  163.  
  164. function UseSpaces(...)
  165. if a:0 > 0
  166. let width = a:1
  167. else
  168. let width = 4
  169. end
  170. let &softtabstop=width
  171. let &shiftwidth=width
  172. set expandtab
  173. endfunction
  174. command UseSpaces call UseSpaces()
  175. " Commented out because Vim Sleuth should figure it out automatically
  176. "set softtabstop=4
  177. "set shiftwidth=4
  178. "set expandtab
  179. "set smarttab
  180. set autoindent
  181. set autoindent
  182. "Indent entire document
  183. map <Leader><C-i> mzgg=G'z
  184.  
  185. "Statusline stuff
  186. "Display status line always
  187. set laststatus=2
  188. set ruler
  189. set showcmd
  190. set ch=1
  191.  
  192. "Ignore some file types
  193. set wildmenu " Cool cmd completion
  194. set wildignorecase
  195. "%% is directory containing current file
  196. cabbr <expr> %% expand('%:p:h')
  197. set wildignore+=.hg,.git,.svn " Version control
  198. set wildignore+=*.pyc " Python byte code
  199. set wildignore+=*.beam " Erlang byte code
  200. set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
  201. set wildignore+=*.class,*.o
  202.  
  203. "Display whitespace
  204. set listchars=tab:>.,trail:.
  205. set list
  206.  
  207. "Line numbers and limits
  208. set number " Show line numbers
  209. set relativenumber
  210. set cc=100 " Ver line in 80 column
  211. set cursorline
  212.  
  213. "Folds
  214. set foldmethod=indent
  215. set foldcolumn=1
  216. set foldlevel=99
  217.  
  218. "Movement
  219. set scrolloff=8 " Start scrolling n lines before border
  220. "Scroll wrapped lines normally
  221. noremap <buffer> <silent> k gk
  222. noremap <buffer> <silent> j gj
  223. "Alternate scrolling
  224. map x27j 5j
  225. map x27k 5k
  226. map x27h 5h
  227. map x27l 5l
  228. "End of line
  229. inoremap <C-e> <C-o>$
  230. "Start of line
  231. inoremap <C-a> <C-o>^
  232.  
  233. " Search
  234. set hlsearch " Highlight searches
  235. set incsearch " Highlight dynamically as pattern is typed
  236. set ignorecase " Ignore case of searches
  237. " Search and replace word under curser with F4
  238. nnoremap <F4> :%s/<c-r><c-w>//g<c-f>$F/i
  239. " Leader / to clear search highligting
  240. nmap <Leader>/ :nohlsearch<CR>
  241.  
  242. " Fuzzy find
  243. nmap <C-p> :Files<Cr>
  244. nmap <C-b> :Buffers<Cr>
  245. nmap <C-c> :Commits<Cr>
  246. nmap <C-n> :FZFMru<Cr>
  247.  
  248. "Allows undo after file is closed
  249. if exists("&undodir")
  250. set undofile
  251. set undodir=/tmp
  252. endif
  253. "Swap files and backup are super annoying. I save often
  254. set noswapfile
  255. set nobackup
  256.  
  257. "Nerdtree file browser
  258. let NERDTreeDirArrows=0
  259. let NERDTreeShowHidden=1
  260. nmap <F2> :NERDTreeToggle<CR>
  261. let NERDTreeIgnore=['\.py[co]$', '\~$']
  262.  
  263. "Gundo
  264. nnoremap <F3> :GundoToggle<CR>
  265.  
  266. "Tagbar
  267. nmap <Leader>t :TagbarToggle<CR>
  268.  
  269. "Set cursorcolumn
  270. nmap <Leader>scc :set cuc<CR>
  271. nmap <Leader>Scc :set nocuc<CR>
  272.  
  273. "Buffers
  274. noremap <silent><Leader>bp :bprevious<CR>
  275. noremap <silent><Leader>bn :bnext<CR>
  276. noremap <silent><Leader>bc :bd<CR>
  277.  
  278. "Tabs
  279. map <leader>tn :tabnew<cr>
  280. map <leader>to :tabonly<cr>
  281. map <leader>tc :tabclose<cr>
  282. map <leader>tm :tabmove
  283.  
  284. "Changlist
  285. noremap <silent><Leader>cp :cprev<CR>
  286. noremap <silent><Leader>cn :cnext<CR>
  287.  
  288. "Quickfix
  289. noremap <Leader>q :copen<CR>
  290. noremap <Leader>Q :cclose<CR>
  291. noremap gn :cn<CR>
  292. noremap gp :cp<CR>
  293.  
  294. "Diff
  295. "Diff
  296. map <leader>gd :Gdiff<cr>
  297. map <leader>gs :Gstatus<cr>
  298. map <leader>gb :Gblame<cr>
  299. map <leader>gw! :Gwrite!<cr>
  300.  
  301. "Selection
  302. noremap gV `[v`]
  303. map <leader>gd :Gdiff<cr>
  304. map <leader>gs :Gstatus<cr>
  305. map <leader>gb :Gblame<cr>
  306. map <leader>gw! :Gwrite!<cr>
  307.  
  308. "Selection
  309. "Select what was pasted
  310. map <leader>gv `[v`]
  311.  
  312. "Spelling
  313. "Pressing ,ss will toggle and untoggle spell checking
  314. setlocal spell spelllang=en_gb
  315. setlocal nospell
  316. map <leader>ss :setlocal spell!<cr>
  317. "Next, previous
  318. map <leader>sn ]s
  319. map <leader>sp [s
  320. "Add word to spellfile
  321. map <leader>sa zg
  322. "Suggest spelling
  323. map <leader>s? z=
  324.  
  325. "Delete surrounding function
  326. nmap <silent> dsf ds)db
  327.  
  328. "FileTypes
  329. "web
  330. autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
  331. autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
  332. autocmd FileType css set omnifunc=csscomplete#CompleteCSS
  333. autocmd FileType html,htmldjango setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab
  334. autocmd BufEnter *html map <F11> :setfiletype htmldjango<CR>
  335. autocmd BufEnter *html map <S-F11> :setfiletype django<CR>
  336.  
  337. "Python
  338. let python_highlight_all = 1
  339. "Fix double indentation
  340. let g:pyindent_open_paren = '&sw'
  341. autocmd FileType python set omnifunc=pythoncomplete#Complete
  342. autocmd FileType python nnoremap <F5> :w<CR>:!python %<CR>
  343. autocmd FileType python setlocal complete-=i
  344. autocmd FileType python setlocal complete-=i
  345. autocmd FileType python setlocal dictionary=~/.vim/dict/python
  346. autocmd FileType python setlocal complete+=k
  347. autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab
  348. "Remove trailing whitespace upon saving python file
  349. autocmd BufWritePre *.py :%s/\s\+$//e
  350. let g:neomake_python_flake8_maker = { 'args': ['--max-line-length=100', '--ignore=E302'], }
  351.  
  352. "Add Python virtualenv's site-packages to vim path
  353. py << EOF
  354. import os.path
  355. import sys
  356. if 'VIRTUAL_ENV' in os.environ:
  357. virtualenv_dir = os.environ['VIRTUAL_ENV']
  358. project_dir = os.getcwd()
  359. sys.path.insert(0, project_dir)
  360. activate_this = os.path.join(
  361. virtualenv_dir,
  362. 'bin/activate_this.py')
  363. execfile(activate_this, dict(__file__=activate_this))
  364. EOF
  365.  
  366. "Make it easier to navigate windows
  367. map <C-h> <C-w>h
  368. map <C-j> <C-w>j
  369. map <C-k> <C-w>k
  370. map <C-l> <C-w>l
  371.  
  372. "Vimrc stuff
  373. nmap <silent> <Leader>ev :tabe $MYVIMRC<CR>
  374. nmap <silent> <Leader>sv :so $MYVIMRC<CR>
  375. nmap <silent> <Leader>bi :BundleInstall<CR>
  376.  
  377. "Newline
  378. map <Leader>o o<Esc>
  379. map <Leader>O O<Esc>
  380.  
  381. "Copy, paste and cut to system clipboard
  382. map <Leader>y "+y
  383. map <Leader>x "+d
  384. map <Leader>p :set paste<CR>"+p:set nopaste<CR>
  385. map <Leader>P :set paste<CR>"+P:set nopaste<CR>
  386. "Copy to end of line
  387. noremap Y y$
  388. " Save cursor after yanking in visual mode
  389. vnoremap y myy`y
  390. vnoremap Y myY`y
  391.  
  392. "Arguments on new lines
  393. map <silent> <leader>a :ArgWrap<CR>
  394. "Closing bracket on last arg line
  395. let g:argwrap_wrap_closing_brace = 0
  396.  
  397. "Tasklist
  398. map <Leader>td <Plug>TaskList
  399.  
  400. "Run line in shell
  401. map <Leader>r :exec '!'.getline('.')<CR>
  402. "Run line in shell and insert output below
  403. "TODO
  404.  
  405. "Camel case motion
  406. "map <S-W> <Plug>CamelCaseMotion_w
  407. "map <S-B> <Plug>CamelCaseMotion_b
  408. "map <S-E> <Plug>CamelCaseMotion_e
  409.  
  410. "Significantly improve performance using The Silver Searcher
  411. if executable('ag')
  412. " Use ag over grep
  413. set grepprg=ag\ --nogroup\ --nocolor
  414.  
  415. " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
  416. let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
  417.  
  418. " ag is fast enough that CtrlP doesn't need to cache
  419. let g:ctrlp_use_caching = 0
  420. endif
  421.  
  422. "Delimitmate
  423. let delimitMate_expand_cr = 1
  424. let delimitMate_expand_space = 1
  425.  
  426. "Diffs
  427. "Diffs should be vertically split!
  428. set diffopt+=vertical
  429. set re=1
  430.  
  431. "Repeat motion
  432. let repmo_key=","
  433. let repmo_revkey="\\"
  434.  
  435. "Use local config if available
  436. if filereadable("~/.config/nvim/init.local")
  437. so ~/.config/nvim/init.local
  438. endif
Add Comment
Please, Sign In to add comment