Guest User

Untitled

a guest
Feb 25th, 2018
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.63 KB | None | 0 0
  1. " Map Leader key
  2. let mapleader= ","
  3.  
  4. " Set always commands as VIM mode, not VI mode.
  5. set nocompatible
  6.  
  7. " Pathogen plugins
  8. execute pathogen#infect()
  9. call pathogen#helptags()
  10.  
  11. " Syntax highlighting
  12. syntax on
  13.  
  14. filetype indent on
  15. filetype on
  16. filetype plugin on
  17.  
  18. set modelines=0
  19.  
  20. " Enable syntax colors
  21. syntax enable
  22.  
  23. " Solarized scheme color preferences
  24. let g:solarized_termcolors=256
  25. let g:solarized_termtrans = 1
  26. let g:solarized_bold = 1
  27. let g:solarized_underline = 1
  28. let g:solarized_italic = 1
  29. let g:solarized_contrast = "normal"
  30. let g:solarized_visibility= "high"
  31.  
  32. colorscheme solarized
  33.  
  34. " Background color from color scheme
  35. " set background=light
  36. set background=dark
  37.  
  38. " Show selected line with background
  39. set cursorline
  40. :hi CursorLine cterm=NONE ctermbg=0 guibg=darkblue ctermfg=NONE ctermfg=NONE
  41. :hi Visual cterm=NONE ctermbg=0 ctermfg=NONE
  42.  
  43. " Incremental search: each time I type a letter, vim will perfom a search
  44. set incsearch
  45.  
  46. " Make searches insensite case
  47. set ignorecase
  48.  
  49. " Highlight results
  50. set hlsearch
  51. nnoremap <leader><Space> :noh<CR>
  52.  
  53. " If use capital case, search will be case sensitive, if use normal case,
  54. " search will be insensive case.
  55. set smartcase
  56.  
  57. " Auto-indentation
  58. set autoindent
  59.  
  60. " Set indentation to 2 espaces
  61. set softtabstop=2
  62. set shiftwidth=2
  63.  
  64. " Convert tabs to spaces
  65. set expandtab
  66.  
  67. " Autoindent in cmd mode
  68. set smartindent
  69.  
  70. " Auto indent in PHP and HTML files
  71. au BufRead *.php set ft=php.html
  72. au BufNewFile *.php set ft=php.html
  73. au BufRead *.htm set ft=php.html
  74. au BufNewFile *.htm set ft=php.html
  75. au BufRead *.html set ft=php.html
  76. au BufNewFile *.html set ft=php.html
  77.  
  78.  
  79. """"""""""""""""""""""""" TIM POPE """"""""""""""""""""""""""
  80.  
  81. " Delete comment character when joining commented lines
  82. if v:version > 703 || v:version == 703 || v:version > 800 && has("patch541")
  83. set formatoptions+=j
  84. endif
  85.  
  86. set autoread
  87. set fileformats+=mac
  88.  
  89. " set formatoptions-=cro
  90.  
  91. " Deactivate auto commenting in second line
  92. " Check :help fo-table in help
  93. autocmd BufNewFile,BufRead * setlocal formatoptions-=cro
  94.  
  95. set showcmd
  96. set wildmenu
  97. set hidden
  98. set ttyfast
  99. set complete-=i
  100. set smarttab
  101.  
  102. " Search
  103. nnoremap / /\v
  104. vnoremap / /\v
  105. nnoremap <leader>s /\v
  106. set gdefault
  107.  
  108. " Use 'tab' key to go to parethesis inmediately
  109. nnoremap <tab> %
  110. vnoremap <tab> %
  111.  
  112. set wrap
  113.  
  114. " Max width
  115. set textwidth=79
  116. " set formatoptions=qrn1
  117.  
  118. " Scroll speed
  119. if !&scrolloff
  120. set scrolloff=1
  121. endif
  122. if !&sidescrolloff
  123. set sidescrolloff=5
  124. endif
  125. set display+=lastline
  126.  
  127. if &shell =~# 'fish$'
  128. set shell=/bin/bash
  129. endif
  130.  
  131. " Allow color schemes to do bright colors without forcing bold.
  132. if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
  133. set t_Co=16
  134. endif
  135.  
  136. set nrformats-=octal
  137. set ttimeout
  138. set ttimeoutlen=100
  139.  
  140. " Set rows number from 1 to 9
  141. set relativenumber
  142.  
  143. " Create a undofile to recover things
  144. set undofile
  145.  
  146. " Disable arrow keys
  147. nnoremap <up> <nop>
  148. nnoremap <down> <nop>
  149. nnoremap <left> <nop>
  150. nnoremap <right> <nop>
  151. inoremap <up> <nop>
  152. inoremap <down> <nop>
  153. inoremap <left> <nop>
  154. inoremap <right> <nop>
  155. inoremap <BS> <nop>
  156. inoremap <del> <nop>
  157. nnoremap j gj
  158. nnoremap k gk
  159.  
  160. " Save on losing focus
  161. au FocusLost * :wa
  162.  
  163. " Ack Plugin
  164. nnoremap <leader>a :Ack "
  165.  
  166.  
  167. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  168.  
  169. " Set Line numbers
  170. set number
  171.  
  172. " Always display row/column info in bottom
  173. " set ruler
  174.  
  175. " Use UTF-8 as the default text encoding
  176. set encoding=utf-8
  177. set fileencoding=utf-8
  178.  
  179. " start: allows to erase furtheR from the starting point
  180. " eol: allows to continue deleting from one line to another up (joining lines)
  181. " indent: allows to delete indents
  182. set backspace=indent,eol,start
  183.  
  184. " Allows to use delete key to join lines
  185. set ts=2 sts=2 sw=2 expandtab
  186.  
  187. " Coloring matching braces (), []. {}, etc...
  188. set showmatch
  189.  
  190. " Show all tabs, stops, etc
  191. set nolist
  192. " set list
  193. " set listchars=tab:▸\ ,eol:¬,nbsp:⋅,trail:•
  194. " set listchars=tab:▸\ ,eol:¬,nbsp:⋅,trail:•
  195.  
  196. " Set vim font
  197. set guifont=PragmataPro
  198.  
  199. if &listchars ==# 'eol:$'
  200. set listchars=tab:▸\ ,trail:•,eol:¬,extends:>,precedes:<,nbsp:+
  201. endif
  202.  
  203. " if &listchars ==# 'eol:$'
  204. " set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
  205. " endif
  206.  
  207. " No create swap backup files
  208. set noswapfile
  209.  
  210. " Only alert flashin the screen
  211. set visualbell
  212.  
  213. " Set guide color column
  214. set cc=80
  215. " hi ColorColumn ctermbg=darkgray guibg=darkgray
  216.  
  217. " Folding method
  218. set fdm=manual
  219. :hi Folded cterm=NONE ctermbg=0 guibg=NONE ctermfg=NONE
  220. " :hi CursorLine cterm=NONE ctermbg=0 guibg=darkblue ctermfg=NONE ctermfg=NONE
  221. " :hi Visual cterm=NONE ctermbg=0 ctermfg=NONE
  222.  
  223. " Keep folds automatically
  224. augroup remember_folds
  225. autocmd!
  226. autocmd BufWinLeave *.* mkview
  227. autocmd BufWinEnter *.* loadview
  228. augroup END
  229.  
  230.  
  231. "############## Insert mode mappings ############
  232.  
  233. " Complete sentece/word/code and select fordwards from completition menu
  234. inoremap <leader><Tab> <C-n>
  235.  
  236. " Select backwards from completition menu
  237. " inoremap <S-Tab> <C-p>
  238.  
  239. " CTRL + d = Delete
  240. inoremap <C-d> <Del>
  241.  
  242. " CTRL + h = Backspace
  243. inoremap <C-h> <BS>
  244.  
  245. " Arrow moves
  246. inoremap <C-p> <Up>
  247. inoremap <C-n> <Down>
  248.  
  249. inoremap <C-b> <Left>
  250. inoremap <C-f> <Right>
  251.  
  252. " Move to beginging/end of the line
  253. inoremap <C-e> <C-o><S-$>
  254. inoremap <C-a> <C-o><S-^>
  255.  
  256. " Insert a new line above
  257. inoremap <C-k> <Up><C-o><S-$><CR>
  258.  
  259. " Insert a new line bellow
  260. inoremap <C-j> <C-o><S-$><CR>
  261.  
  262. " Quickly escape
  263. inoremap jj <ESC>
  264.  
  265. "############## Normal mode mapping ##############"
  266.  
  267. " Save and source at once
  268. nnoremap <leader>w <Esc>:w<CR><Esc>:so %<CR>
  269.  
  270. " Same as type ":" colon to type a command in vim
  271. nnoremap <Space> <Esc>:
  272.  
  273. " Close panels/tabs
  274. nnoremap <leader>q <Esc>:q<CR>
  275.  
  276. " Set paste mode
  277. nnoremap <leader>, <Esc>:set paste!<CR>
  278.  
  279. " Copy 'Yank selected text'
  280. nnoremap <leader>y "*y
  281. " PBCOPY
  282. vnoremap <leader>y :!pbcopy<CR>u
  283. " PBPASTE
  284. nnoremap <leader>p :read !pbpaste<CR>
  285.  
  286. " Sort lines ascendently
  287. vnoremap <leader>s :!sort<CR>
  288.  
  289. " Open vimrc in a vertical split window
  290. nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
  291.  
  292. " Reselect text that previously paste
  293. nnoremap <leader>v V`]
  294.  
  295. " Move between panel windows
  296. nnoremap <C-h> <C-w>h
  297. nnoremap <C-j> <C-w>j
  298. nnoremap <C-k> <C-w>k
  299. nnoremap <C-l> <C-w>l
  300.  
  301. " Move lines up/down
  302. nnoremap <leader>2 :m .+1<CR>==
  303. nnoremap <leader>1 :m .-2<CR>==
  304. inoremap <leader>2 <Esc>:m .+1<CR>==gi
  305. inoremap <leader>1 <Esc>:m .-2<CR>==gi
  306. vnoremap <leader>2 :m '>+1<CR>gv=gv
  307. vnoremap <leader>1 :m '<-2<CR>gv=gv
  308.  
  309. " JS and PHP CONSOLE (builds) in split window
  310. command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
  311. function! s:RunShellCommand(cmdline)
  312. let isfirst = 1
  313. let words = []
  314. for word in split(a:cmdline)
  315. if isfirst
  316. let isfirst = 0 " don't change first word (shell command)
  317. else
  318. if word[0] =~ '\v[%#<'
  319. let word = expand(word)
  320. endif
  321. let word = shellescape(word, 1)
  322. endif
  323. call add(words, word)
  324. endfor
  325. let expanded_cmdline = join(words)
  326. botright new
  327. setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
  328. call setline(1, 'You entered: ' . a:cmdline)
  329. call setline(2, 'Expanded to: ' . expanded_cmdline)
  330. call append(line('$'), substitute(getline(2), '.', '=', 'g'))
  331. silent execute '$read !'. expanded_cmdline
  332. 1
  333. endfunction
  334.  
  335. " Command to run JS console with RunJS
  336. command! -complete=file -nargs=* NodeJS call s:RunShellCommand('node '.<q-args>)
  337.  
  338. " Command to run PHP console with PHPBuild
  339. command! -complete=file -nargs=* PHPBuild call s:RunShellCommand('php '.<q-args>)
  340.  
  341. " Keyboard Shorcut for NodeJS % in split window
  342. nnoremap <leader>j <Esc>:w<CR><Esc>:NodeJS %<CR>
  343.  
  344. " Keyboard Shorcut for NodeJS % in split window
  345. " nnoremap <leader>p <Esc>:w<CR><Esc>:PHPBuild %<CR>
  346.  
  347. " Node % in shell
  348. nmap <leader>n <ESC>:!node
  349.  
  350. "############### Plugins ###############"
  351.  
  352. " HTML5 Syntax Hi
  353. let g:html5_event_handler_attributes_complete = 1
  354. let g:html5_rdfa_attributes_complete = 1
  355. let g:html5_microdata_attributes_complete = 1
  356. let g:html5_aria_attributes_complete = 1
  357.  
  358. " Syntastic populate location list with errors
  359. let g:syntastic_always_populate_loc_list = 1
  360.  
  361. " Syntastic will open/close location list automatically
  362. " 0 Not auto
  363. " 1 Automatic
  364. " 2 Not open auto, but closes auto
  365. let g:syntastic_auto_loc_list = 0
  366.  
  367. " Syntastic location list height
  368. let g:syntastic_loc_list_height = 4
  369.  
  370. " Syntastic check on open
  371. let g:syntastic_check_on_open = 1
  372.  
  373. " Syntastic check whenever buffers are wirtten to disk
  374. let g:syntastic_check_on_wq = 1
  375.  
  376. " Syntastic enable all checkers that apply to the current filetype
  377. " including style checkers
  378. let g:syntastic_aggregate_errors = 1
  379. let g:syntastic_id_checkers = 1
  380.  
  381. " Syntastic error symbols
  382. let g:syntastic_error_symbol = "✗"
  383. let g:syntastic_warning_symbol = "⚠"
  384.  
  385. " Syntastic preferences for statusline
  386. set statusline+=%#warningmsg#
  387. set statusline+=%{SyntasticStatuslineFlag()}
  388. set statusline+=%*
  389.  
  390. let g:syntastic_javascript_checkers = ['eslint']
  391. let g:syntastic_html_checkers = ['jshint']
  392. let g:syntastic_css_checkers = ['csslint']
  393. let g:syntastic_php_checkers = ['PHPLint', 'php']
  394.  
  395. " Syntastic Javascript allowed checkers
  396. let g:syntastic_javascript_jshint_exec = '/Users/Stevens/.nvm/versions/node/v6.3.1/bin/jshint' " Syntax checker
  397. let g:syntastic_css_csslint_exec = '/Users/Stevens/.nvm/versions/node/v6.3.1/bin/csslint'
  398.  
  399. " Path /usr/local/Cellar/tidy-html5/4.9.35
  400. let g:syntastic_html_tidy_exec = 'tidy5'
  401.  
  402. " TernJS
  403. let g:tern_show_signature_in_pum = 1
  404. " Enable keyboard shorcuts
  405. let g:tern_map_keys= 1
  406. " Automatic hints after a dealy
  407. let g:tern_show_argument_hints = "on_hold"
  408.  
  409. " Emmet Zen Coding
  410.  
  411. " Emmet only active in HTML and CSS
  412. let g:user_emmet_install_global = 0
  413. autocmd FileType html,css EmmetInstall
  414.  
  415. " Emmet Expand key
  416. let g:user_emmet_leader_key="<Tab>"
  417. let g:use_emmet_complete_tag = 0
  418.  
  419. " Emmet activated in insert mode only. Options n, i, v, a.
  420. let g:user_emmet_mode='i'
  421.  
  422. " TComment
  423. " Make single line comment or comment selected lines
  424. map <leader>c <c-_><c-_>
  425.  
  426. " Lightline
  427. set laststatus=2
  428. set noshowmode
  429. let g:lightline = {
  430. \ 'colorscheme': 'solarized',
  431. \ 'active': {
  432. \ 'left': [ [ 'mode', 'paste' ],
  433. \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
  434. \ },
  435. \ 'component_function': {
  436. \ 'gitbranch': 'fugitive#head'
  437. \ },
  438. \ }
  439.  
  440. " NerdTree Sidebar Explorer
  441. " Autoload if there is no file specified
  442. autocmd StdinReadPre * let s:std_in=1
  443. autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
  444.  
  445. " NerdTree open sidebar
  446. map <leader>m :NERDTreeToggle<CR>
  447.  
  448. " NerdTree closes if is the only one window
  449. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
  450.  
  451. " Show hidden files
  452. let NERDTreeShowHidden=1
  453.  
  454. " Tabularize
  455. " if exists(":Tabularize")
  456. " nmap <leader>a= :Tabularize /=<CR>
  457. " vmap <leader>a= :'<,'>Tabularize /=<CR>
  458. " nmap <leader>a: :Tabularize /:<CR>
  459. " vmap <leader>a: :'<,'>Tabularize /:<CR>
  460. " " nmap <leader>a: :Tabularize /:\zs<CR>
  461. " " vmap <leader>a: :'<,'>Tabularize /:\zs<CR>
  462. " endif
  463.  
  464. " Tabular
  465. inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
  466.  
  467. " Tabular align in realtime when using "|"
  468. function! s:align()
  469. let p = '^\s*|\s.*\s|\s*$'
  470. if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
  471. let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
  472. let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
  473. Tabularize/|/l1
  474. normal! 0
  475. call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
  476. endif
  477. endfunction
  478.  
  479. " YouCompleteMe and UltiSnips compatibility, with the helper of supertab
  480. let g:ycm_key_list_select_completion = ['<A-¶>', '<A-Space>', '<Down>']
  481. let g:ycm_key_list_previous_completion = ['<A-§>', '<A-π>', '<Up>']
  482.  
  483. " Plugin 'ervandew/supertab'
  484. let g:SuperTabDefaultCompletionType = '<A-Space>'
  485. let g:SuperTabCrMapping = 0
  486.  
  487. " Plugin 'SirVer/ultisnips'
  488. let g:UltiSnipsExpandTrigger="<tab>"
  489. let g:UltiSnipsJumpForwardTrigger="<tab>"
  490. let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
  491. let g:snips_author="Stevens Garcia"
  492. let g:snips_author_email="smalmsteeng@gmail.com"
  493.  
  494. let g:UltiSnipsSnippetDirectories=["UltiSnips", "/bundle/vim-snippets"]
  495. " let g:UltiSnipsSnippetDirectories=["UltiSnips"]
  496. let g:UltiSnipsEnableSnipMate = 1
  497. let g:UltiSnipsEditSplit = "vertical"
  498.  
  499. " UltiSnips load javascript snippets order
  500. autocmd FileType javascript UltiSnipsAddFiletypes javascript.javascript-node.javascript-jsdoc.javascript-angular
  501.  
  502. " You Complete Me Options
  503. let g:ycm_show_diagnostics_ui = 0
  504. let g:ycm_enable_diagnostic_highlighting = 0
  505. let g:ycm_enable_diagnostic_signs = 0
  506. let g:ycm_show_diagnostics_ui = 0
  507. let g:ycm_open_loclist_on_ycm_diags = 0
  508. let g:ycm_complete_in_comments = 0
  509. let g:ycm_complete_in_strings = 0
  510. let g:ycm_collect_identifiers_from_comments_and_strings = 0
  511. let g:ycm_collect_identifiers_from_tags_files = 1
  512.  
  513. " let g:ycm_autoclose_preview_window_after_completion = 0
  514. " let g:ycm_autoclose_preview_window_after_insertion = 0
  515.  
  516. " Autotag
  517. let g:autotagTagsFile=".tags"
Add Comment
Please, Sign In to add comment