Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 10.58 KB | None | 0 0
  1. " Section: General Config {{{1
  2. "
  3. " ----------------------------
  4. let mapleader = " "
  5. " Deactivating arrow keys.
  6. " Appearance
  7. set autoindent " Automatically set indent of new line.
  8. set smartindent " Automatically inserts one extra level of indentation in some cases.
  9. set ttyfast " Faster redrawing.
  10. set scrolloff=8 " Keep the cursor 8 lines from the top and the bottom.
  11. set wildmenu " Enhanced command line completion.
  12. set showmatch " Show matching braces.
  13. set mat=2 " How many tenths of a second to blink.
  14. set t_CO=256
  15. set guitablabel=\[%N\]\ %t\ %M
  16.  
  17. " Searching
  18. set ignorecase " case insensitive searching
  19. set smartcase " case-sensitive if expresson contains a capital letter
  20. set hlsearch " highlight search results
  21. set incsearch " set incremental search, like modern browsers
  22. set nolazyredraw " don't redraw while executing macros
  23.  
  24. set shell=zsh " Set bash as the prompt for Vim
  25. set backspace=2   " Backspace deletes like most programs in insert mode
  26. set nobackup
  27. set nowritebackup
  28. set noswapfile    " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
  29. set history=50
  30. set ruler         " show the cursor position all the time
  31. set showcmd       " display incomplete commands
  32. set laststatus=2  " Always display the status line
  33. set autowrite     " Automatically :write before running commands
  34. set noshowmode
  35. set timeoutlen=1000
  36. set ttimeoutlen=0
  37. set tabstop=2
  38. set shiftwidth=2
  39. set shiftround
  40. set expandtab
  41. set scrolloff=3
  42. set list listchars=tab:»·,trail:·  " Display extra whitespace characters
  43. set hidden
  44. set inccommand=nosplit
  45. set autochdir
  46.  
  47.  
  48. " Line numbers
  49. set number
  50. set numberwidth=5
  51.  
  52. " Set spellfile to location that is guaranteed to exist, can be symlinked to
  53. " Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm.
  54. set spellfile=$HOME/.vim-spell-en.utf-8.add
  55.  
  56. " Highlight search matches
  57. set hlsearch
  58.  
  59. " Make it obvious where 120 characters is {{{2
  60. " Lifted from StackOverflow user Jeremy W. Sherman
  61. " http://stackoverflow.com/a/3765575/2250435
  62. if exists('+colorcolumn')
  63.   set textwidth=120
  64.   set colorcolumn=+1
  65. else
  66.   au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>120v.\+', -1)
  67. endif " }}}2
  68. " Open new split panes to right and bottom, which feels more natural {{{2
  69. set splitbelow
  70. set splitright
  71. " }}}2
  72.  
  73. " Configure grep to use The Silver Searcher {{{2
  74. if executable('ag')
  75.   " Use ag over grep
  76.   set grepprg=ag\ --nogroup\ --nocolor
  77.  
  78.   command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
  79. endif
  80. " }}}2
  81. " }}}1
  82. " Section: Autocommands {{{1
  83. " --------------------------
  84. if has("autocmd")
  85.   filetype plugin indent on
  86.  
  87.   autocmd BufReadPost * " {{{2
  88.     " When editing a file, always jump to the last known cursor position.
  89.     " Don't do it for commit messages, when the position is invalid, or when
  90.     " inside an event handler (happens when dropping a file on gvim).
  91.     \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
  92.     \   exe "normal g`\"" |
  93.     \ endif "}}}2
  94.  
  95.   " Automatically clean trailing whitespace
  96.   autocmd BufWritePre * :%s/\s\+$//e
  97.  
  98.   autocmd BufRead,BufNewFile COMMIT_EDITMSG call pencil#init({'wrap': 'soft'})
  99.                                         \ | set textwidth=0
  100.  
  101.   autocmd BufRead,BufNewFile *.md set filetype=markdown
  102.  
  103.   autocmd BufRead,BufNewFile .eslintrc,.jscsrc,.jshintrc,.babelrc set ft=json
  104.  
  105.   au BufRead,BufNewFile *.scss set filetype=scss.css
  106.  
  107.   autocmd BufRead,BufNewFile gitconfig set ft=.gitconfig
  108. endif
  109. " }}}1
  110. " Section: External Functions {{{
  111.  
  112. " Open current file in Marked {{{
  113. function! MarkedPreview()
  114.   :w
  115.   exec ':silent !open -a "Marked 2.app" ' . shellescape('%:p')
  116.   redraw!
  117. endfunction
  118. nnoremap <leader>md :call MarkedPreview()<CR>
  119. nnoremap <leader>r :NERDTreeFind<cr>
  120.  
  121. " }}}
  122. " Open current repo in Tower {{{
  123. function! OpenInGitTower()
  124.   call system('gittower `git rev-parse --show-toplevel`')
  125. endfunction
  126. nnoremap <leader>gt :call OpenInGitTower()<CR>
  127. " }}}
  128. " }}}
  129. " Section: Load vim-plug plugins {{{
  130.  
  131. " Specify plugins {{{2
  132. call plug#begin()
  133.  
  134. " UI {{{3
  135. Plug 'trevordmiller/nova-vim'
  136. Plug 'vim-airline/vim-airline'            " Handy info
  137. Plug 'retorillo/airline-tablemode.vim'
  138. Plug 'ryanoasis/vim-webdevicons'
  139. Plug 'ryanoasis/vim-devicons'
  140. Plug 'junegunn/goyo.vim'
  141. Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' }
  142. Plug 'dikiaap/minimalist'
  143.  
  144. " Project Navigation {{{3
  145. Plug 'mhinz/vim-grepper'
  146. Plug 'vim-scripts/ctags.vim'              " ctags related stuff
  147. Plug 'majutsushi/tagbar'
  148. Plug 'rbgrouleff/bclose.vim'              " Required by ranger.vim
  149. Plug 'francoiscabrol/ranger.vim'
  150.  
  151. " File Navigation {{{3
  152. Plug 'vim-scripts/matchit.zip'            " More powerful % matching
  153. Plug 'Lokaltog/vim-easymotion'            " Move like the wind!
  154. Plug 'jeffkreeftmeijer/vim-numbertoggle'  " Smarter line numbers
  155. Plug 'kshenoy/vim-signature'              " Show marks in the gutter
  156. Plug 'haya14busa/incsearch.vim'           " Better search highlighting
  157. Plug 'scrooloose/nerdtree'
  158. "
  159. " Editing {{{3
  160. Plug 'tpope/vim-surround'                 " Change word surroundings
  161. Plug 'tpope/vim-commentary'               " Comments stuff
  162. Plug 'tpope/vim-repeat'
  163. Plug 'tpope/vim-endwise'
  164. Plug 'tpope/vim-unimpaired'
  165. Plug 'dhruvasagar/vim-table-mode',        { 'on': 'TableModeEnable' }
  166. Plug 'kana/vim-textobj-user'
  167. Plug 'jasonlong/vim-textobj-css'
  168. Plug 'editorconfig/editorconfig-vim'
  169. Plug 'ctrlpvim/ctrlp.vim'
  170.  
  171. " Git
  172. Plug 'tpope/vim-fugitive'                 " Git stuff in Vim
  173. Plug 'airblade/vim-gitgutter'
  174. Plug 'junegunn/gv.vim',                   { 'on': 'GV' }
  175. Plug 'jez/vim-github-hub'                 " Filetype for hub pull requests
  176.  
  177. " Task Running
  178. Plug 'tpope/vim-dispatch'                 " Run tasks asychronously in Tmux
  179. Plug 'w0rp/ale'                           " Linter
  180. Plug 'christoomey/vim-tmux-navigator'
  181.  
  182. " Autocomplete {{{3
  183. Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  184. Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern' }
  185. Plug 'autozimu/LanguageClient-neovim', {
  186.     \ 'branch': 'next',
  187.     \ 'do': 'bash install.sh',
  188.     \ }
  189. Plug 'ervandew/supertab'
  190. Plug 'jiangmiao/auto-pairs'
  191. Plug 'valloric/youcompleteme'
  192.  
  193. " Language Support {{{3
  194. " JavaScript {{{4
  195. Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  196. Plug 'carlitux/deoplete-ternjs', { 'for': ['javascript', 'javascript.jsx'] }
  197. Plug 'honza/vim-snippets'
  198. Plug 'othree/jspc.vim', { 'for': ['javascript', 'javascript.jsx'] }
  199. Plug 'ternjs/tern_for_vim', { 'for': ['javascript', 'javascript.jsx'] }
  200. Plug 'SirVer/ultisnips'
  201. Plug 'steelsojka/deoplete-flow'
  202. Plug 'mxw/vim-jsx'
  203. Plug 'pangloss/vim-javascript'
  204. Plug 'othree/javascript-libraries-syntax.vim'
  205.  
  206.  
  207. " HTML {{{4
  208. Plug 'othree/html5.vim'
  209. Plug 'mattn/emmet-vim', { 'for': ['javascript.jsx', 'javascript', 'html', 'css'] }
  210.  
  211. " CSS {{{4
  212. Plug 'hail2u/vim-css3-syntax',            { 'for': 'css' }
  213.  
  214. " Sass {{{4
  215. Plug 'cakebaker/scss-syntax.vim'
  216.  
  217. " Markdown {{{4
  218. Plug 'reedes/vim-pencil'                  " Markdown, Writing
  219. Plug 'godlygeek/tabular',                 { 'for': 'markdown' } " Needed for vim-markdown
  220. Plug 'plasticboy/vim-markdown',           { 'for': 'markdown' }
  221.  
  222.  
  223. call plug#end()
  224. " Load plugin configurations {{{2
  225. " For some reason, a few plugins seem to have config options that cannot be
  226. " placed in the `plugins` directory. Those settings can be found here instead.
  227. let g:javascript_plugin_jsdoc = 1
  228. let g:javascript_plugin_ngdoc = 1
  229. let g:javascript_plugin_flow = 1
  230. let g:jsx_ext_required = 0
  231.  
  232. let g:airline#extensions#tabline#fnamemod = ':t'
  233.  
  234. let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git'
  235. let g:deoplete#sources = {}
  236. let g:deoplete#sources['javascript.jsx'] = ['file', 'ultisnips', 'ternjs']
  237. let g:tern#command = ['tern']
  238. let g:tern#arguments = ['--persistent']
  239. let g:deoplete#enable_at_startup = 1
  240. let g:deoplete#auto_complete_delay = 0
  241. let g:echodoc_enable_at_startup=1
  242. let g:tern#command = ['tern']
  243. let g:SuperTabDefaultCompletionType = "<c-x><c-o>"
  244. let g:UltiSnipsExpandTrigger="<C-j>"
  245. "inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
  246. "
  247. let g:UltiSnipsExpandTrigger="<tab>"
  248. let g:UltiSnipsJumpForwardTrigger="<c-b>"
  249. let g:UltiSnipsJumpBackwardTrigger="<c-z>"
  250.  
  251. " vim-airline {{{3
  252. let g:airline_powerline_fonts = 1 " Enable the patched Powerline fonts
  253.  
  254. " emmet-vim {{{3
  255. " lets emmet use jsx shortcuts
  256. let g:user_emmet_expandabbr_key='<tab>'
  257.  
  258. imap <expr> <tab> emmet#expandAbbrIntelligent("\<tab>")
  259. let g:user_emmet_settings = {
  260. \  'javascript.jsx' : {
  261. \      'extends': 'jsx',
  262. \      'quote_char': "'",
  263. \  },
  264. \}
  265. let g:jsx_ext_required = 0
  266.  
  267. " }}}3
  268. " make YCM compatible with UltiSnips (using supertab)
  269. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  270. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  271. let g:SuperTabDefaultCompletionType = '<C-n>'
  272.  
  273. " better key bindings for UltiSnipsExpandTrigger
  274. let g:UltiSnipsExpandTrigger = "<tab>"
  275. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  276. let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
  277.  
  278. let g:ale_sign_error = '●' " Less aggressive than the default '>>'
  279. " Section: Remaps {{{1
  280.  
  281. " Normal Mode Remaps {{{2
  282.  
  283. nnoremap zr zR
  284. nnoremap zm zM
  285. noremap <up> <nop>
  286. noremap <down> <nop>
  287. noremap <left> <nop>
  288. noremap <right> <nop>
  289.  
  290. " NERDTree
  291. map <F1> :NERDTreeToggle<cr>
  292. map <F2> :NERDTreeClose<cr>
  293.  
  294. nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
  295.  
  296. " Smarter pasting
  297. nnoremap <Leader>p :set invpaste paste?<CR>
  298. nnoremap <Leader>k ddkP
  299. nnoremap <Leader>j ddp
  300.  
  301. " -- Smart indent when entering insert mode with i on empty lines --------------
  302. function! IndentWithI()
  303.   if len(getline('.')) == 0
  304.     return "\"_ddO"
  305.   else
  306.     return "i"
  307.   endif
  308. endfunction
  309. nnoremap <expr> i IndentWithI()
  310.  
  311. " Remap the increment and decrement features of Vim
  312. nnoremap <A-a> <C-a>
  313. nnoremap å <C-a>
  314.  
  315. nnoremap <A-x> <C-x>
  316. nnoremap<C-x>
  317.  
  318. " Tab Shortcuts
  319. nnoremap tk :tabfirst<CR>
  320. nnoremap tn :tabnext<CR>
  321. nnoremap tp :tabprev<CR>
  322. nnoremap tj :tablast<CR>
  323. nnoremap tnew :tabnew<CR>
  324. nnoremap tc :CtrlSpaceTabLabel<CR>
  325. nnoremap td :tabclose<CR>
  326.  
  327. nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
  328.  
  329. " }}}2
  330. " Insert Mode Remaps {{{2
  331.  
  332. set completeopt=longest,menuone
  333.  
  334. " }}}2
  335. " }}}1
  336. " Section: Theme {{{
  337.  
  338. syntax enable
  339. let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  340. set t_ut=                " fix 256 colors in tmux http://sunaku.github.io/vim-256color-bce.html
  341. if has("termguicolors")  " set true colors
  342.     set termguicolors
  343.   endif
  344. set background=dark
  345. colorscheme minimalist
  346. " }}}
  347. " Section: Local-Machine Config {{{
  348.  
  349. if filereadable($DOTFILES . "/nvim/init.local.vim")
  350.   source $DOTFILES/nvim/init.local.vim
  351. endif
  352. " }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement