This Neovim plugin enhances code sharing by allowing the easy copying of lines along with their file paths, line numbers, and repository URLs. By including essential metadata, it supports clearer communication, especially when collaborating with AI tools and improving coding efficiency.
The copy_with_context.nvim plugin enables developers to copy code snippets with contextual metadata, including file paths, line numbers, and direct repository URLs. This functionality enhances the clarity and utility of shared code snippets, making it easier to understand the specific context where the code resides within a project.
Using this plugin transforms code sharing as illustrated below:
Without Context:
Here's my login function:
def authenticate(user)
validate_credentials(user)
end
How do I add OAuth?
With Context (using this plugin):
Here's my login function:
def authenticate(user)
validate_credentials(user)
end
# app/controllers/auth_controller.rb:45-47
# https://github.com/user/repo/blob/abc123/app/controllers/auth_controller.rb#L45-L47
How do I add OAuth?
The inclusion of line numbers and file paths allows for precise communication and aids AI tools in providing tailored guidance based on the specific codebase structure.
The plugin allows users to copy lines in different contexts, utilizing customizable key mappings for various purposes:
Customization is straightforward with options to define mappings and formats:
require('copy_with_context').setup({
mappings = {
relative = '<leader>cy',
absolute = '<leader>cY',
remote = '<leader>cr',
},
formats = {
default = '# {filepath}:{line}',
remote = '# {remote_url}',
},
trim_lines = false,
})
The plugin automatically generates links to your code snippets hosted on platforms like GitHub, GitLab, and Bitbucket, ensuring that your shared code always has the correct permalink for reference.
With copy_with_context.nvim, enhancing the quality of shared code snippets becomes efficient and effective, allowing developers to focus on coding rather than context gathering.
No comments yet.
Sign in to be the first to comment.