Skip to content

antonk52/npm_scripts.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm_scripts.nvim

Run npm scripts from the comfort of your favorite editor.

Features:

  • Workspace support
  • Run a script from the current buffer's project(monorepo)
  • Uses vim.ui.select() for a picker which makes it easy to seamlessly integrate with your setup(telescope/fzf or anything else). See opts.select

ezgif-1-6cc93e2db3

Install

" using vim-plug
Plug 'antonk52/npm_scripts.nvim'
-- using packer.nvim
use {'antonk52/npm_scripts.nvim'}

Setup

-- optional
-- call this if you want to override global plugin options
require'npm_scripts'.setup(opts)

API

  • require'npm_scripts'.run_script() to run a script from a root package.json
  • require'npm_scripts'.run_workspace_script() Execute a script in a workspace
  • require'npm_scripts'.run_buffer_script() Find current buffer's closest package.json and executes a script from it
  • require'npm_scripts'.run_from_all() Find all package.json and select a script from a single list of package.json#name: script_name

opts.select

Function. By default set to vim.ui.select. You can provide a custom function with the same signature(see :help vim.ui.select) or use a 3rd party solution like stevearc/dressing.nvim for telescope, fzf, fzf-lua support, or telescope-ui-select.nvim to override global vim.ui.select and have your favorite picker everywhere.

opts.package_manager

String. Pick a package manager to use to run scripts. By default it searches for lock files and pick one of bun, pnpm, yarn or npm. If no lock files found fallbacks to npm.

opts.run_script

Function. Takes a table run_opts with fields script_name, path, and package_manager. It is called after a user selects a script to run. By default opens a terminal in a split and runs the selected script there.

opts.select_script_prompt

String. Default "Select a script to run:"

opts.select_script_format_item

Function. Default tostring

opts.select_workspace_prompt

String. Default "Select a workspace to run a script:"

opts.select_workspace_format_item

Function. Default tostring

opts.workspace_script_solo_picker

Boolean. Default true

Whether to pick a workspace script via a single search or two searches, over workspaces and picked workspace scripts

TODO

  • run any npm scripts
  • overridable optsions for vim.ui.select
  • workspace picker support
  • buffer workspace picker support
  • global options setup
  • local options
  • fzf integration readme example
  • vim docs
  • tmux run_script example
  • quiet option ie run script in background

About

Run npm scripts from your favourite editor

Topics

Resources

Stars

Watchers

Forks

Languages