Skip to content

Instantly share code, notes, and snippets.

@daqing
Last active October 21, 2024 06:57
Show Gist options
  • Save daqing/fa475e2d9a5f3241b239c57c1a6f9c68 to your computer and use it in GitHub Desktop.
Save daqing/fa475e2d9a5f3241b239c57c1a6f9c68 to your computer and use it in GitHub Desktop.
My Latest vim config
" General
set shell=/bin/zsh
set nocompatible " Disable vi compatibility
set history=256 " Number of things to remember
set autowrite " Writes on make/shell commands
set autoread
"set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay)
set clipboard+=unnamed " Yanks go on clipboard instead
set tags=./tags;$HOME " Walk directory tree up to $HOME looking for tags
noremap <S-t> :! ctags -R --languages=Ruby --exclude=.git --exclude=log --exclude=node_modules -f tags<CR>
noremap <C-a> :! git add %<CR>
noremap <C-x> :ccl<CR>
noremap <C-]> :ALEGoToDefinition<CR>
set guifont=Monaco:h22
" let &guifont="Cascadia Code:h22"
set t_Co=256
set termguicolors
set wildignore=*.swp,*.back,node_modules/*,*.o,tmp/*
set noswapfile
" File encoding
set encoding=utf-8
set fileencoding=utf-8
" Modeline
set modeline
set modelines=5 " Default numbers of lines to read for modeline instructions
" Backup
set nowritebackup
set nobackup
set directory=/tmp// " Prepend(^=) $HOME/.tmp/ to default path; use full path as backup filename(//)
" Buffers
set hidden " The current buffer can be put to the background without writing to disk
" Match and search
set hlsearch " Highlight search
set ignorecase " Do case-insensitive matching
set smartcase " Be sensitive when there's a capital letter
set incsearch
nmap <silent> ,/ :nohlsearch<CR>
" formatting
set fo+=o " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode.
set fo-=r " Don not automatically insert a comment leader after an enter
"set fo-=t " Do not auto-wrap text using textwidth (does not apply to comments)
set fo+=t
set fo-=l
set nowrap
" set wrap
"set textwidth=80
set colorcolumn=80
set wildmode=longest,list " At comment line, complete longest common string, then list alternatives.
set backspace=indent,eol,start " more powerful backspacing
set tabstop=2
set softtabstop=2
set shiftwidth=2 " Set the default shift width for indents
set expandtab " Make tabs into spaces (set by tabstop)
set smarttab " Smarter tab levels
set autoindent
set smartindent
set copyindent
set cindent
set cinoptions=:s,ps,ts,cs
set cinwords=if,else,while,do,for,switch,case
" Misc.
let mapleader = ","
map <F1> :wqall<CR>
noremap ; <S-:>
" Visual
set number
set showmatch " Show matching brackets
set matchtime=5 " Bracket blinking
"set novisualbell " No blinking
"set noerrorbells " No noise
set laststatus=2 "Always show status line
set ruler " Show ruler
set showcmd " Display an incomplete command in the lower right corner of the Vim window
set shortmess=atI " Shortens messages
set list
set lcs=tab:>-,trail:-
"set listchars=eol:↴
set showmode
set title
set foldenable " Turn on folding
set foldmethod=indent
set foldlevel=4
set foldopen=block,hor,mark,percent,quickfix,tag
set mouse=a " enable mouse
set mousehide " Hide mouse after chars typed
"set ttymouse=sgr
"set balloondelay=250
set updatetime=500
set signcolumn=yes
set splitbelow
set splitright
" Commands and Auto commands
" Sudo write
comm! W exec 'w !sudo tee % > /dev/null' | e!
" Auto commands
au BufRead,BufNewFile {Gemfile,Rakefile,Capfile,*.rake,config.ru} set ft=ruby
au BufRead,BufNewFile {*.md,*.mkd,*.markdown} set ft=markdown
au BufRead,BufNewFile {COMMIT_EDITMSG} set ft=gitcommit
" Tabs
map <silent> tp :tabprev<CR>
map <silent> tn :tabnext<CR>
map <silent> tq :tabclose<CR>
" Clear patch +/-
map <silent> pa :% s/^[+-]//<CR>
let g:rustfmt_autosave = 1
" required
filetype off
" set runtimepath to vundle
set rtp+=~/.vim/bundle/Vundle.vim/
" Plugins
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
" Golang
Plugin 'fatih/vim-go'
" Plugin 'govim/govim'
" Rust
Plugin 'rust-lang/rust.vim'
" Python
Plugin 'python-mode/python-mode'
" Lint
Plugin 'dense-analysis/ale'
" The silver searcher
Plugin 'rking/ag.vim'
let g:ackprg = 'ag --nogroup --nocolor --column --ignore=db --ignore=log --ignore=tmp --ignore=test'
" Nerd tree
Plugin 'scrooloose/nerdtree'
map <leader>n :NERDTreeToggle<CR>
Plugin 'bitc/vim-bad-whitespace'
map <c-l> :EraseBadWhitespace<CR>
autocmd BufWritePre * :EraseBadWhitespace
Plugin 'ervandew/supertab'
let g:SuperTabDefaultCompletionType = '<c-n>'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
map <leader>t :Files<CR>
" Quickfix
map <c-m> :cp<CR>
map <c-n> :cn<CR>
" Color scheme
"Plugin 'w0ng/vim-hybrid'
"Plugin 'drewtempelmeyer/palenight.vim'
"Plugin 'tomasr/molokai'
"Plugin 'chriskempson/base16-vim'
Plugin 'phanviet/vim-monokai-pro'
Plugin 'zivyangll/git-blame.vim'
nnoremap <C-b> :<C-u>call gitblame#echo()<CR>
Plugin 'tomtom/tcomment_vim'
" Plugin 'tabnine/YouCompleteMe'
call vundle#end()
set background=dark
filetype plugin indent on
syntax on
colorscheme monokai_pro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment