-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
**Title**: Implement Functions to Extract and Handle Code from Markdown in Vim #5
base: master
Are you sure you want to change the base?
Conversation
…wn in Vim **Description**: This PR introduces two new functions to the `chatvim.py` plugin for Vim, enhancing the handling of code blocks within Markdown files. The functions are designed to streamline the process of extracting code from Markdown and managing it within the Vim environment. **Changes**: 1. **ExtractCodeFromMarkdown**: This function extracts code from Markdown code blocks and stores it in a specified Vim register. It toggles the detection of code blocks upon encountering triple backticks (```). The extracted code is then stored in the specified register, or the default register if none is specified. 2. **PasteCodeToNewFile**: After extracting code with the `ExtractCodeFromMarkdown` function, this function facilitates the creation of a new buffer, pastes the code from the specified register, and saves the buffer as `llm_code.py`. This function simplifies the workflow of handling code snippets extracted from Markdown documents, making it easier to save and edit them as standalone Python files. **Usage**: - To extract code from a Markdown file and store it in a register, a user can call `:call ExtractCodeFromMarkdown('a')`, where `'a'` is the register name. - To paste the extracted code into a new file and save it, the user can subsequently call `:call PasteCodeToNewFile('a')`. **Benefits**: - **Efficiency**: Automates the tedious process of manually extracting and saving code blocks from Markdown files. - **Flexibility**: Allows users to specify different registers for different code blocks, facilitating more organized scripting and coding within Vim. - **Integration**: Seamlessly integrates into existing Vim workflows, requiring minimal adjustments to current practices. This enhancement is particularly useful for developers and writers who frequently work with Markdown documents and need an efficient way to manage code snippets embedded within these documents.
@@ -25,6 +25,31 @@ class GPTPlugin: | |||
def __init__(self, nvim): | |||
self.nvim = nvim | |||
|
|||
@pynvim.function("ExtractCodeFromMarkdown", sync=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Can you reply with a joke?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Why do programmers prefer dark mode? Because light attracts bugs! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, can you reply with another! @mentat-butler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Why do Java developers wear glasses? Because they don't see sharp! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tell me another @MentatBot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly! Here's another programming joke for you:
Why do programmers always mix up Halloween and Christmas?
Because Oct 31 == Dec 25! 😄
This joke plays on the fact that in octal (base 8) notation, 31 is equal to 25 in decimal (base 10). It's a bit of a nerdy one, but I hope you find it amusing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad you enjoyed the jokes! Here's one more for you:
Why do programmers prefer iOS development? Because it's a Swift process! 😄
This joke plays on the double meaning of 'Swift' - both as a programming language used for iOS development and as an adjective meaning 'quick' or 'fast'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad you enjoyed the jokes! Here's one more for you:
Why do programmers prefer iOS development? Because it's a Swift process! 😄
This joke plays on the double meaning of 'Swift' - both as a programming language used for iOS development and as an adjective meaning 'quick' or 'fast'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've responded to the request for another joke. The pull request itself looks good and doesn't require any changes at this time.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've provided another programming joke as requested. Regarding the pull request, it looks good as is and doesn't require any changes at this time. The new functions ExtractCodeFromMarkdown
and PasteCodeToNewFile
are well-implemented and will be useful additions to the plugin.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the opportunity to share more jokes! Regarding the pull request, I've reviewed it again and it looks good as is. The new functions ExtractCodeFromMarkdown
and PasteCodeToNewFile
are well-implemented and will be useful additions to the plugin. No further changes are needed at this time.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
Description:
This PR introduces two new functions to the
chatvim.py
plugin for Vim, enhancing the handling of code blocks within Markdown files. The functions are designed to streamline the process of extracting code from Markdown and managing it within the Vim environment.Changes:
ExtractCodeFromMarkdown: This function extracts code from Markdown code blocks and stores it in a specified Vim register. It toggles the detection of code blocks upon encountering triple backticks (```). The extracted code is then stored in the specified register, or the default register if none is specified.
PasteCodeToNewFile: After extracting code with the
ExtractCodeFromMarkdown
function, this function facilitates the creation of a new buffer, pastes the code from the specified register, and saves the buffer asllm_code.py
. This function simplifies the workflow of handling code snippets extracted from Markdown documents, making it easier to save and edit them as standalone Python files.Usage:
:call ExtractCodeFromMarkdown('a')
, where'a'
is the register name.:call PasteCodeToNewFile('a')
.Benefits:
This enhancement is particularly useful for developers and writers who frequently work with Markdown documents and need an efficient way to manage code snippets embedded within these documents.
Closes #4