1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 07:00:04 +08:00

Add lang#reason & lang#rescript layer (#4089)

This commit is contained in:
Wang Shidong 2021-02-15 15:14:24 +08:00 committed by GitHub
parent c8753bc0ca
commit 6a9b01def5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 842 additions and 18 deletions

View File

@ -1,6 +1,6 @@
"=============================================================================
" language.vim --- programming language information layer
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" regex.vim --- regex parser for vim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" povray.vim --- POV-Ray language support
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -0,0 +1,52 @@
"=============================================================================
" reason.vim --- Reason programming language layer
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
if exists('s:JSON')
finish
endif
let s:JSON = SpaceVim#api#import('data#json')
function! SpaceVim#layers#lang#reason#plugins() abort
let plugins = []
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-reason', {'merged' : 0}])
return plugins
endfunction
function! SpaceVim#layers#lang#reason#config() abort
call SpaceVim#plugins#tasks#reg_provider(funcref('s:reasonml_tasks'))
call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings'))
endfunction
function! s:language_specified_mappings() abort
if SpaceVim#layers#lsp#check_filetype('reason')
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
endif
endfunction
function! s:reasonml_tasks() abort
let detect_task = {}
let conf = {}
if filereadable('package.json')
let conf = s:JSON.json_decode(join(readfile('package.json', ''), ''))
endif
if has_key(conf, 'scripts')
for task_name in keys(conf.scripts)
call extend(detect_task, {
\ task_name : {'command' : conf.scripts[task_name], 'isDetected' : 1, 'detectedName' : 'esy:'}
\ })
endfor
endif
return detect_task
endfunction

View File

@ -0,0 +1,45 @@
"=============================================================================
" rescript.vim --- ReScript programming language layer
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
if exists('s:JSON')
finish
endif
let s:JSON = SpaceVim#api#import('data#json')
function! SpaceVim#layers#lang#rescript#plugins() abort
let plugins = []
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-rescript', {'merged' : 0}])
return plugins
endfunction
function! SpaceVim#layers#lang#rescript#config() abort
call SpaceVim#plugins#tasks#reg_provider(funcref('s:rescript_tasks'))
if index(g:spacevim_project_rooter_patterns, 'package.json') ==# -1
call add(g:spacevim_project_rooter_patterns, 'package.json')
endif
endfunction
function! s:rescript_tasks() abort
let detect_task = {}
let conf = {}
if filereadable('package.json')
let conf = s:JSON.json_decode(join(readfile('package.json', ''), ''))
endif
if has_key(conf, 'scripts')
for task_name in keys(conf.scripts)
call extend(detect_task, {
\ task_name : {'command' : conf.scripts[task_name], 'isDetected' : 1, 'detectedName' : 'bsb:'}
\ })
endfor
endif
return detect_task
endfunction

View File

@ -124,6 +124,7 @@ let s:lsp_servers = {
\ 'ada' : ['ada_language_server'],
\ 'c' : ['clangd'],
\ 'cpp' : ['clangd'],
\ 'crystal' : ['scry'],
\ 'css' : ['css-languageserver', '--stdio'],
\ 'dart' : ['dart_language_server'],
\ 'dockerfile' : ['docker-langserver', '--stdio'],
@ -137,12 +138,12 @@ let s:lsp_servers = {
\ 'php' : ['php', g:spacevim_plugin_bundle_dir . 'repos/github.com/phpactor/phpactor/bin/phpactor', 'language-server'],
\ 'purescript' : ['purescript-language-server', '--stdio'],
\ 'python' : ['pyls'],
\ 'crystal' : ['scry'],
\ 'reason' : ['ocaml-language-server'],
\ 'ruby' : ['solargraph', 'stdio'],
\ 'rust' : ['rustup', 'run', 'nightly', 'rls'],
\ 'scala' : ['metals-vim'],
\ 'sh' : ['bash-language-server', 'start'],
\ 'typescript' : ['typescript-language-server', '--stdio'],
\ 'ruby' : ['solargraph', 'stdio'],
\ 'vue' : ['vls']
\ }

View File

@ -1,6 +1,6 @@
"=============================================================================
" scrollbar.vim --- scrollbar support for SpaceVim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" git.vim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" manager.vim --- Git branch manager
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" push.vim --- push command for git.vim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" License: GPLv3
"=============================================================================

View File

@ -1,6 +1,6 @@
"=============================================================================
" git.vim --- git plugin for spacevim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" ctags.vim --- ctags generator
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -1,6 +1,6 @@
"=============================================================================
" povray.vim --- povray ftplugin
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3

View File

@ -0,0 +1,2 @@
au BufRead,BufNewFile *.re set filetype=reason
au BufRead,BufNewFile *.rei set filetype=reason

View File

@ -0,0 +1,220 @@
"=============================================================================
" reason.vim --- reason indent file
" Copyright (c) 2016-2021 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
" Only load this indent file when no other was loaded.
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
" m1 is needed to make parens line up correct:
"
" let result = callSomething (
" 1,
" 2
" );
"
" fN (See the docs) - additional indentation *w.r.t the "prevailing indent" only applies to blocks
" *not* in nested braces! We want it to match the blocks *inside* nested braces - and be zero, but
" the problem is that the "prevailing indent" not inside of braces is different than inside braces.
setlocal cinoptions=L0,(0,Ws,J1,j1,m1,{0,f0s
" cinkeys is ignored if indentexpr is activated so this setting is useless. See indentkeys below.
setlocal cinkeys=0{,0},0),!^F,o,O,0[,0]
" Don't think cinwords will actually do anything at all... never mind
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fun,let,extern
" Some preliminary settings
setlocal nolisp " Make sure lisp indenting doesn't supersede us
setlocal autoindent " indentexpr isn't much help otherwise
" Also do indentkeys, otherwise # gets shoved to column 0 :-/
setlocal indentkeys=0{,0},0),!^F,o,O,0[,0]
setlocal indentexpr=GetReasonIndent(v:lnum)
" Only define the function once.
if exists("*GetReasonIndent")
finish
endif
" Come here when loading the script the first time.
function! s:get_line_trimmed(lnum)
" Get the line and remove a trailing comment.
" Use syntax highlighting attributes when possible.
" NOTE: this is not accurate; /* */ or a line continuation could trick it
let line = getline(a:lnum)
let line_len = strlen(line)
if has('syntax_items')
" If the last character in the line is a comment, do a binary search for
" the start of the comment. synID() is slow, a linear search would take
" too long on a long line.
if synIDattr(synID(a:lnum, line_len, 1), 'name') =~# 'Comment\|Todo'
let min = 1
let max = line_len
while min < max
let col = (min + max) / 2
if synIDattr(synID(a:lnum, col, 1), 'name') =~# 'Comment\|Todo'
let max = col
else
let min = col + 1
endif
endwhile
let line = strpart(line, 0, min - 1)
endif
return substitute(line, "\s*$", '', '')
else
" Sorry, this is not complete, nor fully correct (e.g. string "//").
" Such is life.
return substitute(line, "\s*//.*$", "", "")
endif
endfunction
function! s:is_string_comment(lnum, col)
if has('syntax_items')
for id in synstack(a:lnum, a:col)
let synname = synIDattr(id, "name")
if synname == "rustString" || synname =~ "^rustComment"
return 1
endif
endfor
else
" without syntax, let's not even try
return 0
endif
endfunction
function GetReasonIndent(lnum)
" Starting assumption: cindent (called at the end) will do it right
" normally. We just want to fix up a few cases.
let line = getline(a:lnum)
if has('syntax_items')
let synname = synIDattr(synID(a:lnum, 1, 1), "name")
if synname == "rustString"
" If the start of the line is in a string, don't change the indent
return -1
elseif synname =~ '\(Comment\|Todo\)'
\ && line !~ '^\s*/\*' " not /* opening line
if synname =~ "CommentML" " multi-line
if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*'
" This is (hopefully) the line after a /*, and it has no
" leader, so the correct indentation is that of the
" previous line.
return GetReasonIndent(a:lnum - 1)
endif
endif
" If it's in a comment, let cindent take care of it now. This is
" for cases like "/*" where the next line should start " * ", not
" "* " as the code below would otherwise cause for module scope
" Fun fact: " /*\n*\n*/" takes two calls to get right!
return cindent(a:lnum)
endif
endif
" cindent gets second and subsequent match patterns/struct members wrong,
" as it treats the comma as indicating an unfinished statement::
"
" switch a {
" | b => c
" | d => e
" | f => g
" };
" Search backwards for the previous non-empty line.
let prevlinenum = prevnonblank(a:lnum - 1)
let prevline = s:get_line_trimmed(prevlinenum)
while prevlinenum > 1 && prevline !~ '[^[:blank:]]'
let prevlinenum = prevnonblank(prevlinenum - 1)
let prevline = s:get_line_trimmed(prevlinenum)
endwhile
" Handle where clauses nicely: subsequent values should line up nicely.
if prevline[len(prevline) - 1] == ","
\ && prevline =~# '^\s*where\s'
return indent(prevlinenum) + 6
endif
if prevline =~ "\s*|.*[{(\[]$"
" \ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
" \ && prevline !~ '^\s*fun\s'
" \ && prevline !~ '([^()]\+,$'
" Oh ho! The previous line ended in a comma! I bet cindent will try to
" take this too far... For now, let's normally use the previous line's
" indent.
" One case where this doesn't work out is where *this* line contains
" square or curly brackets; then we normally *do* want to be indenting
" further.
"
" Another case where we don't want to is one like a function
" definition with arguments spread over multiple lines:
"
" fun foo(baz: Baz,
" baz: Baz) // <-- cindent gets this right by itself
"
" Another case is similar to the previous, except calling a function
" instead of defining it, or any conditional expression that leaves
" an open paren:
"
" foo(baz,
" baz);
"
" if baz && (foo ||
" bar) {
"
" There are probably other cases where we don't want to do this as
" well. Add them as needed.
return indent(prevlinenum) + &shiftwidth
endif
if prevline =~ "\s*|"
return indent(prevlinenum)
endif
if !has("patch-7.4.355")
" cindent before 7.4.355 doesn't do the module scope well at all; e.g.::
"
" static FOO : &'static [bool] = [
" true,
" false,
" false,
" true,
" ];
"
" uh oh, next statement is indented further!
" Note that this does *not* apply the line continuation pattern properly;
" that's too hard to do correctly for my liking at present, so I'll just
" start with these two main cases (square brackets and not returning to
" column zero)
call cursor(a:lnum, 1)
if searchpair('{\|(', '', '}\|)', 'nbW',
\ 's:is_string_comment(line("."), col("."))') == 0
if searchpair('\[', '', '\]', 'nbW',
\ 's:is_string_comment(line("."), col("."))') == 0
" Global scope, should be zero
return 0
else
" At the module scope, inside square brackets only
"if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
if line =~ "^\\s*]"
" It's the closing line, dedent it
return 0
else
return &shiftwidth
endif
endif
endif
endif
" Fall back on cindent, which does it mostly right
return cindent(a:lnum)
endfunction

View File

@ -0,0 +1,223 @@
" Vim syntax file
" Language: Reason (Forked from Rust)
" Maintainer: (Jordan - for Reason changes) Patrick Walton <pcwalton@mozilla.com>
" Maintainer: Ben Blum <bblum@cs.cmu.edu>
" Maintainer: Chris Morgan <me@chrismorgan.info>
" Last Change: January 29, 2015
" Portions Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Syntax definitions {{{1
" Basic keywords {{{2
syn keyword reasonConditional try switch if else for while
syn keyword reasonOperator as to downto
" syn keyword reasonKeyword fun nextgroup=reasonFuncName skipwhite skipempty
syn match reasonAssert "\<assert\(\w\)*"
syn match reasonFailwith "\<failwith\(\w\)*"
syn keyword reasonStorage when where fun mutable class pub pri val inherit let external rec nonrec and module type exception open include constraint
" FIXME: Scoped impl's name is also fallen in this category
syn match reasonIdentifier contains=reasonIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
syn match reasonFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
"
" syn match labelArgument "\(\l\|_\)\(\w\|'\)*::\(?\)\?"lc=0 "Allows any space between label name and ::
" syn match labelArgumentPunned "::\(?\)\?\(\l\|_\)\(\w\|'\)*"lc=0 "Allows any space between label name and ::
syn match labelArgument "\~\(\l\|_\)\(\w\|'\)*"lc=0 "Allows any space between label name and ::
syn match labelArgumentPunned "\~\(\l\|_\)\(\w\|'\)*\(?\)\?"lc=0 "Allows any space between label name and ::
syn match reasonConstructor "\<\u\(\w\|'\)*\>"
" Polymorphic variants
syn match reasonConstructor "`\w\(\w\|'\)*\>"
syn match reasonModPath "\<\u\(\w\|'\)* *\."he=e-1
syn match reasonModPath "\(\<open\s\+\)\@<=\u\(\w\|\.\)*"
syn match reasonModPath "\(\<include\s\+\)\@<=\u\(\w\|\.\)*"
syn match reasonModPath "\(\<module\s\+\)\@<=\u\(\w\|\.\)*"
syn match reasonModPath "\(\<module\s\+\u\w*\s*=\s*\)\@<=\u\(\w\|\.\)*"
" {} are handled by reasonFoldBraces
" Built-in types {{{2
syn keyword reasonType result int float option list array unit ref bool string
" Things from the libstd v1 prelude (src/libstd/prelude/v1.rs) {{{2
" This section is just straight transformation of the contents of the prelude,
" to make it easy to update.
" Reexported functions {{{3
" Theres no point in highlighting these; when one writes drop( or drop::< it
" gets the same highlighting anyway, and if someone writes `let drop = …;` we
" dont really want *that* drop to be highlighted.
"syn keyword reasonFunction drop
" Reexported types and traits {{{3
syn keyword reasonEnum Option
syn keyword reasonConstructor Some None
syn keyword reasonEnum Result
syn keyword reasonConstructor Ok Error
" Other syntax {{{2
syn keyword reasonSelf self
syn keyword reasonBoolean true false
" This is merely a convention; note also the use of [A-Z], restricting it to
" latin identifiers rather than the full Unicode uppercase. I have not used
" [:upper:] as it depends upon 'noignorecase'
"syn match reasonCapsIdent display "[A-Z]\w\(\w\)*"
syn match reasonOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\)=\?"
" This one isn't *quite* right, as we could have binary-& with a reference
" This isn't actually correct; a closure with no arguments can be `|| { }`.
" Last, because the & in && isn't a sigil
syn match reasonOperator display "&&\|||"
" This is reasonArrowCharacter rather than reasonArrow for the sake of matchparen,
" so it skips the ->; see http://stackoverflow.com/a/30309949 for details.
syn match reasonArrowCharacter display "=>"
syn match reasonEscapeError display contained /\\./
syn match reasonEscape display contained /\\\([nrt0\\'"]\|x\x\{2}\)/
syn match reasonEscapeUnicode display contained /\\\(u\x\{4}\|U\x\{8}\)/
syn match reasonEscapeUnicode display contained /\\u{\x\{1,6}}/
syn match reasonStringContinuation display contained /\\\n\s*/
syn region reasonString start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=reasonEscape,reasonEscapeError,reasonStringContinuation
syn region reasonString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=reasonEscape,reasonEscapeUnicode,reasonEscapeError,reasonStringContinuation,@Spell
syn region reasonString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell
syn region reasonMultilineString start=+b{|+ skip=+\\\\\|\\"+ end=+|}+ contains=reasonEscape,reasonEscapeError,reasonStringContinuation
syn region reasonMultilineString start=+{|+ end=+|}+ contains=reasonEscape,reasonEscapeUnicode,reasonEscapeError,reasonStringContinuation,@Spell
" https://github.com/pangloss/vim-javascript/blob/master/syntax/javascript.vim
" lc=1 means leading context, for "not backslashed"
syntax region reasonTemplateExpression contained matchgroup=reasonTemplateBraces start=+\(^\|[^\\]\)${+lc=1 end=+}+ contains=@interpolation keepend
syntax region reasonTemplateString start=+`\($\| \)+ skip=+\\`+ end=+`+ contains=reasonTemplateExpression,jsSpecial,@Spell extend
syntax match reasonTaggedTemplate /\<\K\k*\ze`/ nextgroup=reasonTemplateString
syn region reasonAttribute start="#!\?\[" end="\]" contains=reasonString,reasonDerive
" This list comes from src/libsyntax/ext/deriving/mod.rs
" Some are deprecated (Encodable, Decodable) or to be removed after a new snapshot (Show).
" Number literals
syn match reasonDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\)\)\="
syn match reasonHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(size\|8\|16\|32\|64\)\)\="
syn match reasonOctNumber display "\<0o[0-7_]\+\%([iu]\%(size\|8\|16\|32\|64\)\)\="
syn match reasonBinNumber display "\<0b[01_]\+\%([iu]\%(size\|8\|16\|32\|64\)\)\="
" Special case for numbers of the form "1." which are float literals, unless followed by
" an identifier, which makes them integer literals with a method call or field access,
" or by another ".", which makes them integer literals followed by the ".." token.
" (This must go first so the others take precedence.)
syn match reasonFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\|\.\)\@!"
" To mark a number as a normal float, it must have at least one of the three things integral values don't have:
" a decimal point and more numbers; an exponent; and a type suffix.
syn match reasonFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\="
syn match reasonFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\="
syn match reasonFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)"
" For the benefit of delimitMate
syn match reasonCharacterInvalid display contained /b\?'\zs[\n\r\t']\ze'/
" The groups negated here add up to 0-255 but nothing else (they do not seem to go beyond ASCII).
syn match reasonCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:graph:][:alnum:][:space:]]\ze'/
syn match reasonCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=reasonEscape,reasonEscapeError,reasonCharacterInvalid,reasonCharacterInvalidUnicode
syn match reasonCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\|u{\x\{1,6}}\)\)'/ contains=reasonEscape,reasonEscapeUnicode,reasonEscapeError,reasonCharacterInvalid
syn match reasonShebang /\%^#![^[].*/
syn region reasonCommentLine start="//" end="$" contains=reasonTodo,@Spell
" syn region reasonCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=reasonTodo,@Spell
syn region reasonCommentBlock matchgroup=reasonCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=reasonTodo,reasonCommentBlockNest,@Spell
syn region reasonCommentBlockDoc matchgroup=reasonCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=reasonTodo,reasonCommentBlockDocNest,@Spell
syn region reasonCommentBlockNest matchgroup=reasonCommentBlock start="/\*" end="\*/" contains=reasonTodo,reasonCommentBlockNest,@Spell contained transparent
syn region reasonCommentBlockDocNest matchgroup=reasonCommentBlockDoc start="/\*" end="\*/" contains=reasonTodo,reasonCommentBlockDocNest,@Spell contained transparent
" FIXME: this is a really ugly and not fully correct implementation. Most
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
" a comment, but in practice at present it leaves comments open two levels
" deep. But as long as you stay away from that particular case, I *believe*
" the highlighting is correct. Due to the way Vim's syntax engine works
" (greedy for start matches, unlike Zust's tokeniser which is searching for
" the earliest-starting match, start or end), I believe this cannot be solved.
" Oh you who would fix it, don't bother with things like duplicating the Block
" rules and putting ``\*\@<!`` at the start of them; it makes it worse, as
" then you must deal with cases like ``/*/**/*/``. And don't try making it
" worse with ``\%(/\@<!\*\)\@<!``, either...
syn keyword reasonTodo contained TODO FIXME XXX NB NOTE
" Folding rules {{{2
" Trivial folding rules to begin with.
" FIXME: use the AST to make really good folding
syn region reasonFoldBraces start="{" end="}" transparent fold
" These mess up the highlighting
" reasonIdentifier,reasonIdentifierPrime,
syntax cluster interpolation contains=reasonTemplateString,reasonCommentLine,reasonCommentBlock,reasonMultilineString,reasonString,reasonSelf,reasonBoolean,reasonType,reasonStorage,reasonAssert,reasonFailwith,reasonOperator,reasonConditional,reasonNumber,reasonCharacter,reasonConstructor,labelArgument,labelArgumentPunned,reasonCapsIdent,reasonFloat,reasonModPath,reasonDecNumber,reasonHexNumber,reasonOctNumber,reasonBinNumber,reasonArrowCharacter
" Default highlighting {{{1
hi def link labelArgument Special
hi def link labelArgumentPunned Special
hi def link reasonDecNumber reasonNumber
hi def link reasonHexNumber reasonNumber
hi def link reasonOctNumber reasonNumber
hi def link reasonBinNumber reasonNumber
hi def link reasonIdentifierPrime reasonIdentifier
hi def link reasonEscape Special
hi def link reasonEscapeUnicode reasonEscape
hi def link reasonEscapeError Error
hi def link reasonStringContinuation Special
hi def link reasonString String
hi def link reasonMultilineString String
hi def link reasonTemplateString String
hi def link reasonCharacterInvalid Error
hi def link reasonCharacterInvalidUnicode reasonCharacterInvalid
hi def link reasonCharacter Character
hi def link reasonNumber Number
hi def link reasonBoolean Boolean
hi def link reasonEnum reasonType
hi def link reasonConstructor Constant
hi def link reasonModPath Include
hi def link reasonConstant Constant
hi def link reasonSelf Constant
hi def link reasonFloat Float
hi def link reasonArrowCharacter reasonOperator
hi def link reasonOperator Keyword
hi def link reasonKeyword Keyword
hi def link reasonConditional Conditional
hi def link reasonIdentifier Identifier
hi def link reasonCapsIdent reasonIdentifier
hi def link reasonFunction Function
hi def link reasonFuncName Function
hi def link reasonShebang Comment
hi def link reasonCommentLine Comment
" hi def link reasonCommentLineDoc Comment
hi def link reasonCommentBlock Comment
hi def link reasonCommentBlockDoc Comment
hi def link reasonAssert Precondit
hi def link reasonFailwith PreCondit
hi def link reasonType Type
hi def link reasonTodo Todo
hi def link reasonAttribute PreProc
hi def link reasonStorage Keyword
hi def link reasonObsoleteStorage Error
hi def link reasonTemplateBraces Noise
hi def link reasonTaggedTemplate StorageClass
syn sync minlines=200
syn sync maxlines=500
let b:current_syntax = "reason"

View File

@ -0,0 +1,2 @@
au BufRead,BufNewFile *.res set filetype=rescript
au BufRead,BufNewFile *.resi set filetype=rescript

View File

@ -0,0 +1,69 @@
"=============================================================================
" rescript.vim --- ReScript indent file
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
setlocal nolisp
setlocal indentexpr=RescriptIndent(v:lnum)
if exists('*RescriptIndent')
finish
endif
function! s:SkipRescriptBlanksAndComments(startline)
let lnum = a:startline
while lnum > 1
let lnum = prevnonblank(lnum)
if getline(lnum) =~# '\*/\s*$'
while getline(lnum) !~ '/\*' && lnum > 1
let lnum = lnum - 1
endwhile
if getline(lnum) =~# '^\s*/\*'
let lnum = lnum - 1
else
break
endif
elseif getline(lnum) =~# '^\s*//'
let lnum = lnum - 1
else
break
endif
endwhile
return lnum
endfunction
function! RescriptIndent(lnum)
let l:prevlnum = s:SkipRescriptBlanksAndComments(a:lnum-1)
if l:prevlnum == 0 " We're at top of file
return 0
endif
" Prev and current line with line-comments removed
let l:prevl = substitute(getline(l:prevlnum), '//.*$', '', '')
let l:thisl = substitute(getline(a:lnum), '//.*$', '', '')
let l:previ = indent(l:prevlnum)
let l:ind = l:previ
if l:prevl =~# '\v(\(|\{|\[|\=|\=\>)\s*$'
" Opened a block, assignment, fat arrow
let l:ind += shiftwidth()
endif
if l:thisl =~# '^\s*[)}\]]'
" Closed a blocked
let l:ind -= shiftwidth()
endif
return l:ind
endfunction

View File

@ -0,0 +1,111 @@
if exists('b:current_syntax')
finish
endif
" See https://github.com/rescript-lang/vim-rescript/issues/14
syntax sync minlines=600
" Boolean
syntax keyword resBoolean true false
" Keywords
syntax keyword resKeyword let rec type external mutable lazy private of with
syntax keyword resKeyword if else switch when
syntax keyword resKeyword and as open include module in constraint import export
syntax keyword resKeyword for to downto while
syntax keyword resKeyword try catch exception assert
" Types
syntax keyword resType bool int float char string unit
syntax keyword resType list array option ref exn format
" Operators
syntax keyword resOperator mod land lor lxor lsl lsr asr
syntax keyword resOperator or
syntax match resOperator "\v\="
syntax match resOperator "\v\*"
syntax match resOperator "\v/"
syntax match resOperator "\v\+"
syntax match resOperator "\v-"
syntax match resOperator "\v\*\."
syntax match resOperator "\v/\."
syntax match resOperator "\v\+\."
syntax match resOperator "\v-\."
syntax match resOperator "\v\<"
syntax match resOperator "\v\<\="
syntax match resOperator "\v\>"
syntax match resOperator "\v\>\="
syntax match resOperator "\v\@"
syntax match resOperator "\v\!"
syntax match resOperator "\v\|"
syntax match resOperator "\v\&"
" Refs
syntax match resOperator "\v\:\="
" Arrows / Pipes
syntax match resArrowPipe "\v\=\>"
syntax match resArrowPipe "\v\-\>"
syntax match resArrowPipe "\v\|\>"
syntax match resArrowPipe "\v\@\@"
" Comment
syntax region resSingleLineComment start="//" end="$" contains=resTodo,@Spell
syntax region resMultiLineComment start="/\*\s*" end="\*/" contains=@Spell,resTodo,resMultiLineComment
syntax keyword resTodo contained TODO FIXME XXX NOTE
" Char
syntax match resChar "\v'\\.'|'.'"
syntax match resNumber "-\=\<\d\(_\|\d\)*[l|L|n]\?\>"
syntax match resNumber "-\=\<0[x|X]\(\x\|_\)\+[l|L|n]\?\>"
syntax match resNumber "-\=\<0[o|O]\(\o\|_\)\+[l|L|n]\?\>"
syntax match resNumber "-\=\<0[b|B]\([01]\|_\)\+[l|L|n]\?\>"
syntax match resFloat "-\=\<\d\(_\|\d\)*\.\?\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>"
" Module / Constructor
syntax match resModuleOrVariant "\v<[A-Z][A-Za-z0-9_'$]*"
syntax match resPolyVariant "\v#[A-za-z][A-Za-z0-9_'$]*"
syntax match resModuleChain "\v<[A-Z][A-Za-z0-9_'$]*\."
" Attribute
syntax match resAttribute "\v\@([a-zA-z][A-Za-z0-9_']*)(\.([a-zA-z])[A-Za-z0-9_']*)*"
" String
syntax match resUnicodeChar "\v\\u[A-Fa-f0-9]\{4}" contained
syntax match resEscapedChar "\v\\[\\"'ntbrf]" contained
syntax region resString start="\v\"" end="\v\"" contains=resEscapedQuote,resEscapedChar,resUnicodeChar
syntax match resInterpolationVariable "\v\$[a-z_][A-Za-z0-0_'$]*" contained
syntax region resString start="\v`" end="\v`" contains=resInterpolationVariable
syntax region resString start="\v[a-z]`" end="\v`" contains=resInterpolationVariable
highlight default link resBoolean Boolean
highlight default link resKeyword Keyword
highlight default link resType Type
highlight default link resOperator Operator
highlight default link resArrowPipe Operator
highlight default link resSingleLineComment Comment
highlight default link resMultiLineComment Comment
highlight default link resTodo TODO
highlight default link resChar Character
highlight default link resNumber Number
highlight default link resFloat Float
highlight default link resModuleOrVariant Function
highlight default link resPolyVariant Function
highlight default link resModuleChain Macro
highlight default link resUnicodeChar Character
highlight default link resEscapedChar Character
highlight default link resString String
highlight default link resInterpolationVariable Macro
highlight default link resAttribute PreProc
let b:current_syntax = 'rescript'

View File

@ -146,6 +146,7 @@ gem install solargraph
| `purescript` | `['purescript-language-server', '--stdio']` |
| `python` | `['pyls']` |
| `ruby` | `['solargraph', 'stdio']`
| `reason` | `['ocaml-language-server']` |
| `rust` | `['rustup', 'run', 'nightly', 'rls']` |
| `sh` | `['bash-language-server', 'start']` |
| `typescript` | `['typescript-language-server', '--stdio']` |

View File

@ -71,7 +71,7 @@ Some layers are enabled by default. The following example shows how to disable `
| [checkers](checkers/) | Syntax checking automatically within SpaceVim, display error on the sign column and statusline. |
| [chinese](chinese/) | Layer for chinese users, include chinese docs and runtime messages |
| [colorscheme](colorscheme/) | colorscheme provides a list of colorscheme for SpaceVim, default colorscheme is gruvbox with dark theme. |
| [core#banner](core/banner/) | This layer provides many default banner on welcome page. |
| [core#banner](core/banner/) | This layer provides many default banners on welcome page. |
| [core#statusline](core/statusline/) | This layer provides default statusline for SpaceVim |
| [core#tabline](core/tabline/) | SpaceVim core#tabline layer provides a better tabline for SpaceVim |
| [core](core/) | SpaceVim core layer provides many default key bindings and features. |
@ -88,7 +88,7 @@ Some layers are enabled by default. The following example shows how to disable `
| [fzf](fzf/) | This layers provide a heavily customized fzf centric work-flow |
| [git](git/) | This layers adds extensive support for git |
| [github](github/) | This layer provides GitHub integration for SpaceVim |
| [gtags](gtags/) | This layer provide gtags manager for project |
| [gtags](gtags/) | This layer provides gtags manager for project |
| [japanese](japanese/) | Layer for japanese users, include japanese docs and runtime messages |
| [lang#WebAssembly](lang/WebAssembly/) | This layer adds WebAssembly support to SpaceVim |
| [lang#actionscript](lang/actionscript/) | This layer is for actionscript syntax highlighting |
@ -135,7 +135,7 @@ Some layers are enabled by default. The following example shows how to disable `
| [lang#kotlin](lang/kotlin/) | This layer adds Kotlin language support to SpaceVim, including syntax highlighting, code runner and REPL support. |
| [lang#lasso](lang/lasso/) | Lasso language support, include syntax highlighting. |
| [lang#latex](lang/latex/) | This layer provides support for writing LaTeX documents, including syntax highlighting, code completion, formatting etc. |
| [lang#lisp](lang/lisp/) | This layer is for Lisp development, provide autocompletion, syntax checking, code format for Lisp file. |
| [lang#lisp](lang/lisp/) | This layer is for Common Lisp development, provide autocompletion, syntax checking, code format for Common Lisp file. |
| [lang#livescript](lang/livescript/) | This layer is for livescript development, provide syntax checking, code runner and repl support for livescript file. |
| [lang#lua](lang/lua/) | This layer is for Lua development, provide autocompletion, syntax checking, code format for Lua file. |
| [lang#markdown](lang/markdown/) | Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file. |
@ -159,8 +159,11 @@ Some layers are enabled by default. The following example shows how to disable `
| [lang#python](lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for Python file. |
| [lang#r](lang/r/) | This layer is for R development, provide autocompletion, syntax checking and code format. |
| [lang#racket](lang/racket/) | This layer adds racket language support to SpaceVim, including syntax highlighting, code runner and REPL support. |
| [lang#reason](lang/reason/) | This layer is for reason development, provide syntax checking, code runner and repl support for reason file. |
| [lang#red](lang/red/) | This layer is for Red development, provide autocompletion, syntax checking and code format. |
| [lang#rescript](lang/rescript/) | This layer is for ReScript development, provide syntax checking, code runner and repl support for ReScript file. |
| [lang#ring](lang/ring/) | This layer is for ring development, provide syntax checking, code runner and repl support for ring file. |
| [lang#rst](lang/rst/) | Take Notes in reStructuredText, autopreview in the default browser. |
| [lang#ruby](lang/ruby/) | This layer is for Ruby development, provide autocompletion, syntax checking, code format for Ruby file. |
| [lang#rust](lang/rust/) | This layer is for Rust development, provide autocompletion, syntax checking, code format for Rust file. |
| [lang#scala](lang/scala/) | This layer adds Scala language support to SpaceVim |
@ -174,7 +177,7 @@ Some layers are enabled by default. The following example shows how to disable `
| [lang#typescript](lang/typescript/) | This layer is for TypeScript development, includding code completion, Syntax lint, and doc generation. |
| [lang#v](lang/v/) | This layer is for v development, provide syntax checking, code runner and repl support for v file. |
| [lang#vbnet](lang/vbnet/) | This layer is for Visual Basic .NET development, provide code runner vb file. |
| [lang#vim](lang/vim/) | This layer is for writing Vimscript, including code completion, syntax checking and buffer formatting |
| [lang#vim](lang/vim/) | This layer is for writing Vimscript, including code completion, syntax checking and buffer formatting |
| [lang#vue](lang/vue/) | This layer adds Vue language support to SpaceVim |
| [lang#wolfram](lang/wolfram/) | This layer is for wolfram development, provide syntax checking, code runner and repl support for wolfram file. |
| [lang#xml](lang/xml/) | This layer is for xml development, provide syntax checking, indent etc. |

View File

@ -1,6 +1,6 @@
---
title: "SpaceVim core#banner layer"
description: "This layer provides many default banners on welcome page."
description: "This layer provides many default banner on welcome page."
---
# [Available Layers](../) >> core#banner

View File

@ -0,0 +1,53 @@
---
title: "SpaceVim lang#reason layer"
description: "This layer is for reason development, provide syntax checking, code runner and repl support for reason file."
---
# [Available Layers](../../) >> lang#reason
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Install](#install)
- [Features](#features)
- [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
## Description
This layer is for [reason](http://reasonml.github.io/) development.
## Install
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#reason"
```
## Features
- syntax highlighting
- esy tasks detection
## Key bindings
The following key bindings are reason language specific key binding, only available when editing
reason file.
| Key binding | Description |
| --------------- | --------------- |
| `K` / `SPC l d` | Show cursor doc |
| `SPC l e` | Rename symbol |
**NOTE:** These key bindings require `lsp` layer loaded:
```toml
[[layers]]
name = "lsp"
filetypes = [
"reason"
]
```

View File

@ -0,0 +1,39 @@
---
title: "SpaceVim lang#rescript layer"
description: "This layer is for ReScript development, provide syntax checking, code runner and repl support for ReScript file."
---
# [Available Layers](../../) >> lang#rescript
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Install](#install)
- [Features](#features)
- [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
## Description
This layer is for [ReScript](https://rescript-lang.org/) development.
## Install
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#rescript"
```
## Features
- syntax highlighting
- tasks detection
## Key bindings
| Key binding | Description |
| ----------- | -------------- |
| `SPC p t l` | list all tasks |

View File

@ -155,7 +155,7 @@ default language server commands:
| language | server command |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ada` | `['ada_language_server']` |
| `ada` | `['ada_language_server']` |
| `c` | `['clangd']` |
| `cpp` | `['clangd']` |
| `crystal` | `['scry']` |
@ -173,6 +173,7 @@ default language server commands:
| `purescript` | `['purescript-language-server', '--stdio']` |
| `python` | `['pyls']` |
| `ruby` | `['solargraph', 'stdio']` |
| `reason` | `['ocaml-language-server']` |
| `rust` | `['rustup', 'run', 'nightly', 'rls']` |
| `sh` | `['bash-language-server', 'start']` |
| `typescript` | `['typescript-language-server', '--stdio']` |

View File

@ -74,6 +74,8 @@ This is a list of programming languages supported in SpaceVim:
| Red | [lang#red](https://spacevim.org/layers/lang/red/) | |
| Ring | [lang#ring](https://spacevim.org/layers/lang/ring) | |
| Ruby | [lang#ruby](https://spacevim.org/layers/lang/ruby/) | |
| Reason | [lang#ruby](https://spacevim.org/layers/lang/reason/) | |
| ReScript | [lang#ruby](https://spacevim.org/layers/lang/rescript/) | |
| Rust | [lang#rust](https://spacevim.org/layers/lang/rust/) | |
| Scala | [lang#scala](https://spacevim.org/layers/lang/scala/) | |
| Scheme | [lang#scheme](https://spacevim.org/layers/lang/scheme/) | |