Code Monkey home page Code Monkey logo

tmux.nvim's Introduction

tmux.nvim

This plugin still under development

tmux.nvim

This plugin provides a framework to turns Neovim into terminal multiplexer (heavily based on tmux)

The intention of this plugin is to eliminate the need of tmux for a basic terminal multiplexing feature by leveraging Neovim split and tab features

For those who's on Windows, this could be a workaround for lack of tmux but only for terminal multiplexing

Table Of Contents

Features

This are non exhaustive list of features available

  • Panes
  • Windows
  • Status bar1
  • Copy mode1
  • (Detachable) Sessions2

1: Partially implemented
2: This requires Neovim to implement a server / client architecture which planned in neovim#10071

Getting Started

To quickly setup and run the first session of tmux.nvim

curl -fLo ~/.tmux.nvim/init.lua --create-dirs https://raw.githubusercontent.com/spywhere/tmux.nvim/main/tests/git.lua
nvim -u ~/.tmux.nvim/init.lua

This will download a basic configuration to ~/.tmux.nvim/init.lua and run it. In which, it will automatically install and setup the plugin using vim-plug.

Configurations

As the plugin still under development, please find the default configurations from following locations...

  • Neovim configurations: lua/tmux/config.lua
  • Status bar (built using tabline): lua/tmux/statusbar.lua
  • Key bindings: lua/tmux/bindings.lua
  • Available commands: lua/tmux/commands.lua

Please note that some options are opinionated and will be updated to match tmux's defaults later on

Installation

Requires neovim v0.7.0 or later.

If you wish to use tmux.nvim with older neovim version (v0.5.0 up to v0.6.1), check out nvim-0.5.0 branch. Do note that nvim-0.5.0 branch is for migration purpose only so the code will not be maintained.

It is highly recommended to clone the repository (or download a zip file) and place it somewhere (~/.tmux.nvim would work too)

git clone https://github.com/spywhere/tmux.nvim ~/.tmux.nvim

or install using a plugin manager of your choice, for example:

Plug 'spywhere/tmux.nvim'

Integration

Create a file named init.lua and place it somewhere (in this example, ~/.tmux.nvim/init.lua will be used)

-- if you're cloning the repository, you will need to add the plugin directory
--   to the 'runtimepath'
vim.opt.rtp:append('~/.tmux.nvim')

local tmux = require('tmux')

-- some configurations go here

tmux.start() -- this will start a terminal session

then, when you're ready to use Neovim as terminal multiplexer, just run

nvim -u ~/.tmux.nvim/init.lua

Supported Features

These are a list of features that required a certain version of Neovim

Neovim 0.8 or later is required for

  • Cleaner status line (hide the command line)

Neovim 0.7 or later is required for

  • Status line on the bottom (above command line)

Neovim 0.5 or later is required for

  • Basic functionality

Contributes

During the development, you can use the following command to automatically setup a working configurations to test the plugin...

make testrun

or

nvim -u tests/init.lua

Alternatively, if you wish to test the plugin through direct cloning, use...

make testrun-from-git

or

nvim -u tests/git.lua

License

Released under the MIT License

tmux.nvim's People

Contributors

spywhere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmux.nvim's Issues

Support repeatable key bindings

Commands such as resize the pane are expected to be repeatable, that is to be able to hold the key sequence to repeat the operation. Currently this would get consumed by vim as the sequence is required 2 steps (prefix then the key).

Idea for implementation

Create a custom key map table. Pressing prefix would rebind all vim key map to all key bindings starts with prefix. Then if there is no key press after certain amount of time, cancelled the key map back to the previous one.

This would mimicking a custom mode in vim, where pressing prefix could put vim into "tmux" mode.

Current workaround

Use vim count to repeat the key bindings for certain amount of times.

Extended Default Key Bindings

These are keybindings that involve a client attach and detach feature...

  • $ Rename the current session.
  • C-z Suspend the tmux client.
  • ( Switch the attached client to the previous session.
  • ) Switch the attached client to the next session.
  • D Choose a client to detach.
  • L Switch the attached client back to the last session.
  • d Detach the current client.
  • s Select a new session for the attached client interactively.

Default Key Bindings

Make a first release of tmux.nvim by providing a basic support for all default key bindings

  • C-b Send the prefix key (C-b) through to the application.
  • C-o Rotate the panes in the current window forwards.
  • ! Break the current pane out of the window.
  • " Split the current pane into two, top and bottom.
  • # List all paste buffers.
  • % Split the current pane into two, left and right.
  • & Kill the current window.
  • ' Prompt for a window index to select.
  • , Rename the current window.
  • - Delete the most recently copied buffer of text.
  • . Prompt for an index to move the current window.
  • 0 to 9 Select windows 0 to 9.
  • : Enter the tmux command prompt.
  • ; Move to the previously active pane.
  • = Choose which buffer to paste interactively from a list.
  • ? List all key bindings.
  • [ Enter copy mode to copy text or view the history.
  • ] Paste the most recently copied buffer of text.
  • c Create a new window.
  • f Prompt to search for text in open windows.
  • i Display some information about the current window.
  • l Move to the previously selected window.
  • m Mark the current pane (see select-pane -m).
  • M Clear the marked pane.
  • n Change to the next window.
  • o Select the next pane in the current window.
  • p Change to the previous window.
  • q Briefly display pane indexes.
  • r Force redraw of the attached client.
  • t Show the time. #3
  • w Choose the current window interactively.
  • x Kill the current pane.
  • z Toggle zoom state of the current pane.
  • { Swap the current pane with the previous pane.
  • } Swap the current pane with the next pane.
  • ~ Show previous messages from tmux, if any.
  • Page Up Enter copy mode and scroll one page up.
  • Up, Down, Left, Right Change to the pane above, below, to the left, or to the right of the current pane.
  • M-1 to M-5 Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
  • Space Arrange the current window in the next preset layout.
  • M-n Move to the next window with a bell or activity marker.
  • M-o Rotate the panes in the current window backwards.
  • M-p Move to the previous window with a bell or activity marker.
  • C-Up, C-Down, C-Left, C-Right Resize the current pane in steps of one cell.
  • M-Up, M-Down, M-Left, M-Right Resize the current pane in steps of five cells.

Repeatable key bindings will be addressed separately.

  • #5 -- check out for a workaround

More key bindings are planned after client attach and detach is supported.

Clock

Bitmap

00000     1 22222 33333 4   4 55555 66666 77777 88888 99999
0   0     1     2     3 4   4 5     6         7 8   8 9   9   :
0   0     1 22222 33333 44444 55555 66666     7 88888 99999
0   0     1 2         3     4     5 6   6     7 8   8     9   :
00000     1 22222 33333     4 55555 66666     7 88888 99999

Bitmap encoded into numbers

[x, y]=0123456789:

[0, 0]=10111111110 1534
[1, 0]=10110111110 1470
[2, 0]=10110111110 1470
[3, 0]=10110111110 1470
[4, 0]=11111111110 2046

[0, 1]=10001110110 1142
[1, 1]=00000000000 0   
[2, 1]=00000000001 1   
[3, 1]=00000000000 0   
[4, 1]=11111001110 1998

[0, 2]=10111110110 1526
[1, 2]=00111110110 502 
[2, 2]=00111110110 502 
[3, 2]=00111110110 502 
[4, 2]=11111111110 2046

[0, 3]=10100010100 1300
[1, 3]=00000000000 0   
[2, 3]=00000000001 1   
[3, 3]=00000000000 0   
[4, 3]=11011111110 1790

[0, 4]=10110110110 1462
[1, 4]=10110110110 1462
[2, 4]=10110110110 1462
[3, 4]=10110110110 1462
[4, 4]=11111111110 2046

Code to generate encoded bitmap

function digit(x, y)
  local y_2 = y % 2
  local ey = y // 2
  local oy = (y - 1) // 2

  if x == 4 then
    if y_2 == 0 then
      return 2046
    else
      return 1998 - 208 * oy
    end
  elseif y == 4 then
    return 1462
  elseif x == 0 then
    if y_2 == 0 then
      return 1534 - 8 * ey
    else
      return 1142 + 158 * oy
    end
  elseif y_2 == 0 then
    return 1470 - 968 * ey
  elseif y_2 == 1 then
    return 1 - (x % 2)
  end
  return 0
end

local time = os.date('*t')
local hour = time.hour
local minute = time.min
-- local hour = time.min
-- local minute = time.sec

for y=0, 4 do
  local str = ''

  for c=0, 4 do
    local ch = '#'
    local n = 0
    if c == 0 then
      n = hour // 10
      -- ch = tostring(n)
    elseif c == 1 then
      n = hour % 10
      -- ch = tostring(n)
    elseif c == 2 then
      n = 10 + (time.sec % 2)
      -- ch = ':'
    elseif c == 3 then
      n = minute // 10
      -- ch = tostring(n)
    elseif c == 4 then
      n = minute % 10
      -- ch = tostring(n)
    end

    for x=0, 4 do
      local d = digit(x, y)
      if (d >> (10 - n)) & 1 == 1 then
        str = str .. ch
      else
        str = str .. ' '
      end
    end

    str = str .. ' | '
  end

  print(str)
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.