is0n/jaq-nvim

github github
code-runner
star 13
stars
alert-circle 0
open issues
users 1
subscribers
git-branch 0
forks
CREATED

2021-10-30

UPDATED

last month


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

jaq-nvim is Just Another Quickrun plugin for Neovim that's written in less than 100 lines of Lua. Inspired by quickrun.vim. In short, it is a plugin that lets you run the code of any language with a single command.

Demo:

Demo

Run C++ Code w/ :Jaq Bang

Jaq Bang

Run C++ Code w/ :Jaq Float

Jaq Float

Run C++ Code w/ :Jaq Term

Jaq Term

Installation:

Configuration:

The following is an example config...

require('jaq-nvim').setup{
    -- Commands used with 'Jaq'
    cmds = {
        -- Default UI used (see `Usage` for options)
        default = "float"

        -- Uses external commands such as 'g++' and 'cargo'
        external = {
            typescript = "deno run %",
            javascript = "node %",
            markdown = "glow %",
            python = "python3 %",
            rust = "rustc % && ./$fileBase && rm $fileBase",
            cpp = "g++ % -o $fileBase && ./$fileBase",
            go = "go run %",
            sh = "sh %",
        },

        -- Uses internal commands such as 'source' and 'luafile'
        internal = {
            lua = "luafile %",
            vim = "source %"
        }
    },

    -- UI settings
    ui = {
        -- Start in insert mode
        startinsert = false,

        -- Floating Window settings
        float = {
            -- Floating window border (see ':h nvim_open_win')
            border    = "none",

            -- Num from `0 - 1` for measurements
            height    = 0.8,
            width     = 0.8,

            -- Highlight group for floating window/border (see ':h winhl')
            border_hl = "FloatBorder",
            float_hl  = "Normal",

            -- Floating Window Transparency (see ':h winblend')
            blend     = 0
        },

        terminal = {
            -- Position of terminal
            position = "bot",

            -- Size of terminal
            size     = 10
        },

        quickfix = {
            -- Position of quickfix window
            position = "bot",

            -- Size of quickfix window
            size     = 10
        }
    }
}

Usage:

:Jaq by default uses the float option to run code, however, both bang and term are appropriate terms. Append any of the following terms to the end of :Jaq to override the default value.

  • float • opens a floating window with :lua vim.api.nvim_open_win()
  • quickfix / qf • command output is placed in a quickfix
  • term • opens a terminal with :terminal
  • bang • opens a small window with :!
  • internal • runs a vim command

Example: :Jaq bang

The commands for :Jaq also have certain variables that can help in running code. You can put any of the following in your require('jaq-nvim').setup()...

  • % • Current File
  • $file • Current File
  • $filePath • Path to Current File
  • $fileBase • Basename of File (no extension)
  • $altFile • Alternate File
  • $dir • Current Working Directory (CWD)
  • $moduleName • Python Module Name

Similar Plugins:

Lua