Switching from Neotree win to Obsidian causing error.
🐛 Describe the bug
Whenever the cursor is switched from Neotree to any markdown file this error occurs.
E5108: Error executing lua: ...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:729: BufEnter Autocommands for "*.md": Vim(append):Error executing lua callback: ...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/init.lua:151: attempt to call field 'get_config' (a nil value)
stack traceback:
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/init.lua:151: in function <...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/init.lua:117>
[C]: in function 'nvim_set_current_win'
...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:729: in function 'open_file'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:733: in function 'open'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:755: in function 'open_with_cmd'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:764: in function 'open'
...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>
stack traceback:
[C]: in function 'nvim_set_current_win'
...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:729: in function 'open_file'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:733: in function 'open'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:755: in function 'open_with_cmd'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:764: in function 'open'
...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>
Config
{
"epwalsh/obsidian.nvim",
-- version = "*",
lazy = true,
cmd = "ObsidianQuickSwitch",
ft = "markdown",
keys = {
{ "<leader>wW", mode = "n", "<cmd>ObsidianQuickSwitch<cr>", desc = "Obsidian Notes" },
},
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
-- event = {
-- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'.
-- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md"
-- "BufReadPre path/to/my-vault/**.md",
-- "BufNewFile path/to/my-vault/**.md",
-- },
dependencies = {
-- Required.
"nvim-lua/plenary.nvim",
"hrsh7th/nvim-cmp",
"nvim-treesitter/nvim-treesitter",
"3rd/image.nvim",
},
opts = {
ui = {
enable = false,
},
templates = {
debug = true,
folder = "~/Code/Obsidian/Templates",
},
daily_notes = {
folder = "Daily",
template = "/Daily Notes.md",
},
attachments = {
img_folder = "Images",
},
follow_url_func = function(url)
print("Opening URL: " .. url)
vim.fn.jobstart({ "xdg-open", url }) -- linux
end,
workspaces = {
{
name = "personal",
path = "~/Code/Obsidian/",
},
},
pickers = {
name = "fzf-lua",
},
},
}
Environment
Even the debug command is throwing an error and here it is coming from fzf-lua.
NVIM v0.10.2
Build type: RelWithDebInfo
LuaJIT 2.1.1731601260
Run "nvim -V1 -v" for more info
fzf-lua fatal: '_G._fzf_lua_server', '_G._devicons_path' both nil
fzf-lua fatal: '_G._fzf_lua_server', '_G._devicons_path' both nil
Error detected while processing command line:
E5108: Error executing lua .../nvim/lazy/obsidian.nvim/lua/obsidian/commands/debug.lua:28: attempt to call field 'get_config' (a nil value)
stack traceback:
.../nvim/lazy/obsidian.nvim/lua/obsidian/commands/debug.lua:28: in function 'check_completion'
.../nvim/lazy/obsidian.nvim/lua/obsidian/commands/debug.lua:65: in function <.../nvim/lazy/obsidian.nvim/lua/obsidian/commands/debug.lua:34>
...al/share/nvim/lazy/obsidian.nvim/lua/obsidian/client.lua:316: in function 'command'
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/init.lua:67: in function 'info'
[string ":lua"]:1: in main chunk%
```
It is also sometimes throwing this error when moving cursor from neotree to an .md file.
E11: Invalid in command-line window; <CR> executes, CTRL-C quits: wincmd k
I am also getting the same error when navigating to .md files using oil.
i second this. i am facing same issue with obsidian whenever i switch to or open a .md file from any other buffer.
The issue stems from using blink.cmp, works fine when using with nvim-cmp.
My guess is no implementation of using blink.compat to register obsidian sources on the autocmds that run on entering the buffer and assigning workspace.
cloned the repo and changing this function to :
config.CompletionOpts.default = function()
local has_nvim_cmp, _ = pcall(require, "cmp")
local has_blink_cmp, _ = pcall(require, "blink.cmp")
if has_blink_cmp then
has_nvim_cmp = false
end
return {
nvim_cmp = has_nvim_cmp,
min_chars = 2,
}
end
stops that error as nvim-cmp is a hard coded dependency at the moment. cmp-cmdline by blink does not work for me so I could check registering the cmp sources provided by obsidian but for the time being this remedies the error constantly.