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