feat(links): add smart paste feature#191
Merged
YousefHadder merged 9 commits intomainfrom Jan 2, 2026
Merged
Conversation
- Add smart_paste module require - Call smart_paste.setup() in M.setup() - Add <Plug>(MarkdownPlusSmartPaste) keymap with default <leader>mp
Add comprehensive tests for smart_paste helper functions: - _is_url: URL detection (http/https, paths, queries, fragments) - _html_unescape: HTML entity decoding - _parse_title: HTML title extraction (og:title, twitter:title, <title>)
- Add smart paste feature description to vimdoc - Add configuration options to config section - Add <Plug>(MarkdownPlusSmartPaste) to plug mappings - Add smart_paste API documentation - Add curl health check for smart paste feature - Minor stylua formatting in validate.lua
Some sites (like lua.org) use uppercase <TITLE> tags. The title extraction pattern now handles any case combination. Add tests for uppercase and mixed-case title tags.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a smart paste feature to the links module that automatically converts clipboard URLs into markdown links by asynchronously fetching their page titles. The feature is opt-in (disabled by default) and includes comprehensive helper function tests, configuration validation, health checks, and documentation.
Key changes:
- Asynchronous title fetching using
vim.system()with curl and HTML parsing for og:title, twitter:title, and<title>tags - User fallback prompts when title fetch fails, with option to cancel and insert raw URL
- Configuration options for enabling the feature and setting fetch timeout
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
lua/markdown-plus/types.lua |
Adds type definitions for links and smart_paste configuration |
lua/markdown-plus/config/validate.lua |
Adds validation for links.smart_paste config including positive timeout check |
lua/markdown-plus/links/smart_paste.lua |
Core implementation with HTML parsing, async fetching, and placeholder management |
lua/markdown-plus/links/init.lua |
Integrates smart_paste module and sets up keymaps |
lua/markdown-plus/init.lua |
Adds default configuration for smart_paste (disabled by default, 5s timeout) |
lua/markdown-plus/health.lua |
Adds health checks for curl availability and Neovim 0.10+ version requirement |
spec/markdown-plus/links_spec.lua |
Adds comprehensive unit tests for helper functions (_is_url, _html_unescape, _parse_title) |
doc/markdown-plus.txt |
Documents smart paste feature, configuration, usage, and requirements |
- Add buffer modifiability check before initial placeholder insertion - Add buffer modifiability check in cancel path of prompt_for_title - Handle URLs with special characters (parentheses, spaces) by wrapping in angle brackets per markdown spec - Add url_needs_brackets and format_url_for_markdown helper functions - Add 13 new tests for URL formatting helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a "smart paste" feature to the links module that automatically converts clipboard URLs into markdown links with fetched page titles.
vim.system()(no UI freeze)links.smart_paste.enabledoption (disabled by default, opt-in)<Plug>(MarkdownPlusSmartPaste)mapping (default:<leader>mp)How it works
<leader>mpin a markdown buffer[⏳ Loading...](url)appears immediately[Page Title](url)Configuration
Requirements
curlmust be installedvim.system()async API)Health check (
:checkhealth markdown-plus) verifies these requirements when smart paste is enabled.Changes
links.smart_pasteconfig types and validationlua/markdown-plus/links/smart_paste.luamodule<Plug>(MarkdownPlusSmartPaste)keymapTest plan
make check- all tests passCloses #190