Skip to content

Instantly share code, notes, and snippets.

@louisrli
Created June 2, 2020 18:24
Show Gist options
  • Save louisrli/fae3012056aeb881a6846e8b5ff9c539 to your computer and use it in GitHub Desktop.
Save louisrli/fae3012056aeb881a6846e8b5ff9c539 to your computer and use it in GitHub Desktop.
filetype on
filetype indent on
filetype plugin on
syntax on
set wildmenu
set splitright
let g:goyo_width=110
" Performance reasons, maybe
let g:airline#extensions#whitespace#mixed_indent_algo = 0
set wildignore=*.swp,*.bak,*.pyc,*.class,*.jar,*.gif,*.png,*.jpg,*.aux,*.log,*/node_modules/*
" Some of these might be overrided by vim-sensible
set hlsearch
set showcmd
set autoindent smartindent
set autochdir
" Remap command key
let mapleader=","
nore ; :
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
nnoremap <Leader>p :Gstatus<CR>
nnoremap <Leader>c :Gcommit<CR>
nnoremap <Leader>e :e#<CR>
nnoremap <Leader>v :set paste!<CR>
nnoremap <Leader>t :tabnew<CR>
nnoremap <F2> :bp<bar>sp<bar>bn<bar>bd<CR>
nnoremap <F3> :ccl<BR>
nmap <space> :w<CR>
:nnoremap <Tab> <C-w>w
" latex-box
let g:LatexBox_viewer="open"
let g:tex_flavor='latex' " Default to ft=tex
" Search
set smartcase
set ignorecase
" Relative line numbers
set rnu
" Change tabs to 4 spaces
set expandtab
set smarttab
set shiftwidth=2
set softtabstop=2
" pathogen
execute pathogen#infect()
Helptags
" Airline
set laststatus=2
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='base16_google'
" Highlight colors for current line and visual block
set cul
set notermguicolors
hi CursorLine term=none cterm=none ctermbg=yellow ctermfg=black
hi Visual ctermfg=Black ctermbg=White cterm=none term=none
hi LineNr ctermfg=lightgrey ctermbg=black
hi Search cterm=NONE ctermfg=black ctermbg=blue
hi Todo ctermfg=NONE cterm=bold ctermbg=darkgrey
hi def link tsxCloseTagName tsxCloseString
nnoremap <C-l> :noh<CR>
" Highlight colors for spelling aka for syntax
hi SpellBad ctermfg=red
" 2 space tabs
au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.html setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.md setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.less setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.lessimport setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.js setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.py setl shiftwidth=2 expandtab
" 100 char lines on tex and md files
au BufNewFile,BufReadPost *.tex setl tw=100
" Syntax checking via Syntastic
"let g:syntastic_mode_map={ 'mode': 'active',
" \ 'active_filetypes': [],
" \ 'passive_filetypes': ['html'] }
"let g:syntastic_python_checkers=['pylint']
au FileType python set nosmartindent " prevents # from being set to left
autocmd FileType python nnoremap <buffer> <F4> :exec '!python' shellescape(@%, 1)<CR>
" autoregen ctags with exuberant c-tags
au BufWritePost *.c,*.cpp,*.h silent! !ctags -R &
" autoindent ocaml
autocmd FileType python nnoremap <leader>y :0,$!yapf<Cr><C-o>
au BufNewFile,BufRead *.prisma set ft=graphql
:imap ;; <Esc>
" Fix backspace not working in insert mode.
set backspace=indent,eol,start
" Autowrap when hitting 80 chars. Need to set after ft mods.
autocmd FileType * set formatoptions+=t
set textwidth=80
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
highlight Pmenu ctermbg=white ctermfg=black
" Remaps C-w C-w so that if its quickfix, it skips again
nnoremap <silent> <C-w><C-w> <C-w><C-w>:if &buftype ==# 'quickfix'<Bar>wincmd w<Bar>endif<CR>
let g:closetag_filenames = '*.html,*.jsx,*.tsx'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx'
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>>'
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
" https://vim.fandom.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
" Auto quickfix height https://vim.fandom.com/wiki/Automatically_fitting_a_quickfix_window_height
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment