vim / vim

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

[vim9script] development tools #13460

Open errael opened 10 months ago

errael commented 10 months ago

This is a companion to #13156 and a comment I was going to add to #13197

vim9script is targeted to both small and large projects. Some features that make it handy for quick and dirty scripting, create issues in larger projects. Development tools would help alleviate the issues.

vim9script want to be suitable for both simple scripting tasks and large scale projects; conflicting requirements. For example, I've grown to like the default constructor for small tasks, but in larger projects I always define

def new()
enddef

to avoid the default constructor.

Instead of pushing the language in one direction or the other, I'd say that vim9script development tools can alleviate a lot of issues associated with the language targeted at both tiny and large projects/tasks.

Consider #13156, if there is a way to scan all files in a project then something like lint could be more easily implemented. Imagine something like

    var proj_info_id = project_scan({files})
    var proj_classes = project_classes(proj_info_id, {filter})

where project_classes() returns maybe a list<dict<any>>, one dict per class. And enough information to report which classes have default constructors. Then it becomes easy to detect and report classes that are using default constructors. Then they can be fixed.

I'd also like to see some code generation commands, there could be a menu of them. For example, one item could be vim9constructor which inserts a constructor based on defined object members, like from :help default-constructor

def new(this.name = v:none, this.age = v:none, this.gender = v:none)
enddef

Anyway, the idea is that vim9script should have development tools. And that these can mitigate the issues of using a language suitable for small scale scripting tasks in a larger project.

dkearns commented 10 months ago

In general, it seems like Vim should ship with a first-class Vim-script development environment. That hasn't been the case, to date.

There are external tools like the vint linter but I don't think it does Vim9 script yet and it's written in Python. Maybe that can be your next project?

@chrisbra, on a related note, I don't suppose you inherited Bram's runtime file linting scripts did you? I asked him for them a few times over the years but he told me I didn't want them. :)

chrisbra commented 10 months ago

yes, those are lost (as all other changes he made to his runtime tree and did not manage to push out since then).