-
Notifications
You must be signed in to change notification settings - Fork 136
Completions based on your path #17
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
Conversation
@skovhus I'd love if you could give this a review. I realise it's a bit messy, sorry about that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff! If you have time it would be super nice to have one PR with the change to move to a class based approach. And the motivation. : )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a skip here.
Btw, you should remove the "It" from the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skovhus The skip
is there because the test fails currently as it doesn't look at the executable bit yet 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using await
in these tests might make it easier. Then you don’t need the expect.assertions. : )
server/src/analyser.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: iniailize
server/src/analyser.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling: provdied
server/src/analyser.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we change to underscore here?
@skovhus I moved to using classes as I didn't like having state in the modules as top-level const
s. With a class based approach it's clear what the state is and where it lives :) Are you against using classes? If so why? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that you are using await
you don't need:
expect.assertions(1)
- and returning the last
expect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mads-hartmann this was the reason why I suggested using await
here, so we could get rid of these extra things you need to remember to do. : )
With a class based approach it's clear what the state is and where it lives :) Are you against using classes? If so why?
So if you need state (which you do), then I usually go for small files with top-level state variable(s). The singleton module pattern makes this possible... I'm just very used to this pattern.
If using classes makes this more clear then I'm all for it. 👍But interesting if I should start using this more... 🤔
server/src/analyser.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should an export default class Analyzer
here, so import would be import Analyzer from ...
.
server/src/executables.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest export default
server/src/executables.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would call this findExecutablesInPath
, then we can almost get rid of the code comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: I prefer not having code comments like this and make the function name more descriptive: execShellScript(body: string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use https://github.com/sindresorhus/execa for all child process handling. It has a few advantages but also introduces more dependencies. Pros cons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skovhus Let's switch to execa
if we find bugs in this code :)
server/src/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: superfluous comment... In general, I really try to get rid of most code comments as:
- they quickly become outdated
- the code can often explain itself (or at least it should)
- when code needs a comment (and sometimes it really does), the comment now becomes visible (as less important comments are gone)
server/src/server.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest export default
server/src/analyser.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would rename all of these, so the comment would become superfluous.
Example: uriToFileContent
, uriToTreeSitterDocument
. I would prefer that. : )
It uses the MAN pages for the executable to provide extra information on hover and in the completion selection menu. I also ended up refactoring most of the code so this is a bit of a messy commit. Sorry.
9dae994
to
be1d796
Compare
No description provided.