nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
2.86k stars 125 forks source link

No agenda entries found #712

Closed tanj closed 3 months ago

tanj commented 3 months ago

Describe the bug

Open agenda view and see no entries. (emacs looking at same directory shows entries)

Steps to reproduce

  1. nvim -u minimal_init.lua
  2. <leader>oaa
  3. see agenda mode with no files listed

Expected behavior

there should be todos and capture records showing

Emacs functionality

yes, and it points to the same files as neovim orgmode. Emacs shows multiple entries from the past week.

Minimal init.lua


-- Enter your minimal_init.lua here
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"

vim.g.mapleader = " "
vim.g.maplocalleader = " "

-- 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({
    { -- Highlight, edit, and navigate code
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        opts = {
            ensure_installed = {
                "org",
            },
            config = function(_, opts)
                ---@diagnostic disable-next-line: missing-fields
                require("nvim-treesitter.configs").setup(opts)
            end,
        },
    },

    {
        "nvim-orgmode/orgmode",
        event = "VeryLazy",
        branch = "master",
        config = function()
            require("orgmode").setup()
            org_agenda_files = "~/Dropbox/org/*"
        end,
        dependencies = {
            { "nvim-treesitter/nvim-treesitter", lazy = true },
        },
    },
}, {
    root = lazy_root,
    lockfile = nvim_root .. "/lazy.json",
    install = {
        missing = false,
    },
})

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

Screenshots and recordings

Emacs agenda view

image

nvim orgmode

image

OS / Distro

Windows 11 Pro

Neovim version/commit

NVIM v0.10.0-dev-2826+gf6dcc464f

Additional context

captures log to the org files that agenda looks at.

This was working before the treesitter requirement was dropped. This config also works fine in linux without issue.

kristijanhusak commented 3 months ago

There are multiple issues with your config:

  1. org_agenda_files goes inside setup. You put it after the setup call
  2. nvim-treesitter is not necessary any more.

This is the correct config for you:

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',
    event = 'VeryLazy',
    branch = 'master',
    config = function()
      require('orgmode').setup({
        org_agenda_files = '~/Dropbox/org/*'
      })
    end
  },
}, {
  root = lazy_root,
  lockfile = nvim_root .. '/lazy.json',
  install = {
    missing = false,
  },
})

require('lazy').sync({
  wait = true,
  show = false,
})
tanj commented 3 months ago

whoops, messed that up with building the minimal config, but it is correct in my main config. After fixing the minimal config the behaviour is still the same.

I had issues with even opening agenda mode without adding the treesitter config. I kept having errors come up until I manually set the TMPDIR variable when launching nvim.

Do you know if neovim is using any of the temp dir variables as part of how orgmode operates? I had issues in the past with lualatex and temp dirs not being set in expected way on windows.

kristijanhusak commented 3 months ago

I kept having errors come up until I manually set the TMPDIR variable when launching nvim.

What is the result of the 1st line in the minimal config for you?

Do you know if neovim is using any of the temp dir variables as part of how orgmode operates?

tempname() function is being used to generate temporary capture files.

tanj commented 3 months ago

The first line is the result of putting print(tmp_dir) after the first line of the minimal config

C:\Users\JTEBOK~1\AppData\Local\Temp
Error detected while processing C:/Users/jtebokkel/Documents/junk/minimal_init-2.lua:
E5113: Error while calling lua chunk: ...Local/Temp/nvim_orgmode/lazy/lazy.nvim/lua/lazy/help.lua:42:
Vim:E151: No match: C:\Users\JTEBOK~1\AppData\Local\Temp\nvim_orgmode\lazy\lazy.nvim\doc\**
stack traceback:
[C]: in function 'helptags'
...Local/Temp/nvim_orgmode/lazy/lazy.nvim/lua/lazy/help.lua:42: in function 'update'
...emp/nvim_orgmode/lazy/lazy.nvim/lua/lazy/manage/init.lua:94: in function 'cb'
...p/nvim_orgmode/lazy/lazy.nvim/lua/lazy/manage/runner.lua:158: in function 'install'
...emp/nvim_orgmode/lazy/lazy.nvim/lua/lazy/manage/init.lua:190: in function 'sync'
C:/Users/jtebokkel/Documents/junk/minimal_init-2.lua:42: in main chunk
Press ENTER or type command to continue

After pressing enter

[orgmode] Installing tree-sitter grammar...
[orgmode] Done!
E5108: Error executing lua ...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:104: no parser for 'org' language, see :help treesitter-parsers
stack traceback:
[C]: in function 'error'
...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:104: in function 'add'
...s/Neovim/share/nvim/runtime/lua/vim/treesitter/query.lua:250: in function 'fn'
...iles/Neovim/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
...iles/Neovim/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'get'
...y/orgmode/lua/orgmode/colors/highlighter/markup/init.lua:13: in function 'new'
...ode/lazy/orgmode/lua/orgmode/colors/highlighter/init.lua:28: in function '_setup'
...ode/lazy/orgmode/lua/orgmode/colors/highlighter/init.lua:21: in function 'new'
...ocal/Temp/nvim_orgmode/lazy/orgmode/lua/orgmode/init.lua:47: in function 'init'
...ocal/Temp/nvim_orgmode/lazy/orgmode/lua/orgmode/init.lua:200: in function 'instance'
...ocal/Temp/nvim_orgmode/lazy/orgmode/lua/orgmode/init.lua:150: in function 'action'
[string ":lua"]:1: in main chunk 

This happens on each launch unless I execute like TMPDIR=$junk/orgmode-tmp-2 nvim -u $junk/minimal_init-2.lua where $junk is a folder in my home directory. If I set my own TMPDIR like that then I can bring up agenda view, but again no items are in the list.

kristijanhusak commented 3 months ago

I pushed a fix for loading agenda files. Just start up with minimal init and do :Lazy sync to bring up latest master. Restart nvim and check if agenda files appear.

tanj commented 3 months ago

that fixed it! Thank you so much!