LoricAndre / OneTerm.nvim

One terminal plugin to rule them all ! (eventually)
53 stars 1 forks source link
fzf neovim neovim-plugin nvim

      # ###                             /###           /                                         
    /  /###                            /  ############/                                          
   /  /  ###                          /     #########                                            
  /  ##   ###                         #     /  #                                                 
 /  ###    ###                         ##  /  ##                                                 
##   ##     ## ###  /###       /##        /  ###            /##    ###  /###    ### /### /###    
##   ##     ##  ###/ #### /   / ###      ##   ##           / ###    ###/ #### /  ##/ ###/ /##  / 
##   ##     ##   ##   ###/   /   ###     ##   ##          /   ###    ##   ###/    ##  ###/ ###/  
##   ##     ##   ##    ##   ##    ###    ##   ##         ##    ###   ##           ##   ##   ##   
##   ##     ##   ##    ##   ########     ##   ##         ########    ##           ##   ##   ##   
 ##  ##     ##   ##    ##   #######       ##  ##         #######     ##           ##   ##   ##   
  ## #      /    ##    ##   ##             ## #      /   ##          ##           ##   ##   ##   
   ###     /     ##    ##   ####    /       ###     /    ####    /   ##           ##   ##   ##   
    ######/      ###   ###   ######/         ######/      ######/    ###          ###  ###  ###  
      ###         ###   ###   #####            ###         #####      ###          ###  ###  ### 

One terminal plugin to rule them all (eventually).

asciicast

Introduction

This is my second take at a neovim plugin using the terminal (first was https://github.com/LoricAndre/fzterm.nvim).
I dropped the first one because it quickly became a mess and creating another one was faster than refactoring the first one.
This does not mean that I'll drop support for this one though, since it is well better designed (for reference, adding a new command now takes little knowledge of lua and only a little bit of tinkering, but with fzterm it was quite the fight).
Main difference you'll see with fzterm is the way it is configured and the fact that you can now open files in a new split/tab.

Requirements

The base framework is using neovim nightly features, so you need to be using the latest nightly release.
Most commands require fzf. files and rg require ripgrep, ag requires the silver searcher andranger requires, well, ranger. git uses lazygit and gitui uses gitui.
Credits to all the devs of those projects :heart:.

Usage

Install the plugin using your favorite package manager (or whatever way you deem best). Then, all you have to do is type :OneTerm <Tab> and browse through the commands. Using the term command also requires you to have hidden set : set hidden

Implemented commands

Configuration

OneTerm's window is configurable using the following variables. You can set them using either let g:var from vimscript or vim.g.var from lua.

Using the framework

Each of the commands calls the same lua function, accessible using lua require('oneterm').main(arg_object).
arg_object should be an object, with the following keys :

The way this function works is very simple : if cmd is a function, it is ran and writes its output to "/tmp/onetermcmd" (or windows' temp dir), then opens a terminal reading from this file and piping it to matcher (after having built it) then writing the output to "/tmp/oneterm". If cmd is a string, the terminal is opened, running the command inside and piping to the rest of the treatment. Check init.lua for examples

TODO