Giter Site home page Giter Site logo

gist.nvim's Introduction

gist.nvim

Showcase

gist.nvim is a Neovim plugin that allows you to create a GitHub Gist from the current file. The plugin uses the gh command-line tool to create the Gist and provides a simple interface for specifying the Gist's description and privacy settings.

Installation

To use gist.nvim, you need to have Neovim installed on your system. You also need to have the gh command-line tool installed and configured with your GitHub account.

If you intend to use the GistsList command to list and edit all your gists, I suggest the nvim-unception plugin.

Once you have Neovim and gh installed, you can install gist.nvim using your favorite plugin manager.

Using lazy.nvim:

return {
  {
    "Rawnly/gist.nvim",
    cmd = { "GistCreate", "GistCreateFromFile", "GistsList" },
    config = true
  },
  -- `GistsList` opens the selected gif in a terminal buffer,
  -- nvim-unception uses neovim remote rpc functionality to open the gist in an actual buffer
  -- and prevents neovim buffer inception
  {
    "samjwill/nvim-unception",
    lazy = false,
    init = function() vim.g.unception_block_while_host_edits = true end
  }
}
use {
  "rawnly/gist.nvim",
  config = function() require("gist").setup() end,
  -- `GistsList` opens the selected gif in a terminal buffer,
  -- this plugin uses neovim remote rpc functionality to open the gist in an actual buffer and not have buffer inception
  requires = { "samjwill/nvim-unception", setup = function() vim.g.unception_block_while_host_edits = true end }
}

Usage

To create a Gist from the current file, use the :GistCreate command in Neovim. The plugin will prompt you for a description and whether the Gist should be private or public.

  :GistCreate [description] [public=true]
  • :GistCreate will create the gist from the current selection
  • :GistCreateFromFile will create the gist from the current file

Both the commands accept the same options which are [description=] and [public=true]

If you don't pass the description it will prompt to insert one later. If you pass [public=true] it won't prompt for privacy later.

After you enter the description and privacy settings, the plugin ask for confirmation and will create the Gist using the gh command-line tool and copy the Gist's URL to the given clipboard registry.

You can also list your gists and edit their files on the fly.

    :GistsList
  • :GistsList will list all your gists and after you select one it will open a buffer to edit it

Configuration

gist.nvim provides a few configuration options that you can with the setup function:

    require("gist").setup({
        private = false, -- All gists will be private, you won't be prompted again
        clipboard = "+", -- The registry to use for copying the Gist URL
        list = {
            -- If there are multiple files in a gist you can scroll them,
            -- with vim-like bindings n/p next previous
            mappings = {
                next_file = "<C-n>",
                prev_file = "<C-p>"
            }
        }
    })

License

gist.nvim is released under MIT License. See LICENSE for details.

Contributing

If you find a bug or would like to contribute to gist.nvim, please open an issue or a pull request. All contributions are welcome and appreciated!

gist.nvim's People

Contributors

aspeddro avatar lnc3l0t avatar rawnly avatar rezaarezvan 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

gist.nvim's Issues

Creating a gist from selection is not working as expected.

This is my configuration, using lazy.nvim:

  {
    "Rawnly/gist.nvim",
    cmd = { "GistCreate", "GistCreateFromFile", "GistsList" },
    config = function ()
      require("gist").setup({
        private = false, -- All gists will be private, you won't be prompted again
        clipboard = "+", -- The registry to use for copying the Gist URL
        list = {
          mappings = {
            next_file = "<C-n>",
            prev_file = "<C-p>"
          }
        }
      })
    end,
    requires = {
      "samjwill/nvim-unception",
      lazy = true,
      event = "VeryLazy",
      init = function() vim.g.unception_block_while_host_edits = true end
    },
  },

And I use which-key to bind the commands to some keybindings:

g = {
  name = "  Git",
  i = {
    name = "  Gist",
    s = {"<cmd>GistCreate<cr>", "Gist from Selection", mode="v"},
    f = {"<cmd>GistCreateFromFile<cr>", "Gist from File", mode="n"},
    l = {"<cmd>GistsList<cr>", "Gist List", mode="n"},
  },
},

I am having two issues right now:

  1. The first is that I cannot make a gist from selection, only as the entire file.
  2. I cannot make the gist be persistently public, despite private = false in the configuration.

This make the plugin more of a burden now, since I only want to create public gists, and I never (or rarely) want to save the entire file as a gist.

Add a config option

It might be preferred by the community to have a .setup() method over the global variables.
This seem to be a more common approach to the configuration and also more centralised.

So instead of

return { 
  {
    "Rawnly/gist.nvim",
    cmd = { "CreateGist", "CreateGistFromFile", "ListGists" },
    init = function()
      vim.g.gist_is_private = false -- All gists will be private, you won't be prompted again
      vim.g.gist_clipboard = "+" -- The registry to use for copying the Gist URL
    end,
  },
}

it would be

return { 
  {
    "Rawnly/gist.nvim",
    cmd = { "CreateGist", "CreateGistFromFile", "ListGists" },
    opts = {
      is_private = false, -- All gists will be private, you won't be prompted again
      clipboard = "+" -- The registry to use for copying the Gist URL
    },
  },
}

Error when creating gist

Hey love the idea of this plugin, but when i create a gist for standalone python files, these error happens.

image

image

After the first error happens, my nvim ui gets messed up too. In both cases, the gists are created correctly.

Interestingly, this doesn't happen for python files (or other files) that are within a github repo, not sure if this is correlated.

Support creation from selection

It would be nice to be able to create the gist from current user selection
I'm new to plugin development so it could take some time to achieve this

If anyone is interested in helping with this, PRs are super welcome!

I still don't know if we should keep 1 single command and use selection if available or create a separate command to create from the current file.

Better commands name

I think prefixing the plugin "name" is better than suffixing it.

Let's have the commands become:

  • CreateGist -> GistCreate
  • CreateGistFromFile -> GistFromFile
  • ListGists -> GistsList

I think the commands may be more easily remembered

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.