return {
  "akinsho/toggleterm.nvim",
  version = "*",
  cmd = { "ToggleTerm", "TermExec" },
  keys = {
    -- normal terminal (horizontal split)
    { "<C-t>", "<cmd>ToggleTerm direction=horizontal<CR>", desc = "Toggle horizontal terminal" },
    -- floating terminal
    { "<C-f>", "<cmd>ToggleTerm direction=float<CR>", desc = "Toggle floating terminal" },
    -- vertical terminal
    { "<leader>tv", "<cmd>ToggleTerm direction=vertical size=60<CR>", desc = "Toggle vertical terminal" },
  },
  opts = {
    size = function(term)
      if term.direction == "horizontal" then
        return 15
      elseif term.direction == "vertical" then
        return vim.o.columns * 0.4
      end
    end,
    open_mapping = [[<C-t>]],
    shading_factor = 2,
    direction = "horizontal",
    float_opts = {
      border = "rounded",
      width = math.floor(vim.o.columns * 0.9),
      height = math.floor(vim.o.lines * 0.9),
      winblend = 0,
    },
    highlights = {
      FloatBorder = { link = "FloatBorder" },
    },
    persist_size = true,
    persist_mode = true,
    shell = vim.o.shell,
    auto_scroll = true,
    close_on_exit = true,
  },
  config = function(_, opts)
    require("toggleterm").setup(opts)

    -- send escape to leave terminal mode
    vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]])

    -- quick access to lazygit (requires lazygit binary)
    vim.keymap.set("n", "<leader>gg", function()
      local Terminal = require("toggleterm.terminal").Terminal
      local lazygit = Terminal:new({
        cmd = "lazygit",
        direction = "float",
        hidden = true,
        on_open = function(t)
          vim.api.nvim_buf_set_keymap(t.bufnr, "t", "<Esc>", [[<C-\><C-n>]], { noremap = true, silent = true })
        end,
      })
      lazygit:toggle()
    end, { desc = "LazyGit floating window" })
  end,
}
