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-return and telescope #553

Closed danilshvalov closed 1 year ago

danilshvalov commented 1 year ago

Describe the bug

Error occurs when opening org file through telescope.nvim and pressing <CR> in insert mode (see video example).

Steps to reproduce

This is a terribly hard to reproduce bug. So far I have reduced it to the following steps:

  1. Open neovim
  2. Open Telescope oldfiles (I do it with SPC f r)
  3. Open org file via telescope
  4. Press <CR> in insert mode

Expected behavior

An error should not occur.

Emacs functionality

No response

Minimal init.lua

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = "nvim-lua/plenary.nvim",
    config = function()
      vim.keymap.set("n", "<leader>fr", "<Cmd>Telescope oldfiles<CR>")
      vim.keymap.set("n", "<Space>", "<leader>", { remap = true })
    end,
  },
  {
    "nvim-orgmode/orgmode",
    build = ":TSUpdate",
    dependencies = "nvim-treesitter/nvim-treesitter",
    config = function()
      require("orgmode").setup_ts_grammar()
      require("nvim-treesitter.configs").setup({
        highlight = {
          enable = true,
          additional_vim_regex_highlighting = { "org" },
        },
        ensure_installed = { "org" },
      })
      require("orgmode").setup({})
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.opt.termguicolors = true

Screenshots and recordings

I was only able to reproduce the bug on the first and last try on this video

https://user-images.githubusercontent.com/57654917/235885439-1736c241-8f06-487e-a57a-01e791a21b71.mp4

OS / Distro

macOS Ventura 13.2

Neovim version/commit

0.9

Additional context

No response

danilshvalov commented 1 year ago

See also nvim-telescope/telescope.nvim#1975. As I understand it, the problem is not in the telescope itself, but in the fact that the orgmode plugin calls telescope mappings when it is closed.