" Vim indent file
" Language: Erlang (http://www.erlang.org)
" Author: Csaba Hoch <csaba.hoch@gmail.com>
" Contributors: Edwin Fine <efine145_nospam01 at usa dot net>
" Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
" Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" Last Update: 2020-Jun-11
" License: Vim license
" URL: https://github.com/vim-erlang/vim-erlang-runtime
" Note About Usage:
" This indentation script works best with the Erlang syntax file created by
" Kreąimir Marľić (Kresimir Marzic) and maintained by Csaba Hoch.
" Notes About Implementation:
"
" - LTI = Line to indent.
" - The index of the first line is 1, but the index of the first column is 0.
" Initialization {{{1
" ==============
" Only load this indent file when no other was loaded
" Vim 7 or later is needed
if exists("b:did_indent") || version < 700
finish
else
let b:did_indent = 1
endif
setlocal indentexpr=ErlangIndent()
setlocal indentkeys+=0=end,0=of,0=catch,0=after,0=when,0=),0=],0=},0=>>
" Only define the functions once
if exists("*ErlangIndent")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
" Logging library {{{1
" ===============
" Purpose:
" Logs the given string using the ErlangIndentLog function if it exists.
" Parameters:
" s: string
function! s:Log(s)
if exists("*ErlangIndentLog")
call ErlangIndentLog(a:s)
endif
endfunction
" Line tokenizer library {{{1
" ======================
" Indtokens are "indentation tokens". See their exact format in the
" documentation of the s:GetTokensFromLine function.
" Purpose:
" Calculate the new virtual column after the given segment of a line.
" Parameters:
" line: string
" first_index: integer -- the index of the first character of the segment
" last_index: integer -- the index of the last character of the segment
" vcol: integer -- the virtual column of the first character of the token
" tabstop: integer -- the value of the 'tabstop' option to be used
" Returns:
" vcol: integer
" Example:
" " index: 0 12 34567
" " vcol: 0 45 89
" s:CalcVCol("\t'\tx', b", 1, 4, 4) -> 10