-
Notifications
You must be signed in to change notification settings - Fork 49
feature: allow using in git COMMIT_EDITMSG files #141
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
Comments
I can get this plugin to work in |
Thank you, I'm glad you're liking it :) That's a neat idea, I largely write markdown for my own commit messages and don't know why I didn't think to figure this out. It's pretty straightforward, just requires 2 changes and is the same process as adding
Since we're not modifying the file type to accomplish this it should avoid starting any I ended up making this change for my own config: MeanderingProgrammer/dotfiles@680bc0a A couple of other minor things to consider:
Note In case you're wondering why are there 2 identical lists?
Since sharing information between a plugin and plugin manager is in no way standardized there's not really a way to have it only defined in one place, other than using a local variable in your config of course. |
In case you want to set different configuration values for commit files I pushed a change to allow overrides based on filetype here: 952b1c0. So to disable headings in opts = {
...
overrides = {
filetype = {
gitcommit = { heading = { enabled = false } },
},
},
} |
Wow this solution is incredible! Huge thanks. In my image you can see the full diff at the bottom - it's there for github copilot to get some context when suggesting what to write in the commit message. I never read it and don't really care if it's not highlighted 🙂 |
Sweet, no problem :) I looked at your change and removing the heading isn't strictly necessary, though likely a good idea if you use the default
Then re-enable headings. Huh, I've not seen the putting the diff in the commit approach before, make sense. Depending on how that diff gets there if you have any control over it, surrounding it with a code block using the diff language will make it look nicer:
Assuming you have the diff parser installed. |
I didn't know I'm sure the diff highlighting could be made to work with a I might look into this later, I should learn a bit more about how the parsers work. |
I got a version of this that's almost perfect, however doesn't support the custom Instead of parsing the entire commit as markdown using: Then install the gitcommit parser: Finally extending the
This will use the parser to highlight the main commit message, comments and diff with The Even with a custom |
Wow this solution is amazing! For now I think I can work around the limitations of I think this is a really cool feature. Have you thought about including it in the plugin? |
Do you mean adding details about enabling the plugin for commit messages or support for the alternate markdown heading syntax? |
I mean, is it possible to simplify the setup for using render-markdown.nvim in gitcommit buffers, and make it a more "batteries included" experience within render-markdown.nvim for example? To be honest, I don't know if plugins can add treesitter injections. I feel like this is one of those "it's clearly better to have this" features, and got a bit excited. 😄 |
Ah, gotcha. I'll look into it and see. Similarly I have no idea if a plugin can define injections programatically. Worst case I'll add some documentation, best case I can add some default injections based on filetype and allow users to opt out and define their own. |
## Details Discussed here: #141 When using this plugin with multiple filetypes it would be nice if the tree-sitter injection logic could be offloaded from the user and be handled by the plugin. Especially when the way markdown would be injected is likely to be the same for anyone that wants the plugin to work within the filetype. Turns out this is fairly straightforward using the vim.treesitter.query.set API, and specifying the injections query name. The only slight complication is that in order to be able to extend the existing injections (instead of overwriting them) we need a way to get the current injection query as a string. The only way I found to do that is to pull the files associated with injections then read and append them together. All other ways to get the query return different kinds of objects that would need to be serialized back into a string. I have made this part of the configuration users can modify with the top level `injections` field. Currently a value is only specified for the gitcommit filetype. Injections are only processed if this plugin is meant to run on that filetype, meaning additional configurations can be added without impacting users who do not use this plugin on multiple file types. Users are free to: - modify the queries used - disable the injection, by setting enabled to false - add entirely new queries that are coupled to this plugin rather than needing to live in their global queries configuration
I've implemented a batteries included approach here: 5ff9a59 Takes care of setting injections using With this you can remove the Since this does happen as part of the plugin's configuration lazy loading the plugin could cause problems in that the injection will be added after the buffer loads. So if it doesn't work I would suggest disabling lazy loading and giving that a try. Thanks for the suggestion, I personally like it as well! |
I can confirm it works nicely. 👍🏻 No issues with lazy loading have come up either. |
Useful for the integration discussed in MeanderingProgrammer/render-markdown.nvim#141
Is your feature request related to a problem? Please describe.
Thanks for this awesome plugin! I use it through lazyvim.
I often write my git commit messages in neovim, and fenced code blocks would look nice if they were rendered by this plugin.
Is this possible to configure? I don't have much experience with this.
Describe the solution you'd like
Can we provide some example configuration on how to set this up? I would be fine with maintaining this myself if you would like to keep it out of the plugin repo.
Describe alternatives you've considered
Could also enable this by default, maybe with a config option
Additional information
No response
The text was updated successfully, but these errors were encountered: