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

org fold does not work when `.org` file is opened by `telescope` #447

Closed milanglacier closed 1 year ago

milanglacier commented 1 year ago

Describe the bug

org fold does not work when .org file is opened by telescope

i.e

keybindings like zM, zR, <Tab> do not work.

However, it is noted that if after opening the .org buffer by telescope, typing :e to refresh the buffer content will make the fold works

Steps to reproduce

  1. nvim -u minimal-init.lua (note: don't directly open the org file at here)
  2. Open an org file via :Telescope find_files or :Telescope oldfiles
  3. go to a heading and typing <tab>
  4. find that folding does not work

Expected behavior

Folding should work

Emacs functionality

folding should work

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' },
            { 'nvim-telescope/telescope.nvim' },
            { 'nvim-lua/plenary.nvim' },
        },
        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()
    require('telescope').setup()

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()
    _G.load_config()
end

Screenshots and recordings

Screen Shot 2022-11-14 at 17 15 25

OS / Distro

macOS

Neovim version/commit

0.8

Additional context

This is a duplicate of #131. However since that issue was a stale issue and had outdated for a long time. I think it is better to reopen the issue at here.

jgollenz commented 1 year ago

I can reproduce this

kristijanhusak commented 1 year ago

Can you pull latest master and see if it's fixed?

milanglacier commented 1 year ago

This works now! Thanks!

jgollenz commented 1 year ago

@kristijanhusak this can be closed