Skip to content

Exception in org_refile keybinding #675

@JustAPerson

Description

@JustAPerson

Describe the bug

Attempting to use the org_refile keybinding (<Leader>or) inside an org file triggers this exception:

[orgmode] ...cal/share/nvim/lazy/orgmode/lua/orgmode/capture/init.lua:290: attempt to index field '_window' (a nil value)

I don't really have a better stack trace unfortunately.

Steps to reproduce

  • Copy my minimal_init.lua
  • run mkdir org in directory (to create the org_agenda_files path from minimal_init.lua)
  • run nvim -u minimal_init.lua
  • Open and save org/projects.org
  • Hit <Leader>oct to capture a task (will be saved to org/refile.org thanks to org_default_notes_file setting)
  • Open org/refile.org
  • Select task and hit <Leader>or to refile
  • Tab complete the destination to select projects.org/ (Not sure why it has a trailing slash)
  • Hitting enter triggers the exception

Expected behavior

Successfully able to move item to other org file

Emacs functionality

No response

Minimal init.lua

For the minimal_init.lua, I merely added the org_agenda_files and org_default_notes_file settings.

local tmp_dir = vim.env.TMPDIR or vim.env.TMP or vim.env.TEMP or "/tmp"
local nvim_root = tmp_dir .. "/nvim_orgmode"
local lazy_root = nvim_root .. "/lazy"
local lazypath = lazy_root .. "/lazy.nvim"

-- Install lazy.nvim if not already installed
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-orgmode/orgmode",
    dependencies = {
      { "nvim-treesitter/nvim-treesitter", lazy = true },
    },
    event = "VeryLazy",
    config = function()
      -- Load treesitter grammar for org
      require("orgmode").setup_ts_grammar()

      -- Setup treesitter
      require("nvim-treesitter.configs").setup {
        highlight = {
          enable = true,
        },
        ensure_installed = { "org" },
      }

      -- Setup orgmode
      require("orgmode").setup {
        org_agenda_files = "./org/**/*",
        org_default_notes_file = "./org/refile.org",
      }
    end,
  },
}, {
  root = lazy_root,
  lockfile = nvim_root .. "/lazy.json",
  install = {
    missing = false,
  },
})

require("lazy").sync {
  wait = true,
  show = false,
}

Screenshots and recordings

No response

OS / Distro

Debian 11 (Bullseye)

Neovim version/commit

0.9.0

Additional context

It seems like this line of code (orgmode/lua/orgmode/capture/init.lua:290) was recently added in #670

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions