Mercurial > vim
annotate runtime/indent/haml.vim @ 18619:788d76db02ac v8.1.2302
patch 8.1.2302: :lockmarks does not work for '[ and ']
Commit: https://github.com/vim/vim/commit/f4a1d1c0542df151bc59ac3b798ed198b5c71ccc
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 16 13:50:25 2019 +0100
patch 8.1.2302: :lockmarks does not work for '[ and ']
Problem: :lockmarks does not work for '[ and '].
Solution: save and restore '[ and '] marks. (James McCoy, closes https://github.com/vim/vim/issues/5222)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 16 Nov 2019 14:00:05 +0100 |
parents | 63b0b7b79b25 |
children | 5c40013d45ee |
rev | line source |
---|---|
1668 | 1 " Vim indent file |
2202 | 2 " Language: Haml |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | |
11518 | 4 " Last Change: 2017 Jun 13 |
1668 | 5 |
6 if exists("b:did_indent") | |
7 finish | |
8 endif | |
9 runtime! indent/ruby.vim | |
10 unlet! b:did_indent | |
11 let b:did_indent = 1 | |
12 | |
13 setlocal autoindent sw=2 et | |
14 setlocal indentexpr=GetHamlIndent() | |
15 setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when | |
16 | |
17 " Only define the function once. | |
18 if exists("*GetHamlIndent") | |
19 finish | |
20 endif | |
21 | |
22 let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)' | |
23 let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' | |
24 | |
25 if !exists('g:haml_self_closing_tags') | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2420
diff
changeset
|
26 let g:haml_self_closing_tags = 'base|link|meta|br|hr|img|input' |
1668 | 27 endif |
28 | |
29 function! GetHamlIndent() | |
30 let lnum = prevnonblank(v:lnum-1) | |
31 if lnum == 0 | |
32 return 0 | |
33 endif | |
34 let line = substitute(getline(lnum),'\s\+$','','') | |
35 let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') | |
36 let lastcol = strlen(line) | |
37 let line = substitute(line,'^\s\+','','') | |
38 let indent = indent(lnum) | |
39 let cindent = indent(v:lnum) | |
11518 | 40 let sw = shiftwidth() |
1668 | 41 if cline =~# '\v^-\s*%(elsif|else|when)>' |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
42 let indent = cindent < indent ? cindent : indent - sw |
1668 | 43 endif |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
44 let increase = indent + sw |
1668 | 45 if indent == indent(lnum) |
46 let indent = cindent <= indent ? -1 : increase | |
47 endif | |
48 | |
49 let group = synIDattr(synID(lnum,lastcol,1),'name') | |
50 | |
51 if line =~ '^!!!' | |
52 return indent | |
53 elseif line =~ '^/\%(\[[^]]*\]\)\=$' | |
54 return increase | |
2202 | 55 elseif group == 'hamlFilter' |
1668 | 56 return increase |
2202 | 57 elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)' |
58 return increase | |
59 elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' | |
1668 | 60 return increase |
61 elseif line == '-#' | |
62 return increase | |
63 elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^%\v%('.g:haml_self_closing_tags.')>' | |
64 return indent | |
65 elseif group =~? '\v^%(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$' | |
66 return increase | |
67 elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter' | |
68 return GetRubyIndent() | |
69 else | |
70 return indent | |
71 endif | |
72 endfunction | |
73 | |
74 " vim:set sw=2: |