<commit_before>" Language:    CoffeeScript
" Maintainer:  <NAME> <<EMAIL>>
" URL:         http://github.com/kchmck/vim-coffee-script
" License:     WTFPL

if exists("b:did_indent")
  finish
endif

let b:did_indent = 1

setlocal autoindent
setlocal indentexpr=GetCoffeeIndent(v:lnum)
" Make sure GetCoffeeIndent is run when these are typed so they can be outdented
setlocal indentkeys+=0],0),=else,=when,=catch,=finally

" Only define the function once
if exists("*GetCoffeeIndent")
  finish
endif

" Join a list of regexps as branches
function! s:RegexpJoin(regexps)
  return join(a:regexps, '\|')
endfunction

" Create a regexp group from a list of regexps
function! s:RegexpGroup(...)
  return '\%(' . s:RegexpJoin(a:000) . '\)'
endfunction

" Outdent certain keywords and brackets
let s:outdent = '^'
\             . s:RegexpGroup('else', 'when', 'catch', 'finally',
\                             ']', '}', ')')

" Indent after certain keywords
let s:indent_after_keywords = '^'
\                           . s:RegexpGroup('if', 'unless', 'else', 'for',
\                                           'while', 'until', 'loop', 'switch',
\                                           'when', 'try', 'catch', 'finally',
\                                           'class')
\                           . '\>'

" Indent after brackets and functions
let s:indent_after_literals = s:RegexpGroup('\[', '{', '(', '->', '=>') . '$'

" Combine the two regexps above
let s:indent_after = s:RegexpJoin([s:indent_after_keywords,
\                                  s:indent_after_literals])

" Indent after certain keywords used in multi-line assignments
let s:assignment_keywords = s:RegexpGroup(':', '=')
\                         . '\s*\<'
\                         . s:RegexpGroup('if', 'unless', 'for', 'while',
\                                         'until', 'switch', 'try', 'class')
\                         . '\>'

" Outdent after certain keywords
let s:outdent_after = '^'
\                   . s:RegexpGroup('return', 'break', 'continue', 'throw')
\                   . '\>'

" Don't outdent if the line contains one of these keywords (for cases like
" 'return if a is b', 'break unless a', etc.)
let s:dont_outdent_after = '\<' . s:RegexpGroup('if', 'unless') . '\>'

" Check for a single-line statement (e.g., 'if a then b'), which doesn't need an
" indent afterwards
function! s:IsSingleLineStatement(line)<commit_msg>Indent after lines ending in an assignment operator<commit_after>" Language:    CoffeeScript
" Maintainer:  <NAME> <<EMAIL>>
" URL:         http://github.com/kchmck/vim-coffee-script
" License:     WTFPL

if exists("b:did_indent")
  finish
endif

let b:did_indent = 1

setlocal autoindent
setlocal indentexpr=GetCoffeeIndent(v:lnum)
" Make sure GetCoffeeIndent is run when these are typed so they can be outdented
setlocal indentkeys+=0],0),=else,=when,=catch,=finally

" Only define the function once
if exists("*GetCoffeeIndent")
  finish
endif

" Join a list of regexps as branches
function! s:RegexpJoin(regexps)
  return join(a:regexps, '\|')
endfunction

" Create a regexp group from a list of regexps
function! s:RegexpGroup(...)
  return '\%(' . s:RegexpJoin(a:000) . '\)'
endfunction

" Outdent certain keywords and brackets
let s:outdent = '^'
\             . s:RegexpGroup('else', 'when', 'catch', 'finally',
\                             ']', '}', ')')

" Indent after certain keywords
let s:indent_after_keywords = '^'
\                           . s:RegexpGroup('if', 'unless', 'else', 'for',
\                                           'while', 'until', 'loop', 'switch',
\                                           'when', 'try', 'catch', 'finally',
\                                           'class')
\                           . '\>'

" Indent after brackets, functions, and assignments
let s:indent_after_literals = s:RegexpGroup('\[', '{', '(', '->', '=>',
\                                           ':', '=')
\                           . '$'

" Combine the two regexps above
let s:indent_after = s:RegexpJoin([s:indent_after_keywords,
\                                  s:indent_after_literals])

" Indent after certain keywords used in multi-line assignments
let s:assignment_keywords = s:RegexpGroup(':', '=')
\                         . '\s*\<'
\                         . s:RegexpGroup('if', 'unless', 'for', 'while',
\                                         'until', 'switch', 'try', 'class')
\                         . '\>'

" Outdent after certain keywords
let s:outdent_after = '^'
\                   . s:RegexpGroup('return', 'break', 'continue', 'throw')
\                   . '\>'

" Don't outdent if the line contains one of these keywords (for cases like
" 'return if a is b', 'break unless a', etc.)
let s:dont_outdent_after = '\<' . s:RegexpGroup('if', 'unless') . '\>'

" Check for a single-line statement (e.g., 'if a then b'), which doesn't need an
" indent afterwards
function! s:IsSingleLineStatement(line)
{'fraction_non_alphanumeric': 0.14796944109368718, 'fraction_numerical': 0.0024125452352231603, 'mean_word_length': 2.123038292529818, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '461750', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1469, 'n_words': 393}