Coder Social home page Coder Social logo

nvim-macros's Introduction

nvim-macros ๐Ÿ“

nvim-macros is your go-to Neovim plugin for supercharging your macro game! ๐Ÿš€ It's all about making macro management in Neovim a breeze. Say goodbye to the fuss and hello to efficiency! This plugin lets you save, yank, and run your macros like a pro, and even handles those pesky special characters with ease.

Why You'll Love nvim-macros ๐Ÿ˜

  • Yank Macros ๐ŸŽฃ: Grab macros from any register and set them up for action in your default register with just a command.
  • Save Macros ๐Ÿ’พ: Stash your precious macros in a JSON file. Save them with all the fancy termcodes and the raw version - ready when you need them!
  • Select & Yank ๐Ÿ“‹: Pick a macro from your saved collection and yank it into a register, ready for its moment in the spotlight.
  • Smart Encoding/Decoding ๐Ÿค“: nvim-macros speaks Base64 fluently, so it effortlessly handles macros with special characters.
  • Your Storage, Your Rules ๐Ÿ—‚๏ธ: Point nvim-macros to your chosen JSON file for macro storage. It's your macro library, after all!
  • Pretty Printing ๐ŸŽจ: Choose your JSON formatter (jq or yq) to keep your JSON file looking sharp. No more squinting at a jumbled mess of macros!
  • Backup & Restore ๐Ÿ“ฆ: Made a mess editing the JSON file? No worries! nvim-macros keeps a backup of your JSON file, so you can always restore your macros to their former glory auto-magically!

Getting Started ๐Ÿš€

Time to get nvim-macros into your Neovim setup! If you're rolling with lazy.nvim, just pop this line into your plugin configuration:

{
  "kr40/nvim-macros",
  cmd = {"MacroSave", "MacroYank", "MacroSelect", "MacroDelete"},
  opts = {
  
    json_file_path = vim.fs.normalize(vim.fn.stdpath("config") .. "/macros.json"), -- Location where the macros will be stored
    default_macro_register = "q", -- Use as default register for :MacroYank and :MacroSave and :MacroSelect Raw functions
    json_formatter = "none", -- can be "none" | "jq" | "yq" used to pretty print the json file (jq or yq must be installed!)
    
  }
}

How to Use ๐Ÿ› ๏ธ

Once you've got nvim-macros installed, Neovim is your macro playground! ๐ŸŽ‰

  • :MacroYank [register]: Yanks a macro from a register. If you don't specify, it'll politely ask you to choose one.
  • :MacroSave [register]: Saves a macro into the book of legends (aka your JSON file). It'll prompt for a register if you're feeling indecisive.
  • :MacroSelect: Brings up your macro menu. Pick one, and it'll be ready for action.
  • :MacroDelete: Summon a list of your macros, then select one to permanently vanish it from your collection, as if it never existed.

Example ๐ŸŒŸ

Imagine you've got a nifty macro recorded in the q register that magically turns the current line into a to-do list item. After recording it, just summon :MacroYank q to yank the macro. Then, you can elegantly bind it to a key sequence in your Neovim setup like this:

vim.keymap.set('n', '<Leader>t', '^i-<Space>[<Space>]<Space><Esc>', { remap = true })

๐Ÿ“ Note: We highly recommend setting remap = true to ensure your macro runs as smoothly as if you were performing a magic trick yourself!

Making It Yours ๐ŸŽจ

nvim-macros loves to fit in just right. Set up your custom options like so:

require('nvim-macros').setup({
    json_file_path = "/your/very/own/path/to/macros.json",
    default_macro_register = "a",
    json_formatter = "jq",
})

Fine with the defaults? No worries! nvim-macros will go with the flow and use the defaults no need to call setup or opts.

Join the Party ๐ŸŽ‰

Got ideas? Found a bug? Jump in and contribute! Whether it's a pull request or a hearty discussion in the issues, your input is what makes the nvim-macros party rock.

To-Do ๐Ÿ“

nvim-macros is on a quest to make your Neovim experience even more magical! Here are some enchantments we're looking to add:

  • Macro Editing: Forge a way to edit your macros directly within Neovim. This will involve summoning a macro from the JSON grimoire into a buffer, weaving your edits, and then sealing the updated macro back into the tome.

  • Macro Tags/Categories: Introduce the mystic arts of tagging and categorizing your macros. This will allow you to filter and search through your macros based on their assigned tags or categories, managing your macro arsenal with unparalleled ease.

  • Macro Sharing/Importing: Develop an incantation to export and import macros, empowering you to share your macros with fellow sorcerers or swiftly set up your macro sanctum on a new system.

  • Macro Analytics: Offer a crystal ball to gaze into your macro usage, revealing insights such as the frequency of use, helping you to understand your workflow and refine your arsenal of macros.

Feel free to jump in and contribute if you're drawn to any of these upcoming features or if you have your own ideas to sprinkle some extra magic into nvim-macros! ๐ŸŒŸ

Inspiration ๐ŸŒฑ

nvim-macros didn't just spring out of thin air; it's been nurtured by some awesome ideas and projects in the Neovim community. Here's a shoutout to the sparks that ignited this project:

  • nvim-macroni by Jesse Leite: Jesse's enlightening talk and his brilliantly simple plugin sowed the seeds for nvim-macros. It's all about taking those little steps towards macro mastery!
  • cd-project.nvim by LintaoAmons: The innovative use of a JSON file for data storage in this project opened up new pathways for how nvim-macros could manage and store macro magic efficiently.

Big thanks to the creators and contributors of these projects! ๐Ÿ™

nvim-macros's People

Contributors

kr40 avatar

Stargazers

Jonathan Lee Komar avatar  avatar Minjae Kim avatar Fernando avatar Giuseppe Masino avatar  avatar  avatar today avatar Erik Volz avatar Jasper avatar Peter Babiฤ avatar  avatar  avatar Philipp Reimer avatar  avatar  avatar  avatar woshizilong avatar  avatar Chaz avatar  avatar Marcin Dziewulski avatar Erich Gubler avatar  avatar Ibrahim Kettaneh avatar Eddy Ekofo avatar Jonny Gamba avatar Nicholas B avatar Vaso Putica avatar Emille Henry avatar  avatar  avatar  avatar Onam Hernandez avatar xiantang avatar kohane27 avatar Taichi Watanabe avatar Yuta Katayama avatar  avatar Dylan Premo avatar  avatar Hecdin Farias avatar Adelar da Silva Queirรณz avatar Lucas Forato avatar  avatar

Watchers

Adelar da Silva Queirรณz avatar  avatar  avatar

nvim-macros's Issues

"Raw" not explained

The README states for the "Save Macros" feature: "Stash your precious macros in a JSON file. Choose to save with all the fancy termcodes or keep it raw - your call!" This is never explained further.

It seems to me from what I have seen of the macros.json file format that both versions of the macro are automatically saved.

If there is some unexplained functionality relating to raw format vs termcodes format, perhaps the README could be updated to include it? If the current README is inaccurate, perhaps it can be corrected?

Option to pass full options non-interactive

Hi, and thanks for this plugin, that is exactly what I had in mind and looking for
I want to keybind Selection process to just fuzzy find and apply the macro i select. But the selection process is interactive, i want to pass options RAW and q register as input. Also would like to apply @q right after selecting my macro. Is there to keybind all of that to one keybind. Or change options to it activate like that?

Macro not saved

Problem:

  • Installed as per instructions with default options.
  • Created macro on q
  • Ran command MacroSave q, entered macro name at prompt, got message saying "Macro NAME saved."
  • But no write to actual macro file.

Troubleshooting:

  • Created empty macros.json in case it needs to exist first -- no effect
  • Experimented with macro name formats, e.g., no spaces, all lowercase -- no effect

System:

  • linux debian/testing 6.6.13-1 (2024-01-20)
  • tmux 3.3a
  • alacritty 0.12.2
  • NVIM v0.9.5, Build type: Release, LuaJIT 2.1.1692716794

Love the concept of your plugin. Really hope it works for me some day.

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.