rmagatti / gx-extended.nvim Goto Github PK
View Code? Open in Web Editor NEWExtending the use of Neovim's `gx`
Extending the use of Neovim's `gx`
The built-in gx supports navigating to a portion of the text that got selected in visual mode, gx-extended lacks that feature for passing on selected portion of the text extensions, it is currently only capable of sending the extensions the full line.
Eg. for the original gx
if I have a URL in a line:
test url: https://github.com/rmagatti/gx-extended.nvim whatever trailing text
If I place the cursor on the URL and hit gx
it opens the full URL.
If I do a visual selection for only github.com
it will open github.com
Would be cool to allow gx-ing with a visual selection, like performing a google search on it.
Eg. I do a visual selection, then have extensions that are registered as being able to work in visual mode.
Then have a google
extension and a duckduckgo
extension.
When I select text, and hit gx, it would execute only the extensions supporting visual mode, then show me which URL I want to open (like it does in normal mode).
I'm open to contributing this feature as a PR.
Awesome plugin, thanks so much :)
Bug description:
A percent character (%
) breaks URL recognition with this plugin.
Environment:
Windows 10, Neovim 0.9.1, running in nvim-qt 0.2.17.0, plugin installed with lazy.nvim
and up to date, using the configuration suggested in the readme (using netrw open handler).
Expected behavior:
For example if you place your cursor on https://www.duckduckgo.com/?q=site%3Agithub.com+gx-extended&hps=1&ia=web and press gx
, without this plugin installed it opens the correct URL in the browser.
Actual behavior:
With this plugin installed instead it opens https://www.duckduckgo.com/?q=site and if the www.
is missing, it doesn’t open anything.
Besides regex, the original gx-extended plugin allowed for an additional filetype-based filtering, so that the regex matching was only happening in a specific filetype. The filetype detection itself is then handled by vim instead of the plugin.
Only workaround today is defining your own filename pattern, but then you start reimplementing an inferior version of the ftdetect functionality which is already part of vim.
because of this line:
is not matching and not opening. by removing this if, everything works.
Since the merge of #4, when multiple globs should match for a file, it fails to cycle through the multiple matches resulting in a random failure or success open
depending on the order in which the matches were loaded.
Please add a FLOSS license to the repo (eg. MIT, BSD, Apache, whatever).
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
gx-extended.nvim/lua/gx-extended/lib.lua
Line 11 in 6c4bc65
print(vim.fn.expand('%')) -- /home/bennyp/.config/nvim/lua/plugins/ui/gx-extended.lua
print(vim.fn.expand('%:t')) -- gx-extended.lua
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.