raku.vim 4.1 KB

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