Mercurial > vim
annotate runtime/ftplugin/asciidoc.vim @ 34497:7cc0b2479fad v9.1.0155
patch 9.1.0155: can only get getregion() from current buffer
Commit: https://github.com/vim/vim/commit/84bf6e658da51126bdd2e50af1f40cabd149343f
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Wed Mar 6 21:10:18 2024 +0100
patch 9.1.0155: can only get getregion() from current buffer
Problem: can only call getregion() for current buffer
Solution: Allow to retrieve selections from different buffers
(Shougo Matsushita)
closes: #14131
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 06 Mar 2024 21:45:03 +0100 |
parents | ef3a25c3bde8 |
children |
rev | line source |
---|---|
34358
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Vim filetype plugin file |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Original Author: Maxim Kim <habamax@gmail.com> |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Language: asciidoc |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " Maintainer: Luca Saccarola <github.e41mv@aleeas.com> |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " Last Change: 2024 Jan 16 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 if exists("b:did_ftplugin") |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 finish |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let b:did_ftplugin = 1 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 if exists('b:undo_ftplugin') |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 let b:undo_ftplugin .= "|setl cms< com< fo< flp< inex< efm< cfu< fde< fdm<" |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 else |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let b:undo_ftplugin = "setl cms< com< fo< flp< inex< efm< cfu< fde< fdm<" |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 " gf to open include::file.ext[] and link:file.ext[] files |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 setlocal includeexpr=substitute(v:fname,'\\(link:\\\|include::\\)\\(.\\{-}\\)\\[.*','\\2','g') |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 setlocal comments= |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 setlocal commentstring=//\ %s |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 setlocal formatoptions+=cqn |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 setlocal formatlistpat=^\\s*[\\[({]\\?\\([0-9]\\+ |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 setlocal formatlistpat+=\\\|[a-zA-Z]\\)[\\]:.)}]\\s\\+ |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 setlocal formatlistpat+=\\\|^\\s*-\\s\\+ |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 setlocal formatlistpat+=\\\|^\\s*[*]\\+\\s\\+ |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 setlocal formatlistpat+=\\\|^\\s*[.]\\+\\s\\+ |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 function AsciidocFold() |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 let line = getline(v:lnum) |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 if (v:lnum == 1) && (line =~ '^----*$') |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 return ">1" |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 let nested = get(g:, "asciidoc_foldnested", 1) |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 " Regular headers |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 let depth = match(line, '\(^=\+\)\@<=\( .*$\)\@=') |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 " Do not fold nested regular headers |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 if depth > 1 && !nested |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 let depth = 1 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 if depth > 0 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 " fold all sections under title |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 if depth > 1 && !get(g:, "asciidoc_fold_under_title", 1) |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 let depth -= 1 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 " check syntax, it should be asciidocTitle or asciidocH |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 let syncode = synstack(v:lnum, 1) |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 if len(syncode) > 0 && synIDattr(syncode[0], 'name') =~ 'asciidoc\%(H[1-6]\)\|Title' |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 return ">" . depth |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 endif |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 return "=" |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 endfunction |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 if has("folding") && get(g:, 'asciidoc_folding', 0) |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 setlocal foldexpr=AsciidocFold() |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 setlocal foldmethod=expr |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<" |
ef3a25c3bde8
runtime(asciidoc): include basic ftplugin
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 endif |