vim / vim

The official Vim repository
https://www.vim.org
Vim License
36.13k stars 5.41k forks source link

:help vim9-scopes is outdated #9724

Closed bfrg closed 2 years ago

bfrg commented 2 years ago

Steps to reproduce

The section under :h vim9-scopes needs to be updated since it's no longer possible to write def scriptname#function(). Doing so gives the error:

E1263: cannot use name with # in Vim9 script, use export instead

What is the point of keeping the prefix s: for functions or variables? I personally don't see an advantage. Removing it (or forcing it) will make all plugins look more consistent. There is already an inconsistency in Vim's runtime. See for example s:LoadFTPlugin() and SetSyn(name: string).

And out of curiosity, why doesn't the file ftplugin.vim contain any vim9script declaration at the top of the file. The first few lines use the old legacy vimscript syntax, whereas the def function the new syntax. In my option, that's a little bit confusing. Why not just vim9script the entire script? Similar for menu.vim and synmenu.vim.

Version of Vim

8.2.4333

brammool commented 2 years ago

Steps to reproduce

The section under :h vim9-scopes needs to be updated since it's no longer possible to write def scriptname#function(). Doing so gives the error:

E1263: cannot use name with # in Vim9 script, use export instead

I'll fix that.

What is the point of keeping the prefix s: for functions or variables? I personally don't see an advantage. Removing it (or forcing it) will make all plugins look more consistent.

Yes, we could drop it. The only reason I can think of to keep it is that in a legacy function the s: prefix must be used:

vim9script

def Local()
  echo 'local'
enddef

func Legacy()
  call s:Local()  " won't work without s:
endfunc

Legacy()

There is already an inconsistency in Vim's runtime. See for example s:LoadFTPlugin() and SetSyn(name: string).

This comes from converting a legacy script to Vim9. So the question is whether it is good to force removing the "s:" prefix or is it more convenient to let it there?

And out of curiosity, why doesn't the file ftplugin.vim contain any vim9script declaration at the top of the file. The first few lines use the old legacy vimscript syntax, whereas the def function the new syntax. In my option, that's a little bit confusing. Why not just vim9script the entire script? Similar for menu.vim and synmenu.vim.

It's because of the "finish" command. I wasn't quite sure if "vim9script noclear" would work. The "did_load_ftplugin" is cleared in ftplugof.vim. But the function could remain. I'll see if I can make that work.

-- How To Keep A Healthy Level Of Insanity:

  1. Don't use any punctuation marks.

    /// Bram Moolenaar -- @.*** -- http://www.Moolenaar.net \\ /// \\ \\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\ help me help AIDS victims -- http://ICCF-Holland.org ///

bfrg commented 2 years ago

Fixed in 9da17d7.