Ir al contenido

Neovim

El setup de Neovim usa dos plugins upstream que probablemente ya tenés: nvim-treesitter para la gramática, nvim-lspconfig para el servidor LSP. httui-lang se conecta a ambos.

Ventana de terminal
cargo install httui-lsp

O agarra un binario prebuilt de Releases y ponelo en tu PATH. Verifica:

Ventana de terminal
httui-lsp --version
:TSInstall httui

Esto trae tree-sitter-httui y compila el parser en tu install de nvim-treesitter. (Ya registrado upstream desde nvim-treesitter v0.x.)

En tu config de Neovim, agrega:

-- init.lua
local lspconfig = require("lspconfig")
-- httui-lang server
local configs = require("lspconfig.configs")
if not configs.httui_lsp then
configs.httui_lsp = {
default_config = {
cmd = { "httui-lsp" },
filetypes = { "httui", "markdown" },
root_dir = function(fname)
return vim.fs.find(
{ ".httui", "runbooks", "connections.toml", "envs" },
{ upward = true, path = fname }
)[1] and vim.fs.dirname(vim.fs.find(
{ ".httui", "runbooks", "connections.toml", "envs" },
{ upward = true, path = fname }
)[1])
end,
settings = {
httui = {
env = "staging", -- o leído dinámicamente
},
},
},
}
end
lspconfig.httui_lsp.setup({})

(El lspconfig upstream eventualmente shipeará una config built-in httui_lsp — hasta ese momento el snippet de arriba es canónico.)

Decile a Neovim que reconozca .httui como su propio filetype:

vim.filetype.add({
extension = {
httui = "httui",
},
})

El LSP se attachea al filetype httui y a markdown (así corre dentro de bloques fenced en .md).

Habilita highlight + indent + folds vía nvim-treesitter:

require("nvim-treesitter.configs").setup({
ensure_installed = { "httui", "markdown", "markdown_inline" },
highlight = { enable = true },
indent = { enable = true },
fold = { enable = true },
})
-- Opcional: usa folds de tree-sitter
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"

Para la injection de markdown (httui dentro de fences en .md), esto lo manejan automáticamente los parsers — el parser markdown sabe que debe delegar a httui para regiones fenced http/db-*.

Los bindings estándar de LSP funcionan — define una vez en tu on_attach:

local on_attach = function(client, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "<F2>", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>f", function()
vim.lsp.buf.format({ async = true })
end, opts)
end
lspconfig.httui_lsp.setup({ on_attach = on_attach })

Combina con nvim-cmp o tu plugin de completion preferido. httui-lsp da fuentes de completion vía LSP estándar, sin setup custom más allá de tener el LSP source habilitado en cmp:

require("cmp").setup({
sources = {
{ name = "nvim_lsp" },
-- tus otros
},
})

Tipear {{ dispara el popup de completion con todos los aliases arriba del cursor + env vars del env activo.

El LSP levanta el env activo de user.toml en la raíz del vault. Para cambiar desde dentro de Neovim, usa un comando custom:

vim.api.nvim_create_user_command("HttuiEnv", function(opts)
local clients = vim.lsp.get_active_clients({ name = "httui_lsp" })
for _, c in ipairs(clients) do
c.notify("workspace/didChangeConfiguration", {
settings = { httui = { env = opts.args } },
})
end
end, { nargs = 1 })

Luego :HttuiEnv staging cambia el env para hover/completion.

El LSP puede despachar un mensaje “ejecutar este bloque” al desktop de httui si está corriendo en el mismo vault. Bindealo vía un code action o un comando custom:

vim.keymap.set("n", "<leader>br", function()
vim.lsp.buf.execute_command({
command = "httui.runBlock",
arguments = {
uri = vim.uri_from_bufnr(0),
position = vim.api.nvim_win_get_cursor(0),
},
})
end, { desc = "Run httui block under cursor" })

Si el desktop no está corriendo, el comando es no-op (el LSP devuelve “no runtime”).

Para ejecución headless, shell out a httui-tui run:

vim.keymap.set("n", "<leader>brt", function()
local file = vim.api.nvim_buf_get_name(0)
vim.cmd("split | terminal httui-tui run " .. file .. " --env staging")
end, { desc = "Run httui runbook in TUI" })
vim.api.nvim_create_autocmd("FileType", {
pattern = "httui",
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.expandtab = true
vim.opt_local.commentstring = "# %s"
end,
})

Revisa:

:LspLog

Causas comunes: httui-lsp no en PATH, vault root no detectado (provee root_dir explícito).

Asegúrate de que ambos parsers estén instalados:

:TSInstall httui markdown markdown_inline

Y :TSPlayground para confirmar que httui aparece bajo las fences http/db-*.

Probablemente config de env faltante. Agrega a tu setup:

settings = { httui = { env = "local" } }

(Incluso un envs/local.toml vacío hace al LSP feliz si se referencia local.)