initial push

This commit is contained in:
2026-02-20 07:27:32 +01:00
parent a05ef7c5d1
commit 4f406ae891
2 changed files with 50 additions and 1 deletions

View File

@@ -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
View 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