Skip to content

Instantly share code, notes, and snippets.

@JAStanton
Created November 26, 2019 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JAStanton/50e2e0c2daf0d492cbbb028d4260e9bb to your computer and use it in GitHub Desktop.
Save JAStanton/50e2e0c2daf0d492cbbb028d4260e9bb to your computer and use it in GitHub Desktop.
call plug#begin('~/.vim/plugged')
"
" Editor
"
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-commentary'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Fuzzy find
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
" Highlight other occurences of word under cursor
Plug 'RRethy/vim-illuminate'
" Highlight whitespace
Plug 'ntpeters/vim-better-whitespace'
" Colors
Plug 'altercation/vim-colors-solarized'
" Searching
Plug 'haya14busa/incsearch.vim'
"
" Language
"
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'liuchengxu/vista.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
"
" Basic Config
"
" Show line numbers
set number
" Autoindent
filetype plugin indent on
" On pressing tab, insert 2 spaces
set expandtab
" show existing tab with 2 spaces width
set tabstop=2
set softtabstop=2
" when indenting with '>', use 2 spaces width
set shiftwidth=2
" Remap leader
let mapleader=" "
" Hard mode
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" Fix backspace
set bs=2
"
" Remapping
"
nnoremap <C-k><C-v> :Vista!!<CR>
" Better searching
map / <plug>(incsearch-forward)
" Better splits
noremap <C-J> <C-W><C-J>
noremap <C-K> <C-W><C-K>
noremap <C-L> <C-W><C-L>
noremap <C-H> <C-W><C-H>
" Map tsx/jsx to filetype
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.jsx
autocmd BufNewFile,BufRead *.ts,*.js set filetype=typescript.jsx
" Share clipboard with yank
if has("clipboard")
set clipboard=unnamed " copy to the system clipboard
if has("unnamedplus") " X11 support
set clipboard+=unnamedplus
endif
endif
"
" Prettier
"
" when running at every change you may want to disable quickfix
let g:prettier#quickfix_enabled = 0
let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
"
" ALE
"
" Ale configuration
let b:ale_linters = {'javascript': ['prettier']}
" the sign gutter open at all times
let g:ale_sign_column_always = 1
" Enable completion where available.
let g:ale_completion_enabled = 1
let g:ale_completion_tsserver_autoimport = 1
nmap <silent> <Leader>gi <Plug>(ale_detail)
nmap <silent> <Leader>gj <Plug>(ale_next_wrap)
nmap <silent> <Leader>gk <Plug>(ale_previous_wrap)
nmap <silent> <Leader>gh <Plug>(ale_hover)
nmap <silent> <Leader>go <Plug>(ale_go_to_definition)
nmap <silent> <Leader>gr <Plug>(ale_find_references)
" nmap <silent> <Leader>s :call AleSymbolSearch()<CR>
"
" NerdTree
"
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" Toggle
nnoremap <silent> <expr> <C-k><C-B> g:NERDTree.IsOpen() ? "\:NERDTreeClose<CR>" : bufexists(expand('%')) ? "\:NERDTreeFind<CR>" : "\:NERDTree<CR>"
" Quit if its the last thing open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"
" FZF
"
nnoremap <silent> <C-t> :GFiles<cr>
"
" Vista
"
let g:vista_default_executive = 'coc'
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
let g:vista#renderer#enable_icon = 1
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
" THEME
"
" Theme
syntax enable
let g:solarized_termcolors = 16
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
set background=dark
colorscheme solarized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment