diff --git a/README.md b/README.md
index b4af949..4f4897f 100644
--- a/README.md
+++ b/README.md
@@ -122,32 +122,33 @@ require("url_open").setup({
},
},
deep_pattern = false,
+ -- a list of patterns to open url under cursor
extra_patterns = {
- -- [pattern] = prefix: string only or nil
- -- [pattern] = {
- -- prefix = "",
- -- suffix = ""
- -- file_patterns = { "package%.json" }, -- support for only specific file match with pattern
- -- excluded_file_patterns = {}, -- exclude file match with pattern
- -- extra_condition = function(pattern_found) -- the function will be called when pattern found and return boolean
- -- return pattern_found ~= "version" and pattern_found ~= "proxy"
- -- end,
+ -- {
+ -- pattern = '["]([^%s]*)["]:%s*"[^"]*%d[%d%.]*"',
+ -- prefix = "https://www.npmjs.com/package/",
+ -- suffix = "",
+ -- file_patterns = { "package%.json" },
+ -- excluded_file_patterns = nil,
+ -- extra_condition = function(pattern_found)
+ -- return not vim.tbl_contains({ "version", "proxy" }, pattern_found)
+ -- end,
-- },
-
- -- Ex: ['["]([^%s]*)["]:'] = "https://www.npmjs.com/package/",
-- so the url will be https://www.npmjs.com/package/[pattern_found]
- --
- -- Ex: ['["]([^%s]*)["]:'] = {prefix = "https://www.npmjs.com/package/", suffix = "/issues"},
- -- so the url will be https://www.npmjs.com/package/[pattern_found]/issues
- -- E.g:
- -- ['["]([^%s]*)["]:%s*"[^"]*%d[%d%.]*"'] = {
- -- prefix = "https://www.npmjs.com/package/",
- -- suffix = "",
- -- file_patterns = { "package%.json" },
- -- excluded_file_patterns = {},
- -- extra_condition = function() return true end, -- need to return boolean
+
+ -- {
+ -- pattern = '["]([^%s]*)["]:%s*"[^"]*%d[%d%.]*"',
+ -- prefix = "https://www.npmjs.com/package/",
+ -- suffix = "/issues",
+ -- file_patterns = { "package%.json" },
+ -- excluded_file_patterns = nil,
+ -- extra_condition = function(pattern_found)
+ -- return not vim.tbl_contains({ "version", "proxy" }, pattern_found)
+ -- end,
-- },
+ --
+ -- so the url will be https://www.npmjs.com/package/[pattern_found]/issues
},
})
```
diff --git a/docs/index.html b/docs/index.html
index 5ad5509..91b5159 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -100,7 +100,7 @@
Topics
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.html b/docs/modules/url-open.html
index 90c8701..04ce977 100644
--- a/docs/modules/url-open.html
+++ b/docs/modules/url-open.html
@@ -115,7 +115,7 @@ Usage:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.autocmd.html b/docs/modules/url-open.modules.autocmd.html
index 2cbad8f..b511c4b 100644
--- a/docs/modules/url-open.modules.autocmd.html
+++ b/docs/modules/url-open.modules.autocmd.html
@@ -117,7 +117,7 @@ Usage:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.commands.html b/docs/modules/url-open.modules.commands.html
index 42cda23..626a904 100644
--- a/docs/modules/url-open.modules.commands.html
+++ b/docs/modules/url-open.modules.commands.html
@@ -117,7 +117,7 @@ Usage:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.handlers.html b/docs/modules/url-open.modules.handlers.html
index 6bd00ac..3bb37b0 100644
--- a/docs/modules/url-open.modules.handlers.html
+++ b/docs/modules/url-open.modules.handlers.html
@@ -370,7 +370,7 @@ See also:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.highlight.html b/docs/modules/url-open.modules.highlight.html
index 0e9619f..e9d1ba6 100644
--- a/docs/modules/url-open.modules.highlight.html
+++ b/docs/modules/url-open.modules.highlight.html
@@ -201,7 +201,7 @@ See also:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.logger.html b/docs/modules/url-open.modules.logger.html
index 94aafe2..18510b9 100644
--- a/docs/modules/url-open.modules.logger.html
+++ b/docs/modules/url-open.modules.logger.html
@@ -172,7 +172,7 @@ Parameters:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.options.html b/docs/modules/url-open.modules.options.html
index 0653299..ec6e014 100644
--- a/docs/modules/url-open.modules.options.html
+++ b/docs/modules/url-open.modules.options.html
@@ -192,7 +192,7 @@ Fields:
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/modules/url-open.modules.patterns.html b/docs/modules/url-open.modules.patterns.html
index 152e7a5..7ef2293 100644
--- a/docs/modules/url-open.modules.patterns.html
+++ b/docs/modules/url-open.modules.patterns.html
@@ -69,14 +69,14 @@
PATTERNS |
- Default Patterns to match urls. |
+ Default patterns to match urls |
DEEP_PATTERN |
- Deep Pattern to match urls from text. |
+ Deep Pattern to match URLs from text. |
@@ -92,99 +92,34 @@
PATTERNS
- Default Patterns to match urls.
-
- Http(s) URL pattern
- Matches URLs starting with "http://" or "https://"
- Example: "http://example.com", "https://www.example.com"
- Pattern: "(https?://[%w-%.]+%.%w[%w-%.%%%?%.:/+=&%%[%]#<>]*)"
- Prefix: ""
- Suffix: ""
- Filepatterns: All files
- Extracondition: None
- Excludedfilepatterns: None
- Note: This pattern is used to match urls in all files
-
-
- Npm Package pattern
- Matches npm package names
- Example: "react", "react-dom"
- Pattern: '"["]:%s"[^"]%d[%d%.]*"'
- Prefix: "https://www.npmjs.com/package/"
- Suffix: ""
- Filepatterns: "package%.json"
- Extracondition: patternfound ~= "version" and patternfound ~= "proxy"
- Excludedfilepatterns: None
- Note: This pattern is used to match npm packages in package.json files
-
- Git Plugin pattern
- Matches git plugin names
- Example: "airblade/vim-gitgutter", "tpope/vim-fugitive"
- Pattern: "\"'[\"']"
- Prefix: "https://github.com/"
- Suffix: ""
- Filepatterns: All files except package.json and package-lock.json
- Extracondition: None
- Excludedfilepatterns: "package%.json", "package%-lock%.json"
- Note: This pattern is used to match git plugins in all files except package.json and package-lock.json
-
-
- Brew Formula pattern
- Matches brew formula names
- Example: "bat", "exa"
- Pattern: 'brew "["]'
- Prefix: "https://formulae.brew.sh/formula/"
- Suffix: ""
- Filepatterns: All files
- Extracondition: None
- Excludedfilepatterns: None
- Note: This pattern is used to match brew formulas in all files
-
- Cask Formula pattern
- Matches cask formula names
- Example: "firefox", "google-chrome"
- Pattern: 'cask "["]'
- Prefix: "https://formulae.brew.sh/cask/"
- Suffix: ""
- Filepatterns: All files
- Extracondition: None
- Excludedfilepatterns: None
- Note: This pattern is used to match cask formulas in all files
-
- Cargo Package pattern
- Matches cargo package names
- Example: "serde", "serdejson"
- Pattern: "^%s*([%w]+)%s*="
- Prefix: "https://crates.io/crates/"
- Suffix: ""
- Filepatterns: "Cargo%.toml"
- Extracondition: not vim.tblcontains({
- "name",
- "version",
- "edition",
- "authors",
- "description",
- "license",
- "repository",
- "homepage",
- "documentation",
- "keywords",
- }, patternfound)
- Excludedfilepatterns: None
- Note: This pattern is used to match cargo packages in Cargo.toml files
+ Default patterns to match urls
Fields:
+ - pattern
+ string
+ : Pattern to match urls (required)
+
+ - prefix
+ string or nil
+ : Prefix to add to the url
+
- suffix
-
-
-
+ string or nil
+ : Suffix to add to the url
- file_patterns
-
-
-
+ table, string or nil
+ : File patterns to match against
+
+ - excluded_file_patterns
+ table, string or nil
+ : File patterns to exclude
+
+ - extra_condition
+ function(pattern_found), boolean or nil
+ : A callback function will be called with the pattern found as argument. If the function returns false, the pattern will be ignored. If the function returns true, the pattern will be used.
@@ -202,18 +137,24 @@
DEEP_PATTERN
- Deep Pattern to match urls from text. This pattern will find urls in the following formats:
- http://example.com
- https://www.example.com
- ftp://ftp.example.com
- file:///path/to/file.txt
- ssh://user@hostname
- git://github.com/user/repo
- http://example.com/path?param=value
- https://www.example.com/another/path#section
- http://example.com:8080
- https://www.example.com:8443
- ftp://ftp.example.com:2121
+
+Deep Pattern to match URLs from text. This pattern will find URLs in various formats.
+ Supported URL formats:
+
+
+ - http://example.com
+ - https://www.example.com
+ - ftp://ftp.example.com
+ - file:///path/to/file.txt
+ - ssh://user@hostname
+ - git://github.com/user/repo
+ - http://example.com/path?param=value
+ - https://www.example.com/another/path#section
+ - http://example.com:8080
+ - https://www.example.com:8443
+ - ftp://ftp.example.com:2121
+
+
@@ -229,7 +170,7 @@
generated by LDoc 1.5.0
-
Last updated 2023-09-23 12:16:00
+
Last updated 2023-09-23 15:22:04
diff --git a/docs/topics/README.md.html b/docs/topics/README.md.html
index 5cbf3e5..daece0f 100644
--- a/docs/topics/README.md.html
+++ b/docs/topics/README.md.html
@@ -87,7 +87,8 @@ Features
✈️ Open the GitHub page for the Neovim plugin mentioned under the cursor
(e.g. Plug 'nvim-lua/plenary.nvim'
, "sontungexpt/url-open").
🍨 Easily open the npm package specified in the package.json file. (e.g. "lodash": "^4.17.21",
).
- Extend support for recognized formats, including brew formulas and casks.
+ 🍻 Open the Homebrew formula or cask specified in the Brewfile.
+ 🍕 Open the cargo package specified in the Cargo.toml file.
🚀 Provide an optional deep pattern matching feature,
which can be enabled, to accurately identify and handle various URL formats, such as:
http://example.com
@@ -190,32 +191,33 @@ Configuration
},
},
deep_pattern = false,
- extra_patterns = {
-