Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vfmt: automatically add imports for vlib modules #23389

Open
2 tasks
islonely opened this issue Jan 6, 2025 · 4 comments
Open
2 tasks

vfmt: automatically add imports for vlib modules #23389

islonely opened this issue Jan 6, 2025 · 4 comments
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.

Comments

@islonely
Copy link
Contributor

islonely commented Jan 6, 2025

Describe the feature

vfmt should get the mod names from the vlib directory and add import <mod_name> to the top of your file if it's missing.

Use Case

source:

fn main() {
	println(time.minute)
}

after running v fmt -w <file>:

module main

import time

fn main() {
	println(time.minute)
}

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.9 495adc9

Environment details (OS name and version, etc.)

V 0.4.9 4225a34.495adc9
V full version V 0.4.9 4225a34.495adc9
OS macos, macOS, 15.1.1, 24B91
Processor 8 cpus, 64bit, little endian, Apple M3
Memory 0.11GB/16GB
V executable /Users/adamoates/v/v
V last modified time 2025-01-04 20:09:49
V home dir OK, value: /Users/adamoates/v
VMODULES OK, value: /Users/adamoates/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/adamoates/Documents/shattlebip
Git version git version 2.39.5 (Apple Git-154)
V git status weekly.2024.53-29-g495adc9c (8 commit(s) behind V master)
.git/config present true
cc version Apple clang version 16.0.0 (clang-1600.0.26.4)
gcc version Apple clang version 16.0.0 (clang-1600.0.26.4)
clang version Apple clang version 16.0.0 (clang-1600.0.26.4)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 713692d4
emcc version N/A
glibc version N/A
> [!NOTE] > You can use the 👍 reaction to increase the issue's priority for developers. > > Please note that only the 👍 reaction to the issue itself counts as a vote. > Other reactions and those to comments will not be taken into account.
@felipensp felipensp added the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Jan 6, 2025
@jorgeluismireles
Copy link

Afaik vfmt is not even able to sort import rows alphabetically. Is not too much for vfmt to append "missing" rows?

@JalonSolov
Copy link
Contributor

It doesn't sort now... but it could. It could also add missing imports... maybe?

@spytheman
Copy link
Member

It should not sort stuff, especially imports.

@JalonSolov
Copy link
Contributor

It would be fine if it sorted them, as long as there was no order-dependence on the imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants