Vim9Script Types Help

3 years ago by mac to c/vim

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>> {...}
knF 2 points 3 years ago

Could it be because you didn't close the >> after dict<<string ?

path: 0 9131648, hotness: undefined, score: 2, children: 1
mac 2 points 3 years ago

No it's dry l definitely fixed, I managed to get some help elsewhere, the solution was the fact that I'm seeing the your got the dictionary's key, which makes no sense because it would always be a string.

path: 0 9131648 9135368, hotness: undefined, score: 2, children: 0
zeet 1 point 3 years ago

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

path: 0 9130803, hotness: undefined, score: 1, children: 1
mac 1 point 3 years ago

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

path: 0 9130803 9135336, hotness: undefined, score: 1, children: 0
vim
vim

@lemmy.sdf.org

login for more options
1239
41
8

For Vim enthusiasts and anyone interested in Vim/Neovim!

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

#HJKL

go to feed...