Skip to content

hello world example

s1n7ax edited this page Jan 24, 2023 · 1 revision

Hello World Example

-- import renderer from `nvim-react`
local Renderer = require('react.renderers.buffer-renderer')

-- create a functional component
local function App()
    return {
        'Hello World'
    }
end

-- create a buffer and a window to display the text
local buffer = vim.api.nvim_create_buf(false, true)

local win_conf = {
    width = 100,
    height = 100,
    relative = 'editor',
    row = 1,
    col = 1,
}
vim.api.nvim_open_win(buffer, true, win_conf)

-- render app component on the buffer
Renderer:new({
    buffer = buffer
}):render(App)

Clone this wiki locally