-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Nvim plugin for [Alephium](https://alephium.org/) smart contract programming language: [Ralph](https://wiki.alephium.org/ralph/getting-started/) | ||
|
||
This plugin use [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) to provide LSP client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
au BufNewFile,BufRead *.ral set ft=ralph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
setlocal commentstring=//%s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"Indent file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
local function ralph_init() | ||
|
||
local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
|
||
capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true | ||
|
||
local root_dir = vim.fs.dirname(vim.fs.find({'build.ralph', 'contracts', 'artifacts'}, { upward = true })[1]) | ||
|
||
if root_dir == nil then root_dir = vim.fn.getcwd() end | ||
|
||
vim.lsp.start({ | ||
name = 'ralph-lsp', | ||
cmd = {'ralph-lsp'}, | ||
root_dir = root_dir, | ||
capabilities = capabilities | ||
}) | ||
|
||
end | ||
|
||
vim.api.nvim_create_autocmd('FileType', { | ||
pattern = { 'ralph' }, | ||
callback = function() ralph_init() end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
" Vim syntax file | ||
" Language: Ralph | ||
|
||
syn keyword ralphConditional if else | ||
syn keyword ralphRepeat for while | ||
|
||
syn keyword ralphStucture Interface TxScript Contract AssetScript enum event extends skipwhite skipempty nextgroup=ralphInstanceDeclaration | ||
syn keyword ralphKeyword fn nextgroup=ralphFunctionName skipwhite skipempty | ||
syn keyword ralphKeyword pub nextgroup=ralphPubScope skipwhite skipempty | ||
syn keyword ralphKeyword return implements | ||
syn keyword ralphKeyword let mut const nextgroup=ralphNameDefinition skipwhite skipempty | ||
syn keyword ralphStorage Abstract | ||
|
||
syn match ralphInstanceDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained | ||
hi link ralphInstanceDeclaration Special | ||
|
||
syn match ralphNameDefinition /\<[_A-Za-z0-9$]\+\>/ contained | ||
hi link ralphNameDefinition Function | ||
|
||
syn match ralphFunction /[A-Za-z0-9]\+!/ | ||
hi link ralphFunction Function | ||
|
||
syn match ralphFunctionName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained | ||
|
||
syn keyword ralphType Bool I256 U256 Address ByteVec | ||
syn keyword ralphBoolean true false | ||
|
||
syn match ralphOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\)=\?" | ||
|
||
syn match ralphArrowCharacter display "->" | ||
|
||
syn region ralphCommentLine start="//" end="$" | ||
|
||
hi def link ralphNumber Number | ||
hi def link ralphBoolean Boolean | ||
hi def link ralphEnum ralphType | ||
hi def link ralphEnumVariant ralphConstant | ||
hi def link ralphConstant Constant | ||
hi def link ralphOperator Operator | ||
hi def link ralphStucture Structure | ||
hi def link ralphKeyword Keyword | ||
hi def link ralphRepeat Conditional | ||
hi def link ralphConditional Conditional | ||
hi def link ralphFunctionName Function | ||
hi def link ralphCommentLine Comment | ||
hi def link ralphType Type | ||
hi def link ralphStorage StorageClass | ||
|
||
let b:current_syntax = "ralph" |