Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a gist from selection is not working as expected. #15

Open
corei8 opened this issue Jun 19, 2023 · 5 comments
Open

Creating a gist from selection is not working as expected. #15

corei8 opened this issue Jun 19, 2023 · 5 comments
Assignees
Labels
bug Something isn't working cannot reproduce help wanted Extra attention is needed stale The issue has become inactive or has not had recent activity

Comments

@corei8
Copy link

corei8 commented Jun 19, 2023

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.

@rawnly
Copy link
Owner

rawnly commented Jun 19, 2023

Hey thanks for reporting the problem. I cannot replicate it. i see that the private = false setting is ignored, this might be a regression happened when we migrated to the setup() fn. (edit: this was my mistake, didn't updated my config, i usually have private=true by default)

https://gist.github.com/Rawnly/72ce1dfb9a0d2ece2f77f200036dc002

CleanShot 2023-06-19 at 17 29 37

@rawnly rawnly self-assigned this Jun 19, 2023
@rawnly
Copy link
Owner

rawnly commented Jun 19, 2023

This might be a bug in the setup function, i'll investigate further

@rawnly rawnly added bug Something isn't working cannot reproduce labels Jun 19, 2023
@rawnly
Copy link
Owner

rawnly commented Jun 19, 2023

@corei8 i cannot reproduce this issue at all, I tried different configurations and all works as expected

Via the opts key

  {
    "Rawnly/gist.nvim",
    cmd = { "GistCreate", "GistCreateFromFile", "GistsList" },
    opts = {
      clipboard = "+",
      private = false,
    },
  },

Via the config key with the setup fn

  {
    "Rawnly/gist.nvim",
    cmd = { "GistCreate", "GistCreateFromFile", "GistsList" },
    config = function()
      require("gist").setup {
        clipboard = "+",
        private = false,
      }
    end,
  },

Via the config key with table

  {
    "Rawnly/gist.nvim",
    cmd = { "GistCreate", "GistCreateFromFile", "GistsList" },
    config = {
      clipboard = "+",
      private = false,
    },
  },

can you double-check that the plugin is up-to-date and maybe run a Sync in lazy.nvim?

@corei8
Copy link
Author

corei8 commented Jun 19, 2023

@rawnly I can indeed produce the desired result with :GistCreate, but I cannot get the same result when calling the command from which-key.nvim. Perhaps it is a bug in my which-key configuration? I can successfully run the other two commands from which-key, so I am guessing the problem lies with visual mode.

In either case, the option to make the gist private automatically is working, the opposite action (according to the way I think it should work) is not working, i.e. setting private = false does not automatically make the gist public.

I have also noticed a bit of screen tearing after successfully creating a gist with :GistCreate, for example:
image

This screen tearing goes away after a repaint (e.g., toggling NeoTree).

Additionally, I think the following improvements could be made (and I would be willing to create a pull request if I find the time):

  1. Have a configuration option for creating gist.lua automatically, rather than having to select "y" for every gist created. This will save quite a bit of time.
  2. Create a separate window for gists from selection, and have the upload dialog take place in that window.

I can make separate issues for all of these if you wish. This is an very good plugin and I will be making heavy use of it for sure.

@rawnly
Copy link
Owner

rawnly commented Jun 19, 2023

Thanks for your feedback! I like your suggestions. maybe we can deprecate the private=true option and create a new one that defines the default behaviour.

about the repaint, i noticed that too but I'm quite new to neovim plugin development and I didn’t knew if maybe it was something about my config. Maybe a possibile solution could be forcing repaint?

@rawnly rawnly added the stale The issue has become inactive or has not had recent activity label Oct 17, 2023
@rawnly rawnly added the help wanted Extra attention is needed label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cannot reproduce help wanted Extra attention is needed stale The issue has become inactive or has not had recent activity
Projects
None yet
Development

No branches or pull requests

2 participants