gitlinker.nvim icon indicating copy to clipboard operation
gitlinker.nvim copied to clipboard

set `mappings = nil` could not disable the kemaps

Open meijieru opened this issue 3 years ago • 14 comments

Describe the bug As the title, here overrides the mappings.

Here is my config

  require("gitlinker").setup {
    callbacks = {
      ["direct.meijieru.com"] = function(url_data)
        url_data.host = "gitea.meijieru.com"
        return require("gitlinker.hosts").get_gitea_type_url(url_data)
      end,
    },
    mappings = nil,
  }

meijieru avatar Jan 09 '22 21:01 meijieru

Looks like resolving this would result in a breaking API change. If nil is fixed, we would have to remove the default mapping (which may or may not be desirable).

https://github.com/ruifm/gitlinker.nvim/blob/d28028ba21e8be2d9f290ba69eb08f96a31fa769/lua/gitlinker/mappings.lua#L20

ajitid avatar Feb 10 '22 18:02 ajitid

Maybe as a command and let the user map them.

meijieru avatar Feb 12 '22 22:02 meijieru

Or use mappings as false to remove mappings but nil (which equates to not defining a mapping through options) to use the default one?

Edit: This is something many plugins do, here's Telescope as an example:

image

ajitid avatar Feb 16 '22 14:02 ajitid

Or use mappings as false to remove mappings but nil (which equates to not defining a mapping through options) to use the default one?

Sounds like the best option.

I think it was a mistake to auto define mappings. I did it to improve the out-of-the-box experience but now I don't think it's such a good idea and whatever is done will definitely break the API :cry:

ruifm avatar Feb 16 '22 16:02 ruifm

whatever is done will definitely break the API

Kind of. If nil wasn't working for them, and nobody cared to raise an issue about it, it means people rarely considered nullifying gitlinker mappings. So not a huge user base would be affected.

Would you mind taking a PR for this issue?


Unrelated. but in one of the issue I became aware that one cannot give a range through command prompt as the plugin doesn't relies on < and > marks. Was this intended or should I create an issue?

ajitid avatar Feb 17 '22 02:02 ajitid

Submit #77, use "" (empty string) to disable default mappings.

linrongbin16 avatar Feb 18 '23 13:02 linrongbin16

Hi @meijieru , @ajitid , I have fixed this issue in my fork with PR: https://github.com/linrongbin16/gitlinker.nvim/pull/1 Feel free to use it.

linrongbin16 avatar Feb 19 '23 08:02 linrongbin16

I've already forked and am using a different method to suppress mappings. Thanks for mentioning it anyway!

ajitid avatar Feb 19 '23 08:02 ajitid

Cool, I have also fixed another issue #75 (open browser in windows). I use cmd /C start {url}. this method is copied from: https://github.com/axieax/urlview.nvim/blob/main/lua/urlview/actions.lua#L38.

linrongbin16 avatar Feb 19 '23 08:02 linrongbin16

So what's the status for this? Noticed that I still had the default mappings even though I set mappings = nil

ArchitBhonsle avatar Jun 15 '23 03:06 ArchitBhonsle

Hi all, I have make my own fork: https://github.com/linrongbin16/gitlinker.nvim.

It fixed this issue, and also support Windows, and refactored a lot of things, I believe it's much better.

linrongbin16 avatar Jun 15 '23 06:06 linrongbin16