orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

Can't link to headline in file outside of `org_agenda_files`

Open jgollenz opened this issue 2 years ago • 0 comments

Describe the bug

The external file is not yet known to nvim-orgmode, so it can't reason about it's headlines. Emacs can do this just fine.

Steps to reproduce

  1. Set your org_agenda_files to e.g. { "~/org-files/*" }
  2. In any org file create a link to another org file that is outside of the ~/org-files/ directory and specify a headline, e.g. [[file:/home/you/not-org-files/foo.org::*bar]] (the headline must ofc exist in the linked file)

Expected behavior

The linked file should be opened

Emacs functionality

Like the expected behavior

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 = { '~/path/to/your/org/files/*' },
  })

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

Ubuntu 20.04

Neovim version/commit

0.8.3

Additional context

No response

jgollenz avatar Mar 01 '23 22:03 jgollenz