Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set nocompatible " be iMproved, required
- filetype off " required
- " set the runtime path to include Vundle and initialize
- set rtp+=~/.vim/bundle/Vundle.vim
- call vundle#begin()
- " let Vundle manage Vundle, required
- Plugin 'VundleVim/Vundle.vim'
- Plugin 'artur-shaik/vim-javacomplete2'
- Plugin 'skywind3000/asyncrun.vim'
- Plugin 'kien/ctrlp.vim'
- Plugin 'scrooloose/nerdcommenter'
- Plugin 'AndrewRadev/splitjoin.vim'
- Plugin 'ConradIrwin/vim-bracketed-paste'
- Plugin 'cespare/vim-toml'
- Plugin 'corylanou/vim-present', {'for' : 'present'}
- Plugin 'ekalinin/Dockerfile.vim', {'for' : 'Dockerfile'}
- Plugin 'elzr/vim-json', {'for' : 'json'}
- Plugin 'fatih/vim-go'
- Plugin 'fatih/vim-hclfmt'
- Plugin 'fatih/vim-nginx' , {'for' : 'nginx'}
- Plugin 'godlygeek/tabular'
- Plugin 'hashivim/vim-hashicorp-tools'
- Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
- Plugin 'junegunn/fzf.vim'
- Plugin 'mileszs/ack.vim'
- Plugin 'plasticboy/vim-markdown'
- Plugin 'scrooloose/nerdtree'
- Plugin 't9md/vim-choosewin'
- Plugin 'roxma/vim-tmux-clipboard'
- Plugin 'tmux-plugins/vim-tmux', {'for': 'tmux'}
- Plugin 'tmux-plugins/vim-tmux-focus-events'
- Plugin 'tpope/vim-commentary'
- Plugin 'tpope/vim-eunuch'
- Plugin 'tpope/vim-fugitive'
- Plugin 'tpope/vim-repeat'
- Plugin 'tpope/vim-scriptease'
- Plugin 'ervandew/supertab'
- " All of your Plugins must be added before the following line
- call vundle#end() " required
- filetype plugin indent on " required
- "=====================================================
- "===================== SETTINGS ======================
- set encoding=utf-8 " Set default encoding to UTF-8
- set autoread " Automatically reread changed files without asking me anything
- set autoindent
- set smartindent
- set shiftwidth=4 " Sets indent width to be consistent with netbeans:
- set backspace=indent,eol,start " Makes backspace key more powerful.
- set incsearch " Shows the match while typing
- set hlsearch " Highlight found searches
- set clipboard=unnamed " Changes default clipboard to system
- "set mouse=a "Enable mouse mode
- " Disables automatic comment insertion for newlines
- autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
- set noerrorbells " No beeps
- set number " Show line numbers
- set showcmd " Show me what I'm typing
- set noswapfile " Don't use swapfile
- set nobackup " Don't create annoying backup files
- set splitright " Split vertical windows right to the current windows
- set splitbelow " Split horizontal windows below to the current windows
- set autowrite " Automatically save before :next, :make etc.
- set hidden
- set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
- set noshowmatch " Do not show matching brackets by flickering
- set noshowmode " We show the mode with airline or lightline
- set ignorecase " Search case insensitive...
- set smartcase " ... but not it begins with upper case
- set completeopt=menu,menuone
- set nocursorcolumn " speed up syntax highlighting
- set nocursorline
- set updatetime=300
- set pumheight=10 " Completion window max size
- set conceallevel=2 " Concealed text is completely hidden
- set shortmess+=c " Shut off completion messages
- set belloff+=ctrlg " If Vim beeps during completion
- " increase max memory to show syntax highlighting for large files
- set maxmempattern=20000
- " ~/.viminfo needs to be writable and readable. Set oldfiles to 1000 last
- " recently opened files, :FzfHistory uses it
- set viminfo='1000
- if has('persistent_undo')
- set undofile
- set undodir=~/.cache/vim
- endif
- " color
- colorscheme monokai
- syntax enable
- set background=dark
- "=====================================================
- "===================== STATUSLINE ====================
- " Always show the status line
- set laststatus=2
- let s:modes = {
- \ 'n': 'NORMAL',
- \ 'i': 'INSERT',
- \ 'R': 'REPLACE',
- \ 'v': 'VISUAL',
- \ 'V': 'V-LINE',
- \ "\<C-v>": 'V-BLOCK',
- \ 'c': 'COMMAND',
- \ 's': 'SELECT',
- \ 'S': 'S-LINE',
- \ "\<C-s>": 'S-BLOCK',
- \ 't': 'TERMINAL'
- \}
- let s:prev_mode = ""
- function! StatusLineMode()
- let cur_mode = get(s:modes, mode(), '')
- " do not update higlight if the mode is the same
- if cur_mode == s:prev_mode
- return cur_mode
- endif
- if cur_mode == "NORMAL"
- exe 'hi! StatusLine ctermfg=236'
- exe 'hi! myModeColor cterm=bold ctermbg=148 ctermfg=22'
- elseif cur_mode == "INSERT"
- exe 'hi! myModeColor cterm=bold ctermbg=23 ctermfg=231'
- elseif cur_mode == "VISUAL" || cur_mode == "V-LINE" || cur_mode == "V_BLOCK"
- exe 'hi! StatusLine ctermfg=236'
- exe 'hi! myModeColor cterm=bold ctermbg=208 ctermfg=88'
- endif
- let s:prev_mode = cur_mode
- return cur_mode
- endfunction
- function! StatusLineFiletype()
- return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
- endfunction
- function! StatusLinePercent()
- return (100 * line('.') / line('$')) . '%'
- endfunction
- function! StatusLineLeftInfo()
- let branch = fugitive#head()
- let filename = '' != expand('%:t') ? expand('%:t') : '[No Name]'
- if branch !=# ''
- return printf("%s | %s", branch, filename)
- endif
- return filename
- endfunction
- exe 'hi! myInfoColor ctermbg=240 ctermfg=252'
- " start building our statusline
- set statusline=
- " mode with custom colors
- set statusline+=%#myModeColor#
- set statusline+=%{StatusLineMode()}
- set statusline+=%*
- " left information bar (after mode)
- set statusline+=%#myInfoColor#
- set statusline+=\ %{StatusLineLeftInfo()}
- set statusline+=\ %*
- " go command status (requires vim-go)
- set statusline+=%#goStatuslineColor#
- set statusline+=%{go#statusline#Show()}
- set statusline+=%*
- " right section seperator
- set statusline+=%=
- " filetype, percentage, line number and column number
- set statusline+=%#myInfoColor#
- set statusline+=\ %{StatusLineFiletype()}\ %{StatusLinePercent()}\ %l:%v
- set statusline+=\ %*
- "=====================================================
- "===================== MAPPINGS ======================
- " This comes first, because we have mappings that depend on leader
- " With a map leader it's possible to do extra key combinations
- " i.e: <leader>w saves the current file
- let mapleader = ","
- " Some useful quickfix shortcuts for quickfix
- map <C-n> :cn<CR>
- map <C-m> :cp<CR>
- nnoremap <leader>a :cclose<CR>
- " Fast saving
- nnoremap <leader>w :w!<cr>
- nnoremap <silent> <leader>q :q!<CR>
- " Center the screen
- nnoremap <space> zz
- " Remove search highlight
- nnoremap <leader><space> :nohlsearch<CR>
- function! s:clear_highlight()
- let @/ = ""
- call go#guru#ClearSameIds()
- endfunction
- nnoremap <silent> <leader><space> :<C-u>call <SID>clear_highlight()<CR>
- " Source the current Vim file
- nnoremap <leader>pr :Runtime<CR>
- " Close all but the current one
- nnoremap <leader>o :only<CR>
- " Better split switching
- map <C-j> <C-W>j
- map <C-k> <C-W>k
- map <C-h> <C-W>h
- map <C-l> <C-W>l
- " Print full path
- map <C-p> :echo expand("%:p")<cr>
- " Visual linewise up and down by default (and use gj gk to go quicker)
- noremap <Up> gk
- noremap <Down> gj
- noremap j gj
- noremap k gk
- " Exit on j
- imap jj <Esc>
- " Source (reload configuration)
- nnoremap <silent> <F5> :source $MNVIMRC<CR>
- nnoremap <F6> :setlocal spell! spell?<CR>
- " Search mappings: These will make it so that going to the next one in a
- " search will center on the line it's found in.
- nnoremap n nzzzv
- nnoremap N Nzzzv
- " Same when moving up and down
- noremap <C-d> <C-d>zz
- noremap <C-u> <C-u>zz
- " Remap H and L (top, bottom of screen to left and right end of line)
- nnoremap H ^
- nnoremap L $
- vnoremap H ^
- vnoremap L g_
- " Act like D and C
- nnoremap Y y$
- " Do not show stupid q: window
- map q: :q
- " Don't move on * I'd use a function for this but Vim clobbers the last search
- " when you're in a function so fuck it, practicality beats purity.
- nnoremap <silent> * :let stay_star_view = winsaveview()<cr>*:call winrestview(stay_star_view)<cr>
- " mimic the behavior of /%Vfoobar which searches within the previously
- " selected visual selection
- " while in search mode, pressing / will do this
- vnoremap / <Esc>/\%><C-R>=line("'<")-1<CR>l\%<<C-R>=line("'>")+1<CR>l
- vnoremap ? <Esc>?\%><C-R>=line("'<")-1<CR>l\%<<C-R>=line("'>")+1<CR>l
- " Time out on key codes but not mappings.
- " Basically this makes terminal Vim work sanely.
- if !has('gui_running')
- set notimeout
- set ttimeout
- set ttimeoutlen=10
- augroup FastEscape
- autocmd!
- au InsertEnter * set timeoutlen=0
- au InsertLeave * set timeoutlen=1000
- augroup END
- endif
- " Visual Mode */# from Scrooloose {{{
- function! s:VSetSearch()
- let temp = @@
- norm! gvy
- let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
- let @@ = temp
- endfunction
- vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o>
- vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
- " create a go doc comment based on the word under the cursor
- function! s:create_go_doc_comment()
- norm "zyiw
- execute ":put! z"
- execute ":norm I// \<Esc>$"
- endfunction
- nnoremap <leader>ui :<C-u>call <SID>create_go_doc_comment()<CR>
- "===================== PLUGINS ======================
- " plugins expect bash - not fish, zsh, etc
- set shell=bash
- " pathogen will load the other modules
- execute pathogen#infect()
- " use goimports for formatting
- let g:go_fmt_command = "goimports"
- " turn highlighting on
- let g:go_highlight_functions = 1
- let g:go_highlight_methods = 1
- let g:go_highlight_structs = 1
- let g:go_highlight_operators = 1
- let g:go_highlight_build_constraints = 1
- let g:syntastic_go_checkers = ['go', 'golint', 'errcheck']
- let g:go_modifytags_transform = 'camelcase'
- let g:go_fold_enable = []
- nmap <C-g> :GoDecls<cr>
- imap <C-g> <esc>:<C-u>GoDecls<cr>
- " Open go doc in vertical window, horizontal, or tab
- au Filetype go nnoremap <leader>v :vsp <CR>:exe "GoDef" <CR>
- au Filetype go nnoremap <leader>s :sp <CR>:exe "GoDef"<CR>
- au Filetype go nnoremap <leader>t :tab split <CR>:exe "GoDef"<CR>
- " run :GoBuild or :GoTestCompile based on the go file
- function! s:build_go_files()
- let l:file = expand('%')
- if l:file =~# '^\f\+_test\.go$'
- call go#test#Test(0, 1)
- elseif l:file =~# '^\f\+\.go$'
- call go#cmd#Build(0)
- endif
- endfunction
- augroup go
- autocmd!
- autocmd FileType go nmap <silent> <leader>b :<C-u>call <SID>build_go_files()<CR>
- autocmd FileType go nmap <silent> <leader>t <Plug>(go-test)
- autocmd FileType go nmap <silent> <leader>r <Plug>(go-run)
- autocmd FileType go nmap <silent> <leader>e <Plug>(go-install)
- " TEST FOR python TODO
- " autocmd FileType py nmap <silent> <leader>r <!python %>
- " we want to tell the syntastic module when to run
- " we want to see code highlighting and checks when we open a file
- " but we don't care so much that it reruns when we close the file
- let g:syntastic_check_on_open = 1
- let g:syntastic_check_on_wq = 0
- " we also want to get rid of accidental trailing whitespace on save
- autocmd BufWritePre * :%s/\s\+$//e
- " tell vim to allow you to copy between files, remember your cursor
- " position and other little nice things like that
- set viminfo='100,\"2500,:200,%,n~/.viminfo
- " ==================== Fugitive ====================
- vnoremap <leader>gb :Gblame<CR>
- nnoremap <leader>gb :Gblame<CR>
- " ==================== NerdTree ====================
- " For toggling
- noremap <Leader>n :NERDTreeToggle<cr>
- noremap <Leader>f :NERDTreeFind<cr>
- let NERDTreeShowHidden=1
- " ==================== ag ====================
- let g:ackprg = 'ag --vimgrep --smart-case'
- " ==================== NerdCommenter ====================
- " Add spaces after comment delimiters by default
- let g:NERDSpaceDelims = 1
- " Quick Run
- " Quick run via <F5>
- nnoremap <Leader>r :call <SID>compile_and_run()<CR>
- function! s:compile_and_run()
- exec 'w'
- if &filetype == 'c'
- exec "AsyncRun! gcc % -o %<; time ./%<"
- elseif &filetype == 'cpp'
- exec "AsyncRun! g++ -std=c++11 % -o %<; time ./%<"
- elseif &filetype == 'java'
- exec "AsyncRun! javac %; time java %<"
- elseif &filetype == 'sh'
- exec "AsyncRun! time bash %"
- elseif &filetype == 'python'
- exec "AsyncRun! time python %"
- endif
- endfunction
- " Deprecated:
- " augroup SPACEVIM_ASYNCRUN
- " autocmd!
- " " Automatically open the quickfix window
- " autocmd User AsyncRunStart call asyncrun#quickfix_toggle(15, 1)
- " augroup END
- "
- " asyncrun now has an option for opening quickfix automatically
- let g:asyncrun_open = 15
- " TRY OR DELETE!!
- :" Only do this part when compiled with support for autocommands.
- if has("autocmd")
- autocmd Filetype java setlocal omnifunc=javacomplete#Complete
- endif
- setlocal omnifunc=javacomplete#Complete
- helptags $HOME/.vim/doc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement