Advertisement
Guest User

my vimrc

a guest
Aug 9th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 10.58 KB | None | 0 0
  1. """""""""""""""""""""""""""""""""""""
  2. " Michael Leon Vimrc configuration
  3. """""""""""""""""""""""""""""""""""""
  4. set nocompatible
  5. syntax on
  6. set nowrap
  7. set encoding=utf8
  8.  
  9. """" START Vundle Configuration
  10.  
  11. " Disable file type for vundle
  12. filetype off                  " required
  13.  
  14. " set the runtime path to include Vundle and initialize
  15. set rtp+=~/.vim/bundle/Vundle.vim
  16. call vundle#begin()
  17.  
  18. " let Vundle manage Vundle, required
  19. Plugin 'gmarik/Vundle.vim'
  20.  
  21. " Utility
  22. Plugin 'ctrlpvim/ctrlp.vim'
  23. Plugin 'scrooloose/nerdtree'
  24. Plugin 'morhetz/gruvbox'
  25. Plugin 'sheerun/vim-polyglot'
  26. Plugin 'vim-airline/vim-airline'
  27. Plugin 'airblade/vim-gitgutter'
  28. Plugin 'majutsushi/tagbar'
  29. Plugin 'universal-ctags/ctags'
  30. Plugin 'tomtom/tcomment_vim'
  31. Plugin 'scrooloose/syntastic'
  32. Plugin 'SirVer/ultisnips'
  33. Plugin 'honza/vim-snippets'
  34. Plugin 'bergercookie/vim-debugstring'
  35.  
  36. " for react
  37. Plugin 'pangloss/vim-javascript'
  38.  
  39. " textobjects
  40. Plugin 'kana/vim-textobj-user'
  41. Plugin 'kana/vim-textobj-indent'
  42.  
  43. " Themes
  44. Plugin 'ryanoasis/vim-devicons'
  45.  
  46. call vundle#end()            " required
  47. filetype plugin on    " required
  48. filetype plugin indent on    " required
  49. """" END Vundle Configuration
  50.  
  51.  
  52. """""""""""""""""""""""""""""""""""""
  53. " Configuration Section
  54. """""""""""""""""""""""""""""""""""""
  55.  
  56. augroup basic_settings
  57.   " set space as leader!!
  58.   map <space> <leader>
  59.  
  60.   " Show linenumbers
  61.   set number
  62.   set relativenumber
  63.   set ruler
  64.  
  65.   " highlight/searching
  66.   set incsearch
  67.   set hls
  68.  
  69.   " tab settings
  70.   set smartindent   " Do smart autoindenting when starting a new line
  71.   set shiftwidth=2  " Set number of spaces per auto indentation
  72.   set expandtab     " When using <Tab>, put spaces instead of a <tab> character
  73.  
  74.   " good to have for consistency
  75.   set tabstop=2   " Number of spaces that a <Tab> in the file counts for
  76.   set smarttab    " At <Tab> at beginning line inserts spaces set in shiftwidth
  77.  
  78.   " change buffers without saving
  79.   set hidden
  80.  
  81.   " Always display the status line
  82.   set laststatus=2
  83.  
  84.   " Enable highlighting of the current line
  85.   set cursorline
  86.  
  87.   " react snippets are also available in .js files
  88.   let g:jsx_ext_required = 0
  89.  
  90.   " left/right moves past newline
  91.   set whichwrap+=<,>,h,l,[,]
  92.  
  93. augroup end
  94.  
  95. " activate relative numbers in windows spawned by plugins
  96. augroup rel_numbers
  97.   " Tagbar
  98.   let g:tabgar_autofocus=1
  99.   let g:tagbar_show_linenumbers = -1
  100.   "
  101.   " enable line numbers
  102.   let NERDTreeShowLineNumbers=1
  103.   autocmd FileType nerdtree setlocal relativenumber
  104.   let NERDTreeIgnore = ['\.pyc$']
  105. augroup end
  106.  
  107. """""""""""""""""""""""""""""""""""""
  108. " Mappings configurationn
  109. """""""""""""""""""""""""""""""""""""
  110. augroup mappings
  111.   nnoremap <C-x> :NERDTreeToggle<CR>
  112.   nnoremap <C-t> :TagbarToggle<CR>
  113.   nnoremap <C-g> :GitGutterAll<CR>
  114.   nnoremap <leader>c :!ctags -R<CR>
  115.   nnoremap <leader>g :!gotags -R . > tags<CR>
  116.   nnoremap <leader>j :tjump /
  117.   nnoremap <leader>m :CtrlPTag<CR>
  118.  
  119.   " No ARRRROWWS!!!!
  120.   nnoremap <Up>    :resize +2<CR>
  121.   nnoremap <Down>  :resize -2<CR>
  122.   nnoremap <Left>  :vertical resize +2<CR>
  123.   nnoremap <Right> :vertical resize -2<CR>
  124.  
  125.   " search in visual mode
  126.   vnoremap // y/<C-R>"<CR>
  127.  
  128.   " set b/l to go to begin or end of line
  129.   nnoremap <leader>b ^
  130.   nnoremap <leader>l $
  131.   vnoremap <leader>b ^
  132.   vnoremap <leader>l $
  133.  
  134.   " U reverts file to last save
  135.   nnoremap U :e!<CR>
  136.  
  137.   " have Y mimic D and C etc
  138.   nnoremap Y y$
  139.  
  140.   " source current file easily
  141.   nnoremap <leader>s <ESC>:source<Space>%<CR>
  142.  
  143.   " make o turn off highlight
  144.   nnoremap <leader>o <ESC>:noh<CR>
  145.   " make O turn on highlight
  146.   nnoremap <leader>O <ESC>:set hls<CR>
  147.  
  148.   " this is for easy buffer access
  149.   nnoremap gb :ls<CR>:b<Space>
  150.  
  151.   " Syntastic toggle
  152.   nnoremap <leader>e :<C-u>call ToggleErrors()<CR>
  153.  
  154.   " ctrl b gets caught by tmux, so use ctrl-k instead
  155.   nnoremap <C-k> <C-b>
  156.  
  157.   " ctrl f gets caught by tmux, so use ctrl-j instead
  158.   nnoremap <C-j> <C-f>
  159.  
  160.   " re-purpose pgup and pgdwn to more useful commands
  161.   nnoremap <PageUp> <ESC>:bnext<CR>
  162.   nnoremap <PageDown> <ESC>:bprev<CR>
  163.  
  164.   " make new lines while staying where you are
  165.   nnoremap <leader>i mlo<ESC>`l
  166.   nnoremap <leader>I mlO<ESC>`l
  167.  
  168.   " surround current line with a newlines above and below
  169.   nnoremap <leader>S mlO<ESC>jo<ESC>`l
  170.  
  171.   " Re-order lines
  172.   nnoremap J :let c=col(".")<CR>:execute "normal! ddp" . c . "\|"<CR>
  173.   nnoremap K :let c=col(".")<CR>:execute "normal! ddkP" . c . "\|"<CR>
  174.  
  175.   " Re-order lines while staying in visual mode
  176.   vnoremap J <ESC>:execute "normal! gvdpV" . (line("'>") - line("'<")) ."j"<CR>
  177.   vnoremap K <ESC>:execute "normal! gvdkPV" . (line("'>") - line("'<")) ."j"<CR>
  178.   " using the move command is slower for some reason
  179.   " vnoremap J :m '>+1<CR>gv=gv
  180.  
  181.   " Shift text around in character visual mode, only use with one line selection
  182.   vnoremap L <ESC>:execute "normal! gvdpv" . (col("'>") - col("'<")) ."h"<CR>
  183.   vnoremap H <ESC>:execute "normal! gvdhPv" . (col("'>") - col("'<")) ."h"<CR>
  184.  
  185.   " swap ` and '
  186.   nnoremap ' `
  187.  nnoremap ` '
  188.  
  189.   " search current word but not move your cursor position
  190.   nnoremap S ml*`l
  191.  
  192.   " d
  193.   nnoremap <leader>r ml*`lcgn
  194.   nnoremap <leader>R ml*`lcgN
  195.  
  196.   nnoremap Q :q<CR>
  197. augroup end
  198.  
  199. augroup tmux
  200.   " rerun the last command in the rightmost pane
  201.   nnoremap <Leader>tR :silent !tmux send-keys -t \\! "Up" C-m <CR> <C-l>
  202.   " rerun the last command, leave fullscreen first
  203.   nnoremap <Leader>tr :silent !tmux resize-pane -Z<CR> :silent !tmux send-keys -t \\! "Up" C-m <CR> <C-l>
  204.   " rerun the last two command in the rightmost pane
  205.   nnoremap <Leader>2tR :silent !tmux send-keys -t \\! "Up" "Up" C-m <CR>:silent !tmux send-keys -t \\! "Up" "Up" C-m <CR> <C-l>
  206.   " rerun the last two command, leave fullscreen first
  207.   nnoremap <Leader>2tr :silent !tmux resize-pane -Z<CR> :silent !tmux send-keys -t \\! "Up" "Up" C-m <CR>:silent !tmux send-keys "Up" "Up" C-m <CR> <C-l>
  208.   " like tr but a 'force run' -- run Ctrl-C first
  209.   " like tr but a 'force run' -- run Ctrl-C first
  210.   nnoremap <Leader>tf :silent !tmux resize-pane -Z<CR> :silent !tmux send-keys -t \\! C-c<CR>:silent !tmux send-keys -t right "Up" C-m <CR> <C-l>
  211.   " like tR but a 'force run' -- run Ctrl-C first
  212.   nnoremap <Leader>tF :silent !tmux send-keys -t right C-c<CR>:silent !tmux send-keys -t \\! "Up" C-m <CR> <C-l>
  213.  
  214.   " rerun the last command in the rightmost pane, leave fullscreen and exit insert mode and save file
  215.   inoremap jk <ESC>:w<CR>:silent !tmux resize-pane -Z<CR> :silent !tmux send-keys -t right "Up" C-m <CR> <C-l>
  216.   " rerun the last command in the rightmost pane, and exit insert mode and save file
  217.   inoremap jK <ESC>:w<CR>:silent !tmux send-keys -t right "Up" C-m <CR> <C-l>
  218.  
  219.   " close the current process rerun the last command in the rightmost pane, leave fullscreen and exit insert mode and save file
  220.   inoremap jf <ESC>:w<CR>:silent !tmux resize-pane -Z<CR>:silent !tmux send-keys -t right C-c<CR>:silent !tmux send-keys -t right "Up" C-m <CR> <C-l>
  221.   " close the current process rerun the last command in the rightmost pane, and exit insert mode and save file
  222.   inoremap jF <ESC>:w<CR>:silent !tmux send-keys -t right C-c<CR>:silent !tmux send-keys -t right "Up" C-m <CR> <C-l>
  223.  
  224.   " kill the program running in the last active tmux pane
  225.   nnoremap <Leader>tc :silent !tmux send-keys -t \\! C-c <CR> <C-l>
  226.  
  227.   " send current line to last active pane -- VERY BUGGY
  228.   nnoremap <Leader>tp :exe "!tmux send-keys -t \\! \"" . getline(".") . "\" C-m" <CR> <C-l>
  229.   " send selected visual area to last active tmux pane -- VERY BUGGY
  230.   vnoremap <Leader>tp <ESC>:exe "!tmux send-keys -t \\! \"" . @* . "\" C-m" <CR> <C-l>
  231.  
  232.   " Launch a python shell interpreter in last active pane
  233.   nnoremap <Leader>tip :silent !tmux send-keys -t \\! "python3.6" C-m "import numpy as np" C-m<CR> <C-l> :silent !tmux select-pane -t \\!<CR>
  234.   " Launch a javascript shell interpreter in last active pane
  235.   nnoremap <Leader>tij :silent !tmux send-keys -t \\! "node" C-m <CR> <C-l> :silent !tmux select-pane -t \\!<CR>
  236.   " Launch a javascript shell interpreter in last active pane
  237.   nnoremap <Leader>tir :silent !tmux send-keys -t \\! "irb" C-m <CR> <C-l> :silent !tmux select-pane -t \\!<CR>
  238. augroup end
  239.  
  240. augroup pending
  241.   " make in( behave like the text object i"
  242.   onoremap in( :<c-u>normal! f(vi(<cr>
  243.  
  244.   " make in[ behave like the text object i"
  245.   onoremap in[ :<c-u>normal! f[vi[<cr>
  246.  
  247.   " make in{ behave like the text object i"
  248.   onoremap in{ :<c-u>normal! f{vi{<cr>
  249.  
  250.   " operate inside last pair of parenthesis
  251.   onoremap il( :<c-u>normal! F)vi(<cr>
  252.  
  253.   " textobject for underscore
  254.   onoremap i_ :<c-u>execute "normal! /_\\\|)\\\|,\\\|\\s\rhvNl" \| set nohlsearch<cr>
  255.   onoremap a_ :<c-u>execute "normal! /_\\\|)\\\|,\\\|\\s\rhvN" \| set nohlsearch<cr>
  256.  
  257.   " set b/l to go to begin or end of line
  258.   onoremap <leader>b ^
  259.   onoremap <leader>l $
  260.  
  261.   " Motion for going to previous set of quotes
  262.   onoremap I" :<c-u>normal! F"vi"<cr>
  263.  
  264.   " Motion for targeting current word, and also searching it
  265.   onoremap gf :<c-u>execute "normal! ml*`lviw"<cr>
  266. augroup end
  267.  
  268. augroup golang
  269.   let g:tagbar_type_go = {
  270.         \ 'ctagstype' : 'go',
  271.         \ 'kinds'     : [
  272.         \ 'p:package',
  273.         \ 'i:imports:1',
  274.         \ 'c:constants',
  275.         \ 'v:variables',
  276.         \ 't:types',
  277.         \ 'n:interfaces',
  278.         \ 'w:fields',
  279.         \ 'e:embedded',
  280.         \ 'm:methods',
  281.         \ 'r:constructor',
  282.         \ 'f:functions'
  283.         \ ],
  284.         \ 'sro' : '.',
  285.         \ 'kind2scope' : {
  286.         \ 't' : 'ctype',
  287.         \ 'n' : 'ntype'
  288.         \ },
  289.         \ 'scope2kind' : {
  290.         \ 'ctype' : 't',
  291.         \ 'ntype' : 'n'
  292.         \ },
  293.         \ 'ctagsbin'  : 'gotags',
  294.         \ 'ctagsargs' : '-sort -silent'
  295.         \ }
  296. augroup end
  297.  
  298. augroup styling
  299.   " for devicons
  300.   set encoding=UTF-8
  301.   let g:airline_powerline_fonts = 1
  302.  
  303.   " colorscheme space-vim-dark
  304.   colorscheme gruvbox
  305.   " colorscheme dracula
  306.   set bg=dark
  307. augroup end
  308.  
  309. " Snytastic stuff
  310. function! ToggleErrors()
  311.   let old_last_winnr = winnr('$')
  312.   lclose
  313.   if old_last_winnr == winnr('$')
  314.     " Nothing was closed, open syntastic error location panel
  315.     Errors
  316.   endif
  317. endfunction
  318.  
  319. if has("autocmd")
  320.   au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  321. endif
  322.  
  323. let g:syntastic_go_checkers = ['govet']
  324. let g:syntastic_c_checkers = ["make"]
  325. let g:syntastic_python_checkers = ["pylint"]
  326. let g:syntastic_javascript_checkers = ['eslint']
  327. let g:syntastic_cpp_checkers = ["make"]
  328. let g:syntastic_always_populate_loc_list = 1
  329. let g:syntastic_auto_loc_list = 1
  330. let g:syntastic_check_on_open = 1
  331. let g:syntastic_check_on_wq = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement