hanschen / vim-ipython-cell

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

Is it possible to use this plugin in NvChad? #48

Closed arafive closed 6 months ago

arafive commented 6 months ago

Hi! I think is not a real issue, but I am struggling to try to use it on NvChad.

First, I have added in ~/.config/nvim/lua/custom/plugins.lua the following lines:

local plugins = {
    {
        'jpalardy/vim-slime'
    },
    {
        'hanschen/vim-ipython-cell'
    },

    -- other plugins

return plugins

then, with :Lazy sync, I have installed it. So everything seems ok. It told me:

Installed (2)
     vim-ipython-cell 
     vim-slime 

but when I open a python script (in tmux) with two pane (one for script and the other for ipython), NvChad doesn't know any of your command, such as :SlimeSend1 ipython --matplotlib or :IPython....

I used it with success vim-ipython-cell in Vim and NeoVim using vim-plug to install it, but now I am moving to NvChad.

Any idea? Thanks

hanschen commented 6 months ago

I don't see why it shouldn't work with NvChad. I don't use the distribution myself, so unfortunately I don't know what could be wrong.

What do you get when you run :echo has('python') and :echo has('python3') in your editor?

Do you get any error messages on startup? (:messages)

Do you have the commands provided by vim-slime, such as :SlimeSend1? If not, then it seems like an issue with how you load plugins.

arafive commented 6 months ago

So I tried to fix :echo has('python3') and I found the issue #1875 from NvChad. I added:

local enable_providers = {
      "python3_provider",
      "node_provider",
      -- and so on
    }

    for _, plugin in pairs(enable_providers) do
      vim.g["loaded_" .. plugin] = nil
      vim.cmd("runtime " .. plugin)
    end

to custom/init.lua and now I can use the command from vim-ipython-cell. Now the "problem" is to set your Example Vim configuration in custom/init.lua. It will be great one last tip to handle this last step.

hanschen commented 6 months ago

Nice that you found a fix!

For the configuration in lua that's a bit out of scope for the issues here, but here's an example:

vim.g.slime_target = "tmux"
vim.g.slime_python_ipython = true
vim.g.slime_default_config = {
  socket_name = "default",
  target_pane = "{top-right}",
}
vim.g.slime_dont_ask_default = true

I don't know how to set up keymaps in NvChad, but generally you can use vim.keymap.set.

Since the problem seems to be solved I'll close this issue.