1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-22 01:35:11 +01:00
vim/runtime/indent/teraterm.vim

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.4 KiB
VimL
Raw Normal View History

2015-07-21 19:19:13 +02:00
" Vim indent file
" Language: Tera Term Language (TTL)
2018-09-02 21:07:30 +02:00
" Based on Tera Term Version 4.100
2015-07-21 19:19:13 +02:00
" Maintainer: Ken Takata
" URL: https://github.com/k-takata/vim-teraterm
2021-10-23 12:08:41 +01:00
" Last Change: 2021-10-18
2015-07-21 19:19:13 +02:00
" Filenames: *.ttl
" License: VIM License
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal nosmartindent
setlocal noautoindent
setlocal indentexpr=GetTeraTermIndent(v:lnum)
setlocal indentkeys=!^F,o,O,e
setlocal indentkeys+==elseif,=endif,=loop,=next,=enduntil,=endwhile
2021-10-23 12:08:41 +01:00
let b:undo_indent = "setl ai< inde< indk< si<"
2015-07-21 19:19:13 +02:00
if exists("*GetTeraTermIndent")
finish
endif
function! GetTeraTermIndent(lnum)
let l:prevlnum = prevnonblank(a:lnum-1)
if l:prevlnum == 0
" top of file
return 0
endif
" grab the previous and current line, stripping comments.
let l:prevl = substitute(getline(l:prevlnum), ';.*$', '', '')
let l:thisl = substitute(getline(a:lnum), ';.*$', '', '')
let l:previ = indent(l:prevlnum)
let l:ind = l:previ
2016-08-18 22:54:46 +02:00
if l:prevl =~ '^\s*if\>.*\<then\>'
2015-07-21 19:19:13 +02:00
" previous line opened a block
let l:ind += shiftwidth()
2015-07-21 19:19:13 +02:00
endif
if l:prevl =~ '^\s*\%(elseif\|else\|do\|until\|while\|for\)\>'
" previous line opened a block
let l:ind += shiftwidth()
2015-07-21 19:19:13 +02:00
endif
if l:thisl =~ '^\s*\%(elseif\|else\|endif\|enduntil\|endwhile\|loop\|next\)\>'
" this line closed a block
let l:ind -= shiftwidth()
2015-07-21 19:19:13 +02:00
endif
return l:ind
endfunction
" vim: ts=8 sw=2 sts=2