diff --git a/README.md b/README.md index f27ad00..0517239 100644 --- a/README.md +++ b/README.md @@ -7,25 +7,27 @@ It provides the convenience of automatically detecting and highlighting all URLs are using macos or windows and you have any problem with this plugin, please open an issue or create a pull request to fix it -- [Features](#features) -- [Installation](#installation) -- [Configuration](#configuration) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) +- 🚀 [Features](#features) +- 👀 [Installation](#installation) +- 💻 [Configuration](#configuration) +- 😆 [Usage](#usage) +- 😁 [Contributing](#contributing) +- ✌️ [License](#license) ## Features -- Automatically detect and highlight all URLs within the text content and +- 🎨 Automatically detect and highlight all URLs within the text content and provide visual cues when hovering over clickable URLs. -- Open the URLs under the cursor, including the Markdown link (e.g. `https://github.com/sontungexpt/url-open`). -- Open the GitHub page for the Neovim plugin mentioned under the cursor +- 🛠️ Allow for opening URLs from anywhere on a line, as long as the line contains only one URL. + If one line has multiple URLs, the first URLs in the right side of cursor will be opened. +- 🎉 Open the URLs under the cursor, including the Markdown link (e.g. `https://github.com/sontungexpt/url-open`). +- ✈️ 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",`). +- 🍨 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. -- Provide an optional deep pattern matching feature, +- 🚀 Provide an optional deep pattern matching feature, which can be enabled, to accurately identify and handle various URL formats, such as: - http://example.com - https://www.example.com @@ -38,13 +40,9 @@ open an issue or create a pull request to fix it - http://example.com:8080 - https://www.example.com:8443 - ftp://ftp.example.com:2121 -- Allow for opening URLs from anywhere on a line, as long as the line contains only one URL. - If one line has multiple URLs, the first URLs in the right side of cursor will be opened. ## Preview -- Highlight url which can be opened then you can open it by `:OpenUrlUnderCursor` - ![highlight-url](./docs/readme/preview1.png) ![highlight-all-url](./docs/readme/preview2.png) @@ -60,7 +58,7 @@ https://github.com/sontungexpt/url-open/assets/92097639/c51b3e1c-8eae-48f0-a542- { "sontungexpt/url-open", event = "VeryLazy" - cmd = "OpenUrlUnderCursor", + cmd = "URLOpenUnderCursor", config = function() local status_ok, url_open = pcall(require, "url-open") if not status_ok then @@ -80,7 +78,7 @@ https://github.com/sontungexpt/url-open/assets/92097639/c51b3e1c-8eae-48f0-a542- "sontungexpt/url-open", branch = "mini", event = "VeryLazy" - cmd = "OpenUrlUnderCursor", + cmd = "URLOpenUnderCursor", config = function() local status_ok, url_open = pcall(require, "url-open") if not status_ok then @@ -130,7 +128,9 @@ require("url_open").setup({ -- suffix = "" -- file_patterns = { "package%.json" }, -- support for only specific file match with pattern -- excluded_file_patterns = {}, -- exclude file match with pattern - -- extra_condition = function() return true end, -- need to return boolean + -- 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, -- }, -- Ex: ['["]([^%s]*)["]:'] = "https://www.npmjs.com/package/", @@ -153,16 +153,18 @@ require("url_open").setup({ ## Usage -- This plugin provide a command `:OpenUrlUnderCursor` to open url under cursor +| **Command** | **Description** | +| --------------------------- | ----------------------------------------- | +| `:URLOpenUnderCursor` | Open url under cursor | +| `:URLOpenHighlightAll` | Highlight all url in current buffer | +| `:URLOpenHighlightAllClear` | Clear all highlight url in current buffer | - This plugin will not map any key by default, you can map it by yourself ```lua -vim.keymap.set("n", "gx", ":OpenUrlUnderCursor") +vim.keymap.set("n", "gx", ":URLOpenUnderCursor") ``` -- You can also use command `:HighlightAllUrls` to highlight all urls in the buffer manually - ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. diff --git a/docs/index.html b/docs/index.html index ac21a5f..5ad5509 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,6 +36,7 @@

Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -70,6 +71,10 @@

    Modules

    url-open.modules.handlers Handlers for opening urls + + url-open.modules.highlight + The module for working with the highlight effects. + url-open.modules.logger This module provides a simple wrapper around vim.notify to make it easier to @@ -95,7 +100,7 @@

    Topics

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.html b/docs/modules/url-open.html index e3a5562..90c8701 100644 --- a/docs/modules/url-open.html +++ b/docs/modules/url-open.html @@ -43,6 +43,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -114,7 +115,7 @@

    Usage:

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.modules.autocmd.html b/docs/modules/url-open.modules.autocmd.html index af9d881..2cbad8f 100644 --- a/docs/modules/url-open.modules.autocmd.html +++ b/docs/modules/url-open.modules.autocmd.html @@ -43,6 +43,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -94,23 +95,19 @@

    Parameters:

    -

    Returns:

    -
      - - nil - - - -

    See also:

    +

    Usage:

    +
      +
      require("url-open.modules.autocmd").setup(opts)
      +
    @@ -120,7 +117,7 @@

    See also:

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.modules.commands.html b/docs/modules/url-open.modules.commands.html index 9056421..42cda23 100644 --- a/docs/modules/url-open.modules.commands.html +++ b/docs/modules/url-open.modules.commands.html @@ -43,6 +43,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -67,7 +68,7 @@

    Functions

    - +
    setup (user_opts)Setup the OpenUrlUnderCursor command and HighlightAllUrls command.Setup the OpenUrlUnderCursor command and URLOpenHighlightAlls command.
    @@ -83,7 +84,7 @@

    Functions

    setup (user_opts)
    - Setup the OpenUrlUnderCursor command and HighlightAllUrls command. + Setup the OpenUrlUnderCursor command and URLOpenHighlightAlls command.

    Parameters:

    @@ -99,8 +100,8 @@

    Parameters:

    See also:

    Usage:

    @@ -116,7 +117,7 @@

    Usage:

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.modules.handlers.html b/docs/modules/url-open.modules.handlers.html index cd0ca18..6bd00ac 100644 --- a/docs/modules/url-open.modules.handlers.html +++ b/docs/modules/url-open.modules.handlers.html @@ -43,6 +43,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -70,28 +71,20 @@

    Functions

    Call a vim command - change_color_highlight (opts, group_name) - Change the color of the highlight + check_condition_pattern (pattern_found, condition) + Check if the pattern found matches the condition check_file_patterns (file_patterns, is_excluded) Check if the file path matches any of the patterns - delete_url_effect (group_name) - Delete the syntax matching rules for URLs/URIs if set. - - - find_first_url_in_text (user_opts, text, start_pos) - Find the first url in the text + find_first_url_in_line (user_opts, text, start_pos) + Find the first url in the line find_first_url_matching_patterns (text, patterns, start_pos, found_url_smaller_pos) - Check if the text contains any of the patterns - - - highlight_cursor_url (user_opts) - Highlight the url under the cursor + Find the first url in the text that matches any of the patterns open_url (user_opts) @@ -99,8 +92,12 @@

    Functions

    If there is only one url in the line, then open it anywhere in the line. - set_url_effect (user_opts) - Add syntax matching rules for highlighting URLs/URIs. + open_url_with_app (apps, url) + Open the url with the specified app + + + system_open_url (user_opts, url) + Open the url relying on the operating system @@ -137,41 +134,36 @@

    Parameters:

    - - change_color_highlight (opts, group_name) + + check_condition_pattern (pattern_found, condition)
    - Change the color of the highlight + Check if the pattern found matches the condition

    Parameters:

      -
    • opts - table - : The user options -
    • -
    • group_name +
    • pattern_found string - : The name of the highlight group + : The url to check +
    • +
    • condition + function or boolean + : The condition to check (function(pattern_found))

    Returns:

      - nil - - - + boolean + : True if the pattern found matches the condition, otherwise false

    See also:

    @@ -208,33 +200,11 @@

    Returns:

    - - delete_url_effect (group_name) + + find_first_url_in_line (user_opts, text, start_pos)
    - Delete the syntax matching rules for URLs/URIs if set. - - -

    Parameters:

    -
      -
    • group_name - - - -
    • -
    - - - - - -
    -
    - - find_first_url_in_text (user_opts, text, start_pos) -
    -
    - Find the first url in the text + Find the first url in the line

    Parameters:

    @@ -263,7 +233,9 @@

    Returns:

    See also:

    @@ -273,7 +245,7 @@

    See also:

    find_first_url_matching_patterns (text, patterns, start_pos, found_url_smaller_pos)
    - Check if the text contains any of the patterns + Find the first url in the text that matches any of the patterns

    Parameters:

    @@ -306,11 +278,12 @@

    See also:

    - - highlight_cursor_url (user_opts) + + open_url (user_opts)
    - Highlight the url under the cursor + Open the url under the cursor + If there is only one url in the line, then open it anywhere in the line.

    Parameters:

    @@ -325,47 +298,59 @@

    Parameters:

    See also:

    - - open_url (user_opts) + + open_url_with_app (apps, url)
    - Open the url under the cursor - If there is only one url in the line, then open it anywhere in the line. + Open the url with the specified app

    Parameters:

      -
    • user_opts +
    • apps table - : User options + : The table of apps to open the url +
    • +
    • url + string + : The url to open
    +

    See also:

    +
    - - set_url_effect (user_opts) + + system_open_url (user_opts, url)
    - Add syntax matching rules for highlighting URLs/URIs. + Open the url relying on the operating system

    Parameters:

    • user_opts - - - + table + : User options +
    • +
    • url + string + : The url to open
    @@ -373,7 +358,7 @@

    Parameters:

    See also:

    @@ -385,7 +370,7 @@

    See also:

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.modules.highlight.html b/docs/modules/url-open.modules.highlight.html new file mode 100644 index 0000000..0e9619f --- /dev/null +++ b/docs/modules/url-open.modules.highlight.html @@ -0,0 +1,216 @@ + + + + + url-open + + + + +
    + +
    + +
    +
    +
    + + +
    + + + + + + +
    + +

    Module url-open.modules.highlight

    +

    The module for working with the highlight effects.

    +

    + +

    + + +

    Functions

    + + + + + + + + + + + + + + + + + +
    change_color_highlight (opts, group_name)Change the color of the highlight
    delete_url_effect (group_name)Delete the syntax matching rules for URLs/URIs if set.
    highlight_cursor_url (user_opts)Highlight the url under the cursor
    set_url_effect (user_opts)Add syntax matching rules for highlighting URLs/URIs.
    + +
    +
    + + +

    Functions

    + +
    +
    + + change_color_highlight (opts, group_name) +
    +
    + Change the color of the highlight + + +

    Parameters:

    +
      +
    • opts + table + : The user options +
    • +
    • group_name + string + : The name of the highlight group +
    • +
    + + + +

    See also:

    + + + +
    +
    + + delete_url_effect (group_name) +
    +
    + Delete the syntax matching rules for URLs/URIs if set. + + +

    Parameters:

    +
      +
    • group_name + + + +
    • +
    + + + + + +
    +
    + + highlight_cursor_url (user_opts) +
    +
    + Highlight the url under the cursor + + +

    Parameters:

    +
      +
    • user_opts + table + : User options +
    • +
    + + + +

    See also:

    + + + +
    +
    + + set_url_effect (user_opts) +
    +
    + Add syntax matching rules for highlighting URLs/URIs. + + +

    Parameters:

    +
      +
    • user_opts + + + +
    • +
    + + + +

    See also:

    + + + +
    +
    + + +
    +
    +
    +generated by LDoc 1.5.0 +Last updated 2023-09-23 12:16:00 +
    +
    + + + diff --git a/docs/modules/url-open.modules.logger.html b/docs/modules/url-open.modules.logger.html index 3332b3d..94aafe2 100644 --- a/docs/modules/url-open.modules.logger.html +++ b/docs/modules/url-open.modules.logger.html @@ -43,6 +43,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -171,7 +172,7 @@

    Parameters:

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.modules.options.html b/docs/modules/url-open.modules.options.html index 8b98e05..0653299 100644 --- a/docs/modules/url-open.modules.options.html +++ b/docs/modules/url-open.modules.options.html @@ -44,6 +44,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -115,8 +116,8 @@

    Returns:

    See also:

    @@ -191,7 +192,7 @@

    Fields:

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/modules/url-open.modules.patterns.html b/docs/modules/url-open.modules.patterns.html index 519779b..152e7a5 100644 --- a/docs/modules/url-open.modules.patterns.html +++ b/docs/modules/url-open.modules.patterns.html @@ -33,6 +33,7 @@

    url-open

    Contents

    @@ -43,6 +44,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -63,6 +65,13 @@

    Module url-open.modules.patterns

    +

    Tables

    + + + + + +
    PATTERNSDefault Patterns to match urls.

    Fields

    @@ -75,6 +84,116 @@

    Fields


    +

    Tables

    + +
    +
    + + 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 + + +

    Fields:

    +
      +
    • suffix + + + +
    • +
    • file_patterns + + + +
    • +
    + + + + + +
    +

    Fields

    @@ -84,43 +203,19 @@

    Fields

    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 -
      -
    • http: - //example.com:8080 -
    • -
    • https: - //www.example.com:8443 -
    • -
    • ftp: - //ftp.example.com:2121 -
    • -
    • file: - ///path/to/file.txt -
    • -
    • ssh: - //user@hostname -
    • -
    • git: - //github.com/user/repo -
    • -
    • http: - //example.com:8080 -
    • -
    • https: - //www.example.com:8443 -
    • -
    • http: - //example.com:8080 -
    • -
    • https: - //www.example.com:8443 -
    • -
    • ftp: - //ftp.example.com:2121 -
    • -
    @@ -134,7 +229,7 @@

    Fields

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/docs/topics/README.md.html b/docs/topics/README.md.html index cf3dd25..5cbf3e5 100644 --- a/docs/topics/README.md.html +++ b/docs/topics/README.md.html @@ -43,6 +43,7 @@

    Modules

  • url-open.modules.autocmd
  • url-open.modules.commands
  • url-open.modules.handlers
  • +
  • url-open.modules.highlight
  • url-open.modules.logger
  • url-open.modules.options
  • url-open.modules.patterns
  • @@ -55,20 +56,20 @@

    Modules

    Introduction

    -

    This plugin allow you to open url under cursor in neovim without netrw with -default browser of your system.

    +

    This plugin enables you to effortlessly open the URL under the cursor in Neovim, bypassing the need for netrw, and instead utilizing the default browser of your system. +It provides the convenience of automatically detecting and highlighting all URLs within the text content.

    -

    NOTE: Since I am the linux user so i only test this plugin on linux, if you +

    NOTE: Since I am the linux user so i only test this plugin on linux, if you are using macos or windows and you have any problem with this plugin, please open an issue or create a pull request to fix it

    @@ -78,12 +79,17 @@

    Introduction

    Features

      -
    • Highlight all urls in the buffer and highlight url that can be opened when cursor move over it
    • -
    • Open the url under cursor include markdown link (e.g. https://github.com/sontungexpt/url-open)
    • -
    • Open the github page of neovim plugin name under cursor (e.g. Plug 'nvim-lua/plenary.nvim', "sontungexpt/url-open")
    • -
    • Open the npm package in package.json (e.g. "lodash": "^4.17.21",)
    • -
    • Support brew formula, and cask
    • -
    • Support deep pattern (disabled by default) to match with url below
    • +
    • 🎨 Automatically detect and highlight all URLs within the text content and + provide visual cues when hovering over clickable URLs.
    • +
    • 🛠️ Allow for opening URLs from anywhere on a line, as long as the line contains only one URL. + If one line has multiple URLs, the first URLs in the right side of cursor will be opened.
    • +
    • 🎉 Open the URLs under the cursor, including the Markdown link (e.g. https://github.com/sontungexpt/url-open).
    • +
    • ✈️ 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.
    • +
    • 🚀 Provide an optional deep pattern matching feature, + which can be enabled, to accurately identify and handle various URL formats, such as:
    • http://example.com
    • https://www.example.com
    • ftp://ftp.example.com
    • @@ -95,15 +101,10 @@

      Features

    • http://example.com:8080
    • https://www.example.com:8443
    • ftp://ftp.example.com:2121
    • -
    • Allow you to open url from anywhere in the line if it only contains 1 url

    Preview

    -
      -
    • Highlight url which can be opened then you can open it by :OpenUrlUnderCursor
    • -
    -

    highlight-url

    highlight-all-url

    @@ -120,7 +121,7 @@

    Installation

    { "sontungexpt/url-open", event = "VeryLazy" - cmd = "OpenUrlUnderCursor", + cmd = "URLOpenUnderCursor", config = function() local status_ok, url_open = pcall(require, "url-open") if not status_ok then @@ -144,7 +145,7 @@

    Installation

    "sontungexpt/url-open", branch = "mini", event = "VeryLazy" - cmd = "OpenUrlUnderCursor", + cmd = "URLOpenUnderCursor", config = function() local status_ok, url_open = pcall(require, "url-open") if not status_ok then @@ -164,13 +165,13 @@

    Configuration

     -- default values
     require("url_open").setup({
    -    -- if true, only open url when cursor in the middle of url
    -    -- if false, open next url found from cursor position it means you can open
    -    -- url even when the cursor is in front of url or in the middle of url
    -    open_app = "default",
         -- default will open url with default browser of your system or you can choose your browser like this
         -- open_app = "micorsoft-edge-stable",
         -- google-chrome, firefox, micorsoft-edge-stable, opera, brave, vivaldi
    +    open_app = "default",
    +    -- If true, only open the URL when the cursor is in the middle of the URL.
    +    -- If false, open the next URL found from the cursor position,
    +    -- which means you can open a URL even when the cursor is in front of the URL or in the middle of the URL.
         open_only_when_cursor_on_url = false,
         highlight_url = {
             all_urls = {
    @@ -196,7 +197,9 @@ 

    Configuration

    -- suffix = "" -- file_patterns = { "package%.json" }, -- support for only specific file match with pattern -- excluded_file_patterns = {}, -- exclude file match with pattern - -- extra_condition = function() return true end, -- need to return boolean + -- 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, -- }, -- Ex: ['["]([^%s]*)["]:'] = "https://www.npmjs.com/package/", @@ -220,21 +223,22 @@

    Configuration

    Usage

    +

    | Command | Description | +| --------------------------- | ----------------------------------------- | +| :URLOpenUnderCursor | Open url under cursor | +| :URLOpenHighlightAll | Highlight all url in current buffer | +| :URLOpenHighlightAllClear | Clear all highlight url in current buffer |

    +
      -
    • This plugin provide a command :OpenUrlUnderCursor to open url under cursor

    • -
    • This plugin will not map any key by default, you can map it by yourself

    • +
    • This plugin will not map any key by default, you can map it by yourself
    -vim.keymap.set("n", "gx", "<esc>:OpenUrlUnderCursor<cr>")
    +vim.keymap.set("n", "gx", "<esc>:URLOpenUnderCursor<cr>")
     
    -
      -
    • You can also use command :HighlightAllUrls to highlight all urls in the buffer manually
    • -
    -

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    @@ -248,7 +252,7 @@

    License

    generated by LDoc 1.5.0 -Last updated 2023-09-22 09:34:57 +Last updated 2023-09-23 12:16:00
    diff --git a/lua/url-open/modules/commands.lua b/lua/url-open/modules/commands.lua index 30b3ef7..5884eb0 100644 --- a/lua/url-open/modules/commands.lua +++ b/lua/url-open/modules/commands.lua @@ -10,8 +10,8 @@ local highlight = require("url-open.modules.highlight") --- Setup the OpenUrlUnderCursor command and URLOpenHighlightAlls command. --- @tparam table user_opts : User options. --- @see url-open.modules.handlers.open_url ---- @see url-open.modules.handlers.set_url_effect ---- @see url-open.modules.handlers.change_color_highlight +--- @see url-open.modules.highlight.set_url_effect +--- @see url-open.modules.highlight.change_color_highlight --- @usage require("url-open.modules.commands").setup(opts) M.setup = function(user_opts) new_cmd("OpenUrlUnderCursor", function() diff --git a/lua/url-open/modules/highlight.lua b/lua/url-open/modules/highlight.lua index cd46f36..ccd3c5f 100644 --- a/lua/url-open/modules/highlight.lua +++ b/lua/url-open/modules/highlight.lua @@ -1,3 +1,5 @@ +--- The module for working with the highlight effects. +-- local M = {} local api = vim.api diff --git a/lua/url-open/modules/patterns.lua b/lua/url-open/modules/patterns.lua index 5647950..cbe5ff9 100644 --- a/lua/url-open/modules/patterns.lua +++ b/lua/url-open/modules/patterns.lua @@ -107,20 +107,20 @@ M.PATTERNS = { extra_condition = function(pattern_found) return pattern_found ~= "version" and pattern_found ~= "proxy" end, - }, --- npm package + }, -- npm package ["[\"']([^%s~/]*/[^%s~/]*)[\"']"] = { prefix = "https://github.com/", suffix = "", excluded_file_patterns = { "package%.json", "package%-lock%.json" }, - }, --- plugin name git + }, -- plugin name git ['brew ["]([^%s]*)["]'] = { prefix = "https://formulae.brew.sh/formula/", suffix = "", - }, --- brew formula + }, -- brew formula ['cask ["]([^%s]*)["]'] = { prefix = "https://formulae.brew.sh/cask/", suffix = "", - }, --- cask formula + }, -- cask formula ["^%s*([%w_]+)%s*="] = { prefix = "https://crates.io/crates/", suffix = "", @@ -139,7 +139,7 @@ M.PATTERNS = { "keywords", }, pattern_found) end, - }, --- cargo package + }, -- cargo package } return M