Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 8.36 KB | None | 0 0
  1. let mapleader ="ç"
  2.  
  3. " Vim-plug
  4. call plug#begin('~/.config/nvim/plugged')
  5. Plug 'bling/vim-airline'
  6. Plug 'dhruvasagar/vim-table-mode'
  7. Plug 'drmingdrmer/vim-toggle-quickfix'
  8. Plug 'dyng/ctrlsf.vim'
  9. Plug 'gorodinskiy/vim-coloresque', {'for': ['css', 'html']}
  10. Plug 'haya14busa/incsearch.vim'
  11. Plug 'honza/vim-snippets'
  12. Plug 'junegunn/fzf.vim'
  13. Plug 'junegunn/goyo.vim'
  14. Plug 'luochen1990/rainbow'
  15. Plug 'majutsushi/tagbar' " F9
  16. Plug 'othree/html5.vim'
  17. Plug 'pbrisbin/vim-mkdir'
  18. Plug 'scrooloose/nerdtree'
  19. Plug 'sheerun/vim-polyglot'
  20. Plug 'SirVer/ultisnips'
  21. Plug 'suan/vim-instant-markdown'
  22. Plug 'Townk/vim-autoclose'
  23. Plug 'tpope/vim-commentary'
  24. Plug 'tpope/vim-fugitive'
  25. Plug 'tpope/vim-repeat'
  26. Plug 'tpope/vim-speeddating'
  27. Plug 'tpope/vim-surround'
  28. Plug 'vim-scripts/a.vim'
  29. Plug 'vim-scripts/repmo.vim'
  30. Plug 'vimwiki/vimwiki'
  31. Plug 'w0rp/ale' " Linter
  32. Plug 'wesQ3/vim-windowswap'
  33. " vim-devicons should be the last plugin
  34. Plug 'ryanoasis/vim-devicons'
  35. call plug#end()
  36. " fugitive // gitgutter
  37. " command -bang -nargs=? QFix call QFixToggle(<bang>0)
  38. function! QFixToggle()
  39.     if exists("g:qfix_win")
  40.         cclose
  41.         unlet g:qfix_win
  42.     else
  43.         copen 10
  44.         let g:qfix_win = bufnr("$")
  45.     endif
  46. endfunction
  47.  
  48. " IncSearch default bindings
  49. map /  <Plug>(incsearch-forward)
  50. map ?  <Plug>(incsearch-backward)
  51. map g/ <Plug>(incsearch-stay)
  52. map <leader>h :set hlsearch!<cr>
  53. nnoremap <C-S> :CtrlSF
  54.  
  55. xmap <C-B> g<C-A>
  56.  
  57. " Multiple definitions of variables for plugins
  58. " Airline tuning
  59. let g:airline#extensions#tabline#enabled = 1
  60. let g:airline#extensions#tabline#show_buffers = 1
  61. let g:airline#extensions#tabline#show_tabs = 1
  62. let g:airline_theme='minimalist'
  63. let g:ale_lint_on_enter = 0
  64. let g:ale_set_loclist = 0
  65. let g:ale_set_quickfix = 1
  66. let g:ctrlsf_auto_close =  {"normal" : 1, "compact": 1 }
  67. let g:ctrlsf_auto_focus = { "at": "done", "duration_less_than": 2000 }
  68. let g:ctrlsf_context = '-B 0 -A 0'
  69. let g:ctrlsf_default_view_mode = 'compact'
  70. let g:ctrlsf_regex_pattern = 1
  71. let g:fzf_layout = { 'down': '~15%' }
  72. let g:goyo_height=40
  73. let g:goyo_width=100
  74. let g:instant_markdown_autostart = 0
  75. let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'
  76. let g:rainbow_active = 1
  77. let g:vimwiki_ext2syntax = {}
  78. " vimwiki files changed to .markdown for the sake of having different syntax highlighting/bindings
  79. let g:vimwiki_list = [{'path': '~/vimwiki','syntax': 'markdown', 'ext': '.markdown'}]
  80. " NERDTree
  81. let NERDTreeAutoDeleteBuffer = 1
  82. let NERDTreeDirArrows = 1
  83. let NERDTreeMinimalUI = 1
  84. let NERDTreeQuitOnOpen=1
  85. set diffopt+=vertical
  86. " Trigger configuration for UltiSnips
  87. let g:UltiSnipsExpandTrigger="<tab>"
  88. let g:UltiSnipsJumpForwardTrigger="<c-space>"
  89. let g:UltiSnipsJumpBackwardTrigger="<c-g>"
  90. " If you want :UltiSnipsEdit to split your window.
  91. let g:UltiSnipsEditSplit="vertical"
  92.  
  93. " Basic definitions
  94. set nocompatible
  95. nnoremap c "_c
  96. filetype on
  97. syntax on
  98. autocmd BufRead,BufNewFile * ALEDisable
  99. set autoread
  100. set clipboard=unnamedplus " Requires Nvim
  101. set encoding=UTF-8
  102. set foldlevel=1
  103. set foldmethod=manual
  104. set hidden
  105. set ignorecase
  106. " set list lcs=tab:\┊\ "
  107. set list lcs=tab:\|\ "
  108. set magic " apaga y vamonos
  109. set modelines=1
  110. set mouse=a
  111. set nohlsearch " Incsearch is enough
  112. set noshowmode " Mode is up on vim-airline
  113. set number relativenumber
  114. set numberwidth=4
  115. set scrolloff=1
  116. set shiftwidth=4
  117. set shortmess=atI
  118. set smartcase
  119. set spelllang=es
  120. set splitbelow splitright
  121. set tabstop=4
  122. set undodir=~/.vim/undo
  123. set undofile
  124. set wildmode=longest,list,full
  125. set wrap
  126.  
  127. vmap a A
  128. vmap i I
  129.  
  130. " Move visual blocks vertically
  131. vnoremap J :m '>+1<CR>gv=gv
  132. vnoremap K :m '<-2<CR>gv=gv
  133.  
  134. " Open ex mode on return press
  135. nnoremap <CR> :
  136.  
  137. " Center on search
  138. nnoremap n nzzzv
  139. nnoremap N Nzzzv
  140.  
  141. "Remove all comments
  142. nnoremap <leader>v :g/^#/d_<cr>
  143.  
  144. " Maintain Visual Mode after shifting > and <
  145. vmap < <gv
  146. vmap > >gv
  147.  
  148. " Tagbar
  149. nmap <F9> :TagbarToggle<CR>
  150.  
  151. " Quickfix List
  152. nmap <silent> <leader>q :call QFixToggle()<CR>
  153.  
  154. " Editing vimrc in vim
  155. nnoremap <leader>ev :vspl $MYVIMRC<cr>
  156. nnoremap <leader>sv :source $MYVIMRC<cr>
  157.  
  158. " 0 goes to the first character instead of the indent
  159. nnoremap 0 ^
  160.  
  161. " Buffer movement
  162. nnoremap <S-Tab> :bp<cr>
  163. nnoremap <Tab> :bn<cr>
  164.  
  165. "Resizing splits
  166. nnoremap <F5> :vertical resize +5<cr>
  167. nnoremap <F2> :vertical resize -5<cr>
  168. nnoremap <F4> :resize +5<cr>
  169. nnoremap <F3> :resize -5<cr>
  170.  
  171. " Table mode
  172. nnoremap <F6> :TableModeToggle<cr>
  173.  
  174. " Goyo - Distraction free typing
  175. map <leader>f :Goyo \| set linebreak<CR>
  176.  
  177. " Spell-check toggle with <leader>o
  178. map <leader>o :setlocal spell! <CR>
  179.  
  180. " Fuzzy finder
  181. nnoremap <silent> <expr> <C-f> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":FZF\<cr>"
  182.  
  183. " Leah Rowe movement
  184. map <C-h> <C-w>h
  185. map <C-j> <C-w>j
  186. map <C-k> <C-w>k
  187. map <C-l> <C-w>l
  188.  
  189. " Replace all with S
  190. nnoremap S :%s/\v/g<Left><Left>
  191.  
  192. " Allow saving of files as sudo when I forgot to start vim using sudo.
  193. cmap w!! w !sudo /usr/bin/tee > /dev/null %
  194.  
  195. " Indent whole file
  196. nnoremap <leader>i gg=G<C-o>
  197. " Compile document (saves file)
  198. map <leader>c :w! \| !compiler <c-r>% <CR>
  199. map <leader>x :ALEToggle<cr>
  200.  
  201. " Remove ex mode
  202. nnoremap Q <nop>
  203.  
  204. " Remove annoying tutorial
  205. nnoremap <F1> <nop>
  206.  
  207. " Open corresponding .pdf/.html or preview
  208. map <leader>p :!opout <c-r>%<CR><CR>
  209.  
  210. " Automatically deletes all trailing whitespace on save
  211. autocmd BufWritePre * %s/\s\+$//e
  212.  
  213. " Disables automatic commenting on newline
  214. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  215.  
  216. " Nerd tree
  217. map <C-n> :NERDTreeToggle<CR>
  218. " Closes if only tab is NERDTree
  219. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
  220.  
  221. " Terminal emulator bindings
  222. if has('nvim')
  223. au TermOpen * setlocal nonumber norelativenumber
  224. tnoremap <Esc> <C-\><C-n>
  225. au TermOpen  * setlocal nonumber | startinsert
  226. au TermClose * setlocal   number | call feedkeys("\<C-\>\<C-n>")
  227. endif
  228.  
  229. " Sets commentary on c as //
  230. autocmd FileType c,cpp,cs,java setlocal commentstring=//\ %s
  231.  
  232. " Cleans out tex build files on file close
  233. autocmd VimLeave *.tex !texclear %
  234. autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
  235. autocmd FileType pandoc set syntax=markdown
  236. autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
  237. autocmd BufRead,BufNewFile *.tex set filetype=tex
  238.  
  239. " When shortcut files are updated, renew bash and ranger configs with new material
  240. autocmd BufWritePost ~/.bmdirs,~/.bmfiles !shortcuts
  241.  
  242. " Run xrdb whenever Xdefaults or Xresources are updated.
  243. autocmd BufWritePost ~/.Xresources,~/.Xdefaults !xrdb %
  244.  
  245. " Autocompile vimwiki to html
  246. autocmd BufWritePost ~/main/vimwiki/*.markdown !compiler % &
  247.  
  248. " Auto source .vimrc when saved. Nvim friendly
  249. autocmd! BufWritePost ~/.vimrc,~/.config/nvim/init.vim source $MYVIMRC
  250.  
  251. " Too big to be with the rest of the variable definitions
  252. let g:rainbow_conf = {
  253. \   'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
  254. \   'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
  255. \   'operators': '_,_',
  256. \   'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
  257. \   'separately': {
  258. \       '*': {},
  259. \       'tex': {
  260. \           'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
  261. \       },
  262. \       'lisp': {
  263. \           'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
  264. \       },
  265. \       'vim': {
  266. \           'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
  267. \       },
  268. \       'html': {
  269. \           'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
  270. \       },
  271. \       'css': 0,
  272. \   }
  273. \}
  274.  
  275. if exists('$TMUX')
  276.     let &t_SI = "\<Esc>Ptmux;\<Esc>\e[5 q\<Esc>\\"
  277.     let &t_EI = "\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\"
  278.  else
  279.     let &t_SI = "\e[5 q"
  280.     let &t_EI = "\e[2 q"
  281. endif
  282.  
  283. set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
  284. \,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
  285. \,sm:block-blinkwait175-blinkoff150-blinkon175
  286.  
  287. " augroup vimrc
  288. "   au BufReadPre * setlocal foldmethod=indent
  289. "   au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
  290. "   au BufWinEnter * norm zR
  291. " augroup END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement