/tui-nvim

Support for any TUI directly inside of Neovim

Primary LanguageLuaGNU General Public License v3.0GPL-3.0

GitHub Stars PRs Welcome Last Commit GitHub Open Issues GitHub Closed Issues GitHub License Lua

tui-nvim

tui-nvim is fm-nvim's successor that allows for much more customization. tui-nvim's goal is to allow you to use your favorite terminal programs. Some examples are zsh, lf, and glow

Demo:

2022-05-07-10.59.39-recording.mp4

Installation:

Configuration:

 require("tui-nvim").setup ({
  -- File that is read from
  -- useful for file managers
  temp     = "/tmp/tui-nvim",

  -- Command used to open files
  method   = "edit",

  -- Example of a mapping
  mappings = {
    { "<ESC>", "<C-\\><C-n>:q<CR>" }
  },

  -- Execute functions
  -- upon open/exit
  on_open  = {},
  on_exit  = {},

  -- Window border (see ':h nvim_open_win')
  border   = "rounded",

  -- Highlight group for window/border (see ':h winhl')
  borderhl = "Normal",
  winhl    = "Normal",

  -- Window transparency (see ':h winblend')
  winblend = 0,

  -- Num from '0 - 1' for measurements
  height   = 0.8,
  width    = 0.8,
  y        = 0.5,
  x        = 0.5
})

Usage:

tui-nvim does not come with any builtin support any terminal programs. Intead, the user supports their own terminal programs.

If an option such as height is not provided, it will fallback to the defaults or the configuration found in require("tui-nvim").setup()

Open ranger with the current file selected:

function Ranger()
  require("tui-nvim"):new {
    -- Write selected files to '/tmp/tui-nvim'
    cmd      = "ranger --choosefiles=/tmp/tui-nvim --selectfile=" .. vim.fn.fnameescape(vim.fn.expand("%:p"))
    
    -- Read and open files from '/tmp/tui-nvim'
    temp     = "/tmp/tui-nvim",

    -- Open files in splits
    method   = "split"
end

vim.cmd [[ command! Ranger :lua Ranger()<CR> ]]

Open lazygit with the cwd:

function Lazygit()
  require("tui-nvim"):new {
    cmd      = "lazygit -w " .. vim.fn.fnameescape(vim.fn.expand("%:p:h"))
  }
end

vim.cmd [[ command! Lazygit :lua Lazygit()<CR> ]]