hanschen / vim-ipython-cell

Seamlessly run Python code in IPython from Vim
GNU General Public License v3.0
335 stars 18 forks source link

Disabling cell highlighting for Markdown headings #24

Closed gerazov closed 3 years ago

gerazov commented 3 years ago

The cell highlighter messes with markdown headings due to the ### cell type. This could be regulated by limiting cell recognition to Python files, but since the plugin can be used for other programming languages it makes sense to limit it to not highlight markdown.

This can be done in the init.vim so maybe it can be noted in the documentation:

  autocmd FileType markdown,mkd,md let g:ipython_cell_highlight_cells = 0

Or maybe it could be built in by default in the plugin?

hanschen commented 3 years ago

Good point. In general I let the user decide when to load the plugin, but in this instance I can see the default behavior being annoying if the plugin is enabled for all filetypes, which is not good.

I tried different methods but haven't found a satisfactory solution yet that works for e.g. different splits with different filetypes. And for some strange reason I can't reproduce the issue anymore. I'll look into it more tomorrow.

hanschen commented 3 years ago

I've implemented a solution that works for me so far, please report back if you encounter any issues. After this change, cell headers are highlighted in only python files by default.

gerazov commented 3 years ago

Yeah it works! :sunglasses:

I was thinking that maybe it's better just to turn it off for markdown, as other programming languages can benefit from this plugin as well :wink:

hanschen commented 3 years ago

:+1:

I considered your suggestion but it wasn't that straightforward, as e.g. the autocmd in your first post would turn it off for all buffers, so if you open a Markdown file first and a Python file afterwards the highlighting would still be disabled for the Python file.

Ultimately I don't want to annoy people with unexpected behavior because they've installed this plugin, so it felt safer to only enable it for Python files by default.

gerazov commented 3 years ago

Ah ok :+1: I'm not really proficient in Vim script :slightly_smiling_face:

But I think your plugin can be of more general use for other languages (as you mention Julia for example), so it's something to keep in mind :wink:

hanschen commented 3 years ago

Ah ok :+1: I'm not really proficient in Vim script :slightly_smiling_face:

Me neither, it took some time of trial and error to get right. :sweat_smile:

But I think your plugin can be of more general use for other languages (as you mention Julia for example), so it's something to keep in mind :wink:

Yes, that's possible by changing the g:ipython_cell_highlight_cells_ft variable. Currently the match format is fixed, I may make it configurable if somebody opens an issue about it (not sure how e.g. Julia users would write cells for example).