NvChad API
These are list of some functions & tips/tricks which are provided by nvchad plugins that aren't included in the config. You can make commands & mappings out of them.
GotoTab
- This utilizes the
vim.t.bufs
tab table variable where we store buffer numbers of current tab. - Then it loops from 1-9 to create mappings of switching tab by number i.e Alt+1 will switch first tab.
for i = 1, 9, 1 do
vim.keymap.set("n", string.format("<A-%s>", i), function()
vim.api.nvim_set_current_buf(vim.t.bufs[i])
end)
end
Arrange buffer
- Used for arranging buffers left/right in the tabufline.
-- move buffer right
require("nvchad.tabufline").move_buf(1)
-- move buffer left
require("nvchad.tabufline").move_buf(-1)
Toggle transparency
- Used to toggle transparency, make sure that you have transparency option set in your chadrc.
require("base46").toggle_transparency()
Toggle themes
- Used to toggle between 2 themes, make sure that you have
theme_toggle
option set in your chadrc.
require("base46").toggle_theme()
Close all buffers
- Used to close all the buffers in current tab. ( the close icon in tabufline handles this ).
require("nvchad.tabufline").closeAllBufs()
Show only modifed buffers
- This is an autocmd which will show only modified buffers and current buffer, read more.
- Put it in your
custom/init.lua
vim.api.nvim_create_autocmd({ "BufAdd", "BufEnter", "tabnew" }, {
callback = function()
vim.t.bufs = vim.tbl_filter(function(bufnr)
return vim.api.nvim_buf_get_option(bufnr, "modified")
end, vim.t.bufs)
end,
})