Skip to content

Instantly share code, notes, and snippets.

@kmatt
Last active August 27, 2025 19:28
Show Gist options
  • Select an option

  • Save kmatt/06726b1574cd1e7329b15f2f0403379d to your computer and use it in GitHub Desktop.

Select an option

Save kmatt/06726b1574cd1e7329b15f2f0403379d to your computer and use it in GitHub Desktop.
MYVIMRC
" Based on https://thegreata.pe/articles/2020/07/11/vim-syntax-highlighting-for-sql-strings-inside-python-code/
if exists('g:enable_sql_python_string') && g:enable_sql_python_string
let s:bcs = b:current_syntax
unlet b:current_syntax
syn include @SQL syntax/sql.vim
syntax region sqlPythonString
\ matchgroup=SpecialComment
\ start=~\z('''\|"""\)\_s*\(ALTER\|BEGIN\|CALL\|COMMENT\|COMMIT\|CONNECT\|CREATE\|DELETE\|DROP\|END\|EXPLAIN\|EXPORT\|GRANT\|IMPORT\|INSERT\|LOAD\|LOCK\|MERGE\|REFRESH\|RENAME\|REPLACE\|REVOKE\|ROLLBACK\|SELECT\|SET\|TRUNCATE\|UNLOAD\|UNSET\|UPDATE\|UPSERT\|WITH\)~
\ end=+\z1+
\ contains=@SQL
let b:current_syntax = s:bcs
endif
"Linux: curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"PowerShell: iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |` ni $HOME/vimfiles/autoload/plug.vim -Force
let g:go_version_warning = 0
let g:pymode_python = 'python3'
let g:python3_host_prog = expand('/usr/bin/python3')
call plug#begin()
Plug 'chrisbra/vim-diff-enhanced'
Plug 'csexton/trailertrash.vim'
Plug 'dsolstad/vim-wombat256i'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'fidian/hexmode'
Plug 'gabrielelana/vim-markdown'
Plug 'godlygeek/tabular'
Plug 'gryf/wombat256grf'
Plug 'itchyny/lightline.vim'
Plug 'jlanzarotta/bufexplorer'
Plug 'lbrayner/vim-rzip'
Plug 'mattn/vim-xxdcursor'
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
Plug 'rickhowe/diffchar.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-vinegar'
Plug 'whiteinge/diffconflicts'
Plug 'yegappan/mru'
call plug#end()
let g:DiffUnit = 'Char'
let g:lightline = { 'colorscheme': 'wombat' }
let g:netrw_altv=1
let g:pymode_options_colorcolumn = 0
let g:pymode_lint_ignore = ["C901","E115","E265","E401","E402","E501","E702","W0401"]
let g:python_highlight_all = 1
let g:rzipPlugin_extra_ext = '*.twbx,*.tdsx'
[0/1816]
syntax enable
colorscheme wombat256grf
autocmd FileType sql colorscheme slate
" vim-diff-enhanced
if &diff
let &diffexpr='EnhancedDiff#Diff("git diff", "--diff-algorithm=patience")'
endif
filetype on
filetype indent on
filetype plugin on
set autoindent
set background=dark
set encoding=utf-8
set go+=b
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set modeline
set nocul
set nofoldenable
set noundofile
set nu
set paste
set smartcase
set splitright
set switchbuf=useopen,usetab
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
set wrap
" Buffer nav
noremap <C-S-left> :bp<CR>
noremap <C-S-right> :bn<CR>
"nnoremap <silent> <F12> :BufExplorer<CR>
" Tabs to spaces
nnoremap <Leader>dtab :%s:\t: :g<CR>
" Trim trailing whitespace
nnoremap <Leader>sws :%s/\s\+$//e<CR>
" JSON format
"command! Jsonf :execute '%!python -m json.tool'
command! Jsonf :execute '%!jq .'
" Highlight SQL embedded in Python
command! SqlInPython let g:enable_sql_python_string = 1 | source ~/.vim/after/syntax/python.vim | edit
command! DisableSqlInPython syntax clear sqlPythonString
" Cursor modes (highlight does not override color scheme)
hi nCursor guifg=Black guibg=White
hi iCursor guifg=Black guibg=White
" When using vimdiff or diff mode
highlight DiffAdd term=bold ctermbg=darkgreen ctermfg=white cterm=bold guibg=DarkGreen guifg=White gui=bold
highlight DiffText term=reverse,bold ctermbg=darkred ctermfg=yellow cterm=bold guibg=DarkRed guifg=yellow gui=bold
highlight DiffChange term=bold ctermbg=black ctermfg=white cterm=bold guibg=Black guifg=White gui=bold
highlight DiffDelete term=none ctermbg=darkblue ctermfg=darkblue cterm=none guibg=DarkBlue guifg=DarkBlue gui=none
" When viewing a diff or patch file
"highlight diffRemoved term=bold ctermbg=black ctermfg=red cterm=bold guibg=DarkRed guifg=white gui=none
"highlight diffAdded term=bold ctermbg=black ctermfg=green cterm=bold guibg=DarkGreen guifg=white gui=none
"highlight diffChanged term=bold ctermbg=black ctermfg=yellow cterm=bold guibg=DarkYellow guifg=white gui=none
"highlight diffLine term=bold ctermbg=magenta ctermfg=white cterm=bold guibg=DarkMagenta guifg=white gui=none
"highlight diffFile term=bold ctermbg=yellow ctermfg=black cterm=none guibg=DarkYellow guifg=white gui=none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment