luk400 / vim-jukit

Jupyter-Notebook inspired Neovim/Vim Plugin
MIT License
602 stars 23 forks source link

jukit_comment_mark seems not work #40

Closed Mickychen00 closed 1 year ago

Mickychen00 commented 1 year ago

Hi, I want to set the cell title with prefix "#%% ", such as "#%% Example title". So I set jukit_comment_oark variable in a jukit_conf.vim and source it in init.vim: let g:jukit_comment_mark = '#%%' or let g:jukit_comment_mark = '#%% ' (with a space) The above two settings are both not work. Is there any wrong with me?

luk400 commented 1 year ago

I think you have the wrong understanding what g:jukit_comment_mark is doing. If you mean that you don't want to highlight the cell markers using signs and just want to display them as "#%%", then that's not possible, because the cell markers also contain the cell id's which are needed to assign saved outputs to specific cells.

The variable g:jukit_comment_mark really only exists in case you don't use this plugin with python and want to specify a different comment character other than "#" for commenting out the cell markers (e.g. "--" in lua)

Mickychen00 commented 1 year ago

Hi, maybe I understand your explanation. In my work, I just want to use "#%% Some title" to split the py file as several cells. And use the nnoremap :call jukit#send#section(0) to run current cell. Whether the command nnoremap co :call jukit#cells#create_below(0) is the prerequisite command before the nnoremap :call jukit#send#section(0)

When I use firstly, the whole py code will be executed, despite I set several "#%%" cells myself.

luk400 commented 1 year ago

Yeah that does not work, you can not use "#%%" to separate cells. You can not specify your own cell markers. You need to use the designated cell functions to create/split cells

DeadlySquad13 commented 1 year ago

Yeah that does not work, you can not use "#%%" to separate cells. You can not specify your own cell markers. You need to use the designated cell functions to create/split cells

Hi, thanks for your plugin! Is it possible to change cell marker to start with # %% or make it configurable via settings? I suppose it won't look like a useful setting at first but actually it has a lot of use-cases and your plugin will win more people.

As for me, I can't render images on my terminal so I use jupytext and jupyter-ascending. They're cool for visualization-heavy works but require web browser with jupyter notebook always opened. On the other side, your plugin allows to stay entirely in neovim when I want to play with data and calculations: any terminal is enough for that, everything is easily accessible via vim keybindings and there're also a lot of useful commands for managing cells provided by you! However, I can't combine workflow of two plugins, I get something like this when I try to use your functions: image Well, it's expected: plugins use different cell delimiter formats...

Please, consider my words as I'm sure there will be a lot folks who will try to use your plugin with another existing tools. To understand what I mean just look at jupytext notes about format. It seems there're different formats out there and I think a day won't pass without someone creating their own new format : D. Though, # %% seems to be the most popular.

I have tested and it seems to work just fine with # %% id_or_some_other_metadata_you_need_for_your_plugin.

luk400 commented 1 year ago

I have tested and it seems to work just fine with # %% id_or_some_other_metadata_you_need_for_your_plugin

hi, thanks for the input. If this works fine then it should suffice to specify let g:jukit_comment_mark = '# %% ' in your config, because then cell delimiters will start with # %%, example: # %% |%%--%%| <piKA5Zv2Wy|qWQFOOFajV>

(also make sure that the default let g:jukit_use_tcomment = 0 is used, otherwise the tcomment plugin will be used to comment out the cell markers instead of g:jukit_comment_mark)