Mercurial > vim
annotate runtime/indent/logtalk.vim @ 34361:6b9eefad14d8 v9.1.0111
patch 9.1.0111: filetype: no support for bats files
Commit: https://github.com/vim/vim/commit/d00fb4b3a237b375de5a1f453c8453b8b3797d51
Author: Brandon Maier <brandon.maier@collins.com>
Date: Thu Feb 15 00:16:02 2024 +0100
patch 9.1.0111: filetype: no support for bats files
The '*.bats' file type is for Bash Automated Testing System (BATS)
scripts. BATS scripts are Bash with a special '@test' extension but they
otherwise work with Vim's bash filetype.
See https://github.com/bats-core/bats-core
closes: #14039
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 15 Feb 2024 00:30:02 +0100 |
parents | 5c220cf30f1f |
children |
rev | line source |
---|---|
1668 | 1 " Maintainer: Paulo Moura <pmoura@logtalk.org> |
14519 | 2 " Revised on: 2018.08.04 |
33052
5c220cf30f1f
runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents:
14519
diff
changeset
|
3 " 2023 Aug 28 by Vim Project (undo_indent) |
1668 | 4 " Language: Logtalk |
5 | |
6 " This Logtalk indent file is a modified version of the Prolog | |
7 " indent file written by Gergely Kontra | |
8 | |
9 " Only load this indent file when no other was loaded. | |
10 if exists("b:did_indent") | |
11 finish | |
12 endif | |
13 | |
14 let b:did_indent = 1 | |
15 | |
16 setlocal indentexpr=GetLogtalkIndent() | |
17 setlocal indentkeys-=:,0# | |
18 setlocal indentkeys+=0%,-,0;,>,0) | |
19 | |
33052
5c220cf30f1f
runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents:
14519
diff
changeset
|
20 let b:undo_indent = "setlocal indentexpr< indentkeys<" |
5c220cf30f1f
runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents:
14519
diff
changeset
|
21 |
1668 | 22 " Only define the function once. |
23 if exists("*GetLogtalkIndent") | |
24 finish | |
25 endif | |
26 | |
27 function! GetLogtalkIndent() | |
28 " Find a non-blank line above the current line. | |
29 let pnum = prevnonblank(v:lnum - 1) | |
30 " Hit the start of the file, use zero indent. | |
31 if pnum == 0 | |
32 return 0 | |
33 endif | |
34 let line = getline(v:lnum) | |
35 let pline = getline(pnum) | |
36 | |
37 let ind = indent(pnum) | |
38 " Previous line was comment -> use previous line's indent | |
39 if pline =~ '^\s*%' | |
40 retu ind | |
41 endif | |
42 " Check for entity opening directive on previous line | |
43 if pline =~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$' | |
11518 | 44 let ind = ind + shiftwidth() |
1668 | 45 " Check for clause head on previous line |
46 elseif pline =~ ':-\s*\(%.*\)\?$' | |
11518 | 47 let ind = ind + shiftwidth() |
14519 | 48 " Check for grammar rule head on previous line |
49 elseif pline =~ '-->\s*\(%.*\)\?$' | |
50 let ind = ind + shiftwidth() | |
1668 | 51 " Check for entity closing directive on previous line |
52 elseif pline =~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\?$' | |
11518 | 53 let ind = ind - shiftwidth() |
1668 | 54 " Check for end of clause on previous line |
55 elseif pline =~ '\.\s*\(%.*\)\?$' | |
11518 | 56 let ind = ind - shiftwidth() |
1668 | 57 endif |
58 " Check for opening conditional on previous line | |
59 if pline =~ '^\s*\([(;]\|->\)' && pline !~ '\.\s*\(%.*\)\?$' && pline !~ '^.*\([)][,]\s*\(%.*\)\?$\)' | |
11518 | 60 let ind = ind + shiftwidth() |
1668 | 61 endif |
62 " Check for closing an unclosed paren, or middle ; or -> | |
63 if line =~ '^\s*\([);]\|->\)' | |
11518 | 64 let ind = ind - shiftwidth() |
1668 | 65 endif |
66 return ind | |
67 endfunction |