Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
qml.vim60 linesDownload Raw Back to indent
1" Vim indent file2" Language:     QML3" Maintainer:   Chase Knowlden <haroldknowlden@gmail.com>4" Last Change:  2024 Jan 24 by Vim Project5"6" Improved JavaScript indent script.7 8" Indent script in place for this already?9if exists("b:did_indent")10  finish11endif12let b:did_indent = 113let b:undo_indent = "setlocal indentexpr< indentkeys<"14 15setlocal indentexpr=s:GetQmlIndent()16setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*<Return>,=*/17 18" Only define functions once per session19if exists("*s:GetQmlIndent")20  finish21endif22 23" Clean up a line of code by removing trailing '//' and '/* */' comments, and trimming24" whitespace25function! s:Trim(line)26  return substitute(substitute(substitute(a:line, '// .*', '', ''), '/\* .* \*/', '', ''), '^\s*\|\s*$', '', 'g')27endfunction28 29function! s:GetQmlIndent()30  let num = v:lnum31  let line = s:Trim(getline(num))32 33  let pnum = prevnonblank(num - 1)34  if pnum == 035    return 036  endif37  let pline = s:Trim(getline(pnum))38 39  let ind = indent(pnum)40 41  " bracket/brace/paren blocks42  if pline =~ '[{[(]$'43    let ind += shiftwidth()44  endif45  if line =~ '^[}\])]'46    let ind -= shiftwidth()47  endif48 49  " '/*' comments50  if pline =~ '^/\*.*\*/'51    " no indent for single-line form52  elseif pline =~ '^/\*'53    let ind += 154  elseif pline =~ '^\*/'55    let ind -= 156  endif57 58  return ind59endfunction60 
codekingpro/portable-devtools · Team Ai