Mercurial > vim
annotate runtime/indent/haml.vim @ 34190:4f8b57f8b07a v9.1.0046
patch 9.1.0046: :drop does not re-use empty buffer
Commit: https://github.com/vim/vim/commit/f96dc8d07f752ddd96d1447d85278a85255a1462
Author: Rocco Mao <dapeng.mao@qq.com>
Date: Tue Jan 23 21:27:19 2024 +0100
patch 9.1.0046: :drop does not re-use empty buffer
Problem: :drop does not re-use empty buffer
(Rocco Mao)
Solution: Make :drop re-use an empty buffer
(Rocco Mao)
fixes: #13851
closes: #13881
Signed-off-by: Rocco Mao <dapeng.mao@qq.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 23 Jan 2024 21:30:05 +0100 |
parents | dce918af0c00 |
children |
rev | line source |
---|---|
1668 | 1 " Vim indent file |
2202 | 2 " Language: Haml |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | |
28141 | 4 " Last Change: 2022 Mar 15 |
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 | |
18818 | 13 setlocal autoindent |
1668 | 14 setlocal indentexpr=GetHamlIndent() |
15 setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when | |
16 | |
28141 | 17 let b:undo_indent = "setl ai< inde< indk<" |
18 | |
1668 | 19 " Only define the function once. |
20 if exists("*GetHamlIndent") | |
21 finish | |
22 endif | |
23 | |
24 let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)' | |
25 let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' | |
26 | |
27 if !exists('g:haml_self_closing_tags') | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2420
diff
changeset
|
28 let g:haml_self_closing_tags = 'base|link|meta|br|hr|img|input' |
1668 | 29 endif |
30 | |
31 function! GetHamlIndent() | |
32 let lnum = prevnonblank(v:lnum-1) | |
33 if lnum == 0 | |
34 return 0 | |
35 endif | |
36 let line = substitute(getline(lnum),'\s\+$','','') | |
37 let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') | |
38 let lastcol = strlen(line) | |
39 let line = substitute(line,'^\s\+','','') | |
40 let indent = indent(lnum) | |
41 let cindent = indent(v:lnum) | |
11518 | 42 let sw = shiftwidth() |
1668 | 43 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
|
44 let indent = cindent < indent ? cindent : indent - sw |
1668 | 45 endif |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
46 let increase = indent + sw |
1668 | 47 if indent == indent(lnum) |
48 let indent = cindent <= indent ? -1 : increase | |
49 endif | |
50 | |
51 let group = synIDattr(synID(lnum,lastcol,1),'name') | |
52 | |
53 if line =~ '^!!!' | |
54 return indent | |
55 elseif line =~ '^/\%(\[[^]]*\]\)\=$' | |
56 return increase | |
2202 | 57 elseif group == 'hamlFilter' |
1668 | 58 return increase |
2202 | 59 elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)' |
60 return increase | |
61 elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' | |
1668 | 62 return increase |
63 elseif line == '-#' | |
64 return increase | |
65 elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^%\v%('.g:haml_self_closing_tags.')>' | |
66 return indent | |
67 elseif group =~? '\v^%(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$' | |
68 return increase | |
69 elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter' | |
70 return GetRubyIndent() | |
71 else | |
72 return indent | |
73 endif | |
74 endfunction | |
75 | |
76 " vim:set sw=2: |