mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Add vim-raku, closes #490
This commit is contained in:
@@ -10,7 +10,7 @@ A collection of language packs for Vim.
|
||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||
|
||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->148<!--/Package Count--> packages it consists of.
|
||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->149<!--/Package Count--> packages it consists of.
|
||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
||||
@@ -148,6 +148,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [r-lang](https://github.com/vim-scripts/R.vim) (syntax)
|
||||
- [racket](https://github.com/wlangstroth/vim-racket) (syntax, indent, ftplugin)
|
||||
- [ragel](https://github.com/jneen/ragel.vim) (syntax)
|
||||
- [raku](https://github.com/Raku/vim-raku) (syntax, indent, ftplugin)
|
||||
- [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin)
|
||||
- [razor](https://github.com/adamclerk/vim-razor) (syntax, indent, ftplugin)
|
||||
- [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent)
|
||||
|
||||
1
build
1
build
@@ -266,6 +266,7 @@ PACKS="
|
||||
r-lang:vim-scripts/R.vim:_BASIC
|
||||
racket:wlangstroth/vim-racket
|
||||
ragel:jneen/ragel.vim
|
||||
raku:Raku/vim-raku
|
||||
raml:IN3D/vim-raml
|
||||
razor:adamclerk/vim-razor
|
||||
reason:reasonml-editor/vim-reason-plus
|
||||
|
||||
@@ -1201,6 +1201,27 @@ au BufRead,BufNewFile *.rkt,*.rktl call RacketDetectHashLang()
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'raku') == -1
|
||||
augroup filetypedetect
|
||||
" raku, from raku.vim in Raku/vim-raku
|
||||
" whenever a named file is created, writen or read,
|
||||
" set raku filetype if the extension is one of those:
|
||||
" https://github.com/Raku/problem-solving/blob/master/solutions/language/Path-to-Raku.md#extensions
|
||||
|
||||
autocmd BufNewFile,BufWritePost,BufReadPost
|
||||
\ *.pm6,*.p6,*.t6,*.pod6,*.raku,*.rakumod,*.rakudoc,*.rakutest
|
||||
\ set filetype=raku
|
||||
|
||||
" whenever a named file is written or read,
|
||||
" set raku filetype if there is a shebang with raku in it
|
||||
|
||||
autocmd BufWritePost,BufReadPost *
|
||||
\ if getline(1) =~ '^#!.*raku' |
|
||||
\ setf raku |
|
||||
\ endif
|
||||
augroup end
|
||||
endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'raml') == -1
|
||||
augroup filetypedetect
|
||||
" raml, from raml.vim in IN3D/vim-raml
|
||||
|
||||
147
ftplugin/raku.vim
Normal file
147
ftplugin/raku.vim
Normal file
@@ -0,0 +1,147 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'raku') == -1
|
||||
|
||||
" 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
|
||||
" Last Change: {{LAST_CHANGE}}
|
||||
" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
|
||||
"
|
||||
" Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com>
|
||||
|
||||
if exists("b:did_ftplugin") | finish | endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" Make sure the continuation lines below do not cause problems in
|
||||
" compatibility mode.
|
||||
let s:save_cpo = &cpo
|
||||
set cpo-=C
|
||||
|
||||
setlocal formatoptions-=t
|
||||
setlocal formatoptions+=crqol
|
||||
setlocal keywordprg=p6doc
|
||||
|
||||
setlocal comments=:#\|,:#=,:#
|
||||
setlocal commentstring=#%s
|
||||
|
||||
" Provided by Ned Konz <ned at bike-nomad dot com>
|
||||
"---------------------------------------------
|
||||
setlocal include=\\<\\(use\\\|require\\)\\>
|
||||
setlocal includeexpr=substitute(v:fname,'::','/','g')
|
||||
setlocal suffixesadd=.pm6,.pm,.raku,.rakutest,.t6
|
||||
setlocal define=[^A-Za-z_]
|
||||
|
||||
" The following line changes a global variable but is necessary to make
|
||||
" gf and similar commands work. Thanks to Andrew Pimlott for pointing out
|
||||
" the problem. If this causes a " problem for you, add an
|
||||
" after/ftplugin/raku.vim file that contains
|
||||
" set isfname-=:
|
||||
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
|
||||
else
|
||||
let &l:path=&l:path.",".perlpath
|
||||
endif
|
||||
"---------------------------------------------
|
||||
|
||||
" Convert ascii-based ops into their single-character unicode equivalent
|
||||
if get(g:, 'raku_unicode_abbrevs', 0)
|
||||
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 τ
|
||||
endif
|
||||
|
||||
" Undo the stuff we changed.
|
||||
let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< isk< kp< path<" .
|
||||
\ " | unlet! b:browsefilter"
|
||||
|
||||
" Restore the saved compatibility options.
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
endif
|
||||
131
indent/raku.vim
Normal file
131
indent/raku.vim
Normal file
@@ -0,0 +1,131 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'raku') == -1
|
||||
|
||||
" Vim indent 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
|
||||
" Last Change: {{LAST_CHANGE}}
|
||||
" Contributors: Andy Lester <andy@petdance.com>
|
||||
" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
|
||||
"
|
||||
" Adapted from indent/perl.vim by Rafael Garcia-Suarez <rgarciasuarez@free.fr>
|
||||
|
||||
" Suggestions and improvements by :
|
||||
" Aaron J. Sherman (use syntax for hints)
|
||||
" Artem Chuprina (play nice with folding)
|
||||
" TODO:
|
||||
" This file still relies on stuff from the Perl 5 syntax file, which Perl 6
|
||||
" does not use.
|
||||
"
|
||||
" Things that are not or not properly indented (yet) :
|
||||
" - Continued statements
|
||||
" print "foo",
|
||||
" "bar";
|
||||
" print "foo"
|
||||
" if bar();
|
||||
" - Multiline regular expressions (m//x)
|
||||
" (The following probably needs modifying the perl syntax file)
|
||||
" - qw() lists
|
||||
" - Heredocs with terminators that don't match \I\i*
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
" Is syntax highlighting active ?
|
||||
let b:indent_use_syntax = has("syntax")
|
||||
|
||||
setlocal indentexpr=GetRakuIndent()
|
||||
|
||||
" we reset it first because the Perl 5 indent file might have been loaded due
|
||||
" to a .pl/pm file extension, and indent files don't clean up afterwards
|
||||
setlocal indentkeys&
|
||||
|
||||
setlocal indentkeys+=0=,0),0],0>,0»,0=or,0=and
|
||||
if !b:indent_use_syntax
|
||||
setlocal indentkeys+=0=EO
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
|
||||
function! GetRakuIndent()
|
||||
|
||||
" Get the line to be indented
|
||||
let cline = getline(v:lnum)
|
||||
|
||||
" Indent POD markers to column 0
|
||||
if cline =~ '^\s*=\L\@!'
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Get current syntax item at the line's first char
|
||||
let csynid = ''
|
||||
if b:indent_use_syntax
|
||||
let csynid = synIDattr(synID(v:lnum,1,0),"name")
|
||||
endif
|
||||
|
||||
" Don't reindent POD and heredocs
|
||||
if csynid =~ "^rakuPod"
|
||||
return indent(v:lnum)
|
||||
endif
|
||||
|
||||
|
||||
" Now get the indent of the previous perl line.
|
||||
|
||||
" Find a non-blank line above the current line.
|
||||
let lnum = prevnonblank(v:lnum - 1)
|
||||
" Hit the start of the file, use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
let line = getline(lnum)
|
||||
let ind = indent(lnum)
|
||||
" Skip heredocs, POD, and comments on 1st column
|
||||
if b:indent_use_syntax
|
||||
let skippin = 2
|
||||
while skippin
|
||||
let synid = synIDattr(synID(lnum,1,0),"name")
|
||||
if (synid =~ "^rakuPod" || synid =~ "rakuComment")
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
let line = getline(lnum)
|
||||
let ind = indent(lnum)
|
||||
let skippin = 1
|
||||
else
|
||||
let skippin = 0
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
|
||||
if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$'
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
if cline =~ '^\s*[)}\]»>]'
|
||||
let ind = ind - &sw
|
||||
endif
|
||||
|
||||
" Indent lines that begin with 'or' or 'and'
|
||||
if cline =~ '^\s*\(or\|and\)\>'
|
||||
if line !~ '^\s*\(or\|and\)\>'
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
elseif line =~ '^\s*\(or\|and\)\>'
|
||||
let ind = ind - &sw
|
||||
endif
|
||||
|
||||
return ind
|
||||
|
||||
endfunction
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim:ts=8:sts=4:sw=4:expandtab:ft=vim
|
||||
|
||||
endif
|
||||
1974
syntax/raku.vim
Normal file
1974
syntax/raku.vim
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user