Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching from Neotree win to Obsidian causing error. #793

Open
redoxahmii opened this issue Dec 16, 2024 · 5 comments
Open

Switching from Neotree win to Obsidian causing error. #793

redoxahmii opened this issue Dec 16, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@redoxahmii
Copy link

🐛 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%
        ```
@redoxahmii redoxahmii added the bug Something isn't working label Dec 16, 2024
@redoxahmii
Copy link
Author

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

@blancpain
Copy link

I am also getting the same error when navigating to .md files using oil.

@EviLuci
Copy link

EviLuci commented Dec 17, 2024

i second this. i am facing same issue with obsidian whenever i switch to or open a .md file from any other buffer.

@redoxahmii
Copy link
Author

redoxahmii commented Dec 17, 2024

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.

@redoxahmii
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants