Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
hog.vim78 linesDownload Raw Back to indent
1" Vim indent file2" Language:     hog (Snort.conf)3" Maintainer:   Victor Roemer, <vroemer@badsec.org>4" Last Change:  Mar 7, 20135 6" Only load this indent file when no other was loaded.7if exists("b:did_indent")8    finish9endif10let b:did_indent = 111let b:undo_indent = 'setlocal smartindent< indentexpr< indentkeys<'12 13setlocal nosmartindent14setlocal indentexpr=GetHogIndent()15setlocal indentkeys+=!^F,o,O,0#16 17" Only define the function once.18if exists("*GetHogIndent")19    finish20endif21 22let s:cpo_save = &cpo23set cpo&vim24 25let s:syn_blocks = '\<SnortRuleTypeBody\>'26 27function s:IsInBlock(lnum)28    return synIDattr(synID(a:lnum, 1, 1), 'name') =~ s:syn_blocks 29endfunction30 31function GetHogIndent()32    let prevlnum = prevnonblank(v:lnum-1)33 34    " Comment blocks have identical indent35    if getline(v:lnum) =~ '^\s*#' && getline(prevlnum) =~ '^\s*#'36            return indent(prevlnum)37    endif38 39    " Ignore comment lines when calculating indent40    while getline(prevlnum) =~ '^\s*#'41        let prevlnum = prevnonblank(prevlnum-1)42        if !prevlnum43            return previndent44        endif45    endwhile46 47    " Continuation of a line that wasn't indented48    let prevline = getline(prevlnum)49    if prevline =~ '^\k\+.*\\\s*$'50        return shiftwidth() 51    endif52 53    " Continuation of a line that was indented54    if prevline =~ '\k\+.*\\\s*$'55        return indent(prevlnum)56    endif57 58    " Indent the next line if previous line contained a start of a block59    " definition ('{' or '(').60    if prevline =~ '^\k\+[^#]*{}\@!\s*$' " TODO || prevline =~ '^\k\+[^#]*()\@!\s*$'61        return shiftwidth()62    endif63 64    " Match inside of a block65    if s:IsInBlock(v:lnum)66        if prevline =~ "^\k\+.*$"67            return shiftwidth()68        else69            return indent(prevlnum)70        endif71    endif72 73    return 0 74endfunction75 76let &cpo = s:cpo_save77unlet s:cpo_save78 
codekingpro/portable-devtools · Team Ai