Skip to content

Latest commit

 

History

History
174 lines (130 loc) · 2.88 KB

toggle.md

File metadata and controls

174 lines (130 loc) · 2.88 KB

🍿 toggle

Toggle keymaps integrated with which-key icons / colors

image

📦 Setup

-- lazy.nvim
{
  "folke/snacks.nvim",
  ---@type snacks.Config
  opts = {
    toggle = {
      -- your toggle configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    }
  }
}

⚙️ Config

---@class snacks.toggle.Config
---@field icon? string|{ enabled: string, disabled: string }
---@field color? string|{ enabled: string, disabled: string }
---@field map? fun(mode: string|string[], lhs: string, rhs: string|fun(), opts?: vim.keymap.set.Opts)
---@field which_key? boolean
---@field notify? boolean
{
  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 id? string
---@field name string
---@field get fun():boolean
---@field set fun(state:boolean)

📦 Module

Snacks.toggle()

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

Snacks.toggle.animate()

Snacks.toggle.animate()

Snacks.toggle.diagnostics()

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

Snacks.toggle.dim()

Snacks.toggle.dim()

Snacks.toggle.get()

---@param id string
---@return snacks.toggle.Class?
Snacks.toggle.get(id)

Snacks.toggle.indent()

Snacks.toggle.indent()

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
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.profiler()

Snacks.toggle.profiler()

Snacks.toggle.profiler_highlights()

Snacks.toggle.profiler_highlights()

Snacks.toggle.scroll()

Snacks.toggle.scroll()

Snacks.toggle.treesitter()

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

Snacks.toggle.words()

Snacks.toggle.words()

Snacks.toggle.zen()

Snacks.toggle.zen()

Snacks.toggle.zoom()

Snacks.toggle.zoom()