Conversation
This commit adds a new logic to the cell pattern determination. It looks up 3 sources of information and sets the cell pattern to the first one that it finds to be not nil: 1. buffer-local overrides using the `vim.b.pyrepl_cell_pattern` variable 2. per-filetype patterns set in the plugin state `ft_cell_pattern` table 3. the global plugin state `cell_pattern` variable, as before This means the user now has two means of overriding the cell state to their liking.
Added simple documentation to the README tips & tricks section, and the vimdoc configuration options table.
|
Thank you for PR! I love simplicity of this change. Before merging, can you clarify use case for buffer local overrides when |
|
I see 2 benefits behind the buffer-local
and, selfishly, 3. because that's how I had it set up in my dotfiles as a local override before adding this feature ;-) If you think this complicates the public API too much I have no issue with taking it out, just lmk. As an aside: I also have two other small features that I would submit separately as a PR at some point (exposing the repl state and toggling the window on/off) but would maybe raise it as an issue first so we can figure out how much you're okay with adding more stuff to the public API. |
|
I want to keep the core of the plugin minimal. I like idea behind this PR, and users should be able to configure cell pattern per filetype. To allow even more scripting potential, maybe we can allow {
cell_pattern = function()
if vim.bo.filetype == "markdown" then return "^```.*" end
return "^# %%%%.*$"
end,
}Do you like that approach? About the second part of your comment: I am fine with creating toggle command and see it usable. But while I see current plugin API stable enough, I want to keep internals away atleast from main |
|
I think that's also a worthwhile alternative approach - not least since it allows the user to re-implement the extra variable I introduced relatively easily in the function itself (by just having it return I like it, and it accomplishes the same thing without adding the extra config option! If you're fine with me taking another stab give me a day or two and I can re-implement and document the new approach. |
|
Of course I am fine with that. Thank you! |
Love the plugin you have created!
One thing that became apparent relatively quickly with my workflow (working sometimes in pure python files, often in a mix of markdown and quarto files) is that a single cell pattern is not enough for me.
I was working with a local buffer override of the cell determination logic in my configuration for a bit, but thought this might be useful for the plugin itself.
This PR does three things:
ft_cell_patternswhich is a table mapping vim filetypes to cell pattern strings.vim.b.pyrepl_cell_patternwhich will be picked up by the plugin.ft_cell_patternsmappings > the global default. That means if nothing is changed previous user configurations work without changes.It also adds some documentation for this logic (though I am not sure how well the explanations are written).
Let me know if this is a feature that you could see implementing into the plugin - I am also happy to change any aspects you think don't make sense or should work differently.