Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
hamster.vim71 linesDownload Raw Back to indent
1" Vim indent file2" Language:    Hamster Script 3" Version:     2.0.6.14" Last Change: 2021 Oct 115" Maintainer:  David Fishburn <dfishburn dot vim at gmail dot com>6" Download: https://www.vim.org/scripts/script.php?script_id=10997"8"    2.0.6.1 (Oct 2021)9"        Added b:undo_indent10"        Added cpo check11"12 13" Only load this indent file when no other was loaded.14if exists("b:did_indent")15  finish16endif17let b:did_indent = 118 19setlocal indentkeys+==~if,=~else,=~endif,=~endfor,=~endwhile20setlocal indentkeys+==~do,=~until,=~while,=~repeat,=~for,=~loop21setlocal indentkeys+==~sub,=~endsub22 23let b:undo_indent = "setl indentkeys<"24 25" Define the appropriate indent function but only once26setlocal indentexpr=HamGetFreeIndent()27if exists("*HamGetFreeIndent")28  finish29endif30 31let s:keepcpo = &cpo32set cpo&vim33 34function HamGetIndent(lnum)35  let ind = indent(a:lnum)36  let prevline=getline(a:lnum)37 38  " Add a shiftwidth to statements following if,  else, elseif,39  " case, select, default, do, until, while, for, start40  if prevline =~? '^\s*\<\(if\|else\%(if\)\?\|for\|repeat\|do\|while\|sub\)\>' 41    let ind = ind + shiftwidth()42  endif43 44  " Subtract a shiftwidth from else, elseif, end(if|while|for), until45  let line = getline(v:lnum)46  if line =~? '^\s*\(else\|elseif\|loop\|until\|end\%(if\|while\|for\|sub\)\)\>'47    let ind = ind - shiftwidth()48  endif49 50  return ind51endfunction52 53function HamGetFreeIndent()54  " Find the previous non-blank line55  let lnum = prevnonblank(v:lnum - 1)56 57  " Use zero indent at the top of the file58  if lnum == 059    return 060  endif61 62  let ind=HamGetIndent(lnum)63  return ind64endfunction65 66" Restore:67let &cpo = s:keepcpo68unlet s:keepcpo69 70" vim:sw=2 tw=8071 
codekingpro/portable-devtools · Team Ai