Skip to content

Execute commands with variables driven by treesitter

Notifications You must be signed in to change notification settings

d4rkr00t/execa.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Execa.nvim

This is a simple plugin to run shell commands in a terminal buffer with access to different "variables".

Installation

Using lazy.nvim

{
  "d4rkr00t/execa.nvim",
  cmd = "Execa",
  opts = {
    -- Open terminal in a vertical or horizontal split
    split = "vsplit",

    -- Ask for confirmation before running a command
    confirm = true,

    -- Use telescope as a picker for pre-defined commands
    telescope = false,

    -- A list of pre-defined commands
    commands = {
      hello = "echo $EX_FN",
    }
  }
}

Optional dependencies:

Usage

Variables

  • $EX_FN – Current function name (powered by treesitter)
  • $EX_STR – Content of the string under the cursor (powered by treesitter)
  • $EX_FILE_PATH_REL – Relative path to the current file
  • $EX_FILE_PATH – Absolute path to the current file
  • $EX_FILE_NAME_NO_EXT – Current file name without extension
  • $EX_FILE_NAME – Current file name with extension
  • $EX_DIR_PATH – Current dir path
  • $EX_DIR_NAME – Current dir name
  • $EX_LINE – Current line number
  • $EX_COL – Current col number

Supported languages for treesitter based variables

  • Go
  • JSON
  • JavaScript
  • Lua
  • Python
  • Rust
  • Typescript

More languages can be supported by contributing treesitter queries

Run

Runs a command in a terminal buffer.

:Execa run echo $EX_FN

Outputs the current function name.

Repeat

Repeats the last command in the current context. It runs the same command but re-evaluates the variables.

:Execa repeat

Command

Runs a pre-defined command in a terminal buffer.

:Execa command hello

Picker for Pre-defined Commands

Opens a picker with a list of pre-defined commands.

:Execa picker

Examples

Run single test with cargo

:Execa run cargo test $EX_FN

Execa Cargo Test

Get the latest version of a package from npm

:Execa run npm view $EX_STR version

Execa NPM

About

Execute commands with variables driven by treesitter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published