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

Cannot refile to heading containing '/' #388

Closed Ram-Z closed 2 years ago

Ram-Z commented 2 years ago

Describe the bug

When refiling a tree to a heading that contains a /, the operations fails with the following message:

[orgmode] ...e/pack/packer/start/orgmode/lua/orgmode/capture/init.lua:172: attempt to call method '_refile_to' (a nil value)

Steps to reproduce

  1. create file test.org with contents
    * heading/with/slash
    * heading-to-refile

Expected behavior

"heading-to-refile" should be refiled under "heading/with/slash".

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/test.org'}
  })

  -- 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

Arch Linux

Neovim version/commit

NVIM v0.7.2 Build type: Release LuaJIT 2.1.0-beta3

Additional context

No response

jgollenz commented 2 years ago

Can confirm this. It is because the slash is used as separator for headlines within the specified org file. I checked Emacs and it seems things are handled a bit different there: By default, all level 1 headlines in the current buffer are considered to be targets. Headings with slashes work fine in Emacs this way. Not sure when heading is in a different file though.

kristijanhusak commented 2 years ago

This should be fixed now.