Syntax highlighting and language-server support for Wyn.
- Syntax highlighting - all keywords, built-in modules, types, operators, string interpolation, comments
- LSP via
wyn lsp- live diagnostics (type-check only, never runs your code), completions, hover, go-to-definition, find references, rename - Filetype detection for
.wynand.🐉files - Smart indentation, code folding, comment toggling (
gcc/gcwith a commentstring)
{
"wynlang/nvim-wyn",
ft = "wyn",
config = function() require("wyn").setup() end,
}use { "wynlang/nvim-wyn", config = function() require("wyn").setup() end }Plug 'wynlang/nvim-wyn'
" then, in lua: require('wyn').setup()cp -r syntax ftdetect ftplugin lua ~/.config/nvim/Syntax highlighting works with no configuration. Calling require('wyn').setup()
additionally wires up the language server.
require("wyn").setup()That's it. setup():
- works with or without nvim-lspconfig
- if lspconfig is installed it registers the
wynserver there (so:LspInfoworks); otherwise it uses Neovim's built-invim.lsp.startand auto-starts the server when you open a.wynfile,
- if lspconfig is installed it registers the
- resolves the project root from the nearest
wyn.tomlor.git, - requires the
wynbinary on yourPATH(install withwyn install).
Options:
require("wyn").setup({
cmd = "wyn", -- path to the wyn binary (default: "wyn")
auto_start = true, -- start the LSP on FileType wyn (built-in path only)
on_attach = function(client, bufnr) end, -- your keymaps, etc.
capabilities = require("cmp_nvim_lsp").default_capabilities(), -- optional
})The language server provides:
- Diagnostics - errors/warnings from
wyn checkas you type (it type-checks only; it never compiles-and-runs your program) - Completions - keywords, modules, and symbols (triggered by
./:) - Hover - symbol info
- Go to Definition - jump to function/struct/enum declarations
- Find References / Rename - across the open files
require("wyn").setup({
on_attach = function(_, bufnr)
local map = function(k, fn) vim.keymap.set("n", k, fn, { buffer = bufnr }) end
map("gd", vim.lsp.buf.definition)
map("gr", vim.lsp.buf.references)
map("K", vim.lsp.buf.hover)
map("<leader>rn", vim.lsp.buf.rename)
end,
})
-- Build / check the current file
vim.api.nvim_create_autocmd("FileType", {
pattern = "wyn",
callback = function()
vim.keymap.set("n", "<F5>", ":!wyn run %<CR>", { buffer = true })
vim.keymap.set("n", "<F6>", ":!wyn check %<CR>", { buffer = true })
end,
})struct Vec2 {
x: int
y: int
}
fn mag_sq(v: Vec2) -> int {
return v.x * v.x + v.y * v.y
}
fn main() -> int {
var v = Vec2{x: 3, y: 4}
println("${mag_sq(v)}")
return 0
}
The plugin has a headless-Neovim test that loads it with a minimal config and
asserts filetype detection, syntax rules, ftplugin settings, and (when the wyn
binary is on PATH) LSP attachment:
bash tests/run.sh # or: make testCI runs it on Linux and macOS against a freshly built wyn compiler. The syntax
keyword and module lists are kept in sync with the compiler
(src/lexer.c / src/module.c).