Code Monkey home page Code Monkey logo

chuck-nvim's Introduction

chuck-nvim

A Neovim plugin for ChucK offering granular control and a WebChucK-like layout built with NUI.

An example session recorded with asciinema. For some reason colors were not recorded. The UI looks like this

chuck-nvim

Temporary features

Installation

To use chuck-nvim, you need to have:

  • Neovim 0.9.5 or up.
  • The tail command in your path.
  • ChucK installed on your system.

Installing ChucK

To download and install ChucK, visit the official ChucK release page. For more information, including documentation, examples, research publications, and community resources, visit the ChucK homepage.

Homebrew

brew install chuck

Installing chuck-nvim

{
  "gacallea/chuck-nvim",
  version = "*",
  dependencies = {
    { "MunifTanjim/nui.nvim" },
    { -- until https://github.com/gacallea/chuck-nvim/issues/3
      "nvim-tree/nvim-web-devicons",
      opts = {
        override_by_extension = {
          ["ck"] = {
            icon = "󰧚",
            color = "#80ff00",
            name = "ChucK",
          },
        },
      },
    },
  },
  ft = { "chuck" },
  opts = {}, -- see configuration
  cmd = {
    "ChuckLoop",
    "ChuckStatus",
    "ChuckTime",
    "ChuckAddShred",
    "ChuckRemoveShreds",
    "ChuckReplaceShred",
    "ChuckClearShreds",
    "ChuckClearVM",
    "ChuckExit",
  },
  keys = {}, -- see key mappings
}

Configuration

chuck-nvim options to configure this plugin, and a subset of ChucK VM's command-line options.

-- default values:
opts = {
  autorun = false,
  layout = "webchuck", -- or "chuck_on_top"
  chuck_vm = {
    log_level = 1,
    srate = 44100,
    bufsize = 512,
    dac = 0,
    adc = 0,
    channels = 2,
    input = 2,
    output = 2,
    remote = "127.0.0.1",
    port = 8888,
  },
},

Usage

chuck-nvim provides the following functions to interact with the ChucK VM.

ChuckLoop

Starts ChucK in loop mode with chuck --loop using the configuration values.

Tip

You can enable autorun to launch ChucK and the UI automatically.

ChuckStatus

Prints current time and active shreds status in the ChucK VM.

ChuckTime

Prints the ChucK VM's full time information in the ChucK VM.

ChuckAddShred

Adds the current saved buffer to the ChucK VM, as an active shred.

Note

You must save file changes beforehand.

ChuckRemoveShreds

Prompts the user for shred(s) number(s), then removes them from ChucK.

Tip

To remove more than one shred, enter the numbers separated by spaces.

ChuckReplaceShred

Prompts the user for a shred number, then replaces it with the current buffer.

ChuckClearShreds

Removes all active shreds.

ChuckClearVM

Removes all active shreds and resets the type system.

ChuckExit

Cleanly exits the VM, cleans out logs, and quits ChucK.

Key mappings

chuck-nvim doesn't set any key mappings by default. Below, an example configuration for LazyVim.

Warning

Make sure these don't conflict with existing mappings.

Tip

You could map the commands to function keys to speed up operations.

return {
  {
    "folke/which-key.nvim",
    opts = {
      defaults = {
        ["<leader>C"] = { name = "+chuck" },
      },
    },
  },
  {
    "gacallea/chuck-nvim",
    version = "*",
    dependencies = {
      { "MunifTanjim/nui.nvim" },
      { -- until https://github.com/gacallea/chuck-nvim/issues/3
        "nvim-tree/nvim-web-devicons",
        opts = {
          override_by_extension = {
            ["ck"] = {
              icon = "󰧚",
              color = "#80ff00",
              name = "ChucK",
            },
          },
        },
      },
    },
    ft = { "chuck" },
    opts = {},
    cmd = {
      "ChuckLoop",
      "ChuckStatus",
      "ChuckTime",
      "ChuckAddShred",
      "ChuckRemoveShreds",
      "ChuckReplaceShred",
      "ChuckClearShreds",
      "ChuckClearVM",
      "ChuckExit",
    },
    keys = {
      { mode = "n", "<leader>Cl", "<cmd>ChuckLoop<cr>", desc = "Chuck Loop" },
      { mode = "n", "<leader>Cs", "<cmd>ChuckStatus<cr>", desc = "Chuck Status" },
      { mode = "n", "<leader>Ct", "<cmd>ChuckTime<cr>", desc = "Chuck Time" },
      { mode = "n", "<leader>Ca", "<cmd>ChuckAddShred<cr>", desc = "Add Shred" },
      { mode = "n", "<leader>Cd", "<cmd>ChuckRemoveShreds<cr>", desc = "Remove Shred(s)" },
      { mode = "n", "<leader>Cr", "<cmd>ChuckReplaceShred<cr>", desc = "Replace Shred" },
      { mode = "n", "<leader>Cc", "<cmd>ChuckClearShreds<cr>", desc = "Clear Shreds" },
      { mode = "n", "<leader>Cv", "<cmd>ChuckClearVM<cr>", desc = "Clear VM" },
      { mode = "n", "<leader>Ce", "<cmd>ChuckExit<cr>", desc = "Exit ChucK" },
    },
  },
}

License

The code of this repository is licensed under the GPLv2 for compatibility with ChucK licensing.

chuck-nvim's People

Contributors

gacallea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.