quick-lint / quick-lint-js

quick-lint-js finds bugs in JavaScript programs
https://quick-lint-js.com
GNU General Public License v3.0
1.53k stars 192 forks source link

50$: Sublime Text plugin #180

Open strager opened 3 years ago

strager commented 3 years ago

Sublime Text looks like a popular editor for JS development, according to a survey: https://2019.stateofjs.com/other-tools/

strager commented 3 years ago

Documentation: https://www.sublimetext.com/docs/api_reference.html

ghost commented 3 years ago

I claim this for-hire task. I expect payment after I complete this task. I will email the quick-lint-js team if I am assigned this task.

strager commented 3 years ago

@welenofsky made some progress on a Sublime Text plugin already: https://github.com/welenofsky/quick-lint-js-sublime

@welenofsky, do you plan on continuing work on your Sublime Text plugin? Should @cahian pick up your work and continue it?

strager commented 3 years ago

@welenofsky isn't responding, so I give @cahian the green light to hack on this task.

welenofsky commented 3 years ago

@strager I apologize for the delayed response. @cahian can take this one.

strager commented 3 years ago

@cahian Any progress?

ghost commented 3 years ago

@strager Yes. #328

strager commented 2 years ago

I added instructions for installing quick-lint-js for Sublime Text with sublimelsp: https://quick-lint-js.com/install/sublime/

This task is still valid and welcomed. The installation process with LSP is ugly, and performance is suboptimal.

kaste commented 2 years ago

I claim this for-hire task. I expect payment after I complete this task. I will email the quick-lint-js team if I am assigned this task.

I will write a package/plugin for SublimeLinter. (Comparable to the vim integration via ale.) SublimeLinter is the standard linter interface/framework for Sublime -- and I'm also the author of it. The plugin would be hosted on the official SublimeLinter org or your org (or under my username) as a separate repo and registered with PackageControl (the official and only package manager for Sublime Text.)

strager commented 2 years ago

@kaste Sorry, but this task isn't available for claiming right now.

This task was claimed by someone else already. They deleted their GitHub account, which made GitHub remove the assignee for this task.

The person who claimed the task has a mostly-working implementation which I need to finish. Development has been behind the scenes, and thus hasn't been documented publicly in this GitHub issue. =S

I will write a package/plugin for SublimeLinter.

For quick-lint-js, is there a major difference between SublimeLinter and the LSP package? quick-lint-js already works with Sublime's LSP package: https://quick-lint-js.com/install/sublime/nix/

This task is for more tight integration with Sublime Text, leading to simpler installation. It seems like SublimeLinter integration would not meet the simpler-installation requirement; the user would need to install quick-lint-js (OS-specific), the SublimeLinter package, and the SublimeLinter quick-lint-js package.

kaste commented 2 years ago

Erm, you can't do a package for linting that doesn't integrate into LSP and SublimeLinter because what the user wants is an error panel, inline annotations, vast ways to customize the underlines/squiggles, info in the status bar, key bindings to go to the next and previous error. And of course typically you run multiple linters or "tools" on the same file so you need an integration for that. What do you think how many commits and how many lines just the squiggling took?

Of course, you can or could also auto-install binaries. I'm not a fan of auto-downloading binaries and running them. I think the user should initiate something like this. (We're in an IDE so we surely don't run sandboxed in any way.) But it feels nice, yeah: it just works, hooray. (But here we have native binaries, it's not a simple npm install and let npm figure out on what OS and architecture we are -- and probably do the compile.) How do we update; should I scan your Apache server? So it is doable but here for your case: 1. do a winget install ... (et.al. for different platforms) is a global install, and I don't think we can do that "behind the scenes", 2. downloading zips with binaries and extracting them (aka local installation) from a random Apache server (of course it's yours right now) is a no-go. Do you want to ship all-inclusive, so the Sublime package updates everytime the main repo releases?

SublimeLinter is still the linting framework, and you're only linting ("publishDiagnostics") here; LSP does all-the-things. The plugin I wrote yesterday basically squiggled the view and updated the error panel while typing. I had response times around 60ms from last-keystroke-to-updated-panel which is almost instant. (I could get them down to 40ms, don't know if that is preferable and leads to good interaction between all other linters/tools.) Never had a linter that fast. 😆 🤷

lAzXefYTxz

https://recordit.co/lAzXefYTxz Low fps but you get the feel, it's beyond everything.

strager commented 2 years ago

Erm, you can't do a package for linting that doesn't integrate into LSP and SublimeLinter because what the user wants is an error panel, inline annotations, vast ways to customize the underlines/squiggles, info in the status bar, key bindings to go to the next and previous error. And of course typically you run multiple linters or "tools" on the same file so you need an integration for that.

I did some research, and I think you're right. The plugin which Cahian was writing doesn't have these features. But users almost certainly want them.

The plugin I wrote yesterday basically squiggled the view and updated the error panel while typing. I had response times around 60ms from last-keystroke-to-updated-panel which is almost instant. (I could get them down to 40ms, don't know if that is preferable and leads to good interaction between all other linters/tools.) Never had a linter that fast. laughing shrug

60 milliseconds is extremely slow. Is most of the overhead in SublimeLinter?

strager commented 2 years ago

I will write a package/plugin for SublimeLinter.

@kaste I am fine with you working on this task. The work done by the previous engineer is not based on SublimeLinter, so most of it needs to be rewritten. We might be able to reuse some of the Python<->C++ glue code.

Let me know if you're still interested in working on this task given the constraints below:

(Comparable to the vim integration via ale.)

I want the plugin to embed quick-lint-js as a native Python module (.so on Linux, for example) using Python's C API or ctypes. I do not want the user to need to install quick-lint-js separately. I do not want SublimeLinter using quick-lint-js' CLI or LSP server.

The plugin would be hosted on the official SublimeLinter org or your org (or under my username) as a separate repo

Given that I want quick-lint-js compiled as a Python module, I think it'd be best if the native Python module was stored in the same repo as the rest of quick-lint-js' C++ code. In other words, the Sublime Text plugin source code should be in the plugin/sublime-text/ directory of the main quick-lint-js repo.

kaste commented 2 years ago

60 milliseconds is extremely slow

No, it's not. I did this on Windows with the natural overhead of starting the processes. That is: I had 40ms runtime of the tool, plus (40/2)ms wait time. (The default wait/debounce time is just half the time the tool takes to run.) There were no overhead in SublimeLinter as processing e.g. 10 errors takes no time of course. (There is or can be always a "random" penalty somewhere when Sublime Text blocks for short periods of time. But of course it only blocks if the users does something more important than drawing squiggles.)

So I had 40ms runtime which is almost as low as I can get on my home machine (with regards to running subprocesses coming from python on Window.) On a Mac you would have a 10 here. Plus 5ms wait time.

As I said Sublime Text has only one package manager. And for that you need one repo you register against it. I don't see how plugin/sublime-text/ would work here. I think you would need to write a CI action or whatever that copies/builds the Sublime plugin whenever appropriate. But what do I know.

There is a fundamental misunderstanding from my side though because I can't do hours or weeks of work for 50$. Writing a SublimeLinter plugin is okay for that money, but all the other things not.

strager commented 2 years ago

60 milliseconds is extremely slow

No, it's not. I did this on Windows with the natural overhead of starting the processes. That is: I had 40ms runtime of the tool, plus (40/2)ms wait time. [...]

So I had 40ms runtime which is almost as low as I can get on my home machine (with regards to running subprocesses coming from python on Window.) On a Mac you would have a 10 here. Plus 5ms wait time.

Right. That is slow.

A good quick-lint-js plugin should not call CreateProcessW every keystroke.

As I said Sublime Text has only one package manager. And for that you need one repo you register against it. I don't see how plugin/sublime-text/ would work here. I think you would need to write a CI action or whatever that copies/builds the Sublime plugin whenever appropriate.

I didn't know that Package Control was so picky. Thanks for bringing this to my attention.

I checked Package Control's docs. Because we need build artifacts anyway (the compiled .so/.dll/.dylib files), I think "Host .sublime-package files and a packages.json on a web server with SSL" is the most appropriate option for quick-lint-js.

I can do the packaging parts myself. This task is just for the plugin, not distribution.

kaste commented 2 years ago

In the meantime: https://packagecontrol.io/packages/SublimeLinter-contrib-quick-linter-js

That's actually what could be 50$ IMO. Anyhow, I thought host-your-own-channel is only for special members of the community. SublimeLinter itself (currently me) hosts such a channel of course.