milanglacier / yarepl.nvim

Yet Another REPL, flexible, supporting multiple paradigms to interact with REPLs, project-level configs, working with tmux, telescope integration, and native dot repeat.
GNU General Public License v3.0
96 stars 3 forks source link

[POSSIBLE BUG]`wincmd` option in the config does not make any change #17

Closed Roudranil closed 1 year ago

Roudranil commented 1 year ago

Setting wincmd = "vertical 70 split does not result in opening of the REPL window in the said position. It still opens in the default position.

Current config:

local yarepl = require("yarepl")
local M = {
    buflisted = true,
    scratch = true,
    ft = 'REPL',
    wincmd = 'vertical 70 split',
    metas = {
        ipython = {
            cmd = '/path/to/ipython --no-autoindent',
            formatter = yarepl.formatter.bracketed_pasting
        }
    },
    close_on_exit = true,
    scroll_to_bottom_after_sending = true
}
return M

Looking at the source code, in the repl_start part, i dont see the wincmd option being used anywhere (I maybe wrong). Any ideas?

milanglacier commented 1 year ago

try this snippet

require('yarepl').setup {
    buflisted = true,
    scratch = true,
    ft = 'REPL',
    wincmd = 'vertical 70 split',
    metas = {
        ipython = {
            cmd = '/path/to/ipython --no-autoindent',
            formatter = yarepl.formatter.bracketed_pasting
        }
    },
    close_on_exit = true,
    scroll_to_bottom_after_sending = true
}
Roudranil commented 1 year ago

Thanks! that fixed it. However it is a bit weird. I usually setup plugins in this way with lazy.nvim

        'milanglacier/yarepl.nvim',
        opts = function() require("plugins.configs.yarepl") end,
        init = function() require("core.utils").load_mappings("yarepl") end,
        config = function(_, opts)
            require("yarepl").setup(opts)
        end,
        ft = {"python"}

with the above config being returned from plugins.configs.yarepl. With your suggestion i just pasted the table in place of opts and it works. Any idea why? Also, i would like to keep the python file bython file buffer as the current one and not switch focus to the repl window. Any idea on how to do it?

Roudranil commented 1 year ago

Fixed the focus switching one.

milanglacier commented 1 year ago

Thanks! that fixed it. However it is a bit weird. I usually setup plugins in this way with lazy.nvim

        'milanglacier/yarepl.nvim',
        opts = function() require("plugins.configs.yarepl") end,
        init = function() require("core.utils").load_mappings("yarepl") end,
        config = function(_, opts)
            require("yarepl").setup(opts)
        end,
        ft = {"python"}

with the above config being returned from plugins.configs.yarepl. With your suggestion i just pasted the table in place of opts and it works.

I don’t use so many "advanced" config options from lazy. I consider them as over-encapsulation.

I think only three config options from lazy are enough for configuring yarepl (if you want to lazy load).

The first is init where you can preload your keymaps, the second is cmd where you should put the commands from yarepl into this list, the last is config where you should call like this config = function() require 'yarepl'.setup { your config is here } end inside this function.

If you don’t do lazy load, then cmd can be ignored.

Two things to note:

  1. You must call the setup function in yarepl to make it functional, this is the convention of neovim lua plugin.

  2. you can’t use opt option in lazy because you are using some objects fromyarepl (notably formatter.bracketed_pasting) which is only available after you have require “yarepl”, so you should put them under config part.