new vim config
This commit is contained in:
@@ -1,48 +1,12 @@
|
||||
if filereadable($HOME . "/.vimrc_vundle")
|
||||
source $HOME/.vimrc_vundle
|
||||
endif
|
||||
set history=700
|
||||
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader="\<Space>"
|
||||
let g:mapleader="\<Space>"
|
||||
|
||||
filetype plugin on
|
||||
filetype indent on
|
||||
|
||||
"Auto reload files and enable Vim mode
|
||||
set autoread
|
||||
" General settings
|
||||
set nocompatible
|
||||
|
||||
filetype off
|
||||
set hidden
|
||||
set backspace=eol,start,indent
|
||||
set whichwrap+=<,>,h,l
|
||||
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set hlsearch
|
||||
set incsearch
|
||||
set lazyredraw
|
||||
set magic
|
||||
set showmatch
|
||||
set mat=2
|
||||
|
||||
set noerrorbells
|
||||
set novisualbell
|
||||
set t_vb=
|
||||
set tm=500
|
||||
|
||||
syntax enable
|
||||
set nocp
|
||||
|
||||
"enable line numbers
|
||||
set nu
|
||||
set ignorecase
|
||||
filetype plugin indent on
|
||||
|
||||
set encoding=utf8
|
||||
|
||||
set ffs=unix,dos,mac
|
||||
set nobackup
|
||||
set nowb
|
||||
set noswapfile
|
||||
|
||||
" Tab settings
|
||||
set expandtab
|
||||
@@ -51,117 +15,19 @@ set shiftwidth=4
|
||||
set tabstop=4
|
||||
|
||||
"File specific tab settings
|
||||
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
||||
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||
autocmd FileType typescript setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||
autocmd FileType typescriptreact setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||
autocmd FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab
|
||||
|
||||
set lbr
|
||||
|
||||
"Max 100 columns
|
||||
set tw=100
|
||||
|
||||
set autoindent
|
||||
set smartindent
|
||||
|
||||
set path=$PWD/**
|
||||
map j gj
|
||||
map k gk
|
||||
|
||||
"leader bindings
|
||||
map <silent> <leader><cr> :noh<cr>
|
||||
map <leader>ba :1,1000 bd!<cr>
|
||||
map <leader>q :bd<cr>
|
||||
map <leader>qq :q<cr>
|
||||
map <leader>w :w<cr>
|
||||
map <leader>g :NERDTreeToggle<cr>
|
||||
|
||||
"Return to last position when re-opening file
|
||||
autocmd BufReadPost *
|
||||
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
||||
\ exe "normal! g`\"" |
|
||||
\ endif
|
||||
set viminfo^=%
|
||||
|
||||
function! HasPaste()
|
||||
if &paste
|
||||
return 'PASTE MODE '
|
||||
en
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
set laststatus=2
|
||||
set statusline=\ %{HasPaste()}%F%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l/%L\ [Col\ %v]\ M%m\ %=%-5y\ %-5{&ff}
|
||||
|
||||
"Color compatibility with some terminals
|
||||
let g:rehash256=1
|
||||
let &t_Co=256
|
||||
let &t_AF="\e[38;5;%dm"
|
||||
let &t_AB="\e[48;5;%dm"
|
||||
colorscheme monokai
|
||||
|
||||
"change tabs with tab and shift-tab
|
||||
nnoremap <tab> gt
|
||||
nnoremap <S-tab> gT
|
||||
nnoremap <C-p> :CtrlP<cr>
|
||||
|
||||
autocmd BufWritePre * :%s/\s\+$//e
|
||||
|
||||
"Highlight lines that go over 120 columns
|
||||
highlight ColorColumn ctermfg=208 ctermbg=Black
|
||||
function! MarkMargin (on)
|
||||
if exists('b:MarkMargin')
|
||||
try
|
||||
call matchdelete(b:MarkMargin)
|
||||
catch /./
|
||||
endtry
|
||||
unlet b:MarkMargin
|
||||
endif
|
||||
if a:on
|
||||
let b:MarkMargin = matchadd('ColorColumn', '\%120v\s*\S', 120)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup MarkMargin
|
||||
autocmd!
|
||||
autocmd BufEnter * :call MarkMargin(1)
|
||||
autocmd BufEnter *.vp* :call MarkMargin(0)
|
||||
augroup END
|
||||
|
||||
"Reverse directions of # and *
|
||||
nnoremap # *
|
||||
nnoremap * #
|
||||
inoremap jk <Esc>
|
||||
inoremap kj <Esc>
|
||||
|
||||
inoremap <C-F> :compl-filename<CR>
|
||||
|
||||
" Transparent editing of gpg encrypted files.
|
||||
" By Wouter Hanegraaff
|
||||
augroup encrypted
|
||||
au!
|
||||
|
||||
" First make sure nothing is written to ~/.viminfo while editing
|
||||
" an encrypted file.
|
||||
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
|
||||
" We don't want a swap file, as it writes unencrypted data to disk
|
||||
autocmd BufReadPre,FileReadPre *.gpg set noswapfile
|
||||
|
||||
" Switch to binary mode to read the encrypted file
|
||||
autocmd BufReadPre,FileReadPre *.gpg set bin
|
||||
autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
|
||||
" (If you use tcsh, you may need to alter this line.)
|
||||
autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
|
||||
|
||||
" Switch to normal mode for editing
|
||||
autocmd BufReadPost,FileReadPost *.gpg set nobin
|
||||
autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
|
||||
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
|
||||
|
||||
" Convert all text to encrypted text before writing
|
||||
" (If you use tcsh, you may need to alter this line.)
|
||||
autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null
|
||||
" Undo the encryption so we are back in the normal text, directly
|
||||
" after the file has been written.
|
||||
autocmd BufWritePost,FileWritePost *.gpg u
|
||||
augroup END
|
||||
"Space as leader
|
||||
nmap <Tab> <Nop>
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader="\<Space>"
|
||||
let g:mapleader="\<Space>"
|
||||
|
||||
" Window navigation
|
||||
nnoremap <C-h> <C-w>h
|
||||
@@ -169,9 +35,89 @@ nnoremap <C-j> <C-w>j
|
||||
nnoremap <C-k> <C-w>k
|
||||
nnoremap <C-l> <C-w>l
|
||||
|
||||
if v:version > 800
|
||||
tnoremap <C-h> <C-w>h
|
||||
tnoremap <C-j> <C-w>j
|
||||
tnoremap <C-k> <C-w>k
|
||||
tnoremap <C-l> <C-w>l
|
||||
|
||||
set cmdheight=2
|
||||
set updatetime=300
|
||||
set shortmess+=c
|
||||
set signcolumn=yes
|
||||
|
||||
"Auto install vim-plug
|
||||
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
|
||||
if empty(glob(data_dir . '/autoload/plug.vim'))
|
||||
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||||
endif
|
||||
|
||||
"Plugins
|
||||
call plug#begin()
|
||||
Plug 'preservim/nerdtree'
|
||||
Plug 'tmhedberg/SimpylFold'
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'sainnhe/gruvbox-material'
|
||||
Plug 'kien/ctrlp.vim'
|
||||
Plug 'itchyny/lightline.vim'
|
||||
Plug 'junegunn/fzf'
|
||||
Plug 'junegunn/fzf.vim'
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
Plug 'neoclide/coc-snippets'
|
||||
Plug 'pangloss/vim-javascript'
|
||||
Plug 'neoclide/vim-jsx-improve'
|
||||
Plug 'leafgarland/typescript-vim'
|
||||
Plug 'peitalin/vim-jsx-typescript'
|
||||
call plug#end()
|
||||
|
||||
|
||||
"Colorscheme
|
||||
colorscheme gruvbox-material
|
||||
|
||||
|
||||
"Coc Keybinds
|
||||
nmap <leader>d <Plug>(coc-definition)
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
nmap <slient> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
imap <C-x> <Plug>(coc-snippets-expand)
|
||||
|
||||
let g:coc_disable_transparent_cursor=1
|
||||
|
||||
"Use tab for snippet completion and jumping
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? coc#_select_confirm() :
|
||||
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
let g:coc_snippet_next = '<tab>'
|
||||
|
||||
|
||||
"SimpylFold Config
|
||||
let g:SimpylFold_docstring_preview=1
|
||||
|
||||
|
||||
"NERDTree keybinds
|
||||
nmap <leader>g :NERDTreeFind<CR>
|
||||
nmap <leader>tt :NERDTreeFocus<CR>
|
||||
let NERDTreeIgnore = ['__pycache__', '\.pyc$', '\.egg-info$', 'node_modules']
|
||||
|
||||
|
||||
"CtrlP config
|
||||
nmap <C-E> :CtrlPBuffer<CR>
|
||||
let g:ctrlp_working_path_mode= 'ra'
|
||||
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|\.egg-info|\.pyc'
|
||||
|
||||
|
||||
"fzf keybinds
|
||||
let $FZF_DEFAULT_COMMAND = 'ag -g "" --ignore="(dist|*.svg)"'
|
||||
nmap <C-F> :FZF<CR>
|
||||
nmap <C-G> :Ag<CR>
|
||||
|
||||
|
||||
"Wildignore
|
||||
set wildignore+=*/node_modules/*,*/__pycache__/*,*.pyc,*.egg-info
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
set nocompatible " be iMproved, required
|
||||
filetype off " required
|
||||
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader="\<Space>"
|
||||
let g:mapleader="\<Space>"
|
||||
|
||||
" 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 'gmarik/Vundle.vim'
|
||||
|
||||
" The following are examples of different formats supported.
|
||||
" Keep Plugin commands between vundle#begin/end.
|
||||
" plugin on GitHub repo
|
||||
" plugin from http://vim-scripts.org/vim/scripts.html
|
||||
Plugin 'tmhedberg/SimpylFold'
|
||||
Plugin 'vimwiki/vimwiki'
|
||||
Plugin 'kien/ctrlp.vim'
|
||||
Plugin 'octol/vim-cpp-enhanced-highlight'
|
||||
Plugin 'mattn/emmet-vim'
|
||||
Plugin 'tpope/vim-surround'
|
||||
Plugin 'scrooloose/nerdtree'
|
||||
|
||||
" All of your Plugins must be added before the following line
|
||||
call vundle#end() " required
|
||||
filetype plugin indent on " required
|
||||
" 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
|
||||
|
||||
" this mapping Enter key to <C-y> to chose the current highlight item
|
||||
" and close the selection list, same as other IDEs.
|
||||
" CONFLICT with some plugins like tpope/Endwise
|
||||
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||
|
||||
"SimpylFold Config
|
||||
let g:SimpylFold_docstring_preview=1
|
||||
|
||||
"CtrlP config
|
||||
let g:ctrlp_map = '<leader>f'
|
||||
nmap <silent> <leader>b :CtrlPBuffer<CR>
|
||||
nmap <silent> <leader>r :CtrlPMRU<CR>
|
||||
|
||||
"Ranger utility function
|
||||
function! RangeChooser()
|
||||
let temp = tempname()
|
||||
" The option "--choosefiles" was added in ranger 1.5.1. Use the next line
|
||||
" with ranger 1.4.2 through 1.5.0 instead.
|
||||
"exec 'silent !ranger --choosefile=' . shellescape(temp)
|
||||
exec 'silent !ranger --choosefiles=' . shellescape(temp)
|
||||
if !filereadable(temp)
|
||||
redraw!
|
||||
" Nothing to read.
|
||||
return
|
||||
endif
|
||||
let names = readfile(temp)
|
||||
if empty(names)
|
||||
redraw!
|
||||
" Nothing to open.
|
||||
return
|
||||
endif
|
||||
" Edit the first item.
|
||||
exec 'tabe ' . fnameescape(names[0])
|
||||
" Add any remaning items to the arg list/buffer list.
|
||||
for name in names[1:]
|
||||
exec 'argadd ' . fnameescape(name)
|
||||
endfor
|
||||
redraw!
|
||||
endfunction
|
||||
command! -bar RangerChooser call RangeChooser()
|
||||
nnoremap <leader>o :<C-U>RangerChooser<CR>
|
||||
|
||||
let g:ycm_server_python_interpreter="/usr/local/bin/python2"
|
||||
let g:ycm_confirm_extra_conf=0
|
||||
|
||||
let g:user_emmet_leader_key="<C-e>"
|
||||
|
||||
"NERDTree settings
|
||||
nnoremap <leader>tt :NERDTreeFocus<CR>
|
||||
let NERDTreeIgnore = ['__pycache__', '\.pyc$']
|
||||
Reference in New Issue
Block a user