this post was submitted on 05 Apr 2024
8 points (100.0% liked)

VIM - Vi IMproved

1063 readers
1 users here now

For Vim enthusiasts and anyone interested in Vim/Neovim!

"VIM is the greatest editor since the stone chisel." - Dr. Jose Unpingco

#HJKL

founded 1 year ago
MODERATORS
8
submitted 8 months ago* (last edited 8 months ago) by [email protected] to c/[email protected]
 

Vim9Script Types Help

I'm trying to add types to a language list in my vimrc file, the variable looks like this:

var languages = {
  'c': ['c', 'h'],
  'shell': ['sh'],
  'python': ['py'],
  'json': ['json'],
  'typescript': ['tsx', 'jsx', 'js', 'ts'],
}

I've tried adding types like this:

var languages: dict<string, list<string>> {...}

Which should work I think but I'm getting this error:

E488: Trailing characters: , list<string>> = {

I can't figure out which characters are trailing and AI has no idea either.

Solution

I was being a moron and defining a type for the key in the dictionary which makes no sense because the key name would always be a string so therefore only the value type is required:

var languages: dict<list<string>> {...}
you are viewing a single comment's thread
view the rest of the comments
[โ€“] zeet 1 points 8 months ago (1 children)

Shouldn't the last character be a } rather than a ]?

[โ€“] [email protected] 1 points 8 months ago

This is a typo in the post, I'm the actual code it's closed correctly.