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

Intellisense #39

Closed
Di-KaZ opened this issue Aug 11, 2023 · 11 comments
Closed

Intellisense #39

Di-KaZ opened this issue Aug 11, 2023 · 11 comments

Comments

@Di-KaZ
Copy link

Di-KaZ commented Aug 11, 2023

Hi there !

Great work with ags looking forwad to use it,

How can one get intellisense on its config file using ags ?

Even better, is it possible to write it in typescript ?

Thanks in advance :)

edit : wrong repo, my bad

@Aylur Aylur transferred this issue from Aylur/dotfiles Aug 11, 2023
@Aylur
Copy link
Owner

Aylur commented Aug 11, 2023

I don't think it's possible to get intellisense right now, since you are essentially working with plain js obsects.
If you want to use typescript I would have a line in config.js that would run tsc before importing modules.

I have some plans for ags v1 where instead of passing plain objects you would pass them with a function call like

// instead of this
const button1 = ags.Widget({
  type: 'button',
  onClick: () => {},
  child: { type: 'box', children: [/* widgets*/] }
});

// you would do this
const button2 = Button({
  onClick: () => {},
  child: Box({ children: [/* widgets */] )}
});

and with this, it would be possible to import function definitions and therefore have intellisense

@Aylur
Copy link
Owner

Aylur commented Aug 11, 2023

But for user defined widgets I am not sure how intellisense would be achieved, since imports is not recognized like import, at least not on whatever lsp I have

@Di-KaZ
Copy link
Author

Di-KaZ commented Aug 13, 2023

That would be really cool to be able to get intellisense, your proposed syntax looks great

I saw some libs for gjs that can be used to generate typing for it maybe, you can benefit from it

Thank you for your answer

@Aylur
Copy link
Owner

Aylur commented Aug 13, 2023

Just saw gnome migrate to es modules. I will do the same and the import problem will be solved too

@Suyashtnt
Copy link

Any progress on the migration to ESM? Has it potentially improved typings?

@Aylur
Copy link
Owner

Aylur commented Aug 24, 2023

Custom defined widgets are automatically inferred, since they are just functions, but the builtin widgets don't have type definitions yet, JsDoc might be better than typescript types, since most people are not using tsserver, but I don't have the patience to write them manually

@Suyashtnt
Copy link

Custom defined widgets are automatically inferred, since they are just functions, but the builtin widgets don't have type definitions yet, JsDoc might be better than typescript types, since most people are not using tsserver, but I don't have the patience to write them manually

you can import dts files in jsdoc. Maybe using https://github.com/Rich-Harris/dts-buddy to create a dts file and shipping that as a downloadable to put into your ~/.config/ags file could be a good idea

@nenikitov
Copy link
Contributor

Here is ags.ts file I made for my config to get intellisense. I have it in the .config/ags.

This file is incomplete: there are TODOs left and I didn't cover all widget properties.

@Aylur
Copy link
Owner

Aylur commented Nov 6, 2023

11414ff

@Aylur Aylur closed this as completed Nov 6, 2023
@Eclextic
Copy link

Eclextic commented Nov 6, 2023

@Aylur
So how exactly does this now work?
I pulled the changes... Nothing changed? No Intellisense?

Could you please elaborate on why this was closed?

@Aylur Aylur reopened this Nov 6, 2023
@Aylur
Copy link
Owner

Aylur commented Nov 6, 2023

Didn't mean to reopen, I just missclicked
Checkout the typescript wiki page, you need to grab tsconfig.json, package.json and run the setup script that will grab the typedefinitions

@Aylur Aylur closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants