Skip to content

barspielberg/jsplayground.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JS Playground

A Neovim plugin that provides an interactive JavaScript/TypeScript playground buffer. Perfect for quickly testing snippets of JS/TS code directly inside Neovim.

image

📦 Installation

Install the plugin using your favorite package manager. Here's an example for lazy.nvim:

{
  "barspielberg/jsplayground.nvim",
  cmd = "JSPlayground",
  opts = {},
}

⚙️ Configuration

You can customize the plugin behavior by passing your own options. Below are the default settings:

{
  file_name = "playground.js",  -- The default file name for the playground
  cmd = { "node" },             -- The command used to execute the code
  console = {
    screen_ratio = 0.25,         -- Ratio of the buffer for console output
  },
  marks = {
    inline_prefix = "// ",      -- Prefix for inline marks
  },
}

Optional Configurations

Disable Console

If you prefer not to display a console output:

{
  opts = {
    console = false,
  },
}
Disable Marks

To remove inline marks:

{
  opts = {
    marks = false,
  },
}
TypeScript Support

For TypeScript support, simply adjust the file name and command:

{
  opts = {
    file_name = "playground.ts", 
    cmd = { "npx", "ts-node" },  -- Uses ts-node for TypeScript execution
  },
}

🚀 Usage

To create a new JavaScript/TypeScript playground, run:

:JSPlayground

This command opens a buffer where you can write your code. Once you save the buffer, the code will automatically execute, and the results will be displayed.

To detach the execution listener from the buffer, run the command :JSPlayground again.


📝 TODO List
  • bun support
  • deno support
  • console colors support

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors