Skip to content

Latest commit

 

History

History
125 lines (94 loc) · 2.15 KB

toggle.md

File metadata and controls

125 lines (94 loc) · 2.15 KB

🍿 toggle

Toggle keymaps integrated with which-key icons / colors

image

⚙️ Config

---@class snacks.toggle.Config
---@field icon? string|{ enabled: string, disabled: string }
---@field color? string|{ enabled: string, disabled: string }
{
  map = vim.keymap.set, -- keymap.set function to use
  which_key = true, -- integrate with which-key to show enabled/disabled icons and colors
  notify = true, -- show a notification when toggling
  -- icons for enabled/disabled states
  icon = {
    enabled = "",
    disabled = "",
  },
  -- colors for enabled/disabled states
  color = {
    enabled = "green",
    disabled = "yellow",
  },
}

📚 Types

---@class snacks.toggle.Opts: snacks.toggle.Config
---@field name string
---@field get fun():boolean
---@field set fun(state:boolean)

📦 Module

---@class snacks.toggle
---@field opts snacks.toggle.Opts
Snacks.toggle = {}

Snacks.toggle()

---@type fun(... :snacks.toggle.Opts): snacks.toggle
Snacks.toggle()

Snacks.toggle.diagnostics()

---@param opts? snacks.toggle.Config
Snacks.toggle.diagnostics(opts)

Snacks.toggle.inlay_hints()

---@param opts? snacks.toggle.Config
Snacks.toggle.inlay_hints(opts)

Snacks.toggle.line_number()

---@param opts? snacks.toggle.Config
Snacks.toggle.line_number(opts)

Snacks.toggle.new()

---@param ... snacks.toggle.Opts
---@return snacks.toggle
Snacks.toggle.new(...)

Snacks.toggle.option()

---@param option string
---@param opts? snacks.toggle.Config | {on?: unknown, off?: unknown}
Snacks.toggle.option(option, opts)

Snacks.toggle.treesitter()

---@param opts? snacks.toggle.Config
Snacks.toggle.treesitter(opts)

toggle:get()

toggle:get()

toggle:map()

---@param keys string
---@param opts? vim.keymap.set.Opts | { mode: string|string[]}
toggle:map(keys, opts)

toggle:set()

---@param state boolean
toggle:set(state)

toggle:toggle()

toggle:toggle()