neo/vim - diagnosing nomodeline option

I was moving my .profile config to a new ZVDT recently.

# vim:fileencoding=utf-8:foldmethod=marker

export HISTSIZE=99999
export TERMINFO="$HOME/.terminfo"

# {{{ : zopen tools
.  "$ZOT/etc/zopen-config" --nooverride-zos-tools
# }}}

And when I opened it in neovim I was got that it did not fold the zopen tools section. Trying zM did not collapse it either. And moving cursor on the zopen line and trying zc did not work either.

foldmethod

Checking option :set foldmethod? reveled “foldmethod=manual”. This turned out to be because of nomodeline option.

nomodeline

Why did I have nomodeline? I checked the setup on both old and new machine and consistently I had modelineon the old machine and nomodeline on the new one. Same version of neovim, same configs, same environment variables. :mind-exploding:.

To learn why, see TLDR.

FAQ for next time

How do I set an ‘option’ and check its value

vimscript

:set modeline?  " check current the value of 'modeline'
:set modeline   " set 'modeline' to true
:set nomodeline " set 'modeline' to false
:set modeline&. " set 'modeline' to its default value
:echo nvim_get_option_info2("modeline",{}).default   " check the default value of 'modeline'

lua

:lua vim.opt.modeline = true
:lua vim.opt.modeline = false
:lua print(vim.opt.modeline:get())

What scripts were run during starupt

:h scriptnames

How do I limit the scripts loaded at startup

nvim -u NONE -i NONE
nvim --clean
nvim -u NONE
nvim -u NORC
nvim --noplugin

How do I list all options

`:set! all ” the exclamation mark makes every option to go to its own line

How do I check options that have non-default values

`:set! ” the exclamation mark makes every option to go to its own line

How do I redirect the output to a file

:redir! > /tmp/nvim.opts`  " ! will override the file if it alraedy exits
:set!                      " ! will put every option on its own line
:redir END

for more info see :h redir

Where was my option set?

This will

These steps work both for vim and lua scripts.

For more info see

:h :verbose-cmd
:h 'verbose'
:h :verbose

Can I get a detailed log of the startup?

nvim -V99/tmp/nvim.log

TLDR

The ‘modeline’ option has a different defaults for regular users and for root. It is documented in the (neo)vim help:

:h 'modeline'
                                'modeline' 'ml' 'nomodeline' 'noml'            
'modeline' 'ml'         boolean (default on (off for root))                    
                        local to buffer                                        
        If 'modeline' is on 'modelines' gives the number of lines that is      
        checked for set commands.  If 'modeline' is off or 'modelines' is zero 
        no lines are checked.  See modeline.                                   

Notice the default value:

How is it determined that a user is a root? By checking whether its user id is 0.

On z/OS there is no root user per say but a special admin user can have a user id 0. To check your user id run:

# id
uid=0(OMVSKERN) ...

Many thanks to clason and seandewar from the #neovim-dev channel on matrix for pointing me in the right direction after two days of despair.