Skip to content

Instantly share code, notes, and snippets.

@williamboman
Created December 27, 2018 00:12
Show Gist options
  • Select an option

  • Save williamboman/d9c4d2c8fedae3b6c9ba302b03150379 to your computer and use it in GitHub Desktop.

Select an option

Save williamboman/d9c4d2c8fedae3b6c9ba302b03150379 to your computer and use it in GitHub Desktop.

Revisions

  1. williamboman created this gist Dec 27, 2018.
    326 changes: 326 additions & 0 deletions .vimrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,326 @@
    let mapleader=","

    "============================================================
    " Plugins
    "============================================================
    "
    """ prepare vundle
    set nocompatible
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    set rtp+=~/.fzf
    """

    call vundle#begin()
    Plugin 'prettier/vim-prettier'
    Plugin 'Shougo/deoplete.nvim'
    Plugin 'isRuslan/vim-es6'
    Plugin 'sheerun/vim-polyglot'
    Plugin 'mhartington/nvim-typescript'
    Plugin 'styled-components/vim-styled-components'
    Plugin 'vim-scripts/SyntaxComplete'
    Plugin 'vim-scripts/CountJump'
    Plugin 'vim-scripts/ConflictMotions'
    Plugin 'vim-scripts/ingo-library'
    Plugin 'haya14busa/incsearch.vim'
    Plugin 'easymotion/vim-easymotion'
    Plugin 'editorconfig/editorconfig-vim'
    Plugin 'python-mode/python-mode'
    Plugin 'junegunn/vim-peekaboo'
    Plugin 'scrooloose/nerdtree'
    Plugin 'Xuyuanp/nerdtree-git-plugin'
    Plugin 'airblade/vim-gitgutter'
    Plugin 'chrisbra/Colorizer'
    Plugin 'itchyny/lightline.vim'
    Plugin 'ludovicchabant/vim-gutentags'
    Plugin 'junegunn/fzf.vim'
    Plugin 'tpope/vim-repeat'
    Plugin 'tpope/vim-fugitive'
    Plugin 'tpope/vim-sleuth'
    Plugin 'tpope/vim-commentary'
    Plugin 'tpope/vim-surround'
    Plugin 'williamboman/falcon'
    Plugin 'Galooshi/vim-import-js'
    Plugin 'yardnsm/vim-import-cost'
    Plugin 'ryanoasis/vim-devicons'
    " Plugin 'flowtype/vim-flow'
    " Plugin 'posva/vim-vue'
    " Plugin 'jpalardy/vim-slime'
    call vundle#end()

    "============================================================
    " mhartington/nvim-typescript
    "============================================================
    let g:nvim_typescript#javascript_support = 1

    "============================================================
    " prettier/vim-prettier
    "============================================================
    let g:prettier#autoformat = 0
    let g:prettier#config#print_width = 100
    let g:prettier#config#tab_width = 4
    let g:prettier#config#semi = 'false'
    let g:prettier#config#single_quote = 'false'
    let g:prettier#config#bracket_spacing = 'true'

    "============================================================
    " vim-scripts/SyntaxComplete
    "============================================================
    if has("autocmd") && exists("+omnifunc")
    autocmd Filetype *
    \ if &omnifunc == "" |
    \ setlocal omnifunc=syntaxcomplete#Complete |
    \ endif
    endif

    "============================================================
    " junegunn/fzf.vim
    "============================================================
    let g:fzf_history_dir = '~/.local/share/fzf-history'
    let g:fzf_commits_log_options = "--color=always --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=short"

    "============================================================
    " ludovicchabant/vim-gutentags
    "============================================================
    let g:gutentags_ctags_tagfile = '.git/tags'
    let g:gutentags_ctags_extra_args = ['--tag-relative'] " ensure these args are in sync with .git_template/hooks/ctags

    "============================================================
    " haya14busa/incsearch.vim
    "============================================================
    let g:incsearch#auto_nohlsearch = 1

    "============================================================
    " easymotion/vim-easymotion
    "============================================================
    let g:EasyMotion_do_mapping = 0

    "============================================================
    " python-mode/python-mode
    "============================================================
    let g:pymode_folding = 0
    let g:pymode_lint = 0
    let g:pymode_options_max_line_length = 9001

    "============================================================
    " junegunn/vim-peekaboo
    "============================================================
    let g:peekaboo_compact = 1

    "============================================================
    " airblade/vim-gitgutter
    "============================================================
    let g:gitgutter_map_keys = 0

    "============================================================
    " chrisbra/Colorizer
    "============================================================
    let g:colorizer_auto_filetype='css,html,js,jsx,ts,tsx,scss,.vim'

    "============================================================
    " williamboman/falcon
    let g:falcon_lightline = 1
    "============================================================

    "============================================================
    " itchyny/lightline.vim
    "============================================================
    function! LightlineFiletype()
    return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
    endfunction

    function! LightlineFormat()
    return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
    endfunction

    let g:lightline = {
    \ 'colorscheme': 'wombat',
    \ 'active': {
    \ 'left': [
    \ ['mode', 'paste'], ['readonly', 'relativepath', 'modified']
    \ ],
    \ 'right': [
    \ ['lineinfo'], ['percent'], ['fileformat', 'fileencoding', 'filetype'],
    \ ['gitbranch']
    \ ]
    \ },
    \ 'component_function': {
    \ 'gitbranch': 'fugitive#head',
    \ 'filetype': 'LightlineFiletype',
    \ 'fileformat': 'LightlineFormat',
    \ }
    \ }

    "============================================================
    " scrooloose/nerdtree
    "============================================================
    let NERDTreeShowHidden=1

    "============================================================
    " Shougo/deoplete.nvim
    "============================================================
    let g:deoplete#enable_at_startup = 1


    "============================================================
    " Settings
    "============================================================
    set foldmethod=manual
    set nofoldenable
    set hlsearch

    colorscheme falcon
    if !has('gui_running')
    set t_Co=256
    endif

    " https://medium.com/@dubistkomisch/how-to-actually-get-italics-and-true-colour-to-work-in-iterm-tmux-vim-9ebe55ebc2be
    let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
    set termguicolors

    " lightline takes care of showing mode
    set noshowmode
    " Always show status line
    set laststatus=2

    filetype plugin indent on

    " ignore directories
    set wildignore=*/node_modules,*/bower_components

    " Use the OS clipboard by default (on versions compiled with `+clipboard`)
    set clipboard=unnamed
    " Enhance command-line completion
    set wildmenu
    " Make sure backspace works in insert mode
    set backspace=indent,eol,start
    " Optimize for fast terminal connections
    set ttyfast
    " Add the g flag to search/replace by default
    set gdefault
    " Use UTF-8 without BOM
    set encoding=utf-8 nobomb
    " Centralize backups, swapfiles and undo history
    set backupdir=~/.vim/backups
    set directory=~/.vim/swaps
    if exists("&undodir")
    set undodir=~/.vim/undo
    endif
    " Don’t create backups when editing files in certain directories
    set backupskip=/tmp/*,/private/tmp/*
    " Enable line numbers
    set number
    " Enable syntax highlighting
    syntax on
    " Highlight current line
    set cursorline
    " Make tabs as wide as two spaces
    set tabstop=2
    " Ignore case of searches…
    set ignorecase
    " … unless the search includes a capital letter
    set smartcase
    " Enable mouse in all modes
    set mouse=a
    " Disable error bells
    set noerrorbells
    " Don’t reset cursor to start of line when moving around.
    set nostartofline
    " Show the cursor position
    set ruler
    " Don’t show the intro message when starting Vim
    set shortmess=atIc
    " Show the filename in the window titlebar
    set title
    " Show the (partial) command as it’s being typed
    set showcmd
    " Start scrolling three lines before the horizontal window border
    set scrolloff=3

    set diffopt=filler,vertical

    " More natural split openings
    set splitbelow
    set splitright

    " Automatic commands
    if has("autocmd")
    " Treat .md files as Markdown
    autocmd BufNewFile,BufRead *.md setlocal filetype=markdown

    " Enable NERDTree
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif

    " highlight trailing whitespace
    highlight ExtraneousWhitespace ctermbg=red
    match ExtraneousWhitespace /\(\s\+$\| \)/
    autocmd BufWinEnter,CursorMovedI * highlight ExtraneousWhitespace ctermbg=red

    autocmd FileType typescript nmap <buffer> <Leader>t :TSType<CR>
    autocmd FileType typescript nmap <buffer> <Leader>d :TSDef<CR>
    autocmd FileType typescript nmap <buffer> <Leader>D :TSDefPreview<CR>
    autocmd FileType typescript nmap <buffer> <C-d> :bprevious<CR>
    autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
    endif

    "============================================================
    " Mappings
    "============================================================

    " C-r to interactively replace selection
    vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
    "============================================================
    " scrooloose/nerdtree
    "============================================================
    map <Leader>a :NERDTreeFind<CR>
    map <C-n> :NERDTreeToggle<CR>
    "============================================================
    " junegunn/fzf.vim
    "============================================================
    nnoremap <C-l> :Tags<CR>
    nnoremap <C-p> :GFiles<CR>
    "============================================================
    " easymotion/vim-easymotion
    "============================================================
    map <Leader>f <Plug>(easymotion-bd-f)
    nmap <Leader>f <Plug>(easymotion-overwin-f)
    nmap <Leader>s <Plug>(easymotion-overwin-f2)
    map <Leader>L <Plug>(easymotion-bd-jk)
    nmap <Leader>L <Plug>(easymotion-overwin-line)
    map <Leader>w <Plug>(easymotion-bd-w)
    nmap <Leader>w <Plug>(easymotion-overwin-w)
    map <Leader>l <Plug>(easymotion-lineforward)
    map <Leader>h <Plug>(easymotion-linebackward)
    "============================================================
    " haya14busa/incsearch.vim
    "============================================================
    map / <Plug>(incsearch-forward)
    map ? <Plug>(incsearch-backward)
    map g/ <Plug>(incsearch-stay)
    map n <Plug>(incsearch-nohl-n)
    map N <Plug>(incsearch-nohl-N)
    map * <Plug>(incsearch-nohl-*)
    map # <Plug>(incsearch-nohl-#)
    map g* <Plug>(incsearch-nohl-g*)
    map g# <Plug>(incsearch-nohl-g#)
    "============================================================
    " ctags
    "============================================================
    nnoremap <Leader>d <C-]>
    nnoremap <Leader>D :vsp <CR>:exec("tag ".expand("<cword>"))<CR> " open definition in vertical split
    nnoremap <C-d> <C-T>
    "============================================================
    " Shougo/deoplete.nvim
    "============================================================
    inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
    inoremap <expr><s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"