jellydn / quick-code-runner.nvim

A simple and efficient code runner for Neovim.
MIT License
22 stars 0 forks source link
code-runner lua neovim neovim-plugin

Welcome to quick-code-runner.nvim 👋

Efficient Neovim plugin for running code quickly and simply.

IT Man - Introducing quick-code-runner.nvim - A simple and efficient code runner for Neovim

Features

Installation

Add the following to your Neovim configuration to install quick-code-runner.nvim:

Install with lazy.nvim

{
    "jellydn/quick-code-runner.nvim",
    dependencies = { "MunifTanjim/nui.nvim" },
    opts = {
      debug = true,
    },
    cmd = { "QuickCodeRunner", "QuickCodePad" },
    keys = {
      {
        "<leader>cr",
        ":QuickCodeRunner<CR>",
        desc = "Quick Code Runner",
        mode = "v",
      },
      {
        "<leader>cp",
        ":QuickCodePad<CR>",
        desc = "Quick Code Pad",
      },
    },
  }

Configuration

Customize the plugin by modifying the default configuration. Example:

--- Default configuration for quick-code-runner.nvim
local default_config = {
  debug = false, -- Print debug information
  file_types = {
    javascript = { 'bun run' }, -- Run command for javascript, you can change to `node` or `deno`
    typescript = { 'bun run' }, -- Run command for typescript, you can change to `npx tsx run` or `deno`
    python = {
      'python3 -u', -- Run command for python
    },
    go = {
      "go run",
    },
  },
}

Usage

QuickCodePad

The QuickCodePad is a tool designed for writing and running code snippets swiftly. It opens a floating window, providing a convenient environment for coding and testing.

QuickCodePad

After closing the floating window, run :QuickCodeRunner to execute your code.

This feature is particularly useful when you need a quick, isolated environment for writing and testing code, which you can then run the code by press Enter:

Run code

Running Selected Code

The QuickCodeRunner feature allows you to select a code snippet and run it with ease. You can invoke this feature using the keyboard shortcut <leader>cr.

QuickCodeRunner

[!NOTE] The global code block is always executed first, followed by the selected code.

Limitations

Currently optimized for JavaScript, TypeScript, Go, and Python. May work with other languages, but full compatibility is not guaranteed.

Tips

{
    "<leader>cr",
    "gg0vGg$:QuickCodeRunner<CR>",
    desc = "Quick File Code Runner",
    mode = "n",
}

Contributing

If you wish to support more languages, feel free to open a Pull Request. We appreciate any contributions to expand the capabilities of quick-code-runner.nvim.

Credits

Drawing inspiration from the feature-rich code_runner.nvim, I aim to create a more simple and efficient alternative.

Alternative solutions

While quick-code-runner.nvim offers an efficient and simple way to run code in Neovim, other plugins might cater to different requirements or preferences. Here are a few noteworthy alternatives:

Author

👤 Huynh Duc Dung

Show your support

If this guide has been helpful, please give it a ⭐️.

kofi paypal buymeacoffee