blob: 941222bd38c289049892d3b4f6c84890b1f291c1 [file] [log] [blame]
Bram Moolenaar11e3c5b2021-04-21 18:09:37 +02001" Vim filetype plugin file
2" Language: Raku
3" Maintainer: vim-perl <vim-perl@googlegroups.com>
4" Homepage: https://github.com/Raku/vim-raku
5" Bugs/requests: https://github.com/Raku/vim-raku/issues
6" Last Change: 2021-04-16
7" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
8"
9" Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com>
10
11if exists("b:did_ftplugin") | finish | endif
12let b:did_ftplugin = 1
13
14" Make sure the continuation lines below do not cause problems in
15" compatibility mode.
16let s:save_cpo = &cpo
17set cpo-=C
18
19setlocal formatoptions-=t
20setlocal formatoptions+=crqol
21setlocal keywordprg=p6doc
22
23setlocal comments=:#\|,:#=,:#
24setlocal commentstring=#%s
25
26" Provided by Ned Konz <ned at bike-nomad dot com>
27"---------------------------------------------
28setlocal include=\\<\\(use\\\|require\\)\\>
29setlocal includeexpr=substitute(v:fname,'::','/','g')
30setlocal suffixesadd=.rakumod,.rakudoc,.pm6,.pm
31setlocal define=[^A-Za-z_]
32
33" The following line changes a global variable but is necessary to make
34" gf and similar commands work. Thanks to Andrew Pimlott for pointing out
35" the problem. If this causes a problem for you, add an
36" after/ftplugin/raku.vim file that contains
37" set isfname-=:
38set isfname+=:
39setlocal iskeyword=@,48-57,_,192-255,-
40
41" Raku exposes its CompUnits through $*REPO, but mapping module names to
42" compunit paths is nontrivial. Probably it's more convenient to rely on
43" people using zef, which has a handy store of sources for modules it has
44" installed.
45func s:compareReverseFtime(a, b)
46 let atime = getftime(a:a)
47 let btime = getftime(a:b)
48 return atime > btime ? -1 : atime == btime ? 0 : 1
49endfunc
50
51let &l:path = "lib,."
52if exists('$RAKULIB')
53 let &l:path = &l:path . "," . $RAKULIB
54endif
55let &l:path = &l:path . "," . join(
56 \ sort(glob("~/.zef/store/*/*/lib", 0, 1), "s:compareReverseFtime"),
57 \ ',')
58
59" Convert ascii-based ops into their single-character unicode equivalent
60if get(g:, 'raku_unicode_abbrevs', 0)
61 iabbrev <buffer> !(<) ⊄
62 iabbrev <buffer> !(<=) ⊈
63 iabbrev <buffer> !(>) ⊅
64 iabbrev <buffer> !(>=) ⊉
65 iabbrev <buffer> !(cont) ∌
66 iabbrev <buffer> !(elem) ∉
67 iabbrev <buffer> != ≠
68 iabbrev <buffer> (&) ∩
69 iabbrev <buffer> (+) ⊎
70 iabbrev <buffer> (-) ∖
71 iabbrev <buffer> (.) ⊍
72 iabbrev <buffer> (<) ⊂
73 iabbrev <buffer> (<+) ≼
74 iabbrev <buffer> (<=) ⊆
75 iabbrev <buffer> (>) ⊃
76 iabbrev <buffer> (>+) ≽
77 iabbrev <buffer> (>=) ⊇
78 iabbrev <buffer> (\|) ∪
79 iabbrev <buffer> (^) ⊖
80 iabbrev <buffer> (atomic) ⚛
81 iabbrev <buffer> (cont) ∋
82 iabbrev <buffer> (elem) ∈
83 iabbrev <buffer> * ×
84 iabbrev <buffer> **0 ⁰
85 iabbrev <buffer> **1 ¹
86 iabbrev <buffer> **2 ²
87 iabbrev <buffer> **3 ³
88 iabbrev <buffer> **4 ⁴
89 iabbrev <buffer> **5 ⁵
90 iabbrev <buffer> **6 ⁶
91 iabbrev <buffer> **7 ⁷
92 iabbrev <buffer> **8 ⁸
93 iabbrev <buffer> **9 ⁹
94 iabbrev <buffer> ... …
95 iabbrev <buffer> / ÷
96 iabbrev <buffer> << «
97 iabbrev <buffer> <<[=]<< «=«
98 iabbrev <buffer> <<[=]>> «=»
99 iabbrev <buffer> <= ≤
100 iabbrev <buffer> =~= ≅
101 iabbrev <buffer> >= ≥
102 iabbrev <buffer> >> »
103 iabbrev <buffer> >>[=]<< »=«
104 iabbrev <buffer> >>[=]>> »=»
105 iabbrev <buffer> Inf ∞
106 iabbrev <buffer> atomic-add-fetch ⚛+=
107 iabbrev <buffer> atomic-assign ⚛=
108 iabbrev <buffer> atomic-fetch ⚛
109 iabbrev <buffer> atomic-dec-fetch --⚛
110 iabbrev <buffer> atomic-fetch-dec ⚛--
111 iabbrev <buffer> atomic-fetch-inc ⚛++
112 iabbrev <buffer> atomic-inc-fetch ++⚛
113 iabbrev <buffer> atomic-sub-fetch ⚛−=
114 iabbrev <buffer> e 𝑒
115 iabbrev <buffer> o ∘
116 iabbrev <buffer> pi π
117 iabbrev <buffer> set() ∅
118 iabbrev <buffer> tau τ
119endif
120
121" Undo the stuff we changed.
122let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< isk< kp< path<" .
123 \ " | unlet! b:browsefilter"
124
125" Restore the saved compatibility options.
126let &cpo = s:save_cpo
127unlet s:save_cpo