rmagatti / gx-extended.nvim

Extending the use of Neovim's `gx`
MIT License
31 stars 3 forks source link

match on dir, not just pattern #3

Closed bennypowers closed 1 year ago

bennypowers commented 1 year ago

consider this config:

return { 'rmagatti/gx-extended.nvim',
  keys = { 'gx' },
  opts = {
    extensions = {
      patterns = { '*/plugins/**/*.lua' },
      match_to_url = function(line_string)
        local line = string.match(line_string, "[\"|'].*/.*[\"|']")
        local repo = vim.split(line, ':')[1]:gsub('"', '')
        local url = 'https://github.com/' .. repo

        if not line or not repo then
          return nil
        end

        return url
      end,
    }
  }
}

given that https://github.com/rmagatti/gx-extended.nvim/blob/6c4bc65e770fc51a1ffe598cab1d4304f60f3182/lua/gx-extended/lib.lua#L11

print(vim.fn.expand('%')) -- /home/bennyp/.config/nvim/lua/plugins/ui/gx-extended.lua
print(vim.fn.expand('%:t')) -- gx-extended.lua