Neovim Lua API Goodies Link to heading

Useful Lua API snippets to programmatically use inside Neovim.

-- get current line
local line = vim.fn.get_line('.')

-- get clipboard register content
local clipboard = vim.fn.getreg("+")

-- get cwd
local cwd = vim.fn.getcwd()

-- read from a file
local file = io.open(filename, 'r')
local content = file:read '*all'
file:close()

-- Run OS command
os.execute("xdg-open https://google.com")