Neovim Lua

index > dev > language > lua

Neovim API

vim.api.nvim_echo({{'hello', 'healthError'}, {'world'}}, true, {})

System

local cwd = vim.fn.expand('%:p:h')

Buffer

vim.api.nvim_buf_get_name(0)
local line = vim.api.nvim_buf_get_lines(bufnr, 1, -1, false)

Window

-- 0 is current window
vim.fn.winwidth(0)
vim.fn.winheight(0)

Metatable Tricks

local go = setmetatable({}, {
    __index = function(t, k)
        local ok, val = pcall(require, string.format('go.%s', k))
        if ok then
            rawset(t, k, val)
        end

        return val
    end
})