Skip to content

Instantly share code, notes, and snippets.

@jwoffindin
Created December 4, 2023 22:26
Show Gist options
  • Save jwoffindin/613e3a365697dcdc81ab0647a7b24d49 to your computer and use it in GitHub Desktop.
Save jwoffindin/613e3a365697dcdc81ab0647a7b24d49 to your computer and use it in GitHub Desktop.
syntax enable
colorscheme elflord
set nu
set clipboard=unnamed
set syntax=on
set expandtab
set autoindent
set sts=4
set ts=2
set sw=2
set nowrap
" set spell
"
let g:ale_completion_enabled = 1
call plug#begin()
" Nicer defaults
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-surround'
" Nicer searching
Plug 'haya14busa/is.vim'
" Nicer status bar
Plug 'vim-airline/vim-airline'
" Code completer for VIM
" Requires brew install vim or macvim
Plug 'valloric/youcompleteme', {'do':'./install.py --clangd-completer --ts-completer'}
" Github marks in the gutter
Plug 'airblade/vim-gitgutter'
" Pretty for HTML + Jinga2
Plug 'Glench/Vim-Jinja2-Syntax'
" File browser
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
" Support EditorConfig
Plug 'editorconfig/editorconfig-vim'
" Remember position when entering a file
Plug 'farmergreg/vim-lastplace'
" Git support in vim
Plug 'tpope/vim-fugitive'
" TOML support for vim
Plug 'cespare/vim-toml'
" Linter/fixer support (LSP)
Plug 'dense-analysis/ale'
" Plug 'hashivim/vim-terraform'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'rizzatti/dash.vim'
" Plug 'github/copilot.vim'
call plug#end()
" Nicer powerline
let g:airline_powerline_fonts = 1
let g:airline#extensions#ale#enabled = 1
" Ale should use virtualenv by default
let g:ale_python_auto_virtualenv = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'terraform': ['terraform'],
\}
let g:ale_fix_on_save = 1
let g:ale_linters = {
\ 'python': ['ruff'],
\}
let g:ale_fixers = {
\ 'python': ['ruff', 'black'],
\}
" Nerdtree customize
map <C-n> :NERDTreeToggle<CR>
" Extra customization
set mouse=a
set spell
" Needed to use is.vim
:set hlsearch
" Reasonable indentations
set expandtab tabstop=4 shiftwidth=4 softtabstop=4
" Putting should not copy too by default in visual mode
vnoremap p "_dP
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd Filetype ruby setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype html setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype markdown setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype css setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype scss setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype cmake setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType yaml setlocal ts=2 sts=2 sw=2
command Date execute "normal a<C-R>=strftime('%FT%T%z')<CR><ESC>"
let g:terraform_fmt_on_save=1
let g:terraform_align=1
let g:ctrlp_show_hidden=1
set omnifunc=ale#completion#OmniFunc
" ******
set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" (Optional)Remove Info(Preview) window
" set completeopt-=preview
" (Optional)Hide Info(Preview) window after completions
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" Trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
nmap <F5> :r!list-active-tickets -t -a<cr>
" nmap <C-J>="r!list-active-tickets -t -a"
" imap <C-J>=system('list-active-tickets', '-t', '-a')<CR>
" Keep undo history across sessions by storing it in a file
let vimDir = '$HOME/.vim'
if has('persistent_undo')
let myUndoDir = expand(vimDir . '/undodir')
" Create dirs
call system('mkdir ' . vimDir)
call system('mkdir ' . myUndoDir)
let &undodir = myUndoDir
set undofile
endif
set undofile " Save undos after file closes
set undodir=$HOME/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
" Spell-check Markdown files and Git Commit Messages
autocmd FileType markdown setlocal spell
autocmd FileType gitcommit setlocal spell
" MacVim needs a nicer font too
:set guifont=SauceCodeProNF-Light:h18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment