-
Notifications
You must be signed in to change notification settings - Fork 199
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
@annotation.inner and @annotation.outer #684
Comments
In my opinion this is quite niche. But if this can be added to many languages (e.g. python, rust, C, ...), it would make more sense. Some languages have type annotation (TS and Python) and others have just type as a mandatory field (C, Rust). So maybe instead of calling it annotation, it can be called something else? By the way, also note that you can make custom queries for yourself. Even if this doesn't get accepted you can still use it and do whatever you can imagine! |
Yes, I repeat that the bar for adding new types of textobjects is quite high. You need to make a much better case for a new one, including
Remember that consistency across languages is a primary project goal here; we will not make special exceptions for "the best language eva", and especially not web frontend. Such additions belong to dedicated language plugins (as @kiyoon wrote, you can easily extend the bundled queries in your config or a plugin; this is by design). |
Languages that this would impactOk, so first, example for all languages (to show that this is useful in more than just typescript, and to consider the scope of a possible PR implementing all of them. I'd be happy to do it) All Languages that support typesapexInteger age: Integer = 30;
cint age = 30;
c_sharpstring name = "John";
cppint count = 42;
dartint value = 100;
ecmalet isDone: boolean = false;
elixirname :: String.t() = "Alice"
govar isAvailable bool = true
haskellage :: Int
age = 25
hclvariable "count" {
type = number
}
hlslfloat lightIntensity = 1.0f;
javaint speed = 60;
javascriptlet message: string = "Hello";
jsxlet isVisible: boolean = true;
juliax::Int = 42
kotlinval age: Int = 28
lualocal age: number = 30
nimlet pi: float = 3.14
odinpi: f64 = 3.1415;
perlmy int $age = 25;
php$price: float = 19.99;
pythonage: int = 25
rage: numeric = 30
rubyage: Integer = 30
rustlet temperature: f64 = 36.6;
scalaval name: String = "John"
scss$primary-color: Color = #333;
swiftvar isActive: Bool = true
terraformvariable "replicas" {
type = number
}
tsxconst isOnline: boolean = true;
typescriptconst value: string = "hello";
vmut count: int = 10
veriloglogic [7:0] data = 8'b10101010;
vimlet g:age: number = 25
wgslvar<private> color: vec4<f32> = vec4<f32>(1.0, 0.0, 0.0, 1.0);
yamlport: !!int 8080
zigconst value: i32 = 42;
Why is this useful?Changing the type of an assignment is an incredibly common task, at least for me. This isn't possible with any of the current text objects. I had considered some alternatives, e.g. something like this:
But this will be awkward e.g. if the type annotation has spaces, wraps over several lines, etc. I know I could make queries myself, but if I can get a PR for this then it'll improve the experience of, I imagine a lot of people (I'd assume its likely lots more than if It'd be great to be able to just instantly remove a type assignment e.g. with NameI don't have a strong opinion on the name, I had considered |
Without prejudicating any decision on whether this should be added: the name must follow the corresponding highlight capture. |
Ok, so here's some information then In C its So how about the name |
Alternative suggestion: |
Since this will be even more useful and will extend to various contextx e.g. assertions or predicates |
The capture, not the node name. (The latter are very language-dependent, the former not -- that is the point.) |
In that case I think Research: C: https://stackoverflow.com/questions/19345630/c-style-type-annotations-vs-others |
I'd like to
@annotation.inner
and@annotation.outer
if this gets accepted, i'll do a PR for typescript
@annotation.inner and @annotation.outer
If we have
@annotation.inner
:IsString<string>
@annotation.outer
:: IsString<string>
We can use a different name, it's not a big deal to me
The text was updated successfully, but these errors were encountered: