Created
January 14, 2018 10:57
-
-
Save absk1317/e1670cf3998815fbefac7cad0ce74932 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Start of Vundle settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
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() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
" The following are examples of different formats supported. | |
" Keep Plugin commands between vundle#begin/end. | |
" plugin on GitHub repo | |
Plugin 'tpope/vim-fugitive' | |
" https://github.com/ctrlpvim/ctrlp.vim | |
Plugin 'ctrlpvim/ctrlp.vim' | |
" https://github.com/vim-airline/vim-airline | |
Plugin 'vim-airline/vim-airline' | |
" https://github.com/terryma/vim-multiple-cursors | |
Plugin 'terryma/vim-multiple-cursors' | |
" https://github.com/tacahiroy/ctrlp-funky | |
Plugin 'tacahiroy/ctrlp-funky' | |
" https://github.com/mileszs/ack.vim | |
Plugin 'mileszs/ack.vim' | |
" https://github.com/easymotion/vim-easymotion | |
Plugin 'easymotion/vim-easymotion' | |
" https://github.com/haya14busa/incsearch.vim | |
Plugin 'haya14busa/incsearch.vim' | |
" https://github.com/tpope/vim-repeat | |
Plugin 'tpope/vim-repeat' | |
" https://github.com/plasticboy/vim-markdown | |
Plugin 'godlygeek/tabular' " Dependency for vim-markdown | |
Plugin 'plasticboy/vim-markdown' | |
" https://github.com/Shougo/neocomplete.vim | |
Plugin 'Shougo/neocomplete.vim' | |
" https://github.com/vim-scripts/AnsiEsc.vim | |
Plugin 'AnsiEsc.vim' | |
" https://github.com/stephpy/vim-yaml | |
Plugin 'stephpy/vim-yaml' | |
" https://github.com/peterhoeg/vim-qml | |
Plugin 'peterhoeg/vim-qml' | |
" https://github.com/leafgarland/typescript-vim | |
Plugin 'leafgarland/typescript-vim' | |
" https://github.com/klen/python-mode#how-to-install | |
Plugin 'klen/python-mode' | |
" https://github.com/scrooloose/nerdtree | |
Plugin 'scrooloose/nerdtree' | |
" https://github.com/tpope/vim-rails | |
Plugin 'tpope/vim-rails' | |
" https://github.com/vim-scripts/marvim | |
Plugin 'vim-scripts/marvim' | |
" https://github.com/othree/html5.vim | |
Plugin 'othree/html5.vim' | |
" https://github.com/scrooloose/syntastic" | |
"Plugin 'scrooloose/syntastic'" | |
Plugin 'vim-syntastic/syntastic' | |
" To help in auto prettifying" | |
Plugin 'sbdchd/neoformat' | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
" Enable filetype plugins | |
filetype plugin indent on " required by Vundle | |
" To ignore plugin indent changes, instead use: | |
"filetype plugin on | |
" | |
" Brief help | |
" :PluginList - lists configured plugins | |
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate | |
" :PluginSearch foo - searches for foo; append `!` to refresh local cache | |
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal | |
" | |
" see :h vundle for more details or wiki for FAQ | |
" Put your non-Plugin stuff after this line | |
" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => End of Vundle settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"===============> Start of my custom vim settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => General | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" With a map leader it's possible to do extra key combinations | |
" " like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
" Sets how many lines of history VIM has to remember | |
set history=10000 | |
" Line numbers on | |
set nu | |
" Show list instead of just completing | |
set wildmenu | |
" Command <Tab> completion, list matches, then longest common part, then all. | |
set wildmode=list:longest,full | |
" Puts new vsplit windows to the right of the current | |
set splitright | |
" Puts new split windows to the bottom of the current | |
set splitbelow | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
" Causes the left & right arrow keys, h & l, to wrap when used at beginning or end of lines | |
set whichwrap+=<,>,h,l,[,] | |
" Set spell checking on | |
" set spell | |
" Allow buffer switching without saving | |
set hidden | |
" '.' is an end of word designator | |
set iskeyword-=. | |
" '#' is an end of word designator | |
set iskeyword-=# | |
" '-' is an end of word designator | |
set iskeyword-=- | |
" Ignore compiled files | |
set wildignore+=*.o,*~,*.pyc | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
set cmdheight=1 | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Always display the status line, even if only one window is displayed | |
set laststatus=2 | |
" Set the command window height to 2 lines, to avoid many cases of having to press <Enter> to continue" | |
set cmdheight=2 | |
" Set the encoding of the editor | |
set encoding=utf8 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Files related: Backup, swap, encoding, format | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set ffs=unix,dos,mac | |
set undodir=~/.vim/.vimundo// | |
set backupdir=~/.vim/.vimbackup// | |
set directory=~/.vim/tmp | |
scriptencoding utf-8 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Search Related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Show matching brackets/parenthesis | |
set showmatch | |
" Case insensitive search | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Highlight search results | |
set hlsearch | |
" Set incremental search, starts highlighting as search term is typed | |
set incsearch | |
" Disable highlight when <leader><cr> is pressed | |
nnoremap <Leader><Space> :noh<CR> | |
nnoremap <Leader>f :Ack ''<Left> | |
nnoremap <Leader>rf :Ack --ruby ''<Left> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
syntax enable | |
colorscheme desert | |
set background=dark | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Tabs are spaces, not tabs | |
set expandtab | |
" Set softtabstop to control how many columns vim uses when you hit Tab in insert mode. | |
set softtabstop=2 | |
" how many columns a tab counts for | |
set tabstop=2 | |
" how many columns text is indented with the reindent operations (<< and >>) | |
set shiftwidth=2 | |
" When on, a <Tab> in front of a line inserts blanks according to tab settings used in other places. | |
set smarttab | |
"Wrap lines | |
set wrap | |
" Linebreak on 500 characters wrap long lines at a character in 'breakat' | |
set linebreak | |
" Maximum width of text that is being inserted. | |
set tw=500 | |
"Auto indent | |
set ai | |
"Smart indent | |
set si | |
" Wrapped lines goes down/up to next row, rather than next line in file. | |
noremap j gj | |
noremap k gk | |
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy, which is the default | |
noremap Y y$ | |
" Keep the cursor at the same position where left, when switching the buffer | |
set nostartofline | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Buffer Navigation | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nnoremap <Leader>n :bnext<CR> | |
nnoremap <Leader>p :bprevious<CR> | |
nnoremap <Leader>d :bdelete<CR> | |
nnoremap <Leader>d! :bdelete!<CR> | |
nnoremap <Leader>ccl :ccl<CR> | |
nnoremap <Leader>db :bprevious \| bdelete #<CR> | |
nnoremap HH :bprevious<CR> | |
nnoremap LL :bnext<CR> | |
autocmd FileType * autocmd BufWritePre <buffer> call RemoveTrailingSpaces() | |
autocmd FileType qf set nobuflisted | |
autocmd BufWritePre *.js Neoformat | |
autocmd BufWritePre *.jsx Neoformat | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => To automatically save and load session | |
" => http://vim.wikia.com/wiki/Go_away_and_come_back | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Creates a session | |
function! MakeSession() | |
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd() | |
if (filewritable(b:sessiondir) != 2) | |
exe 'silent !mkdir -p ' b:sessiondir | |
redraw! | |
endif | |
let b:sessionfile = b:sessiondir . '/session.vim' | |
exe "mksession! " . b:sessionfile | |
endfunction | |
" Updates a session, BUT ONLY IF IT ALREADY EXISTS | |
function! UpdateSession() | |
let b:current_buffer = expand('%:t') | |
if (b:current_buffer == 'COMMIT_MESSAGE') | |
return 1 | |
endif | |
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd() | |
let b:sessionfile = b:sessiondir . "/session.vim" | |
if (filereadable(b:sessionfile)) | |
exe "mksession! " . b:sessionfile | |
echo "updating session" | |
endif | |
endfunction | |
" Loads a session if it exists | |
function! LoadSession() | |
if argc() == 0 | |
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd() | |
let b:sessionfile = b:sessiondir . "/session.vim" | |
if (filereadable(b:sessionfile)) | |
exe 'source ' b:sessionfile | |
else | |
echo "No session loaded." | |
endif | |
else | |
let b:sessionfile = "" | |
let b:sessiondir = "" | |
endif | |
endfunction | |
au VimEnter * nested :call LoadSession() | |
au VimLeave * :call UpdateSession() | |
map <leader>ms :call MakeSession()<CR> | |
map <leader>ls :call LoadSession()<CR> | |
" Function to print Currentfilepath | |
function! CurrentFilePath() | |
python << EOF | |
import sys, os | |
sys.path.append('%s/.pyenv/versions/2.7.9/lib/python2.7/site-packages' % os.environ['HOME']) | |
import vim | |
import pyperclip | |
current_buffer = vim.current.buffer | |
if current_buffer.name is None: | |
print "No file loaded in current buffer" | |
else: | |
pyperclip.copy(current_buffer.name) | |
print current_buffer.name | |
EOF | |
endfunction | |
" Function to prettify json | |
function PrettyJson() | |
:%!python -m json.tool | |
endfunction | |
command -nargs=0 PrettifyJson call PrettyJson() | |
" Function to replace regex with random number | |
function ReplaceWithRandom() | |
python << EOF | |
import vim | |
import md5 | |
import re | |
current_line = vim.current.line | |
pattern = r'(?<=name: ")(.*?)(?=")' | |
print(current_line) | |
matched_index = re.search(pattern, current_line).group(0) | |
print(matched_index) | |
index_md5 = md5.new() | |
index_md5.update(matched_index) | |
new_line = re.sub(pattern, index_md5.hexdigest(), current_line) | |
vim.current.line = new_line | |
EOF | |
endfunction | |
" Function to remove trailing whitespaces | |
function RemoveTrailingSpaces() | |
%s/\s\+$//ge | |
endfunction | |
" Character line limitation | |
" set colorcolumn=120 | |
" highlight ColorColumn ctermbg=7 guibg=LightGray | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" CtrlP Settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Do not open the file in NERDTree if NERDTree is open | |
" Got from: http://vi.stackexchange.com/a/11300/11793 | |
function! CtrlPCommand() | |
let c = 0 | |
let wincount = winnr('$') | |
" Don't open it here if current buffer is not writable (e.g. NERDTree) | |
while !empty(getbufvar(+expand("<abuf>"), "&buftype")) && c < wincount | |
exec 'wincmd w' | |
let c = c + 1 | |
endwhile | |
exec 'CtrlP' | |
endfunction | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'call CtrlPCommand()' | |
set wildignore+=*.so,*.swp,*.zip,*/vendor/** | |
" Setup some default ignores | |
let g:ctrlp_custom_ignore = { | |
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site|tmp)$', | |
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg)$', | |
\} | |
" Use the nearest .git directory as the cwd | |
" This makes a lot of sense if you are working on a project that is in version | |
" control. It also supports works with .svn, .hg, .bzr. | |
let g:ctrlp_working_path_mode = 'r' | |
" Easy bindings for its various modes | |
nmap <leader>bb :CtrlPBuffer<cr> | |
nmap <leader>bm :CtrlPMixed<cr> | |
nmap <leader>bs :CtrlPMRU<cr> | |
let g:ctrlp_user_command = { | |
\ 'types': { | |
\ 1: ['.git', 'cd %s && git ls-files --cached --exclude-standard --others'], | |
\ 2: ['.hg', 'hg --cwd %s locate -I .'], | |
\ }, | |
\ 'fallback': 'find %s -type f' | |
\ } | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" CtrlPFunky Settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nnoremap <Leader>fu :CtrlPFunky<Cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" airline settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable the list of buffers | |
let g:airline#extensions#tabline#enabled = 1 | |
" Show just the filename | |
let g:airline#extensions#tabline#fnamemod = ':t' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" incsearch settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
map / <Plug>(incsearch-forward) | |
map ? <Plug>(incsearch-backward) | |
" <Plug>(incsearch-stay) doesn't move the cursor. | |
map g/ <Plug>(incsearch-stay) | |
" To search for visual selection - http://vim.wikia.com/wiki/Search_for_visually_selected_text | |
vnoremap // y/<C-R>"<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" vim-markdown settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:vim_markdown_folding_disabled = 1 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" neocomplete settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:acp_enableAtStartup = 0 | |
" Use neocomplete. | |
let g:neocomplete#enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplete#enable_smart_case = 1 | |
" Set minimum syntax keyword length. | |
let g:neocomplete#sources#syntax#min_keyword_length = 3 | |
let g:neocomplete#enable_auto_select = 0 | |
" always use completions from all buffers | |
if !exists('g:neocomplete#same_filetypes') | |
let g:neocomplete#same_filetypes = {} | |
endif | |
let g:neocomplete#same_filetypes._ = '_' | |
" Plugin key-mappings. | |
" <TAB>: completion. | |
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>" | |
" <Down> and <Up> cycle like <Tab> and <S-Tab> | |
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>" | |
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>" | |
" inoremap <expr> <C-g> neocomplete#undo_completion() | |
" inoremap <expr> <C-l> neocomplete#complete_common_string() | |
" " <C-h>, <BS>: close popup and delete backword char. | |
" inoremap <expr> <C-h> neocomplete#smart_close_popup()."\<C-h>" | |
" inoremap <expr> <BS> neocomplete#smart_close_popup()."\<C-h>" | |
" inoremap <expr> <C-y> neocomplete#close_popup() | |
" inoremap <expr> <C-e> neocomplete#cancel_popup() | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" vim-multiple-cursors settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! Multiple_cursors_before() | |
exe 'NeoCompleteLock' | |
echo 'Disabled autocomplete' | |
endfunction | |
function! Multiple_cursors_after() | |
exe 'NeoCompleteUnlock' | |
echo 'Enabled autocomplete' | |
endfunction | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" typescript-vim settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
autocmd QuickFixCmdPost [^l]* nested cwindow | |
autocmd QuickFixCmdPost l* nested lwindow | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" pymode settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:pymode_folding = 0 | |
let g:pymode_options_max_line_length = 120 | |
let g:pymode_lint_ignore = "E302,E731" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" NERDTree binding/settings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nnoremap <leader>nt :NERDTreeToggle<cr> | |
nnoremap <leader>vv :vsplit<cr> | |
nnoremap <leader>ss :split<cr> | |
if has("gui_macvim") | |
" Press Ctrl-Tab to switch between open tabs (like browser tabs) to | |
" the right side. Ctrl-Shift-Tab goes the other way. | |
noremap <C-Tab> :tabnext<CR> | |
noremap <C-S-Tab> :tabprev<CR> | |
" Switch to specific tab numbers with Command-number | |
noremap <D-1> :tabn 1<CR> | |
noremap <D-2> :tabn 2<CR> | |
noremap <D-3> :tabn 3<CR> | |
noremap <D-4> :tabn 4<CR> | |
noremap <D-5> :tabn 5<CR> | |
noremap <D-6> :tabn 6<CR> | |
noremap <D-7> :tabn 7<CR> | |
noremap <D-8> :tabn 8<CR> | |
noremap <D-9> :tabn 9<CR> | |
" Command-0 goes to the last tab | |
noremap <D-0> :tablast<CR> | |
endif | |
nnoremap <C-J> <C-W><C-J> | |
nnoremap <C-K> <C-W><C-K> | |
nnoremap <C-L> <C-W><C-L> | |
nnoremap <C-H> <C-W><C-H> | |
set splitbelow | |
set splitright | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:syntastic_javascript_checkers = ['eslint'] | |
let g:syntastic_javascript_eslint_exe = 'npm run lint --' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment