nvim-FeMaco.lua icon indicating copy to clipboard operation
nvim-FeMaco.lua copied to clipboard

Incorrect indentation in org-mode

Open jaidetree opened this issue 2 years ago • 2 comments

Reproduction

  1. Enable indentation in org_mode (default) or set org_indent_mode to indent
  2. Create at least two levels of headlines and add a src block (see example below)
  3. Invoke the FeMaco binding on the src block
  4. Update the src block content indentation (like ggVG=)
  5. Use the :wq command to write and replace prev src block

Example

#+title: Org FeMaco Indentation Repro

* Heading 1

  ** Heading 2

     #+begin_src fennel
     (let [x 5]
     (+ x 2)) ;; Purposefully incorrectly indented 
     #+end_src

Expected

The indentation level after saving the FeMaco buffer should respect the original org-mode src block indentation

* Heading 1

  ** Heading 2

     #+begin_src fennel
     (let [x 5]
       (+ x 2)) ;; Now correctly indented 
     #+end_src

Actual

The indentation level does not reflect the org-mode src block indentation:

* Heading 1

  ** Heading 2

     #+begin_src fennel
     (let [x 5]
(+ x 2)) ;; Now worse than before :(
     #+end_src

Workarounds

  • For now I've just set org_indent_mode to noindent

jaidetree avatar Mar 02 '23 23:03 jaidetree

I think the built-in orgmode edit special does indent correctly, but not sure how applicable to this tool it is:

https://github.com/nvim-orgmode/orgmode/blob/313ce5a04e7fc3d677ad906a94fc49c1f54d1572/lua/orgmode/objects/edit_special/init.lua

FeMaco is way nicer though. The official just opens a split.

jaidetree avatar Mar 02 '23 23:03 jaidetree

Thanks for the thorough issue @eccentric-j, I'm quite busy atm and have not unfortunately been able to look into this yet.

AckslD avatar Mar 07 '23 16:03 AckslD