Skip to content

Insert mode <CR> always over-indents when #+TITLE is missing #1079

@rsynnest

Description

@rsynnest

Describe the bug

I tested this with a minimal config with only orgmode and nvim-treesitter.
In an orgmode file without #+TITLE as the first line, hitting <CR> in insert mode indents when it should not.

If I type out the following entirely in insert mode, with zero manual indentation, each indents more than it should (especially annoying for hyphen bulleted lists where each new item indents deeper):

* head
   ** a
   - b 
     - c
       - d

The output I expect:

* head
** a
   - b 
   - c
   - d

If I comment out these 3 lines the bug dissapears:
https://github.com/nvim-orgmode/orgmode/blob/3629625199b9a45bdb41fa734bc2c6ef86d251bd/lua/orgmode/org/indent.lua#L76-L78`

checkhealth

==============================================================================
orgmode: ✅

Orgmode ~

  • ✅ OK Treesitter grammar installed (version 2.0.2)
  • ✅ OK Setup called
  • ✅ OK org_agenda_files configured
  • ✅ OK org_default_notes_file configured

Steps to reproduce

  1. Open test.org
  2. Type out the following outline without any manual indentations, entirely in insert mode:
    Expected:
* head
** a
   - b 
   - c
   - d

Actual:

* head
   ** a
   - b 
     - c
       - d

Expected behavior

Indentation should behave the same whether #+TITLE exists or not

Emacs functionality

No response

Minimal init.lua

-- minimal_init.lua
-- Ensure you use the correct syntax for your plugin manager (e.g., Packer, lazy.nvim, etc.)

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

if not vim.uv.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--branch=stable",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end

vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  -- Specify only the plugins you need for troubleshooting:
  "nvim-treesitter/nvim-treesitter",
  -- Add other specific plugins here
  {
    'nvim-orgmode/orgmode',
    event = 'VeryLazy',
    ft = { 'org' },
    config = function()
      -- Setup orgmode
      require('orgmode').setup({
        org_agenda_files = '~/orgfiles/**/*',
        org_default_notes_file = '~/orgfiles/refile.org',
      })
    end,
  },
})

Screenshots and recordings

https://asciinema.org/a/Bxa13dKwP3pIN7cIcbx9RyHp8

nvim-orgmode version

3629625

OS / Distro

MacOS 26.1

Neovim version/commit

v0.11.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions