Neovim
File type#
-- init.lua
vim.filetype.add({ extension = { oxl = "oxl" } })Server: Neovim 0.11+#
vim.lsp.config("oxl", {
cmd = { "oxl", "lsp" },
filetypes = { "oxl" },
root_markers = { "oxl.toml", ".git" },
init_options = { debounceMs = 150 }, -- необязательно
})
vim.lsp.enable("oxl")Server: nvim-lspconfig (Neovim 0.9–0.10)#
lspconfig has no ready OxL server, so register it as a custom one:
local configs = require("lspconfig.configs")
if not configs.oxl then
configs.oxl = {
default_config = {
cmd = { "oxl", "lsp" },
filetypes = { "oxl" },
root_dir = require("lspconfig.util").root_pattern("oxl.toml", ".git"),
single_file_support = true, -- одиночные .oxl анализируются отдельно
},
}
end
require("lspconfig").oxl.setup({})Keys and inlay hints#
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(ev)
local c = vim.lsp.get_client_by_id(ev.data.client_id)
if c and c.name == "oxl" then
vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf }) -- типы, ошибки цепочек, роли шагов
vim.api.nvim_create_autocmd("BufWritePre", { -- форматирование = oxl fmt
buffer = ev.buf, callback = function() vim.lsp.buf.format({ async = false }) end })
end
end,
})Default mappings of Neovim 0.10+: K hover, grn rename, gra code actions, grr references, <C-]> definition. The
categories of inlay hints can be switched off in init_options: init_options = { inlayHints = { callMarkers = false } }
(LSP).
tree-sitter highlighting#
The grammar is in share/oxl/tree-sitter-oxl (in the repository tools/tree-sitter-oxl). The parser source src/parser.c is not
stored in the repository; tree-sitter generate creates it:
cd /opt/oxl-1.0.0-beta/share/oxl/tree-sitter-oxl
npm install && npx tree-sitter generate-- nvim-treesitter (ветка main): регистрируем парсер
vim.api.nvim_create_autocmd("User", {
pattern = "TSUpdate",
callback = function()
require("nvim-treesitter.parsers").oxl = {
install_info = { path = "/opt/oxl-1.0.0-beta/share/oxl/tree-sitter-oxl", generate = false },
}
end,
})
-- затем: :TSInstall oxl
vim.treesitter.language.register("oxl", "oxl")Copy the highlight queries into your configuration:
mkdir -p ~/.config/nvim/queries/oxl
cp /opt/oxl-1.0.0-beta/share/oxl/tree-sitter-oxl/queries/highlights.scm ~/.config/nvim/queries/oxl/The semantic tokens from the server are added on top (contextual words such as on, durable, within are highlighted by meaning).
Debugging: nvim-dap#
local dap = require("dap")
dap.adapters.oxl = { type = "executable", command = "oxl", args = { "dap" } }
dap.configurations.oxl = {
{
name = "Debug OxL package",
type = "oxl",
request = "launch",
program = "${workspaceFolder}", -- пакет, .oxl-файл или исполняемый файл с отладочной информацией
cwd = "${workspaceFolder}",
stopOnEntry = false,
oxlProfile = "dev",
},
}:lua require("dap").continue() builds the package (oxl build --profile dev --debug-info full) and stops at breakpoints. See
debugging.