mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-07 21:15:03 +00:00

Some checks failed
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / build-vsc-assets (push) Has been cancelled
tinymist::ci / build-vscode (push) Has been cancelled
tinymist::ci / build-vscode-others (push) Has been cancelled
tinymist::ci / publish-vscode (push) Has been cancelled
tinymist::ci / build-binary (push) Has been cancelled
tinymist::ci / E2E Tests (darwin-arm64 on macos-latest) (push) Has been cancelled
tinymist::ci / E2E Tests (linux-x64 on ubuntu-22.04) (push) Has been cancelled
tinymist::ci / E2E Tests (linux-x64 on ubuntu-latest) (push) Has been cancelled
tinymist::ci / E2E Tests (win32-x64 on windows-2019) (push) Has been cancelled
tinymist::ci / E2E Tests (win32-x64 on windows-latest) (push) Has been cancelled
* fix: bad link * feat(neovim): init lsp * feat(neovim): add bootstrap script * build: add notice
55 lines
1.2 KiB
Lua
55 lines
1.2 KiB
Lua
local Window = require 'std.nvim.window'
|
|
|
|
---A Neovim tab.
|
|
---@class Tab
|
|
---@field id integer The tab number
|
|
local Tab = {}
|
|
Tab.__index = Tab
|
|
|
|
---Bind to a Neovim tab.
|
|
---@param id? integer tab ID, defaulting to the current one
|
|
---@return Tab
|
|
function Tab:from_id(id)
|
|
return setmetatable({ id = id or vim.api.nvim_get_current_tabpage() }, self)
|
|
end
|
|
|
|
---Bind to the current tab.
|
|
function Tab:current()
|
|
return self:from_id(vim.api.nvim_get_current_tabpage())
|
|
end
|
|
|
|
---All current tabs.
|
|
---@return Tab[] tabs
|
|
function Tab:all()
|
|
return vim
|
|
.iter(vim.api.nvim_list_tabpages())
|
|
:map(function(tab_id)
|
|
return self:from_id(tab_id)
|
|
end)
|
|
:totable()
|
|
end
|
|
|
|
---Open a new tab page.
|
|
function Tab:new()
|
|
-- See https://github.com/neovim/neovim/pull/27223
|
|
vim.cmd.tabnew()
|
|
return self:current()
|
|
end
|
|
|
|
---Close the tab page.
|
|
function Tab:close()
|
|
vim.cmd.tabclose(vim.api.nvim_tabpage_get_number(self.id))
|
|
end
|
|
|
|
---Return the windows present in the tab.
|
|
---@return Window[] windows
|
|
function Tab:windows()
|
|
return vim
|
|
.iter(vim.api.nvim_tabpage_list_wins(self.id))
|
|
:map(function(win_id)
|
|
return Window:from_id(win_id)
|
|
end)
|
|
:totable()
|
|
end
|
|
|
|
return Tab
|