Skip to content

fix suffixeadd #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 41 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
---
vim: tw=72
title: Contributing to vim-raku
---

# Reporting Issues

When submitting an issue relating to highlighting/folding, please attach the following:
When submitting an issue relating to highlighting/folding, please attach
the following:

- A screenshot of the issue.
- The file used in the screenshot. If it's proprietary or too big, please try
to reproduce the issue in a small sample file.
- A link to your vimrc, if it exists.
- The output of `vim --version`.
* A screenshot of the issue.
* The file used in the screenshot. If it's proprietary or too big,
please try to reproduce the issue in a small sample file.
* A link to your vimrc, if it exists.
* The output of `vim --version`.

These things make issues **much** easier to debug!

**IMPORTANT**

To make things easier on everyone, try to reproduce the issue with a minimal vim setup and an up-to-date
checkout of vim-raku. Taking the time to help out with issues you have found makes things easier on all
of us, and that's the whole reason this is an open project. =)
To make things easier on everyone, try to reproduce the issue with a
minimal vim setup and an up-to-date checkout of vim-raku. Taking the
time to help out with issues you have found makes things easier on all
of us, and that's the whole reason this is an open project.

Also, before you report something as a bug, please make sure you're using the latest version of
vim-raku from Git. If you're using an older version, chances are that you're stumbling on a bug that
someone else has in the past.
Also, before you report something as a bug, please make sure you're
using the latest version of vim-raku from Git. If you're using an older
version, chances are that you're stumbling on a bug that someone else
has in the past.

If you have read and understand these guidelines, add the text "I have read the guidelines" in your issue
when you create it.
If you have read and understand these guidelines, add the text "I have
read the guidelines" in your issue when you create it.

# Helping Out

If you would like to contribute to vim-raku, please be aware that we have a test suite which can
be run using the `prove` command. After you've made your changes, run the test suite via `prove`.
The tests test a host of known situations for consistency, as well as verifies that vim-raku still
highlights and folds code the way it does with the latest code on GitHub. Most fixes don't change highlighting,
so the regression test should pass. If it fails, open the file(s) printed and make sure that their highlighting
still makes sense. If it does, note that in your pull request and a maintainer will update the regression corpus
data when he/she merges it.
# Improve the code

TODO: can't make `prove` work. any clue there?

If you would like to contribute to vim-raku, please be aware that we
have a test suite which can be run using the `prove` command. After
you've made your changes, run the test suite via `prove`. The tests
test a host of known situations for consistency, as well as verifies
that vim-raku still highlights and folds code the way it does with the
latest code on GitHub. Most fixes don't change highlighting, so the
regression test should pass. If it fails, open the file(s) printed and
make sure that their highlighting still makes sense. If it does, note
that in your pull request and a maintainer will update the regression
corpus data when he/she merges it.

# Improve the documentation

new sections and translation are very welcome. don't forget to run
`helptags doc` and commit the new `doc/tags` if you do so.
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@
Improved support for Raku in Vim.

## Installation
Installation of this plugin can be done via any of the available plugin
managers, such as [Pathogen][pathogen], [vim-plug][vim-plug], [vundle][vundle]
or any other one.

Once installed, all files ending in `.raku`, `.rakudoc`, and `.rakutest` (and
also `.pl6`, `.pm6`, `.p6`, and `.t6` for legacy purposes) will make use of the
plugin's features.
### vim packages

From the vim command line, see `:help packages` to learn how to install a vim package.
As exemple: you can install this plugin like this:

## Configuring optional features
Not all features are enabled by default. This is in part due to them still
being considered in testing, or because they may influence your regular
workflow too much. These can be enabled by setting a certain variable to a
truthy value.
t=$HOME/.vim/pack/vendor/start/
mkdir -p $t
git clone -C $t git@github.com:Raku/vim-raku.git raku

### Unicode ops
`vim-raku` can use Vim's abbreviation feature to convert ASCII based operators
to their Unicode equivalents on the fly. To enable this feature, add the
following line to your `vimrc` file:
### 3rd party plugin managers

```
let g:raku_unicode_abbrevs = 1
```
If it makes sense for you, you can still use a legacy, 3rd party plugin manager
such as [Pathogen][pathogen], [vim-plug][vim-plug], [vundle][vundle].

Once installed, all files ending in `.raku`, `.rakudoc`, and `.rakutest` (and
also `.pm6`, `.p6`, and `.t6` for legacy purposes) will make use of the
plugin's features.

[pathogen]: https://github.com/tpope/vim-pathogen
[vim-plug]: https://github.com/junegunn/vim-plug
Expand Down
3 changes: 3 additions & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
raku-unicode-ascii vim-raku.txt /*raku-unicode-ascii*
vim-raku vim-raku.txt /*vim-raku*
vim-raku.txt vim-raku.txt /*vim-raku.txt*
130 changes: 130 additions & 0 deletions doc/vim-raku.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
*vim-raku.txt* A raku integration to vim

CONTENTS *vim-raku*

vim-raku provides ftplugin and helpers to be productive with vim and raku.

1. Using unicode in your raku files |raku-unicode-ascii|

USING UNICODE IN YOUR RAKU FILES *raku-unicode-ascii*

Defining new operators using unicode symbols is a good way to make your
script easy to read. see

https://perl6advent.wordpress.com/2012/12/18/day-18-formulas-resistance-is-futile/

the natural way to get this symbols from vim is to use digraph shorteners
(`:help digraphs-use`). a lot of them are defined (type `:digraphs` to get the
list). A convenient way to read the list of digraphs is to save them in a
file. from the shell:

vim +'redir >/tmp/non-existing-file-yet' +digraphs +'redir END' +q

Also, raku comes with some of them included as alterative to ascii ones

https://docs.raku.org/language/unicode_ascii

some of them are available with digraphs

<< « /0 ∅ !< ≮
>> » Ob ∘ !> ≯
., … 00 ∞ (C ⊂
(U ∩ -: ÷ )C ⊃
)U ∪ (_ ⊆ >= ≥
?= ≅ )_ ⊇ =< ≤
(- ∈ ?= ≅ != ≠
-) ∋ ?- ≃

greek alphabet is available with `*` followed by a latin close symbol

*p π
*t τ
*X ×

numbers subscripts and superscripts are availlable with s and S.

0s ₀ 0S ⁰
1s ₁ 1S ¹
2s ₂ 9S ⁹

but some don't come by default. those are digraph definitions you
can add in your ~/.vimrc file.

exec 'digraph \\ '.char2nr('∖')
exec 'digraph \< '.char2nr('≼')
exec 'digraph \> '.char2nr('≽')
exec 'digraph (L '.char2nr('⊈')
exec 'digraph )L '.char2nr('⊉')
exec 'digraph @@ '.char2nr('⚛')
exec 'digraph (/ '.char2nr('⊄')
exec 'digraph )/ '.char2nr('⊅')
exec 'digraph )/ '.char2nr('⊅')
exec 'digraph U+ '.char2nr('⊎')
exec 'digraph 0- '.char2nr('⊖')
" number euler
exec 'digraph ne '.char2nr('𝑒')

alternatively, you can write insert mode abbreviations that
convert ascii-based ops into their single-character
unicode equivalent.

iabbrev <buffer> !(<) ⊄
iabbrev <buffer> !(<=) ⊈
iabbrev <buffer> !(>) ⊅
iabbrev <buffer> !(>=) ⊉
iabbrev <buffer> !(cont) ∌
iabbrev <buffer> !(elem) ∉
iabbrev <buffer> != ≠
iabbrev <buffer> (&) ∩
iabbrev <buffer> (+) ⊎
iabbrev <buffer> (-) ∖
iabbrev <buffer> (.) ⊍
iabbrev <buffer> (<) ⊂
iabbrev <buffer> (<+) ≼
iabbrev <buffer> (<=) ⊆
iabbrev <buffer> (>) ⊃
iabbrev <buffer> (>+) ≽
iabbrev <buffer> (>=) ⊇
iabbrev <buffer> (\|) ∪
iabbrev <buffer> (^) ⊖
iabbrev <buffer> (atomic) ⚛
iabbrev <buffer> (cont) ∋
iabbrev <buffer> (elem) ∈
iabbrev <buffer> * ×
iabbrev <buffer> **0 ⁰
iabbrev <buffer> **1 ¹
iabbrev <buffer> **2 ²
iabbrev <buffer> **3 ³
iabbrev <buffer> **4 ⁴
iabbrev <buffer> **5 ⁵
iabbrev <buffer> **6 ⁶
iabbrev <buffer> **7 ⁷
iabbrev <buffer> **8 ⁸
iabbrev <buffer> **9 ⁹
iabbrev <buffer> ... …
iabbrev <buffer> / ÷
iabbrev <buffer> << «
iabbrev <buffer> <<[=]<< «=«
iabbrev <buffer> <<[=]>> «=»
iabbrev <buffer> <= ≤
iabbrev <buffer> =~= ≅
iabbrev <buffer> >= ≥
iabbrev <buffer> >> »
iabbrev <buffer> >>[=]<< »=«
iabbrev <buffer> >>[=]>> »=»
iabbrev <buffer> Inf ∞
iabbrev <buffer> atomic-add-fetch ⚛+=
iabbrev <buffer> atomic-assign ⚛=
iabbrev <buffer> atomic-fetch ⚛
iabbrev <buffer> atomic-dec-fetch --⚛
iabbrev <buffer> atomic-fetch-dec ⚛--
iabbrev <buffer> atomic-fetch-inc ⚛++
iabbrev <buffer> atomic-inc-fetch ++⚛
iabbrev <buffer> atomic-sub-fetch ⚛−=
iabbrev <buffer> e 𝑒
iabbrev <buffer> o ∘
iabbrev <buffer> pi π
iabbrev <buffer> set() ∅
iabbrev <buffer> tau τ


42 changes: 7 additions & 35 deletions ftplugin/raku.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
" Vim filetype plugin file
" Language: Raku
" Maintainer: vim-perl <vim-perl@googlegroups.com>
" Homepage: https://github.com/vim-perl/vim-perl6
" Bugs/requests: https://github.com/vim-perl/vim-perl6/issues
" Maintainer: rakoons <perl6-users@perl.org>
" Homepage: https://github.com/raku/vim-raku
" Bugs/requests: https://github.com/raku/vim-raku/issues
" Last Change: {{LAST_CHANGE}}
" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
"
Expand All @@ -27,7 +27,7 @@ setlocal commentstring=#%s
"---------------------------------------------
setlocal include=\\<\\(use\\\|require\\)\\>
setlocal includeexpr=substitute(v:fname,'::','/','g')
setlocal suffixesadd=.pm6,.pm,.raku,.rakutest,.t6
setlocal suffixesadd=.pm6,.rakumod
setlocal define=[^A-Za-z_]

" The following line changes a global variable but is necessary to make
Expand All @@ -38,39 +38,11 @@ setlocal define=[^A-Za-z_]
set isfname+=:
setlocal iskeyword=@,48-57,_,192-255,-

" Set this once, globally.
if !exists("perlpath")
if executable("perl6")
try
if &shellxquote != '"'
let perlpath = system('perl6 -e "@*INC.join(q/,/).say"')
else
let perlpath = system("perl6 -e '@*INC.join(q/,/).say'")
endif
let perlpath = substitute(perlpath,',.$',',,','')
catch /E145:/
let perlpath = ".,,"
endtry
else
" If we can't call perl to get its path, just default to using the
" current directory and the directory of the current file.
let perlpath = ".,,"
endif
endif

" Append perlpath to the existing path value, if it is set. Since we don't
" use += to do it because of the commas in perlpath, we have to handle the
" global / local settings, too.
if &l:path == ""
if &g:path == ""
let &l:path=perlpath
else
let &l:path=&g:path.",".perlpath
endif
if exists('$RAKULIB')
let &l:path = "lib,.,".$RAKULIB.",".join(glob("~/.zef/store/*/*/lib",0,1),',')
else
let &l:path=&l:path.",".perlpath
let &l:path = "lib,.,".join(glob("~/.zef/store/*/*/lib",0,1),',')
endif
"---------------------------------------------

" Convert ascii-based ops into their single-character unicode equivalent
if get(g:, 'raku_unicode_abbrevs', 0)
Expand Down