mirror of
https://github.com/tiyn/viper.nvim.git
synced 2026-04-17 02:54:48 +02:00
initial push
This commit is contained in:
@@ -1,2 +1,6 @@
|
|||||||
# viper.nvim
|
# viper.nvim
|
||||||
Simple highlighting tool for the verification language viper.
|
|
||||||
|
viper.nvim is a simple plugin that adds basic highlighting capabilities to NeoVim for the
|
||||||
|
verification language [Viper](https://github.com/viperproject).
|
||||||
|
|
||||||
|
Currently it uses simple parsing and word matching for this and does not use any tree structures.
|
||||||
|
|||||||
45
lua/viper/init.lua
Normal file
45
lua/viper/init.lua
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
local group = vim.api.nvim_create_augroup("ViperSyntax", { clear = true })
|
||||||
|
|
||||||
|
local function enable_viper_syntax()
|
||||||
|
if vim.b.viper_syntax_loaded then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.b.viper_syntax_loaded = true
|
||||||
|
|
||||||
|
vim.cmd("syntax enable")
|
||||||
|
vim.cmd("syntax clear")
|
||||||
|
|
||||||
|
vim.cmd([[
|
||||||
|
syntax keyword viperKeyword method function returns requires ensures invariant
|
||||||
|
syntax keyword viperKeyword if else while var field predicate
|
||||||
|
syntax keyword viperKeyword assert assume inhale exhale fold unfold
|
||||||
|
|
||||||
|
syntax keyword viperType Int Bool Ref
|
||||||
|
|
||||||
|
syntax match viperComment "//.*$"
|
||||||
|
syntax match viperNumber "\v\d+"
|
||||||
|
]])
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "viperKeyword", { link = "Keyword" })
|
||||||
|
vim.api.nvim_set_hl(0, "viperType", { link = "Type" })
|
||||||
|
vim.api.nvim_set_hl(0, "viperComment", { link = "Comment" })
|
||||||
|
vim.api.nvim_set_hl(0, "viperNumber", { link = "Number" })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
group = group,
|
||||||
|
pattern = "viper",
|
||||||
|
callback = enable_viper_syntax,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||||
|
group = group,
|
||||||
|
pattern = "*.vpr",
|
||||||
|
callback = enable_viper_syntax,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
Reference in New Issue
Block a user