nvim-orgmode / orgmode

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

Agenda search doesn't work with TODO states #526

Closed lyz-code closed 1 year ago

lyz-code commented 1 year ago

Describe the bug

I'm trying to use the agenda search to find all the WAITING todo items.

Steps to reproduce

  1. Make the temporal directory /tmp/tmp.ITyANcLp6W
  2. Create a file test.org with the next content:
* TODO element 1
* WAITING element 2
  1. Press ga to go to the agenda, then s to do a text search by element and see that both elements show up.
  2. Press ga to go to the agenda , then m to do a Match a TAGS/PROP/TODO query, enter WAITING or waiting
  3. The element 2 doesn't show up

Expected behavior

WAITING elements should show up in the agenda view

Emacs functionality

No response

Minimal init.lua

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])

local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'

local function load_plugins()
  require('packer').startup({
    {
      'wbthomason/packer.nvim',
      { 'nvim-treesitter/nvim-treesitter' },
      { 'kristijanhusak/orgmode.nvim', branch = 'master' },
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
    },
  })
end

_G.load_config = function()
  require('orgmode').setup_ts_grammar()
  require('nvim-treesitter.configs').setup({
    highlight = {
      enable = true,
      additional_vim_regex_highlighting = { 'org' },
    },
  })

  vim.cmd([[packadd nvim-treesitter]])
  vim.cmd([[runtime plugin/nvim-treesitter.lua]])
  vim.cmd([[TSUpdateSync org]])

  -- Close packer after install
  if vim.bo.filetype == 'packer' then
    vim.api.nvim_win_close(0, true)
  end

  require('orgmode').setup(
  {
      org_agenda_files = {'/tmp/tmp.ITyANcLp6W/*'},
  }

  )

  -- Reload current file if it's org file to reload tree-sitter
  if vim.bo.filetype == 'org' then
    vim.cmd([[edit!]])
  end
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path })
  load_plugins()
  require('packer').sync()
  vim.cmd([[autocmd User PackerCompileDone ++once lua load_config()]])
else
  load_plugins()
  load_config()
end

Screenshots and recordings

No response

OS / Distro

Debian

Neovim version/commit

NVIM v0.8.3

Additional context

Even a text search gas with waiting or WAITING doesn't show the expected elements.

jgollenz commented 1 year ago

If I'm not mistaken, you shouldn't be able to find element 2 with a \oam search, because you didn't specify that WAITING is a TODO-keyword. And I also find the line with a text search, \oas. If you add org_todo_keywords = { 'TODO', 'WAITING', '|', 'DONE' }, you can find it with /WAITING. The leading slash is required.

lyz-code commented 1 year ago

My bad pasting the minimal.lua, I indeed had the org_todo_keywords, but I didn't understand well the syntax of the \oam search. Adding the leading slash made this work thanks!

Does this mean that if you want to search by a property you have to use /Title/? I tried that to find the next element but didn't show up anything, maybe I'm doing it wrong again :S

* CD collection
** Classic
*** Goldberg Variations
    :PROPERTIES:
    :Title:     Goldberg Variations
    :Composer:  J.S. Bach
    :Publisher: Deutsche Grammophon
    :NDisks:    1
    :END:
jgollenz commented 1 year ago

The syntax is PROP_NAME="prop_value". See here. But keep in mind, that we are not feature complete yet and there probably are things that are in emacs orgmode and not yet in nvim orgmode. If you find something that's missing, please open an issue :+1: