jakewvincent / mkdnflow.nvim

Fluent navigation and management of markdown notebooks
GNU General Public License v3.0
695 stars 41 forks source link

[Bug] "Mkdnflow is already running!" message appears upon any action when using a modular configuration file structure #151

Closed paanvaannd closed 1 year ago

paanvaannd commented 1 year ago

Issue

Upon following links using Mkdnflow or using backspace to go to the prior file, the message "Mkdnflow is already running!" is printed. The actions are performed as expected, so this is simply a visual nuisance, but it is something I would like to resolve.

When using a monolithic init.vim file, in which I declare and configure plugins in the same file, I get no warning message. However, if I set up a more modular file structure for my configuration directory (which helps me separate plugin declaration from configuration), I get this aforementioned warning. I have not encountered any issues with setting up my file structure this way with other plugins, however, so I believe this is something specific to Mkdnflow.

Environment

Background

Thank you for helping me with issue #64 last year! I haven't used NeoVim for a few months (new laptop) but recently reinstalled it and am getting the aforementioned error now, similar to issue #60.

Steps taken to debug

To debug this, what I've done so far is start with a fairly bare init.lua file that is structured as follows:

local fn = vim.fn

local status_ok, packer = pcall(require, "packer")
if not status_ok then
    vim.notify("Unable to hail Packer")
    return
end

packer.init {
    display = {
        open_fn = function()
            return require("packer.util").float { border = "rounded" }
        end,
    },
}

return require("packer").startup(function(use)
    use { "wbthomason/packer.nvim" }  -- Allow packer to manage itself
    use({"jakewvincent/mkdnflow.nvim",
        rocks = "luautf8", -- Ensures optional luautf8 dependency is installed
        config = function()
            require("mkdnflow").setup()
        end
    })
end)

This results in perfect execution of the plugin: no error messages or bugs that I can find from my usage!

However, when I try to modularize my configuration file structure to the following hierarchy:

~/.config/nvim
├── init.lua
└── lua
    ├── core
    │   ├── init.lua
    │   └── packer.lua
    └── modules
        ├── init.lua
        └── mkdnflow.lua

I get the aforementioned error. And not much has changed rather than chaining some require() commands in Lua:

Contents of init.lua:

```lua require("core") require("modules") ```

Contents of lua/core/init.lua:

```lua require("core.packer") ```

Contents of packer.lua (TL;DR: the exact same contents as the aforementioned bare init.lua that works flawlessly):

```lua local fn = vim.fn local status_ok, packer = pcall(require, "packer") if not status_ok then vim.notify("Unable to hail Packer") return end packer.init { display = { open_fn = function() return require("packer.util").float { border = "rounded" } end, }, } return require("packer").startup(function(use) use { "wbthomason/packer.nvim" } -- Allow packer to manage itself use({"jakewvincent/mkdnflow.nvim", rocks = "luautf8", -- Ensures optional luautf8 dependency is installed config = function() require("mkdnflow").setup() end }) end) ```

The lua/modules directory files are basically empty as of now: lua/modules/init.lua simply requires lua/modules/mkdnflow.lua, which is where further configuration for the plugin would be housed.

paanvaannd commented 1 year ago

Odd... after painstakingly recreating the config from scratch, adding new config options in the lua/modules/mkdnflow.lua file, etc., the error no longer appears.

I had saved my old configuration directory, with several other plugins and configuration files involved, and just rebased my NeoVim configuration on that. After running :PackerSync, I got the "Mkdnflow is already running!" message echoed 4 times to the screen once again, but quitting and re-opening NeoVim once again has finally squashed the issue.

Given that the issue is now no longer present for me and the fact that the reproducibility is hard to pin down, I will go ahead and close this issue for now. I will continue testing the plugin and various configuration options thoroughly and report back/reopen the issue if I can reliably reproduce the issue again.

Thanks again for the wonderful plugin, and keep up the great work! I'm learning Lua now, finally, and want to try to help with the code base (e.g., issues with "help wanted" tags), contribute features, etc. as time permits after I learn a bit more.