jakewvincent / mkdnflow.nvim

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

Any Mkdn command ends with "Error executing Lua callback:" #189

Closed suntsu42 closed 5 months ago

suntsu42 commented 5 months ago

When i try to execute a command (e.g. ":MkdnCreateLink" or ":MkdnTable") the followng error is shown:

image

Error executing Lua callback: ....local/share/nvim/lazy/mkdnflow.nvim/plugin/mkdnflow.lua:119: attempt to index field 'tables' (a nil value)
stack traceback:
        ....local/share/nvim/lazy/mkdnflow.nvim/plugin/mkdnflow.lua:119: in function <....local/share/nvim/lazy/mkdnflow
.nvim/plugin/mkdnflow.lua:118>

I've boiled down my neovim config to exclude any other problems. I just download pleanry and mkdnflow. No other configuration is loaded.

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    "nvim-lua/plenary.nvim",
    "jakewvincent/mkdnflow.nvim"
})

It looks like everything is properly loaded image

I've also tested with neovim preview and did test on linux and windows and always got the same error.

Any idea what the reason for this error is?

suntsu42 commented 5 months ago

I did some more digging and tried to access part of the mkdnflow in lua.

   local mkdnflow = require('mkdnflow')
   print(mkdnflow) 
   print(mkdnflow.tables) 

The output looks like this: image

mkdnflow.tables seems not to be initialized.

I'm guessing that i miss something obvious, but i can't see what the problem is.

suntsu42 commented 5 months ago

After some more digging, i finally found the reason.

I did not configure treesitter properly. I now configured treesitter with the following settings

require 'nvim-treesitter.configs'.setup {
    ensure_installed = { "javascript", "typescript", "c", "lua" },
    auto_install = true,
}

When i then started a markdown file in neovim, treesitter did download something and all the mkdnflow commands now work. It shows the following message (Even i don't fully understand what exactly is installed for markdown)

[nvim-treesitter] [1/1] Treesitter parser for markdown has been installed 

I just wasn't aware of this dependency.