astroui API documentation
AstroNvim UI Utilities
UI utility functions to use within AstroNvim and user configurations.
This module can be loaded with local astro = require "astroui"
copyright 2023 license GNU General Public License v3.0
AstroUIOptsfunction astroui.get_hlgroup(name: string, fallback?: table)
-> properties: tableGet highlight properties for a given highlight name
param name — The highlight group name
param fallback — The fallback highlight properties
return properties — the highlight group properties
function astroui.get_icon(kind: string, padding?: integer, no_fallback?: boolean)
-> icon: stringGet an icon from the AstroNvim internal icons if it is available and return it
param kind — The kind of icon in astroui.icons to retrieve
param padding — Padding to add to the end of the icon
param no_fallback — Whether or not to disable fallback to text icon
function astroui.get_spinner(kind: string, ...any)
-> spinners: string[]|nilGet a icon spinner table if it is available in the AstroNvim icons. Icons in format kind1,kind2, kind3, ...
param kind — The kind of icon to check for sequential entries of
return spinners — A collected table of spinning icons in sequential order or nil if none exist
function astroui.set_colorscheme()Set the configured colorscheme
function astroui.setup(opts: AstroUIOpts)Setup and configure AstroUI
AstroNvim Status Components
Statusline related component functions to use with Heirline
This module can be loaded with local component = require "astroui.status.component"
copyright 2023 license GNU General Public License v3.0
function astroui.status.component.breadcrumbs(opts?: AstroUIComponentBreadcrumbsOpts)
-> tableA function to build a set of children components for an LSP breadcrumbs section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.breadcrumbs()
function astroui.status.component.builder(opts?: AstroUIComponentBuilderOpts)
-> tableA general function to build a section of astronvim status providers with highlights, conditions, and section surrounding
param opts — component builder options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").components.builder({ { provider = "file_icon", opts = { padding = { right = 1 } } }, { provider = "filename" } })
function astroui.status.component.cmd_info(opts?: AstroUIComponentCmdInfoOpts)
-> tableA function to build a set of children components for information shown in the cmdline
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.cmd_info()
function astroui.status.component.diagnostics(opts?: AstroUIComponentDiagnosticsOpts)
-> tableA function to build a set of children components for a diagnostics section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.diagnostics()
function astroui.status.component.file_info(opts?: AstroUIComponentFileInfoOpts)
-> tableA function to build a set of children components for an entire file information section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.file_info()
function astroui.status.component.fill(opts?: table)
-> tableA Heirline component for filling in the empty space of the bar
param opts — options for configuring the other fields of the heirline component
return — The heirline component table
@usage local heirline_component = require("astroui.status").component.fill()
function astroui.status.component.foldcolumn(opts?: AstroUIComponentFoldcolumnOpts)
-> tableA function to build a set of components for a foldcolumn section in a statuscolumn
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.foldcolumn()
function astroui.status.component.git_branch(opts?: AstroUIComponentGitBranchOpts)
-> tableA function to build a set of children components for a git branch section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.git_branch()
function astroui.status.component.git_diff(opts?: AstroUIComponentGitDiffOpts)
-> tableA function to build a set of children components for a git difference section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.git_diff()
function astroui.status.component.lsp(opts?: AstroUIComponentLspOpts)
-> tableA function to build a set of children components for an LSP section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.lsp()
function astroui.status.component.mode(opts?: AstroUIComponentModeOpts)
-> tableA function to build a set of children components for a mode section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.mode { mode_text = true }
function astroui.status.component.nav(opts?: AstroUIComponentNavOpts)
-> tableA function to build a set of children components for an entire navigation section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.nav()
function astroui.status.component.numbercolumn(opts?: AstroUIComponentNumbercolumnOpts)
-> tableA function to build a set of components for a numbercolumn section in statuscolumn
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.numbercolumn()
function astroui.status.component.separated_path(opts?: AstroUIComponentSeparatedPathOpts)
-> tableA function to build a set of children components for the current file path
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.separated_path()
function astroui.status.component.signcolumn(opts?: AstroUIComponentSigncolumnOpts)
-> tableA function to build a set of components for a signcolumn section in statuscolumn
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.signcolumn()
function astroui.status.component.tabline_file_info(opts?: AstroUIComponentTablineFileInfoOpts)
-> tableA function with different file_info defaults specifically for use in the tabline
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.tabline_file_info()
function astroui.status.component.treesitter(opts?: AstroUIComponentTreesitterOpts)
-> tableA function to build a set of children components for a Treesitter section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.treesitter()
function astroui.status.component.virtual_env(opts?: AstroUIComponentVirtualEnvOpts)
-> tableA function to build a set of children components for a git branch section
param opts — provider options
return — The Heirline component table
@usage local heirline_component = require("astroui.status").component.git_branch()
AstroNvim Status Conditions
Statusline related condition functions to use with Heirline
This module can be loaded with local condition = require "astroui.status.condition"
copyright 2023 license GNU General Public License v3.0
function astroui.status.condition.aerial_available()
-> booleanA condition function if Aerial is available
return — whether or not aerial plugin is installed
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.aerial_available } function M.aerial_available() return is_available "aerial.nvim" end
function astroui.status.condition.buffer_matches(patterns: table<"bufname"|"buftype"|"filetype", string|string[]>, bufnr?: integer, op?: "and"|"or")
-> booleanA condition function if the buffer filetype,buftype,bufname match a pattern
param patterns — the table of patterns to match
param bufnr — of the buffer to match (Default: 0 [current])
param op — whether or not to require all pattern types to match or any (Default: "or")
return — whether or not the buffer filetype,buftype,bufname match a pattern
@usage local heirline_component = { provider = "Example Provider", condition = function() return require("astroui.status").condition.buffer_matches { buftype = { "terminal" } } end }
op:
| "and"
| "or"function astroui.status.condition.file_modified(bufnr: integer|table)
-> booleanA condition function if the current buffer is modified
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not the current buffer is modified
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.file_modified }
function astroui.status.condition.file_read_only(bufnr: integer|table)
-> booleanA condition function if the current buffer is read only
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not the current buffer is read only or not modifiable
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.file_read_only }
function astroui.status.condition.foldcolumn_enabled()
-> booleanA condition function if the foldcolumn is enabled
return — true if vim.opt.foldcolumn > 0, false if vim.opt.foldcolumn == 0
function astroui.status.condition.git_changed(bufnr: integer|table)
-> booleanA condition function if there are any git changes
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not there are any git changes
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.git_changed }
function astroui.status.condition.has_diagnostics(bufnr: integer|table)
-> booleanA condition function if the current file has any diagnostics
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not the current file has any diagnostics
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.has_diagnostics }
function astroui.status.condition.has_filetype(bufnr: integer|table)
-> booleanA condition function if there is a defined filetype
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not there is a filetype
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.has_filetype }
function astroui.status.condition.has_virtual_env()
-> booleanA condition function if a virtual environment is activated
return — whether or not virtual environment is activated
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.has_virtual_env }
function astroui.status.condition.is_active()
-> booleanA condition function if the window is currently active
return — whether or not the window is currently active
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_active }
function astroui.status.condition.is_file(bufnr: integer|table)
-> booleanA condition function if a buffer is a file
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not the buffer is a file
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_file }
function astroui.status.condition.is_git_repo(bufnr: integer|table)
-> booleanA condition function if the current file is in a git repo
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not the current file is in a git repo
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_git_repo }
function astroui.status.condition.is_hlsearch()
-> booleanA condition function if search is visible
return — whether or not searching is currently visible
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_hlsearch }
function astroui.status.condition.is_macro_recording()
-> booleanA condition function if a macro is being recorded
return — whether or not a macro is currently being recorded
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_macro_recording }
function astroui.status.condition.is_statusline_showcmd()
-> booleanA condition function if showcmdloc is set to statusline
return — whether or not statusline showcmd is enabled
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.is_statusline_showcmd }
function astroui.status.condition.lsp_attached(bufnr: integer|table)
-> booleanA condition function if LSP is attached
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not LSP is attached
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.lsp_attached }
function astroui.status.condition.numbercolumn_enabled()
-> booleanA condition function if the number column is enabled
return — true if vim.opt.number or vim.opt.relativenumber, false if neither
function astroui.status.condition.signcolumn_enabled()
-> booleanA condition function if the signcolumn is enabled
return — false if vim.opt.signcolumn == "no", true otherwise
function astroui.status.condition.treesitter_available(bufnr: integer|table)
-> booleanA condition function if a treesitter parser for a given buffer is available
param bufnr — a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer
return — whether or not treesitter is active
@usage local heirline_component = { provider = "Example Provider", condition = require("astroui.status").condition.treesitter_available }
AstroNvim Status Heirline Extensions
Statusline related heirline specific extensions
This module can be loaded with local astro_heirline = require "astroui.status.heirline"
copyright 2023 license GNU General Public License v3.0
function astroui.status.heirline.buffer_picker(callback: function)Run the buffer picker and execute the callback function on the selected buffer
param callback — with a single parameter of the buffer number
function astroui.status.heirline.make_buflist(component: table)
-> tableMake a list of buffers, rendering each buffer with the provided component
function astroui.status.heirline.make_tablist(...any)Alias to require("heirline.utils").make_tablist
function astroui.status.heirline.refresh_colors()Refresh heirline colors
function astroui.status.heirline.tab_type(self: table, prefix?: string)
-> stringA helper function to get the type a tab or buffer is
param self — the self table from a heirline component function
param prefix — the prefix of the type, either "tab" or "buffer" (Default: "buffer")
return — the string of prefix with the type (i.e. "_active" or "_visible")
AstroNvim Status Highlighting
Statusline related highlighting utilities
This module can be loaded with local hl = require "astroui.status.hl"
copyright 2023 license GNU General Public License v3.0
function astroui.status.hl.file_icon(name: string)
-> functionEnable filetype color highlight if enabled in icon_highlights.file_icon options
param name — the icon_highlights.file_icon table element
return — for setting hl property in a component
@usage local heirline_component = { provider = "Example Provider", hl = require("astroui.status").hl.file_icon("winbar") },
function astroui.status.hl.filetype_color(self?: { bufnr: integer })
-> tableGet the foreground color group for the current filetype
param self — component state that may hold the buffer number
return — the highlight group for the current filetype foreground
@usage local heirline_component = { provider = require("astroui.status").provider.fileicon(), hl = require("astroui.status").hl.filetype_color },
function astroui.status.hl.get_attributes(name: string, include_bg?: boolean)
-> tableMerge the color and attributes from user settings for a given name
param name — , the name of the element to get the attributes and colors for
param include_bg — whether or not to include background color (Default: false)
return — a table of highlight information
@usage local heirline_component = { provider = "Example Provider", hl = require("astroui.status").hl.get_attributes("treesitter") },
function astroui.status.hl.lualine_mode(mode: string, fallback: string)
-> stringGet the highlight background color of the lualine theme for the current colorscheme
param mode — the neovim mode to get the color of
param fallback — the color to fallback on if a lualine theme is not present
return — The background color of the lualine theme or the fallback parameter if one doesn't exist
function astroui.status.hl.mode()
-> tableGet the highlight for the current mode
return — the highlight group for the current mode
@usage local heirline_component = { provider = "Example Provider", hl = require("astroui.status").hl.mode },
function astroui.status.hl.mode_bg()
-> stringAstroNvim Status Initializers
Statusline related init functions for building dynamic statusline components
This module can be loaded with local init = require "astroui.status.init"
copyright 2023 license GNU General Public License v3.0
function astroui.status.init.breadcrumbs(opts?: AstroUIInitBreadcrumbsOpts)
-> functionAn init function to build a set of children components for LSP breadcrumbs
param opts — component init options
return — The Heirline init function
@usage local heirline_component = { init = require("astroui.status").init.breadcrumbs { padding = { left = 1 } } }
function astroui.status.init.separated_path(opts?: AstroUIInitSeparatedPathOpts)
-> functionAn init function to build a set of children components for a separated path to file
param opts — component init options
return — The Heirline init function
@usage local heirline_component = { init = require("astroui.status").init.separated_path { padding = { left = 1 } } }
function astroui.status.init.update_events(opts: AstroUIUpdateEvent|AstroUIUpdateEvent[])
-> functionAn init function to build multiple update events which is not supported yet by Heirline's update field
param opts — an array like table of autocmd events as either just a string or a table with custom patterns and callbacks. TODO: UPDATE TYPE
return — The Heirline init function
@usage local heirline_component = { init = require("astroui.status").init.update_events { "BufEnter", { "User", pattern = "LspProgressUpdate" } } }
AstroNvim Status Providers
Statusline related provider functions for building statusline components
This module can be loaded with local provider = require "astroui.status.provider"
copyright 2023 license GNU General Public License v3.0
function astroui.status.provider.bufnr(opts?: AstroUIProviderBufnrOpts)
-> functionA provider function for showing the buffer number
param opts — provider options
return — the function for outputting the buffer number
@usage local heirline_component = { provider = require("astroui.status").provider.bufnr() } @see astroui.status.utils.stylize
function astroui.status.provider.close_button(opts?: AstroUIProviderCloseButtonOpts)
-> stringA provider to simply show a close button icon
param opts — provider options
return — the stylized icon
@usage local heirline_component = { provider = require("astroui.status").provider.close_button() } @see astroui.status.utils.stylize
function astroui.status.provider.diagnostics(opts?: AstroUIProviderDiagnosticsOpts)
-> function|nilA provider function for showing the current diagnostic count of a specific severity
param opts — provider options
return — the function for outputting the diagnostic count
@usage local heirline_component = { provider = require("astroui.status").provider.diagnostics({ severity = "ERROR" }) } @see astroui.status.utils.stylize
function astroui.status.provider.file_encoding(opts?: AstroUIProviderFileEncodingOpts)
-> functionA provider function for showing the current file encoding
param opts — provider options
return — the function for outputting the file encoding
@usage local heirline_component = { provider = require("astroui.status").provider.file_encoding() } @see astroui.status.utils.stylize
function astroui.status.provider.file_format(opts?: AstroUIProviderFileFormatOpts)
-> functionA provider function for showing the current file format
param opts — provider options
return — the function for outputting the file format
@usage local heirline_component = { provider = require("astroui.status").provider.file_format() } @see astroui.status.utils.stylize
function astroui.status.provider.file_icon(opts?: AstroUIProviderFileIconOpts)
-> functionA provider function for showing the current filetype icon
param opts — provider options
return — the function for outputting the filetype icon
@usage local heirline_component = { provider = require("astroui.status").provider.file_icon() } @see astroui.status.utils.stylize
function astroui.status.provider.file_modified(opts?: AstroUIProviderFileModifiedOpts)
-> functionA provider function for showing if the current file is modifiable
param opts — provider options
return — the function for outputting the indicator if the file is modified
@usage local heirline_component = { provider = require("astroui.status").provider.file_modified() } @see astroui.status.utils.stylize
function astroui.status.provider.file_read_only(opts?: AstroUIProviderFileReadOnlyOpts)
-> functionA provider function for showing if the current file is read-only
param opts — provider options
return — the function for outputting the indicator if the file is read-only
@usage local heirline_component = { provider = require("astroui.status").provider.file_read_only() } @see astroui.status.utils.stylize
function astroui.status.provider.filename(opts?: AstroUIProviderFilenameOpts)
-> functionA provider function for showing the current filename
param opts — provider options
return — the function for outputting the filename
@usage local heirline_component = { provider = require("astroui.status").provider.filename() } @see astroui.status.utils.stylize
function astroui.status.provider.filetype(opts?: AstroUIProviderFiletypeOpts)
-> functionA provider function for showing the current filetype
param opts — provider options
return — the function for outputting the filetype
@usage local heirline_component = { provider = require("astroui.status").provider.filetype() } @see astroui.status.utils.stylize
function astroui.status.provider.fill()
-> stringA provider function for the fill string
return — the statusline string for filling the empty space
@usage local heirline_component = { provider = require("astroui.status").provider.fill }
function astroui.status.provider.foldcolumn(opts?: AstroUIProviderFoldcolumnOpts)
-> string|functionA provider function for building a foldcolumn
param opts — provider options
return — a custom foldcolumn function for the statuscolumn that doesn't show the nest levels
@usage local heirline_component = { provider = require("astroui.status").provider.foldcolumn } @see astroui.status.utils.stylize
function astroui.status.provider.git_branch(opts?: AstroUIProviderGitBranchOpts)
-> functionA provider function for showing the current git branch
param opts — provider options
return — the function for outputting the git branch
@usage local heirline_component = { provider = require("astroui.status").provider.git_branch() } @see astroui.status.utils.stylize
function astroui.status.provider.git_diff(opts?: AstroUIProviderGitDiffOpts)
-> function|nilA provider function for showing the current git diff count of a specific type
param opts — provider options
return — the function for outputting the git diff
@usage local heirline_component = { provider = require("astroui.status").provider.git_diff({ type = "added" }) } @see astroui.status.utils.stylize
function astroui.status.provider.lsp_client_names(opts?: AstroUIProviderLspClientNamesOpts)
-> functionA provider function for showing the connected LSP client names
param opts — provider options
return — the function for outputting the LSP client names
@usage local heirline_component = { provider = require("astroui.status").provider.lsp_client_names({ integrations = { null_ls = true, conform = true, lint = true }, truncate = 0.25 }) } @see astroui.status.utils.stylize
function astroui.status.provider.lsp_progress(opts?: AstroUIProviderLspProgressOpts)
-> functionA provider function for showing the current progress of loading language servers
param opts — provider options
return — the function for outputting the LSP progress
@usage local heirline_component = { provider = require("astroui.status").provider.lsp_progress() } @see astroui.status.utils.stylize
function astroui.status.provider.macro_recording(opts?: AstroUIProviderMacroRecordingOpts)
-> functionA provider function for displaying if a macro is currently being recorded
param opts — provider options
return — a function that returns a string of the current recording status
@usage local heirline_component = { provider = require("astroui.status").provider.macro_recording() } @see astroui.status.utils.stylize
function astroui.status.provider.mode_text(opts?: AstroUIProviderModeTextOpts)
-> functionA provider function for showing the text of the current vim mode
param opts — provider options
return — the function for displaying the text of the current vim mode
@usage local heirline_component = { provider = require("astroui.status").provider.mode_text() } @see astroui.status.utils.stylize
function astroui.status.provider.numbercolumn(opts?: AstroUIProviderNumbercolumnOpts)
-> functionA provider function for the numbercolumn string
param opts — provider options
return — the statuscolumn string for adding the numbercolumn
@usage local heirline_component = { provider = require("astroui.status").provider.numbercolumn } @see astroui.status.utils.stylize
function astroui.status.provider.paste(opts?: AstroUIProviderPasteOpts)
-> functionA provider function for showing if paste is enabled
param opts — provider options
return — the function for outputting if paste is enabled
@usage local heirline_component = { provider = require("astroui.status").provider.paste() } @see astroui.status.utils.stylize
function astroui.status.provider.percentage(opts?: AstroUIProviderPercentageOpts)
-> functionA provider function for showing the percentage of the current location in a document
param opts — provider options
return — the statusline string for displaying the percentage of current document location
@usage local heirline_component = { provider = require("astroui.status").provider.percentage() } @see astroui.status.utils.stylize
function astroui.status.provider.ruler(opts?: AstroUIProviderRulerOpts)
-> functionA provider function for showing the current line and character in a document
param opts — provider options
return — the statusline string for showing location in document line_num:char_num
@usage local heirline_component = { provider = require("astroui.status").provider.ruler({ pad_ruler = { line = 3, char = 2 } }) } @see astroui.status.utils.stylize
function astroui.status.provider.scrollbar(opts?: AstroUIProviderScrollbarOpts)
-> functionA provider function for showing the current location as a scrollbar
param opts — provider options
return — the function for outputting the scrollbar
@usage local heirline_component = { provider = require("astroui.status").provider.scrollbar() } @see astroui.status.utils.stylize
function astroui.status.provider.search_count(opts?: AstroUIProviderSearchCountOpts)
-> functionA provider function for displaying the current search count
param opts — provider options
return — a function that returns a string of the current search location
@usage local heirline_component = { provider = require("astroui.status").provider.search_count() } @see astroui.status.utils.stylize
function astroui.status.provider.showcmd(opts?: AstroUIProviderShowcmdOpts)
-> stringA provider function for displaying the current command
param opts — provider options
return — the statusline string for showing the current command
@usage local heirline_component = { provider = require("astroui.status").provider.showcmd() } @see astroui.status.utils.stylize
function astroui.status.provider.signcolumn(opts?: AstroUIProviderSigncolumnOpts)
-> stringA provider function for the signcolumn string
param opts — provider options
return — the statuscolumn string for adding the signcolumn
@usage local heirline_component = { provider = require("astroui.status").provider.signcolumn } @see astroui.status.utils.stylize
function astroui.status.provider.spell(opts?: AstroUIProviderSpellOpts)
-> functionA provider function for showing if spellcheck is on
param opts — provider options
return — the function for outputting if spell is enabled
@usage local heirline_component = { provider = require("astroui.status").provider.spell() } @see astroui.status.utils.stylize
function astroui.status.provider.str(opts?: AstroUIProviderStrOpts)
-> stringA provider function for displaying a single string
param opts — provider options
return — the stylized statusline string
@usage local heirline_component = { provider = require("astroui.status").provider.str({ str = "Hello" }) } @see astroui.status.utils.stylize
function astroui.status.provider.tabnr()
-> functionA provider function for the current tab number
return — the statusline function to return a string for a tab number
@usage local heirline_component = { provider = require("astroui.status").provider.tabnr() }
function astroui.status.provider.treesitter_status(opts?: AstroUIProviderTreesitterStatusOpts)
-> functionA provider function for showing if treesitter is connected
param opts — provider options
return — function for outputting TS if treesitter is connected
@usage local heirline_component = { provider = require("astroui.status").provider.treesitter_status() } @see astroui.status.utils.stylize
function astroui.status.provider.unique_path(opts?: AstroUIProviderUniquePathOpts)
-> functionGet a unique filepath between all buffers
param opts — provider options
return — path to file that uniquely identifies each buffer
@usage local heirline_component = { provider = require("astroui.status").provider.unique_path() } @see astroui.status.utils.stylize
function astroui.status.provider.virtual_env(opts?: AstroUIProviderVirtualEnvOpts)
-> functionA provider function for showing the current virtual environment name
param opts — provider options
return — the function for outputting the virtual environment
@usage local heirline_component = { provider = require("astroui.status").provider.virtual_env() } @see astroui.status.utils.stylize
AstroNvim Status Utilities
Statusline related uitility functions
This module can be loaded with local status_utils = require "astroui.status.utils"
copyright 2023 license GNU General Public License v3.0
function astroui.status.utils.build_provider(opts?: table, provider?: string|function, _: any)
-> table|falseConvert a component parameter table to a table that can be used with the component builder
param opts — a table of provider options
param provider — a provider in M.providers
return — the provider table that can be used in M.component.builder
return #1:
| falsefunction astroui.status.utils.decode_pos(c: integer)
-> line: integer
2. column: integer
3. window: integerDecode a previously encoded position to it's sub parts
param c — the encoded position
function astroui.status.utils.encode_pos(line: integer, col: integer, winnr: integer)
-> the: integerEncode a position to a single value that can be decoded later
param line — line number of position
param col — column number of position
param winnr — a window number
return the — encoded position
function astroui.status.utils.icon_provider(bufnr: integer)
-> icon: string?
2. color: string?Resolve the icon and color information for a given buffer
param bufnr — the buffer number to resolve the icon and color of
return icon — the icon string
return color — the hex color of the icon
function astroui.status.utils.null_ls_providers(params: table)
-> tableGet a list of registered null-ls providers for a given filetype
param params — parameters to use for null-ls providers
return — a table of null-ls sources
function astroui.status.utils.null_ls_sources(params: table)
-> string[]Get the null-ls sources for a given null-ls method
param params — parameters to use for checking null-ls sources
return — the available sources for the given filetype and method
function astroui.status.utils.pad_string(str: string, padding: AstroUIStatusPadding)
-> stringAdd left and/or right padding to a string
param str — the string to add padding to
param padding — a table of the format { left = 0, right = 0} that defines the number of spaces to include to the left and the right of the string
return — the padded string
function astroui.status.utils.setup_providers(opts: table, providers: string[], setup?: function)
-> tableConvert key/value table of options to an array of providers for the component builder
param opts — the table of options for the components
param providers — an ordered list like array of providers that are configured in the options table
param setup — a function that takes provider options table, provider name, provider index and returns the setup provider table, optional, default is M.build_provider
return — the fully setup options table with the appropriately ordered providers
function astroui.status.utils.statuscolumn_clickargs(self: any, minwid: any, clicks: any, button: any, mods: any)
-> tableA helper function for decoding statuscolumn click events with mouse click pressed, modifier keys, as well as which signcolumn sign was clicked if any
param self — the self parameter from Heirline component on_click.callback function call
param minwid — the minwid parameter from Heirline component on_click.callback function call
param clicks — the clicks parameter from Heirline component on_click.callback function call
param button — the button parameter from Heirline component on_click.callback function call
param mods — the button parameter from Heirline component on_click.callback function call
return — the argument table with the decoded mouse information and signcolumn signs information
@usage local heirline_component = { on_click = { callback = function(...) local args = require("astroui.status").utils.statuscolumn_clickargs(...) end } }
function astroui.status.utils.stylize(str?: string, opts?: AstroUIStatusStylizeOpts)
-> stringA utility function to stylize a string with an icon from lspkind, separators, and left/right padding
param str — the string to stylize
param opts — options for stylizing the string
return — the stylized string
@usage local string = require("astroui.status").utils.stylize("Hello", { padding = { left = 1, right = 1 }, icon = { kind = "String" } })
function astroui.status.utils.surround(separator: string|string[], color: string|function|table, component: table, condition: boolean|function, update?: AstroUIUpdateEvent|AstroUIUpdateEvent[])
-> tableSurround component with separator and color adjustment
param separator — the separator index to use in the separators table
param color — the color to use as the separator foreground/component background
param component — the component to surround
param condition — the condition for displaying the surrounded component
param update — control updating of separators, either a list of events or true to update freely
return — the new surrounded component
function astroui.status.utils.width(is_winbar?: boolean)
-> integerA utility function to get the width of the bar
param is_winbar — true if you want the width of the winbar, false if you want the statusline width
return — the width of the specified bar