Giter Club home page Giter Club logo

neocomposer.nvim's Introduction

๐ŸŽป NeoComposer.nvim

Lua Neovim Contributors

NeoComposer

๐ŸŽต Introduction

NeoComposer is a Neovim plugin that streamlines macro management and execution with a customizable Status Line Component and Telescope Extension.

๐ŸŽน Features

  • View the status of your macros interactively with the status component
  • Browse, search, and manage macros using the Telescope extension
  • Delay playback to ensure proper macro execution
  • Edit macros in an interactive buffer
  • Queue, yank, and delete macros
  • Stop macros during playback

๐Ÿ” Dependencies

๐Ÿฅš Optional Dependencies

๐Ÿ”ญ Telescope

Install the Telescope Extension:

require('telescope').load_extension('macros')

Launch the Telescope extension using the Telescope macros command:

:Telescope macros
Keymap Action
yq Yank the currently selected macro, in human readable format (normal)
<cr> Queue the currently selected macro (insert, normal)
<c-d> Delete the currently selected macro (insert)
d Delete the currently selected macro

๐Ÿšฅ Status Line

NeoComposer provides an easy way to display the recording, playback, and delay status in your status line.

demo

require('NeoComposer.ui').status_recording()

Lualine Config:

lualine_c = {
	{ require('NeoComposer.ui').status_recording },
},

For event-driven statuslines such as heirline, Neocomposer emits User autocmd events to notify the user of status changes.

User Event Trigger Data
NeoComposerRecordingSet When when starting or finishing recording a macro { recording: boolean }
NeoComposerPlayingSet When when starting or finishing playing a macro { playing: boolean }
NeoComposerDelaySet When when delay is set { delay: boolean }
{
  provider = function(self)
    return self.status or ""
  end,
  update = {
    "User",
    pattern = { "NeoComposerRecordingSet", "NeoComposerPlayingSet", "NeoComposerDelaySet" },
    callback = function(self)
      self.status = require("neocomposer.ui").status_recording()
    end
  }
}

๐Ÿข Delay Timer

For complex macros over large counts, you can toggle a delay between macro playback using the ToggleDelay command:

:ToggleDelay

demo

๐Ÿ’ญ Popup Menu

Use the toggle_macro_menu keybind <m-q> to open the interactive popup macro menu.

demo

๐Ÿ” Macro Preview

As you cycle your available macros with the cycle_next: <c-n> and cycle_prev: <c-p> keybinds the queued macro will be previewed in the buffer.

demo

๐Ÿช„ Usage

NeoComposer designates macro number 1 as queued for quick access and execution.

Function Keymap Action
play_macro Q Plays queued macro
stop_macro cq Halts macro playback
toggle_macro_menu <m-q> Toggles popup macro menu
cycle_next <c-n> Cycles available macros forward
cycle_prev <c-p> Cycles available macros backward
toggle_record q Starts recording, press again to end recording
yank_macro yq Yank the currently selected macro, in human readable format into the default register

Edit your macros in a more comprehensive way with the EditMacros command:

:EditMacros

Clear the list of macros with the ClearNeoComposer command:

:ClearNeoComposer

๐Ÿ“ฆ Installation

  1. Install via your favorite package manager.
{
  "ecthelionvi/NeoComposer.nvim",
  dependencies = { "kkharji/sqlite.lua" },
  opts = {}
},
use {
  "ecthelionvi/NeoComposer.nvim",
  requires = { "kkharji/sqlite.lua" }
}
  1. Setup the plugin in your init.lua. Skip this step if you are using lazy.nvim with opts set as above.
require("NeoComposer").setup()

๐Ÿ”ง Configuration

You can pass your config table into the setup() function or opts if you use lazy.nvim.

The available options:

Option Keymap Action
notify true Enable/Disable notifications
delay_timer "150" Time in ms between macro playback when Delay Enabled
status_bg "#16161e" Background color of status line component
preview_fg "#ff9e64" Foreground color of macro preview text
toggle_macro_menu <m-q> Toggles popup macro menu
play_macro Q Play queued macro
yank_macro yq Yank the currently selected macro, in human readable format into the default register
stop_macro cq Halts macro playback
toggle_record q Starts recording, press again to end recording
cycle_next <c-n> Cycles available macros forward
cycle_prev <c-p> Cycles available macros backward

Default Config

local config = {
  notify = true,
  delay_timer = 150,
  queue_most_recent = false,
  window = {
    width = 60,
    height = 10,
    border = "rounded",
    winhl = {
      Normal = "ComposerNormal",
    },
  },
  colors = {
    bg = "#16161e",
    fg = "#ff9e64",
    red = "#ec5f67",
    blue = "#5fb3b3",
    green = "#99c794",
  },
  keymaps = {
    play_macro = "Q",
    yank_macro = "yq",
    stop_macro = "cq",
    toggle_record = "q",
    cycle_next = "<c-n>",
    cycle_prev = "<c-p>",
    toggle_macro_menu = "<m-q>",
  },
}

Made with โค๏ธ in Nebraska

neocomposer.nvim's People

Contributors

b0ae989c avatar ecthelionvi avatar feel-ix-343 avatar konosubakonoakua avatar kritpaoin avatar loqusion avatar lvim-tech avatar willothy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

neocomposer.nvim's Issues

[FEAT REQ] `false` to disable keymap(s)

This way, you can set your own keymaps instead of NeoComposer doing it for you. You can disable keymaps you don't need.

Example:

require("NeoComposer").setup({
  keymaps = {
    play_macro = false,
    yank_macro = false,
    stop_macro = false,
    toggle_record = false,
  },
})

-- OR
require("NeoComposer").setup({
  keymaps = false
})

The most recently recorded macro is not preselected

Hello,

When I stop recording macro, it would be convenient to have a possibility to play it straightaway with the "play_macro" action. However, I noticed that the macro list is appended instead of prepended, so the newest macro ends up as the last one in the list. Is there any option to change this behavior?

Feature Request - Adding Filetype-Specific Macros and Namespaces

Hi,

I really like NeoComposer. It reminds me of a plugin I use in normal Vim named Marvim but which hasn't seen much activity lately.

As they basically serve the same purpose (I still haven't tested Marvim in Neovim), I was wondering if you planned on additional some additional features that it supports that I don't see in NeoComposer such as:

  • filetype-specific macros
  • namespaces to more easily manage macros

Thanks

Executing macros in visual mode broken

Attempting to try out the new execute macro in visual mode and get the following error:

Error  08:15:09 AM msg_show.lua_error E5108: Error executing lua vim/_editor.lua:0: bad argument #1 to 'min' (number expected, got nil)
stack traceback:
	[C]: in function 'min'
	vim/_editor.lua: in function 'region'
	...are/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/macro.lua:136: in function 'get_count'
	...are/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/macro.lua:165: in function 'play_macro'
	...are/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/macro.lua:32: in function 'toggle_play_macro'
	[string ":lua"]:1: in main chunk

"handle already closing", ui.lua:137

This happens when using hydra.nvim - the window management hydra from the wiki more specifically. It may be as simple as calling is_closing to ensure it's not already closing before calling close. Happy to contribute a PR if that would be acceptable, just figured I'd create an issue first.

options on setup are ignored

i'm using lazy.nvim for setup and i'm trying to override a single keymap, however, neither lazy.nvim's opts key nor calling neocomposer's setup in a config function seem to achieve it.

in both cases the plugin seems to already be set up and the setup function does an early return.

Frequent errors - on buffer open and during text editing

I'm not sure what could be causing this, but I get the following error semi-frequently:

Error executing vim.schedule lua callback: ...ack/packer/start/NeoComposer.nvim/lua/NeoComposer/ui.lua:137: handle 0x558caffc4660 is already closing
stack traceback:
        [C]: in function 'close'
        ...ack/packer/start/NeoComposer.nvim/lua/NeoComposer/ui.lua:137: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

The error occurs when opening large files sometimes or while editing text and performing operations. My pc is very low spec - I'm not sure if this is valuable info to mention or not. These errors do not occur when actively using features of the plugin, which seems strange to me.

My plugin config:

require('NeoComposer').setup({
  delay_timer = '200',
  keymaps = {
    toggle_record = 'q',
    play_macro    = 'Q',
    stop_macro    = 'cq',
  },
  colors = {
    bg = 'StatusLine'
  }
})

vim.keymap.set('n', '<leader>eq', ':EditMacros<CR>')
vim.keymap.set('n', '<leader>qq', ':ToggleDelay<CR>')

Error in the docs for lualine setup

Cool plugin. I am trying it out rn.

I noticed that the lualine was not working and realized that the docs have require('NeoComposer.ui').status_recording() while it should be require('NeoComposer.ui').status_recording

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.