gcman105

init.vim

Aug 4th, 2017
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 8.66 KB | None | 0 0
  1. " Specify a directory for plugins For Neovim: ~/.local/share/nvim/plugged
  2. " - Avoid using standard Vim directory names like 'plugin'
  3.  
  4. "-----------------------------------------------------------------------------
  5. " vim-plug plugins {{{1
  6. "-----------------------------------------------------------------------------
  7. " Make sure you use single quotes
  8.  
  9. call plug#begin('~/.vim/plugged')
  10. Plug 'Shougo/neomru.vim'
  11. Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  12. Plug 'zchee/deoplete-jedi'
  13. Plug 'Shougo/deoplete-zsh'
  14. Plug 'mattn/webapi-vim'
  15. Plug 'mattn/gist-vim'
  16. Plug 'SirVer/ultisnips'
  17. Plug 'honza/vim-snippets'
  18. Plug 'Shougo/neoinclude.vim'
  19. Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
  20. Plug 'scrooloose/nerdcommenter'
  21. Plug 'mattn/emmet-vim'
  22. Plug 'tpope/vim-surround'
  23. Plug 'tpope/vim-fugitive'
  24. Plug 'tpope/vim-vinegar'
  25. Plug 'tpope/vim-repeat'
  26. Plug 'tpope/vim-unimpaired'
  27. Plug 'rizzatti/dash.vim'
  28. Plug 'kshenoy/vim-signature'
  29. Plug 'vim-airline/vim-airline'
  30. Plug 'vim-airline/vim-airline-themes'
  31. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  32. Plug 'junegunn/fzf.vim'
  33. Plug 'hkupty/iron.nvim'
  34. Plug 'sbdchd/neoformat', {'on': 'Neoformat'}
  35. Plug 'mhartington/nvim-typescript'
  36. Plug 'terryma/vim-multiple-cursors'
  37. Plug 'easymotion/vim-easymotion'
  38. Plug 'junegunn/vim-easy-align', {'on': 'EasyAlign'}
  39. Plug 'frankier/neovim-colors-solarized-truecolor-only'
  40.  
  41. function! BuildComposer(info)
  42.   if a:info.status != 'unchanged' || a:info.force
  43.     if has('nvim')
  44.       !cargo build --release
  45.     else
  46.       !cargo build --release --no-default-features --features json-rpc
  47.     endif
  48.   endif
  49. endfunction
  50.  
  51. Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer') }
  52.  
  53. call plug#end()
  54. " }}} end of vim-plug plugins ------------------------------------------------
  55.  
  56. "-----------------------------------------------------------------------------
  57. " Settings {{{1
  58. "-----------------------------------------------------------------------------
  59. "Want a different map leader than \
  60. let mapleader = ","
  61.  
  62. "Enable filetypes
  63. filetype on
  64. filetype plugin on
  65. filetype indent on
  66. syntax on
  67.  
  68. "Write the old file out when switching between files.
  69. set autowrite
  70.  
  71. set incsearch           " Set incremental searching"
  72. set hlsearch            " Highlight searching
  73. set wildmenu            " Command line completion
  74.  
  75. set cmdheight=2
  76. set autoindent
  77.  
  78. set spelllang=en_gb     " Set region to British English
  79.  
  80. set scrolloff=3         " Keep the cursor 3 lines off of bottom when scrolling
  81. set timeoutlen=800     " A little bit more time for macros
  82. set ttimeoutlen=50      " Make Esc work faster
  83.  
  84. " When completing by tag, show the whole tag, not just the function name
  85. set showfulltag
  86.  
  87. "Syntax coloring lines that are too long just slows down the world
  88. "set synmaxcol=2048
  89. set synmaxcol=512
  90.  
  91. " Don't update the display while executing macros
  92. set lazyredraw
  93.  
  94. "Switch between buffers without saving
  95. set hidden
  96.  
  97. "command tabo, which makes the current tab the only tab
  98. autocmd BufWinEnter,BufNewFile * silent tabo
  99.  
  100. "Allow backspacing over indent, eol, and the start of an insert
  101. set backspace=2
  102.  
  103. " I'm happy to type the case of things.  I tried the ignorecase, smartcase
  104. " thing but it just wasn't working out for me
  105. set noignorecase
  106.  
  107. set number              " Show lines numbers
  108. set relativenumber      " Make line numbers relative
  109. set laststatus=2        " Always show the status line
  110. set clipboard=unnamed
  111. set showmatch           " Show matching brackets.
  112. set cpoptions+=$        " Show $ at the end of a change command
  113. set virtualedit=all     " Allow cursor into places it cant normally go
  114.  
  115. set splitbelow          " More natural split below
  116. set splitright          " More natural split right
  117.  
  118. set nostartofline       " Do not jump to first character with page commands.
  119. set expandtab           " Insert spaces when TAB is pressed.
  120. set tabstop=2           " Render TABs using this many spaces.
  121. set shiftwidth=2        " Indentation amount for < and > commands.
  122.  
  123. set foldlevel=1         " Set the opening fold level
  124. set foldcolumn=3        " Set the fold gutter width
  125. set foldmethod=marker
  126. set foldopen+=jump
  127.  
  128. set termguicolors
  129. set background=dark     " or light
  130. colorscheme solarized
  131.  
  132. " }}} end of settings --------------------------------------------------------
  133.  
  134. "-----------------------------------------------------------------------------
  135. " Keyboard mapping stuff {{{1
  136. "-----------------------------------------------------------------------------
  137. " Map CTRL-E to do what ',' used to do
  138. nnoremap <c-e> ,
  139. vnoremap <c-e> ,
  140.  
  141. " Shortcut for editing  vimrc file in a new tab
  142. nmap <leader>ev :edit $MYVIMRC<CR>
  143. nmap <leader>et :edit ~/.tmux.conf<CR>
  144. nmap <leader>ez :edit ~/.zshrc<CR>
  145. nmap <leader>sv :so $MYVIMRC<CR>
  146. nmap <leader>st :so ~/.tmux.conf<CR>
  147. nmap <leader>sz :so ~/.zshrc<CR>
  148.  
  149. " Toggle spell checking on and off
  150. nmap <silent> <F3> :set spell!<CR>
  151.  
  152. " Map escape key to jj -- much faster
  153. imap jj <esc>
  154. cmap jj <esc>
  155.  
  156. "Saves time; maps the spacebar to colon
  157. nmap <space> :
  158.  
  159. " Gist keyboard mappings
  160. noremap <leader>gl    :Gist -l<CR>
  161. noremap <leader>gp    :Gist<CR>
  162. vnoremap <leader>gv   :'<,'>Gist<CR>
  163.  
  164. " Press F2 to toggle showing white space on/off
  165. nmap <F2> :set list!<CR>
  166.  
  167. " Press F4 to toggle highlighting on/off, and show current value.
  168. :noremap <F4> :set hlsearch! hlsearch?<CR>
  169.  
  170. " Insert a hash rocket with <c-l>
  171. imap <c-l> <space>=><space>
  172.  
  173. " Emmet expandtab
  174. imap <C-e><C-e> <C-y>,
  175.  
  176. " Align selected lines
  177. vnoremap <leader>ib :!align<cr>
  178.  
  179. " Use CTRL-s for saving, also in instert mode
  180. noremap <silent> <C-s> :w<CR>
  181. inoremap <silent> <C-s> <Esc>:w<CR>a
  182. vnoremap <silent> <C-s> <C-c>:update<CR>
  183.  
  184. "Bubble single lines (kicks butt)
  185. "http://vimcasts.org/episodes/bubbling-text/
  186. nmap <C-Up> ddkP
  187. nmap <C-Down> ddp
  188.  
  189. "Bubble multiple lines
  190. vmap <C-Up> xkP`[V`]
  191. vmap <C-Down> xp`[V`]
  192.  
  193. "Better line wrapping
  194. set wrap
  195. set textwidth=79
  196. set formatoptions=qrn1
  197.  
  198. "Indent stuff
  199. set smartindent
  200. set autoindent
  201. set shiftround
  202.  
  203. " A way to iter through buffers
  204. nnoremap <C-b> :buffers<CR>:buffer<Space>
  205.  
  206. " sudo write this
  207. cmap W! w !sudo tee % >/dev/null
  208.  
  209. " ultisnips setup and key bindings {{{2 ------------------
  210. "let g:UltiSnipsExpandTrigger             =  "<tab>"
  211. "let g:UltiSnipsListSnippets              =  "<c-tab>"
  212. "let g:UltiSnipsJumpForwardTrigger        =  "<tab>"
  213. "let g:UltiSnipsJumpBackwardTrigger       =  "<c-tab>"
  214. inoremap <c-x><c-k> <c-x><c-k>
  215. " If you want :UltiSnipsEdit to split your window.
  216. let g:UltiSnipsEditSplit="vertical"
  217. " }}} end of UltiSnips setup and key bindings ------------
  218.  
  219. " Easymotion setup and key bindings {{{2 -----------------
  220. map <leader><leader>    <Plug>(easymotion-prefix)
  221. " }}} end of Easymotion setup and key bindings -----------
  222.  
  223. " NERDTree setup and key bindings {{{2 -------------------
  224. nnoremap <leader>n         :NERDTreeToggle<cr>
  225.  
  226. "Show hidden files in NerdTree
  227. let NERDTreeShowHidden=1
  228.  
  229. " Hide certain files
  230. let NERDTreeIgnore = ['\.pyc$', '__pycache__', '.git', '.cache', '.idea', '.vscode', '.DS_Store', '.projectile', '.noseids', 'htmlcov', 'node_modules']
  231.  
  232. " }}} end of NERDTree setup and key bindings -------------
  233.  
  234. " }}} end of Keyboard mapping stuff ------------------------------------------
  235.  
  236. " Airline stuff {{{2 -------------------------------------
  237. let g:airline_powerline_fonts = 1
  238. let g:airline_solarized_bg='dark'
  239. " }}} end of Airline stuff -------------------------------
  240.  
  241. " Disable Python 2 support:
  242. let g:loaded_python_provider = 1
  243.  
  244. " Enable deoplete
  245. let g:deoplete#enable_at_startup = 1
  246.  
  247. " FZF stuff {{{2 -----------------------------------------
  248. set rtp+=/usr/local/opt/fzf
  249. " Open files in horizontal split
  250. nnoremap <silent> <Leader>s :call fzf#run({
  251. \   'down': '40%',
  252. \   'sink': 'botright split' })<CR>
  253.  
  254. " Open files in vertical horizontal split
  255. nnoremap <silent> <Leader>v :call fzf#run({
  256. \   'right': winwidth('.') / 2,
  257. \   'sink':  'vertical botright split' })<CR>
  258.  
  259. nnoremap <silent> <Leader>C :call fzf#run({
  260. \   'source':
  261. \     map(split(globpath(&rtp, "colors/*.vim"), "\n"),
  262. \         "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"),
  263. \   'sink':    'colo',
  264. \   'options': '+m',
  265. \   'left':    30
  266. \ })<CR>
  267.  
  268. " Open buffer
  269. function! s:buflist()
  270.   redir => ls
  271.   silent ls
  272.   redir END
  273.   return split(ls, '\n')
  274. endfunction
  275.  
  276. function! s:bufopen(e)
  277.   execute 'buffer' matchstr(a:e, '^[ 0-9]*')
  278. endfunction
  279.  
  280. nnoremap <silent> <Leader><Enter> :call fzf#run({
  281. \   'source':  reverse(<sid>buflist()),
  282. \   'sink':    function('<sid>bufopen'),
  283. \   'options': '+m',
  284. \   'down':    len(<sid>buflist()) + 2
  285. \ })<CR>
  286.  
  287. nnoremap <C-p> :GFiles<CR>
  288.  
  289. " }}} end of FZF stuff -----------------------------------
Advertisement