Vim9 dict key notation old fashion depreciated

41 views
Skip to first unread message

Ni Va

unread,
Dec 3, 2020, 3:58:17 AM12/3/20
to vim_use
Hi,


Since Vim.8.2.2082, it appears that this notation of dict' keys used for example in FZF plugin is depreciated. 

g:fzf_colors = { fg:  ['fg', 'Normal'], 
               \ bg:  ["bg", "Normal"],
               \ hl:  ["fg", "IncSearch"],
               \ fg+: ["fg", "CursorLine", "CursorColumn", "Normal"],

Could you confirm or just tell how to solve this ?

Thank you.
NiVa  

Ni Va

unread,
Dec 3, 2020, 5:30:24 AM12/3/20
to vim_use
This,  as a bypass, seems to work:

g:fzf_colors = { fg:  ['fg', 'Normal'], 
               \ bg:  ["bg", "Normal"],
               \ hl:  ["fg", "IncSearch"],
               \ info:    ["fg", "IncSearch"],
               \ border:  ["fg", "Ignore"],
               \ prompt:  ["fg", "Comment"],
               \ pointer: ["fg", "IncSearch"],
               \ marker:  ["fg", "IncSearch"],
               \ spinner: ["fg", "IncSearch"],
               \ header:  ["fg", "WildMenu"] }
g:fzf_colors['fg+'] = ["fg", "CursorLine", "CursorColumn", "Normal"]
g:fzf_colors['bg+'] = ["bg", "CursorLine", "CursorColumn"]
g:fzf_colors['hl+'] = ["fg", "IncSearch"]


Bram Moolenaar

unread,
Dec 3, 2020, 6:34:04 AM12/3/20
to vim...@googlegroups.com, Ni Va

> This, as a bypass, seems to work:
>
> g:fzf_colors = { fg: ['fg', 'Normal'],
> \ bg: ["bg", "Normal"],
> \ hl: ["fg", "IncSearch"],
> \ info: ["fg", "IncSearch"],
> \ border: ["fg", "Ignore"],
> \ prompt: ["fg", "Comment"],
> \ pointer: ["fg", "IncSearch"],
> \ marker: ["fg", "IncSearch"],
> \ spinner: ["fg", "IncSearch"],
> \ header: ["fg", "WildMenu"] }
> g:fzf_colors['fg+'] = ["fg", "CursorLine", "CursorColumn", "Normal"]
> g:fzf_colors['bg+'] = ["bg", "CursorLine", "CursorColumn"]
> g:fzf_colors['hl+'] = ["fg", "IncSearch"]

Looks like your problem is with the "fg+" key, the plus character is not
allowed in a literal key. You can use the Javascript notation, using
square brackets:

g:fzf_colors = { fg: ['fg', 'Normal'],
bg: ["bg", "Normal"],
hl: ["fg", "IncSearch"],
info: ["fg", "IncSearch"],
border: ["fg", "Ignore"],
prompt: ["fg", "Comment"],
pointer: ["fg", "IncSearch"],
marker: ["fg", "IncSearch"],
spinner: ["fg", "IncSearch"],
header: ["fg", "WildMenu"],
['fg+']: ["fg", "CursorLine", "CursorColumn", "Normal"],
['bg+']: ["bg", "CursorLine", "CursorColumn"],
['hl+']: ["fg", "IncSearch"],
}

In Vim9 script you don't need the backslashes.


--
ARTHUR: Ni!
BEDEVERE: Nu!
ARTHUR: No. Ni! More like this. "Ni"!
BEDEVERE: Ni, ni, ni!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Felipe Contreras

unread,
Dec 3, 2020, 6:46:17 AM12/3/20
to vim_use
On Thursday, December 3, 2020 at 5:34:04 AM UTC-6 Bram Moolenaar wrote:
Looks like your problem is with the "fg+" key, the plus character is not
allowed in a literal key. You can use the Javascript notation, using
square brackets:

... 

['fg+']: ["fg", "CursorLine", "CursorColumn", "Normal"],

What's wrong with 'fg+'? In JavaScript there's no need for brackets. It's there for want to you use a variable.

Ni Va

unread,
Dec 3, 2020, 7:55:50 AM12/3/20
to vim_use
It's okay with this new notation and thank you for less chars as backslash.

Do profiler show performance gain for vimscript migrated in vim9 ?

g:fzf_colors = { fg: ['fg', 'Normal'],
bg: ["bg", "Normal"],
hl: ["fg", "IncSearch"],
info: ["fg", "IncSearch"],
border: ["fg", "Ignore"],
prompt: ["fg", "Comment"],
pointer: ["fg", "IncSearch"],
marker: ["fg", "IncSearch"],
spinner: ["fg", "IncSearch"],
header: ["fg", "WildMenu"],
['fg+']: ["fg", "CursorLine", "CursorColumn", "Normal"],
['bg+']: ["bg", "CursorLine", "CursorColumn"],

['hl+']: ["fg", "IncSearch"],
}

Christian Brabandt

unread,
Dec 3, 2020, 8:00:26 AM12/3/20
to vim_use

On Do, 03 Dez 2020, Ni Va wrote:

> It's okay with this new notation and thank you for less chars as backslash.
>
> Do profiler show performance gain for vimscript migrated in vim9 ?

You can profile a vim9 script version and a legacy vimscript version.
That's what I did with the switch on vim-airlines side. The vim9 version
does no longer even show up in the profile output, so much does it safe.

Although it looks quite a bit different I really like it, although there
is quite a bit of work left. E.g. vim-airline uses the optional dict a
lot, not sure how this will work out in the future. That is the reason,
I have not merged this huge branch yet.

But all in all, I quite like the performance boost.

Best,
Christian
--
Grabinschrift: Hier ruhen meine Gebeine, ich wünscht', es wären Deine.

Ni Va

unread,
Dec 3, 2020, 8:11:32 AM12/3/20
to vim_use
Okay thank you for feedback.

if I were joking I would say that all it takes is an advanced substitute to migrate the vimscript dictionaries to vim9. In my plugins, certainly not in vim-airline :)

aro...@vex.net

unread,
Dec 3, 2020, 9:11:15 AM12/3/20
to vim...@googlegroups.com

Vocabulary pedant writing here.

Though the meaning is obvious in this context, "depreciate" means to lose
value, e.g. when a new car is driven off the lot, its value depreciates
25% or so.

To express disapproval of something, "deprecate" it.

There's just an iota of difference between "deprecate" and "depreciate". :-)*

Bram Moolenaar

unread,
Dec 3, 2020, 11:10:59 AM12/3/20
to vim...@googlegroups.com, Felipe Contreras

Filipe Contreras wrote:

> On Thursday, December 3, 2020 at 5:34:04 AM UTC-6 Bram Moolenaar wrote:
>
> > Looks like your problem is with the "fg+" key, the plus character is not
> > allowed in a literal key. You can use the Javascript notation, using
> > square brackets:
>
> ['fg+']: ["fg", "CursorLine", "CursorColumn", "Normal"],
>
>
> What's wrong with 'fg+'? In JavaScript there's no need for brackets. It's
> there for want to you use a variable.

In the browser console:

var d = {key+: 'value'}
% Uncaught SyntaxError: Unexpected token '+'

We do allow for the underscore and minus sign. We could allow for a few
more, but it can get confusing. Javascript doesn't even allow for the
minus sign.

Oh, you mean using single quotes without the brackets works. Double
quotes too. That is simpler. Somehow I didn't find this in the
specification. I see questions on stack overflow from more people who
are confused about this. Only for JSON it's clear that double quotes
are always required.


--
TALL KNIGHT: We are now no longer the Knights Who Say Ni!
ONE KNIGHT: Ni!
OTHERS: Sh!
ONE KNIGHT: (whispers) Sorry.

Bram Moolenaar

unread,
Dec 3, 2020, 11:11:02 AM12/3/20
to vim...@googlegroups.com, Ni Va

> It's okay with this new notation and thank you for less chars as backslash.
>
> Do profiler show performance gain for vimscript migrated in vim9 ?
>
> g:fzf_colors =3D { fg: ['fg', 'Normal'],
> bg: ["bg", "Normal"],
> hl: ["fg", "IncSearch"],
> info: ["fg", "IncSearch"],
> border: ["fg", "Ignore"],
> prompt: ["fg", "Comment"],
> pointer: ["fg", "IncSearch"],
> marker: ["fg", "IncSearch"],
> spinner: ["fg", "IncSearch"],
> header: ["fg", "WildMenu"],
> *['fg+']*: ["fg", "CursorLine", "CursorColumn", "Normal"],
> ['bg+']: ["bg", "CursorLine", "CursorColumn"],
> ['hl+']: ["fg", "IncSearch"],
> }

Changes at the script level won't show much performance gain. You do
get the improved syntax and type checking.

Anything that is executed more than once should be put in a :def
function, that's where you will get a large performance gain. Depending
on what the code is doing something like ten to a hundred times faster.

--
TALL KNIGHT: Firstly. You must get us another shrubbery!
OTHER KNIGHTS: More shrubberies! More shrubberies for the ex-Knights of Ni!
ARTHUR: Not another shrubbery -

Dominique Pellé

unread,
Dec 3, 2020, 11:48:20 AM12/3/20
to Vim List
On Thu, Dec 3, 2020 at 1:55 PM Ni Va <niva...@gmail.com> wrote:

> Do profiler show performance gain for vimscript migrated in vim9 ?

You can see vim9 benchmarks at:
https://github.com/vim/vim/blob/master/README_VIM9.md

That README_VIM9.md file contains the sources of the
benchmarks, so you can run them yourself if you want to verify.

Regards
Dominique

Felipe Contreras

unread,
Dec 3, 2020, 11:41:36 PM12/3/20
to Bram Moolenaar, vim...@googlegroups.com
On Thu, Dec 3, 2020 at 10:10 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

> Oh, you mean using single quotes without the brackets works. Double
> quotes too. That is simpler. Somehow I didn't find this in the
> specification. I see questions on stack overflow from more people who
> are confused about this. Only for JSON it's clear that double quotes
> are always required.

Yeah, I meant 'fg+' (or "fg+").

d = {'key+': 'value'}

--
Felipe Contreras

Ni Va

unread,
Dec 4, 2020, 4:04:53 AM12/4/20
to vim_use
 Why Benchmark does not compare Vim9 to cython instead of python ?

Christian Brabandt

unread,
Dec 4, 2020, 4:10:52 AM12/4/20
to vim_use

On Fr, 04 Dez 2020, Ni Va wrote:

> Why Benchmark does not compare Vim9 to cython instead of python ?

Because nobody has done it. If you can provide benchmarking results,
feel free to open a PR with those additional informations.

Best,
Christian
--
Frage: Welche Hardwareplattform eignet sich am besten, um die
Leistungsfähigkeit von Windows NT zu demonstrieren?
Antwort: Der Overheadprojektor.

Ni Va

unread,
Dec 4, 2020, 4:14:47 AM12/4/20
to vim_use
I'm not a cython or python expert but I'm working on a project that has this kind of code. 
It was just a reflection in the sense that for me vim9 script is precompiled as a cython and not as a python. 

The comparison for me has meaning between two pre-compiled languages. Out of mistake on my part. 

Nota: Sorry for the Pull Request I'm newbee and a simple Vim user

Bram Moolenaar

unread,
Dec 4, 2020, 7:57:01 AM12/4/20
to vim...@googlegroups.com, Ni Va

> I'm not a cython or python expert but I'm working on a project that has
> this kind of code.
> It was just a reflection in the sense that for me vim9 script is
> precompiled as a cython and not as a python.
>
> The comparison for me has meaning between two pre-compiled languages. Out
> of mistake on my part.

It is comparing what is available inside Vim. I don't think cython can
be used as a Vim interface. If you compare with external programs,
write it in C, that's always faster.

--
In Africa some of the native tribes have a custom of beating the ground
with clubs and uttering spine chilling cries. Anthropologists call
this a form of primitive self-expression. In America we call it golf.

Ni Va

unread,
Dec 6, 2020, 1:27:47 PM12/6/20
to vim_use
Is this notation below in red unavailable since recent Vim commits (upper to 8.2.2194) ?

s:higherInfos[apiFileLocation] = 
  \{ blockname: 
    \ { totalnetworks: totalnetworks, 
      \   blocknumber: blocknumber,
      \   networks:  { string(currnetwork): foo.undercursor.variable } 
     \} 
  \}


Ni Va

unread,
Dec 6, 2020, 1:33:50 PM12/6/20
to vim_use
Replacing by This seems good:

      \   networks:  { ['' .. string(currnetwork) ]: foo.undercursor.variable } 


Reply all
Reply to author
Forward
0 new messages