Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vimindent variable is not defined #14111

Open
physixcat opened this issue Feb 28, 2024 · 3 comments · May be fixed by #14936
Open

vimindent variable is not defined #14111

physixcat opened this issue Feb 28, 2024 · 3 comments · May be fixed by #14936
Labels

Comments

@physixcat
Copy link

Steps to reproduce

  1. vim --clean test.vim
  2. :set indentexpr?
    this returns vimindent.Expr()
  3. :echo vimindent.Expr()
    this returns E121: Undefined variable: vimindent

Expected behaviour

vimindent should be defined

This can be temporarily sidestepped by using the old(?) function
:set indentexpr=GetVimIndent()
once inside the session. Trying to do it with an autocommand Filetype or modeline will not work, because then GetVimIndent won't be defined.

Version of Vim

9.1.16

Environment

OS: Debian Sid
terminal: st
$TERM: tmux-256color
shell: 5.2.21

Logs and stack traces

No response

@physixcat physixcat added the bug label Feb 28, 2024
@chrisbra
Copy link
Member

This is vim9 script. That is currenntly only valid when evaluating from within vim9 script context. I think it was discussed before, that one cannot easily call exported vim9 functions.

@physixcat
Copy link
Author

I see. Thank you for clarifying. Problem seems to be that when older plugins check indentexpr for a vim filetype, they will run into the same undefined var issue.

Example: https://github.com/Thyrum/vim-stabs

If you load this plugin, edit a *.vim file, and toggle on autoindent, you get the same error

So the function is being called outside of the vim9 script context all the time

@monkoose
Copy link

monkoose commented Mar 9, 2024

To prevent described error, I guess instead of

import autoload '../autoload/dist/vimindent.vim'
setlocal indentexpr=vimindent.Expr()

setlocal indentexpr=dist#vimindent#Expr() should be used.

smemsh added a commit to smemsh/vim that referenced this issue Jun 7, 2024
)

Needed for 'indentexpr' to evaluate correctly outside vim9 context, ie
with older scripts.  Whereto, it will be an undefined variable,
demonstrate with ':echo vimindent.Expr()' -> E121: Undefined variable:
vimindent
@smemsh smemsh linked a pull request Jun 7, 2024 that will close this issue
smemsh added a commit to smemsh/vim that referenced this issue Jun 10, 2024
)

Needed for 'indentexpr' to evaluate correctly outside vim9 context, ie
with older scripts.  Whereto, it will be an undefined variable,
demonstrate with ':echo vimindent.Expr()' -> E121: Undefined variable:
vimindent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants