wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.87k stars 267 forks source link

goto plugin webpage and browse plugins #1065

Closed mosheavni closed 2 years ago

mosheavni commented 2 years ago

Go to plugin webpage

First feature I'd like to suggest is a keymap or a function that generates a URL for a plugin, and optionally opens it with the browser command based on the OS

  use "neovim/nvim-lspconfig" -- a call to a function should return https://github.com/neovim/nvim-lspconfig and optionally `:!open ` that URL

Something like gx (netrw open shortcut)

Browse plugins

https://github.com/rockerBOO/awesome-neovim This repo is one of the most updated and comprehensive list of nvim plugins, Possibly opening a floating window that lists all of those plugins in the README.md file in the repo, and a cool idea would be to preview the README.md of each plugin in a temporary buffer, or even detect if :MarkdownPreview is installed and maybe previewing the readme in the browser

Thanks!

akinsho commented 2 years ago

So I personally think that whilst this feature is very useful and have something like this setup locally, I think this is out of scope (IMO). There are plugins like https://github.com/axieax/urlview.nvim which already do this, so to my mind there's no reason for packer to take on this additional work/code to maintain when other people are happily already doing it 🤷🏿‍♂️

EdenEast commented 2 years ago

I agree with @akinsho. The maintenance cost of an increasingly hard to maintain plugin is not worth it.

You can use axieax/urlview.nvim or use what I have in my config as a starting point.

configuration ```lua local M = {} local uname = vim.loop.os_uname() M.is_mac = uname.sysname == "Darwin" M.is_linux = uname.sysname == "Linux" M.is_windows = uname.sysname == "Windows_NT" M.is_wsl = not (string.find(uname.release, "microsoft") == nil) M.open_url = function(url) local plat = edn.platform if plat.is_windows then vim.cmd([[:execute 'silent !start ]] .. url .. "'") elseif plat.is_wsl then vim.cmd([[:execute 'silent !powershell.exe start ]] .. url .. "'") elseif plat.is_mac then vim.cmd([[:execute 'silent !open ]] .. url .. "'") elseif plat.is_linux then vim.cmd([[:execute 'silent !xdg-open ]] .. url .. "'") else print("Unknown platform. Cannot open url") end end M.open_url_under_cursor = function() local cword = vim.fn.expand("") -- Remove surronding quotes if exist local url = string.gsub(cword, [[.*['"](.*)['"].*$]], "%1") -- If string starts with https:// if string.match(url, [[^https://.*]]) then return M.open_url(url) end -- If string matches `user/repo` if string.match(url, [[.*/.*]]) then return M.open_url("https://github.com/" .. url) end end return M ```

As for the browse plugins, packer is not the right place for this and is handled better.

mosheavni commented 2 years ago

Thanks.. managed to write something myself. thank you @EdenEast I used your code :)