Skip to content

Instantly share code, notes, and snippets.

@jettero
Last active July 7, 2018 13:28
Show Gist options
  • Save jettero/4a619004fb23ada1e5cf302211eee8ae to your computer and use it in GitHub Desktop.
Save jettero/4a619004fb23ada1e5cf302211eee8ae to your computer and use it in GitHub Desktop.
python configparser syntax for vim
" Vim syntax file
" Language: Python configparser
" Maintainer: Paul Miller (jettero@github)
" EARL: https://gist.github.com/jettero/4a619004fb23ada1e5cf302211eee8ae
" Last Change: 2018-07-07
" Ripped from:
" lang: Good old CFG files
" maint: Igor N. Prischepoff ([email protected], [email protected])
" their lc: 2018 Jul 06
if version < 600
syntax clear
elseif exists ("b:current_syntax")
finish
endif
syn case ignore
syn region CfgSectionContainer start="^\[.*\]" skip='.' end='^\[.*\]'me=s-1,re=s-1 contains=CfgKV,CfgComment,CfgSection
syn match CfgSection '\[.*\]' contained
syn region CfgKV start='^\S\+\s*[:=]' end='^\S'me=s-1,re=s-1 contains=CfgParams,CfgValues contained keepend
syn match CfgParams "^\S\+\s*[:=]"me=e-1 contained
syn match CfgValues "[:=].*"ms=s+1 contained contains=CfgInlineComment,CfgInterpError,CfgInterp
syn match CfgValues "^ .*"ms=s+1 contained contains=CfgInlineComment,CfgInterpError,CfgInterp
syn match CfgInterpError "%[(]\S*" contained contains=CfgInterp
syn match CfgInterp "%[(]\S\+[)][sd]" contained
syn match CfgComment "^[ \t]*#.*"
syn match CfgInlineComment "\s;.*" contained
if version >= 508 || !exists("did_pycfg_syn_inits")
if version < 508
let did_pycfg_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink CfgComment Comment
HiLink CfgInlineComment Comment
HiLink CfgSection Type
HiLink CfgString String
HiLink CfgParams Keyword
HiLink CfgValues Constant
HiLink CfgSectionContainer Error
HiLink CfgInterp Identifier
HiLink CfgInterpError Error
" for debug only
" HiLink CfgKV Identifier
delcommand HiLink
endif
let b:current_syntax = "pycfg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment