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

improve emacs support #353

Merged
merged 7 commits into from
Jun 13, 2021
Merged

improve emacs support #353

merged 7 commits into from
Jun 13, 2021

Conversation

wgrr
Copy link
Contributor

@wgrr wgrr commented Jun 10, 2021

adds support for eglot, lsp-mode and flymake
use --stdin flag in flycheck

still missing update in README documentation, that's a WIP.

Copy link
Collaborator

@strager strager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I enjoyed reading each commit.

Blocking: But tests are failing on CI. =[ Please fix.

Nit: Commit message of commit d5ebeb6 says 'Flamake', but I assume you meant 'Flymake'?

:error-explainer (lambda (err)
(let ((error-code (flycheck-error-id err))
(url "https://quick-lint-js.com/errors/#%s"))
(and error-code `(url . ,(format url error-code)))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you pronounce this expression aloud? =S (I'm an Elisp newb.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"error-code and quote to cons url onto string" perhaps? not sure if that helps much, but it's somehow equialent to:

(and error-code (cons url (format url error-code)))

the backtick quoting differs from apostrophe in that it allows some evaluation inside the quoting, here ,(format url error-code) becomes a cons which car is https://quick-lint-js.com/errors/#%s and cdr is https://quick-lint-js.com/errors/#ENNN

:type '(repeat string))

(add-to-list 'eglot-server-programs `(js-mode . (,eglot-quicklintjs-program
"--lsp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Prefer the full option name in scripts:

Suggested change
"--lsp"
"--lsp-server"

@@ -0,0 +1,62 @@
;;; eglot-quicklintjs --- Eglot support for quick-lint-js -*- lexical-binding: t; -*-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be called eglot-quick-lint-js? (Same with flymake and lsp-mode.) Or are hyphens disallowed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is supposed to be shuold be the file name, it's missing a .el

(mapcar (lambda (pkg) (unless (package-installed-p pkg)
(if (> emacs-major-version 24)
(package-install pkg t)
(package-install pkg)))) deps))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Indentation looks off to me. Shouldn't there be two more spaces before this line to align it with line 15?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been indenting with a script that runs emacs commad "indent-region" in the file, it does indent as you're looking, and lisp code inside emacs /lisp directory is also indented like this:

 (if (> 0 0) ; cond
     (foo) ; then
   (bar)   ; else

so i think it's correct according to Emacs standards


(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Prefer the full option name in scripts:

Suggested change
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp"
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp-server"


(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Collapse interior whitespace?

Suggested change
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp"
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp"

Copy link
Contributor Author

@wgrr wgrr Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catches, i can't tell the difference in the editor, my font is too small :(

(when (>= emacs-major-version 26)
(require 'lsp-quicklintjs)
(ert-deftest quicklintjs-is-in-lsp-clients ()
(should (gethash 'quick-lint-js lsp-clients)))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Collapse interior whitespace?

Suggested change
(should (gethash 'quick-lint-js lsp-clients)))))
(should (gethash 'quick-lint-js lsp-clients)))))

@@ -0,0 +1,138 @@
;;; flymake-quicklintjs.el --- Flymake support for quick-lint-js -*- lexical-binding: t; -*-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why people prefer Flycheck over Flymake... You sure have to do a lot of work yourself.

Comment on lines +108 to +114
(funcall report-fn
:panic :explanation
(buffer-substring
(point-min) (progn (goto-char (point-min))
(line-end-position)))))))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Can you show what a panic looks like in Emacs' UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show what a panic looks like in Emacs' UI?

There is no UI for this, a "panic" just tells that flymake that the backend should be disable and logs the :explanation in flymake log buffer, when i first made this i think i was stuck with a crash/restart.

@wgrr
Copy link
Contributor Author

wgrr commented Jun 11, 2021

Blocking: But tests are failing on CI. =[ Please fix.

I think flymake have had a rework after version 26 of Emacs, i'll check what's with up with version 24 that's running ni C.I

Nit: Commit message of commit d5ebeb6 says 'Flamake', but I assume you meant 'Flymake'?
Yes it's typo

@strager strager linked an issue Jun 11, 2021 that may be closed by this pull request
11 tasks
@wgrr
Copy link
Contributor Author

wgrr commented Jun 11, 2021

@strager The issue with CI was that Emacs 24 has a complete different Flymake implementation, there is no easy way to fix this other than skiping, I feel we should upgrade emacs to at least 26 in CI, since it's by far the most supported version (minimum version for Flymake, Eglot and lsp-mode) and the current version for debian-stable.

@wgrr
Copy link
Contributor Author

wgrr commented Jun 11, 2021

@strager force pushed to fix a merge conflict, ill be updating the README later tonight

Comment on lines 291 to 296
::simdjson::ondemand::value& uri,
::simdjson::ondemand::value& version,
byte_buffer& notification_json) {
EXPECT_EQ(code, u8"let x = x;");
EXPECT_EQ(simdjson_to_jsoncpp(uri), "file:///test.js");
EXPECT_EQ(simdjson_to_jsoncpp(version), 10);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: uri and version changed to string8_view. This is the cause of your build failures:

Suggested change
::simdjson::ondemand::value& uri,
::simdjson::ondemand::value& version,
byte_buffer& notification_json) {
EXPECT_EQ(code, u8"let x = x;");
EXPECT_EQ(simdjson_to_jsoncpp(uri), "file:///test.js");
EXPECT_EQ(simdjson_to_jsoncpp(version), 10);
string8_view uri_json,
string8_view version_json,
byte_buffer& notification_json) {
EXPECT_EQ(code, u8"let x = x;");
EXPECT_EQ(uri_json, u8"\"file:///test.js\"");
EXPECT_EQ(version_json, u8"10");

@strager
Copy link
Collaborator

strager commented Jun 13, 2021

Aside from the test failures, this PR looks good to me.

FYI: When I merge, I'm gonna apply each commit (not squash), except I'm going to fold 311a201 into 8f76d86 and 775e956.

wgrr added 7 commits June 13, 2021 22:24
Also while at it, remove tabs accidentally introduced by vim and correct
the Flycheck spelling.

Signed-off-by: wagner riffel <[email protected]>
This commit also ignores client notifications that would make
quicklintjs to crash and accept "js" as a language_id for files,
that's what Eglot uses for JavaScript.

Signed-off-by: wagner riffel <[email protected]>
@wgrr
Copy link
Contributor Author

wgrr commented Jun 13, 2021

@strager
oops, i didn't noticed the change makes it fail, my bad.

Also, folded 311a201 into 8f76d86 and 775e956

@strager strager merged commit d7e006a into quick-lint:master Jun 13, 2021
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

Successfully merging this pull request may close these issues.

emacs plugin development track
2 participants