GithubHelp home page GithubHelp logo

piemenu.nvim's Introduction

piemenu.nvim

piemenu.nvim is a circular menu plugin for Neovim (nightly).

Example

vim.opt.mouse = "a"

local group = vim.api.nvim_create_augroup("piemenu_setting", {})
vim.api.nvim_create_autocmd({ "FileType" }, {
  group = group,
  pattern = { "piemenu" },
  callback = function()
    vim.o.mousemoveevent = true
    vim.keymap.set("n", "<MouseMove>", [[<Cmd>lua require("piemenu").highlight()<CR>]], { buffer = true })
    vim.keymap.set("n", "<LeftDrag>", [[<Cmd>lua require("piemenu").highlight()<CR>]], { buffer = true })
    vim.keymap.set("n", "<LeftRelease>", [[<Cmd>lua require("piemenu").finish()<CR>]], { buffer = true })
    vim.keymap.set("n", "<RightMouse>", [[<Cmd>lua require("piemenu").cancel()<CR>]], { buffer = true })
  end,
})

vim.keymap.set("n", "<RightMouse>", [[<LeftMouse><Cmd>lua require("piemenu").start("example")<CR>]])
require("piemenu").register("example", {
  menus = {
    {
      text = "๐Ÿ“‹ copy",
      action = function()
        vim.cmd.normal({ args = { "yy" }, bang = true })
      end,
    },
    {
      text = "๐Ÿ“ paste",
      action = function()
        vim.cmd.normal({ args = { "p" }, bang = true })
      end,
    },
    {
      text = "โœ… save",
      action = function()
        vim.cmd.write()
      end,
    },
    {
      text = "๐Ÿ‘‰ goto file",
      action = function()
        vim.cmd.normal({ args = { "gF" }, bang = true })
      end,
    },
    {
      text = "๐Ÿ“š help",
      action = function()
        vim.cmd.help(vim.fn.expand("<cword>"))
      end,
    },
    {
      text = "โŒ close",
      action = function()
        vim.cmd.quit()
      end,
    },
  },
})

-- start by gesture.nvim (optional)
local piemenu = require("piemenu")
local gesture = require("gesture")
gesture.register({
  name = "open pie menu",
  inputs = { gesture.up() },
  action = function(ctx)
    piemenu.start("gesture_example", { position = ctx.last_position })
  end,
})

piemenu.register("gesture_example", {
  menus = {
    {
      text = "๐Ÿ†• new tab",
      action = function()
        vim.cmd.tabedit()
      end,
    },
    {
      text = "๐Ÿ  open vimrc",
      action = function()
        vim.cmd.edit(vim.env.MYVIMRC)
      end,
    },
    {
      text = "๐Ÿ”ƒ reload",
      action = function()
        vim.cmd.edit({ bang = true })
      end,
    },
    {
      text = "๐Ÿ˜ƒ smile",
      action = function()
        vim.cmd.smile()
      end,
    },
  },
})

piemenu.nvim's People

Contributors

notomo avatar willothy avatar

Watchers

 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.