Mercurial > vim
annotate runtime/indent/perl6.vim @ 17867:180fb9981255 v8.1.1930
patch 8.1.1930: cannot recognize .jsx and .tsx files
Commit: https://github.com/vim/vim/commit/92852cee3fcff1dc6ce12387b234634e73267b22
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 26 21:28:15 2019 +0200
patch 8.1.1930: cannot recognize .jsx and .tsx files
Problem: Cannot recognize .jsx and .tsx files.
Solution: Recognize them as javascriptreact and typescriptreact.
(closes #4830)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Aug 2019 21:30:04 +0200 |
parents | 63b0b7b79b25 |
children | bd021eb62e73 |
rev | line source |
---|---|
2152 | 1 " Vim indent file |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2 " Language: Perl 6 |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
3 " Maintainer: vim-perl <vim-perl@googlegroups.com> |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
4 " Homepage: http://github.com/vim-perl/vim-perl |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
5 " Bugs/requests: http://github.com/vim-perl/vim-perl/issues |
11518 | 6 " Last Change: 2017 Jun 13 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
7 " Contributors: Andy Lester <andy@petdance.com> |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
8 " Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> |
2152 | 9 " |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
10 " Adapted from indent/perl.vim by Rafael Garcia-Suarez <rgarciasuarez@free.fr> |
2152 | 11 |
12 " Suggestions and improvements by : | |
13 " Aaron J. Sherman (use syntax for hints) | |
14 " Artem Chuprina (play nice with folding) | |
15 " TODO: | |
16 " This file still relies on stuff from the Perl 5 syntax file, which Perl 6 | |
17 " does not use. | |
18 " | |
19 " Things that are not or not properly indented (yet) : | |
20 " - Continued statements | |
21 " print "foo", | |
22 " "bar"; | |
23 " print "foo" | |
24 " if bar(); | |
25 " - Multiline regular expressions (m//x) | |
26 " (The following probably needs modifying the perl syntax file) | |
27 " - qw() lists | |
28 " - Heredocs with terminators that don't match \I\i* | |
29 | |
30 " Only load this indent file when no other was loaded. | |
31 if exists("b:did_indent") | |
32 finish | |
33 endif | |
34 let b:did_indent = 1 | |
35 | |
36 " Is syntax highlighting active ? | |
37 let b:indent_use_syntax = has("syntax") | |
38 | |
39 setlocal indentexpr=GetPerl6Indent() | |
40 | |
41 " we reset it first because the Perl 5 indent file might have been loaded due | |
42 " to a .pl/pm file extension, and indent files don't clean up afterwards | |
43 setlocal indentkeys& | |
44 | |
45 setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and | |
46 if !b:indent_use_syntax | |
47 setlocal indentkeys+=0=EO | |
48 endif | |
49 | |
50 let s:cpo_save = &cpo | |
51 set cpo-=C | |
52 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
53 function! GetPerl6Indent() |
2152 | 54 |
55 " Get the line to be indented | |
56 let cline = getline(v:lnum) | |
57 | |
58 " Indent POD markers to column 0 | |
59 if cline =~ '^\s*=\L\@!' | |
60 return 0 | |
61 endif | |
62 | |
63 " Don't reindent coments on first column | |
64 if cline =~ '^#' | |
65 return 0 | |
66 endif | |
67 | |
68 " Get current syntax item at the line's first char | |
69 let csynid = '' | |
70 if b:indent_use_syntax | |
71 let csynid = synIDattr(synID(v:lnum,1,0),"name") | |
72 endif | |
73 | |
74 " Don't reindent POD and heredocs | |
75 if csynid =~ "^p6Pod" | |
76 return indent(v:lnum) | |
77 endif | |
78 | |
79 | |
80 " Now get the indent of the previous perl line. | |
81 | |
82 " Find a non-blank line above the current line. | |
83 let lnum = prevnonblank(v:lnum - 1) | |
84 " Hit the start of the file, use zero indent. | |
85 if lnum == 0 | |
86 return 0 | |
87 endif | |
88 let line = getline(lnum) | |
89 let ind = indent(lnum) | |
90 " Skip heredocs, POD, and comments on 1st column | |
91 if b:indent_use_syntax | |
92 let skippin = 2 | |
93 while skippin | |
94 let synid = synIDattr(synID(lnum,1,0),"name") | |
95 if (synid =~ "^p6Pod" || synid =~ "p6Comment") | |
96 let lnum = prevnonblank(lnum - 1) | |
97 if lnum == 0 | |
98 return 0 | |
99 endif | |
100 let line = getline(lnum) | |
101 let ind = indent(lnum) | |
102 let skippin = 1 | |
103 else | |
104 let skippin = 0 | |
105 endif | |
106 endwhile | |
107 endif | |
108 | |
109 if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$' | |
11518 | 110 let ind = ind + shiftwidth() |
2152 | 111 endif |
112 if cline =~ '^\s*[)}\]»>]' | |
11518 | 113 let ind = ind - shiftwidth() |
2152 | 114 endif |
115 | |
116 " Indent lines that begin with 'or' or 'and' | |
117 if cline =~ '^\s*\(or\|and\)\>' | |
118 if line !~ '^\s*\(or\|and\)\>' | |
11518 | 119 let ind = ind + shiftwidth() |
2152 | 120 endif |
121 elseif line =~ '^\s*\(or\|and\)\>' | |
11518 | 122 let ind = ind - shiftwidth() |
2152 | 123 endif |
124 | |
125 return ind | |
126 | |
127 endfunction | |
128 | |
129 let &cpo = s:cpo_save | |
130 unlet s:cpo_save | |
131 | |
132 " vim:ts=8:sts=4:sw=4:expandtab:ft=vim |