Skip to content

Instantly share code, notes, and snippets.

@strboul
Created January 8, 2021 12:09
Show Gist options
  • Save strboul/85638b6b0f9387db1e4b5c4e9ad68869 to your computer and use it in GitHub Desktop.
Save strboul/85638b6b0f9387db1e4b5c4e9ad68869 to your computer and use it in GitHub Desktop.
Nvim Lua API stratch file
-- Resource
-- https://github.com/neovim/neovim/blob/master/runtime/doc/api.txt
-- Windows
vim.api.nvim_list_wins()
vim.api.nvim_get_current_win()
-- example float window
vim.api.nvim_open_win(0, false, {relative='win', row=3, col=3, width=12, height=3})
-- Buffers
vim.api.nvim_list_bufs() -- lists unlisted buffers as well, like ls!
vim.api.nvim_buf_is_loaded(1) -- check loaded buffers
vim.api.nvim_get_current_buf()
vim.api.nvim_set_current_buf(33)
-- Misc
vim.api.nvim_get_commands({})
vim.api.nvim_get_context({types={'bufs'}})
vim.api.nvim_get_current_line()
vim.api.nvim_get_keymap("n")
vim.api.nvim_list_chans()
-- other interesting options:
-- columns, lines, shell, rtp, termguicolors, scrolloff etc.
vim.api.nvim_get_option('columns')
vim.api.nvim_get_proc(1) -- get pid details
vim.api.nvim_strwidth('hello') -- difference from string.len is that counts tabs as one cell?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment