Skip to content

Instantly share code, notes, and snippets.

@Chalks
Last active December 21, 2021 15:24
Show Gist options
  • Save Chalks/1a4255772e01edd2aaeac63b9ac95d58 to your computer and use it in GitHub Desktop.
Save Chalks/1a4255772e01edd2aaeac63b9ac95d58 to your computer and use it in GitHub Desktop.
"""""""""""""""""""" plugin config
" install plugin manager in ~/.vim/autoload
" https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'https://github.com/ctrlpvim/ctrlp.vim' " ctrl+p search for files
Plug 'https://github.com/MaxMEllon/vim-jsx-pretty' " make jsx not ugly
Plug 'https://github.com/posva/vim-vue' " make vue not ugly
Plug 'https://github.com/dense-analysis/ale' " use eslint for javascript files
Plug 'https://github.com/nathanaelkane/vim-indent-guides' " visually display indentation
Plug 'https://github.com/scrooloose/nerdcommenter' " easy commenting
Plug 'https://github.com/airblade/vim-gitgutter' " show git +/- in gutter
Plug 'https://github.com/itchyny/lightline.vim' " pretty status line
Plug 'https://github.com/tpope/vim-fugitive' " git commands from within vim
Plug 'https://github.com/scrooloose/nerdtree' " file browser
Plug 'https://github.com/vim-scripts/YankRing.vim' " buffer management
call plug#end()
" ctrlp config
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|ico|git|svn))$'
" ale config
let g:ale_sign_column_always = 1
let g:ale_sign_error='!!'
let g:ale_linters = {'javascript': ['prettier', 'eslint']}
let g:ale_fixers = {
\ 'javascript': ['prettier', 'eslint'],
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\}
" g + l/L to go to lint errors
nmap gl <Plug>(ale_next_wrap)
nmap gL <Plug>(ale_previous_wrap)
" indent guides config
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 1
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=gray17 ctermbg=235
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=gray38 ctermbg=233
" nerdcommenter config
let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
" gitgutter config
" g + h/H to go to hunks
nmap gh <Plug>(GitGutterNextHunk)
nmap gH <Plug>(GitGutterPrevHunk)
" lightline config
set laststatus=2
set noshowmode
let g:lightline = {
\ 'component_function': {
\ 'filename': 'LightlineFilename',
\ }
\ }
" requires vim-fugitive:
" replace filename with git relative path if it exists, otherwise just full path
function! LightlineFilename()
let root = fnamemodify(get(b:, 'git_dir'), ':h')
let path = expand('%:p')
if path[:len(root)-1] ==# root
return path[len(root)+1:]
endif
return path
endfunction
" nerdtree config
map <leader>o :NERDTreeToggle<CR>
let g:NERDTreeQuitOnOpen = 3
" yankring config
nnoremap <silent> <leader>y :YRShow<CR>
let g:yankring_window_use_horiz = 0
let g:yankring_window_width = 100
"""""""""""""""""""" native config
syntax enable
colorscheme desert
set background=dark
" draw a line 80 characters to the right and make it gray
set colorcolumn=80
highlight ColorColumn ctermbg=8
" make the gutter on the left black
highlight SignColumn ctermbg=black
" recognize mjs as javascript
augroup filetypedetect
au BufRead,BufNewFile *.mjs set filetype=javascript
augroup END
" recognize vue as javascript
augroup filetypedetect
au BufRead,BufNewFile *.vue set filetype=javascript
augroup END
" recognize jsx as javascript.jsx for ale linting
augroup filetypedetect
au BufRead,BufNewFile *.jsx set filetype=javascript.jsx
augroup END
" don't highlight html stupid
highlight htmlItalic gui=italic guifg=#000000 ctermfg=214
" deal with stupid eol stuff
:set binary
:set noeol
" show line numbers
set number
" show autocomplete options when opening files
set wildmenu
" turn on folding, but set fold level to 99
set foldenable " enable folding
set foldmethod=indent
set foldlevelstart=99
" auto collapse folds for javascript and python files
autocmd FileType javascript :normal zM
autocmd FileType python :normal zM
" set up highlighting for searches
set incsearch " search as characters are entered
set hlsearch " highlight matches
" clear search highlight with \<space>
nnoremap <leader><space> :nohlsearch<CR>
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
set expandtab
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
" show tab bar always
set showtabline=2
" update time for vim reduced
set updatetime=100
" <leader> + [1-9] to switch tabs
nnoremap <leader>1 1gt
nnoremap <leader>2 2gt
nnoremap <leader>3 3gt
nnoremap <leader>4 4gt
nnoremap <leader>5 5gt
nnoremap <leader>6 6gt
nnoremap <leader>7 7gt
nnoremap <leader>8 8gt
nnoremap <leader>9 9gt
" <leader> + ]/[ to move tab left/right
map <leader>[ :-tabmove<cr>
map <leader>] :+tabmove<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment