Advertisement
anujpandey

vimrc-Oct-2019

Sep 29th, 2019
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 14.18 KB | None | 0 0
  1. " 1) Basic Syntax and Indentation
  2. syntax enable
  3. set tabstop=4
  4. set expandtab
  5. set nu rnu
  6. filetype indent on
  7. set autoindent
  8. " 2) force minimun window width
  9. set winwidth=110
  10. " Run current line as Vim comand/normal mode
  11. set hlsearch
  12. set incsearch
  13. set ignorecase
  14. set smartcase
  15.  
  16. let g:solarized_termtrans=1
  17. " set background=dark
  18. set rtp+=/usr/share/powerline/bindings/vim/
  19.  
  20. nnoremap <CR> :nohlsearch<cr>
  21.  
  22. set nocompatible
  23. filetype off
  24. let g:airline#extensions#tabline#enabled = 1
  25. let g:airline_powerline_fonts = 1
  26. let g:airline_theme='angr'
  27.  
  28. set rtp+=~/.vim/bundle/Vundle.vim
  29. call vundle#begin()
  30. Plugin 'VundleVim/Vundle.vim'
  31. Plugin 'ryanoasis/vim-devicons'
  32. Plugin 'jiangmiao/auto-pairs'
  33. Plugin 'neoclide/coc.nvim'
  34. Plugin 'mhinz/vim-startify'
  35. Plugin 'vim-airline/vim-airline'
  36. Plugin 'vim-airline/vim-airline-themes'
  37. Plugin 'powerline/powerline'
  38. Plugin 'tpope/vim-surround'                         " Change surrounding marks
  39. Plugin 'tpope/vim-fugitive'
  40. Plugin 'tpope/vim-rhubarb'
  41. Plugin 'mtdl9/vim-log-highlighting'
  42. Plugin 'sheerun/vim-polyglot'
  43. Plugin 'christoomey/vim-tmux-navigator'
  44.  
  45. Plugin 'tpope/vim-eunuch'
  46. Plugin 'tpope/vim-repeat'
  47. Plugin 'tpope/vim-unimpaired'
  48. Plugin 'tpope/vim-abolish'
  49. Plugin 'vim-ruby/vim-ruby'
  50. " Plugin 'mattn/emmet-vim', { 'for': ['javascript.jsx', 'html', 'css'] }
  51. Plugin 'prettier/vim-prettier', { 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
  52. Plugin 'w0rp/ale'
  53. Plugin 'rbgrouleff/bclose.vim'
  54. Plugin 'cohama/lexima.vim'
  55. Plugin 'easymotion/vim-easymotion'
  56. Plugin 'SirVer/ultisnips'
  57. Plugin 'terryma/vim-multiple-cursors'
  58. Plugin 'gorkunov/smartpairs.vim'
  59. Plugin 'djoshea/vim-autoread'
  60. Plugin 'junegunn/fzf'
  61. Plugin 'junegunn/fzf.vim'
  62. Plugin 'posva/vim-vue'
  63. Plugin 'matze/vim-move'
  64.  
  65. Plugin 'pangloss/vim-javascript'
  66. " Plugin 'othree/yajs.vim'
  67. " Plugin 'othree/es.next.syntax.vim'
  68. " Plugin 'othree/javascript-libraries-syntax.vim'
  69. " Plugin 'isRuslan/vim-es6'
  70.  
  71. Plugin 'scrooloose/nerdtree'
  72. Plugin 'mxw/vim-jsx', { 'for': ['jsx','javascript.jsx']}
  73. Plugin 'tpope/vim-commentary' " or Plugin 'tomtom/tcomment_vim'
  74. "Plugin 'ervandew/supertab'
  75. Plugin 'othree/html5.vim'
  76. " Test Run
  77. Plugin 'tpope/vim-obsession'
  78. Plugin 'firegoby/html_entities_helper.vim'
  79. Plugin 'dustinknopoff/TeaCode-Vim-Extension'
  80. Plugin 'tpope/vim-vinegar'
  81. Plugin 'itchyny/lightline.vim'
  82. Plugin 'alvan/vim-closetag'
  83.  
  84. " Themes
  85. " Plugin 'lifepillar/vim-solarized8'
  86. " Colour Themes
  87. Plugin 'GertjanReynaert/cobalt2-vim-theme'
  88. Plugin 'altercation/vim-colors-solarized'
  89. Plugin 'kaicataldo/material.vim'
  90. Plugin 'kyoz/purify'
  91. Plugin 'tomasr/molokai'
  92. Plugin 'chriskempson/base16-vim'
  93. Plugin 'dracula/vim'
  94. Plugin 'sonph/onehalf'
  95. Plugin 'gosukiwi/vim-atom-dark'
  96. Plugin 'jacoborus/tender.vim'
  97. Plugin 'ciaranm/inkpot'
  98. Plugin 'connorholyday/vim-snazzy'
  99. Plugin 'ajh17/Spacegray.vim'
  100.  
  101.  
  102.  
  103. " Add plugins here
  104.  
  105. call vundle#end()
  106. filetype plugin indent on
  107. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  108. " => NERDTree
  109. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  110. " Uncomment to autostart the NERDTree
  111. " autocmd vimenter * NERDTree
  112. map <C-n> :NERDTreeToggle<CR>
  113. let g:NERDTreeDirArrowExpandable = '▸'
  114. let g:NERDTreeDirArrowCollapsible = '▾'
  115. let NERDTreeShowLineNumbers=1
  116. let NERDTreeShowHidden=1
  117. let NERDTreeMinimalUI = 1
  118. "Run current line as Vim comand/normal mode"""""""""""""""""""""
  119.  
  120. set cursorline cursorcolumn
  121. nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
  122. hi CursorLine   cterm=NONE ctermbg=darkgray ctermfg=NONE "guibg=lightgreen guifg=white
  123. hi CursorColumn cterm=NONE ctermbg=darkgray ctermfg=NONE "guibg=lightgreen guifg=blue
  124.  
  125. let g:webdevicons_enable = 1
  126. let g:webdevicons_enable_nerdtree = 1
  127. let g:webdevicons_enable_unite = 1
  128. let g:webdevicons_enable_airline_tabline = 1
  129. let g:webdevicons_enable_airline_statusline = 1
  130. let g:webdevicons_enable_ctrlp = 1
  131. let g:webdevicons_enable_startify = 1
  132.  
  133. nnoremap Q !!sh <cr> -- Map Ctrl Q to run current line as shell command
  134. nnoremap <Leader>L yy:@" <cr> -- Run current line as Vim comand/normal mode
  135. nmap <leader>y "*y
  136. vnoremap <leader>y "*y
  137. nnoremap <leader>Y "*y$
  138. nnoremap <leader>yy "*yy
  139.  
  140. set expandtab
  141.  
  142. " Be smart when using tabs ;)
  143. set smarttab
  144.  
  145. " 1 tab == 4 spaces
  146. set shiftwidth=4
  147. set tabstop=4
  148.  
  149. set runtimepath^=~/.vim/bundle/ctrlp.vim
  150. " set listchars=tab:»·,eol:↲,nbsp:␣,trail:•,extends:→,precedes:←,space:.
  151. set listchars=tab:→\ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨,space:.
  152. set list
  153. let g:github_enterprise_urls = ['https://orahub.oraclecorp.com']
  154. let g:prettier#autoformat = 0
  155. autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
  156. " PrettierAsync
  157.  
  158. " Autocorrect
  159. let b:ale_fixers = ['prettier', 'eslint']
  160. set guifont=FiraCodeNerdFontCompleteM-Regular:h15
  161.  
  162. " Enter date using F3
  163. nmap <F3> i<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
  164. imap <F3> <C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR>
  165.  
  166. " System clipboard sharing
  167. set clipboard=unnamed
  168. set clipboard=unnamedplus
  169.  
  170. set hidden
  171. set wildmenu
  172. set showcmd
  173.  
  174. " Allow backspacing over autoindent, line breaks and start of insert action
  175. set backspace=indent,eol,start
  176.  
  177. " When opening a new line and no filetype-specific indenting is enabled, keep
  178. " the same indent as the line you're currently on. Useful for READMEs, etc.
  179. set autoindent
  180.  
  181. " Stop certain movements from always going to the first character of a line.
  182. " While this behaviour deviates from that of Vi, it does what most users
  183. " coming from other editors would expect.
  184. set nostartofline
  185.  
  186. " Display the cursor position on the last line of the screen or in the status
  187. " line of a window
  188. set ruler
  189.  
  190. " Always display the status line, even if only one window is displayed
  191. set laststatus=2
  192.  
  193. " Instead of failing a command because of unsaved changes, instead raise a
  194. " dialogue asking if you wish to save changed files.
  195. set confirm
  196.  
  197. " Use visual bell instead of beeping when doing something wrong
  198. set visualbell
  199.  
  200. " And reset the terminal code for the visual bell. If visualbell is set, and
  201. " this line is also included, vim will neither flash nor beep. If visualbell
  202. " is unset, this does nothing.
  203. set t_vb=
  204.  
  205. " Enable use of the mouse for all modes
  206. " set mouse=a
  207.  
  208. " Set the command window height to 2 lines, to avoid many cases of having to
  209. " press <Enter> to continue"
  210. " set cmdheight=2
  211. "
  212.  
  213. runtime macros/matchit.vim
  214.  
  215. " =============================================================
  216. "                 GENERAL SETTINGS
  217. " =============================================================
  218.  
  219. set backspace=indent,eol,start
  220. set history=1000
  221. set ruler
  222. set showcmd
  223. set autoindent
  224. set showmatch
  225. set nowrap
  226. set autoread
  227. set autowrite
  228. set backupdir=~/.tmp
  229. set directory=~/.tmp
  230. set viminfo+=!
  231. set guioptions-=T
  232. set laststatus=2
  233. set scrolloff=3
  234. set sidescrolloff=4
  235. set hidden
  236. set tabstop=2
  237. set shiftwidth=2
  238. set softtabstop=2
  239. set expandtab
  240. set regexpengine=1
  241. " set relativenumber
  242. set number
  243. set wrap
  244. set linebreak
  245. set hlsearch
  246. set incsearch
  247. set ignorecase
  248. set smartcase
  249. set mouse=a
  250. set shell=bash
  251. set clipboard=unnamed
  252. set winwidth=100
  253. set winheight=5
  254. set winminheight=5
  255. set winheight=999
  256. set noswapfile
  257. set wildmenu
  258. set nostartofline
  259. " (Hopefully) removes the delay when hitting esc in insert mode
  260. " set noesckeys
  261. set ttimeout
  262. set ttimeoutlen=1
  263. " set listchars=tab:>-,trail:~,extends:>,precedes:<,space:.
  264. set ttyfast
  265. " set lazyredraw
  266. " set re=1
  267.  
  268. set path+=**
  269. set tags=./tags;/
  270. set encoding=UTF-8
  271. set foldmethod=indent
  272. set signcolumn=yes
  273. " =============================================================
  274. "                    AUTOCOMMANDS
  275. " =============================================================
  276.  
  277. if has("autocmd")
  278.   augroup vimrcEx
  279.     au!
  280.  
  281.     autocmd BufRead *
  282.       \ if line("'\"") > 0 && line("'\"") <= line("$") |
  283.       \   exe "normal g`\"" |
  284.       \ endif
  285.  
  286.     autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
  287.     autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
  288.     autocmd BufRead * normal zR
  289.     " autocmd BufWinLeave *.* mkview
  290.  
  291.     " autocmd BufWinEnter *.* silent loadview
  292.     au BufNewFile,BufReadPost *.md set filetype=markdown
  293.     au BufNewFile,BufReadPost *.vue syntax sync fromstart
  294.  
  295.     autocmd FileType javascript set formatprg=prettier\ --stdin
  296.     "autocmd BufLeave,FocusLost * silent! wall
  297.     autocmd filetype crontab setlocal nobackup nowritebackup
  298.  
  299.   augroup END
  300. endif
  301.  
  302. " =============================================================
  303. "                      MAPPINGS
  304. " =============================================================
  305.  
  306. let mapleader = ","
  307.  
  308. " insert mode
  309. "inoremap <c-e> <down>
  310. "inoremap <c-n> <left>
  311. "inoremap <c-y> <up>
  312. "inoremap <c-i> <right>
  313.  
  314. " Quick open most used files
  315. " nnoremap <leader>em :!open -a 'Marked 2.app' '%:p'<cr>
  316. nnoremap <leader>ev :e ~/.vimrc<cr>
  317. nnoremap <leader>es :vs<cr>:UltiSnipsEdit<cr>
  318.  
  319. " UltiSnips
  320. let g:UltiSnipsExpandTrigger="<tab>"
  321. let g:UltiSnipsJumpForwardTrigger="<tab>"
  322.  
  323. " create/open file in current folder
  324. map <Leader>ee :e <C-R>=escape(expand("%:p:h"),' ') . '/'<CR>
  325.  
  326. nnoremap <silent> <space> :nohl<Bar>:echo<CR>
  327. nnoremap <leader>w mzyyp`zj
  328. nnoremap <leader>v :set invpaste paste?<CR>
  329. nnoremap <leader>V V`]
  330. nnoremap <leader>I V`]=
  331. nnoremap <leader>a ggVG
  332. nnoremap <leader>r :syntax sync fromstart<CR>
  333. nmap k gk
  334. nmap j gj
  335.  
  336. noremap <Leader>d :Bclose<CR>
  337. noremap <Leader>D :bufdo bd<CR>
  338.  
  339. cnoremap %% <C-R>=expand("%:p:h") . "/" <CR>
  340.  
  341. " FZF
  342. nnoremap <leader>f :GFiles<cr>
  343. nnoremap <leader>t :Files<cr>
  344. nnoremap <leader>. :Buffers<cr>
  345.  
  346. " Fugitive
  347. nnoremap <leader>gg :Gstatus<CR>:only<CR>
  348. nnoremap <leader>gw :Gwrite<CR>
  349.  
  350. " Tabs
  351. nnoremap <leader>1 1gt<cr>
  352. nnoremap <leader>2 2gt<cr>
  353. nnoremap <leader>3 3gt<cr>
  354. nnoremap <leader>4 4gt<cr>
  355.  
  356. " inc search for range commands
  357. cnoremap $t <CR>:t''<CR>
  358. cnoremap $T <CR>:T''<CR>
  359. cnoremap $m <CR>:m''<CR>
  360. cnoremap $M <CR>:M''<CR>
  361. cnoremap $d <CR>:d<CR>``
  362.  
  363. " saves cursor after yanking in visual mode
  364. vnoremap y myy`y
  365. vnoremap Y myY`y
  366.  
  367. nnoremap <leader>s :w<cr>
  368.  
  369. " =============================================================
  370. "                 PLUGINS CONFIGURATION
  371. " =============================================================
  372.  
  373. " NERDTree
  374. nnoremap <leader>q :NERDTreeToggle<cr>
  375. let NERDTreeMinimalUI=1
  376. let NERDTreeShowLineNumbers=1
  377. let NERDTreeQuitOnOpen=1
  378. let NERDTreeHijackNetrw = 0
  379.  
  380. " Lightline
  381. let g:lightline = {
  382.       \ 'colorscheme': 'one',
  383.       \ 'active': {
  384.       \   'left': [ [ 'mode', 'paste' ],
  385.       \             [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
  386.       \ },
  387.       \ 'component_function': {
  388.       \   'gitbranch': 'fugitive#head'
  389.       \ },
  390.       \ }
  391.  
  392. " Easymotion
  393. nmap S <Plug>(easymotion-s2)
  394. nmap s <Plug>(easymotion-s)
  395.  
  396. " Vim Move
  397. let g:move_key_modifier = 'C'
  398.  
  399. " Vue
  400. " let g:vue_disable_pre_processors=1
  401.  
  402. " Markdown
  403. let g:markdown_fenced_languages = ['css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml', 'html']
  404.  
  405. " JSX
  406. let g:jsx_ext_required = 0
  407. let g:javascript_enable_domhtmlcss = 1
  408. let g:used_javascript_libs = 'underscore,react'
  409.  
  410. " Emmet
  411. " let g:user_emmet_settings={'javascript.jsx': {'extends':'jsx'}}
  412. " let g:user_emmet_leader_key='<C-t>'
  413.  
  414. " Tag Autoclose
  415. let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.vue'
  416.  
  417. " Prettier
  418. nmap <Leader>p <Plug>(Prettier)
  419. let g:prettier#exec_cmd_async = 1
  420. let g:prettier#config#print_width = 80
  421. let g:prettier#config#tab_width = 2
  422. let g:prettier#config#use_tabs = 'false'
  423. let g:prettier#config#semi = 'true'
  424. let g:prettier#config#single_quote = 'false'
  425. let g:prettier#config#bracket_spacing = 'true'
  426. let g:prettier#config#jsx_bracket_same_line = 'false'
  427. let g:prettier#config#trailing_comma = 'none'
  428. let g:prettier#config#parser = 'babylon'
  429. let g:prettier#config#config_precedence = 'prefer-file'
  430. let g:prettier#config#prose_wrap = 'preserve'
  431. let g:prettier#autoformat = 0
  432. autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
  433.  
  434. " Ale
  435. let g:ale_set_highlights = 0
  436. nmap <silent> <Leader>nn <Plug>(ale_previous_wrap)
  437. nmap <silent> <Leader>np <Plug>(ale_next_wrap)
  438. let g:ale_linters = {
  439. \   'javascript': ['eslint'],
  440. \   'ruby': [],
  441. \}
  442.  
  443.  
  444. " =============================================================
  445. "                      APPEARENCE
  446. " =============================================================
  447.  
  448. "set term=xterm
  449. set t_Co=256
  450. let &t_AB="\e[48;5;%dm"
  451. let &t_AF="\e[38;5;%dm"
  452.  
  453. " colorscheme cobalt2
  454. colorscheme dracula
  455. set background=dark
  456.  
  457. if has("gui_running")
  458.   "set guifont=FiraCodeNerdFontCompleteM-Regular:h15
  459.   set guifont=FiraCodeNerdFontCompleteM-Regular:h15
  460.   set linespace=6
  461.   set guioptions-=r
  462.   colorscheme dracula
  463.   let g:material_theme_style = 'default' " 'palenight' | 'dark'
  464.   let g:material_terminal_italics = 1
  465. endif
  466.  
  467. if (has("nvim"))
  468.   "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
  469.   let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  470. endif
  471.  
  472. "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  473. "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  474. " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  475. if (has("termguicolors"))
  476.   set termguicolors
  477. endif
  478.  
  479. " =============================================================
  480. "                      CUSTOM FUNCTIONS
  481. " =============================================================
  482.  
  483. " Create folders on file save
  484. " ===========================
  485.  
  486. function! s:MkNonExDir(file, buf)
  487.     if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
  488.         let dir=fnamemodify(a:file, ':h')
  489.         if !isdirectory(dir)
  490.             call mkdir(dir, 'p')
  491.         endif
  492.     endif
  493. endfunction
  494.  
  495. " Remove whitespaces on save saving cursor position
  496. " =================================================
  497.  
  498. function! <SID>StripTrailingWhitespaces()
  499.     let l = line(".")
  500.     let c = col(".")
  501.     %s/\s\+$//e
  502.     call cursor(l, c)
  503. endfun
  504.  
  505. " Opening  a terminal
  506. " set splitbelow
  507. set splitright
  508. nnoremap <leader>z :terminal<cr><C-w>:exe "resize " . (winheight(0) * 2/3)<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement