-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Conversation
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.
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))))) |
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.
How would you pronounce this expression aloud? =S (I'm an Elisp newb.)
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.
"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
plugin/emacs/eglot-quicklintjs.el
Outdated
:type '(repeat string)) | ||
|
||
(add-to-list 'eglot-server-programs `(js-mode . (,eglot-quicklintjs-program | ||
"--lsp" |
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.
Nit: Prefer the full option name in scripts:
"--lsp" | |
"--lsp-server" |
plugin/emacs/eglot-quicklintjs.el
Outdated
@@ -0,0 +1,62 @@ | |||
;;; eglot-quicklintjs --- Eglot support for quick-lint-js -*- lexical-binding: t; -*- |
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.
Can this be called eglot-quick-lint-js
? (Same with flymake and lsp-mode.) Or are hyphens disallowed?
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.
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)) |
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.
Nit: Indentation looks off to me. Shouldn't there be two more spaces before this line to align it with line 15?
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'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
plugin/emacs/lsp-quicklintjs.el
Outdated
|
||
(lsp-register-client | ||
(make-lsp-client | ||
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp" |
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.
Nit: Prefer the full option name in scripts:
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp" | |
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp-server" |
plugin/emacs/lsp-quicklintjs.el
Outdated
|
||
(lsp-register-client | ||
(make-lsp-client | ||
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp" |
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.
Nit: Collapse interior whitespace?
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp" | |
:new-connection (lsp-stdio-connection `(,lsp-quicklintjs-program "--lsp" |
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 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))))) |
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.
Nit: Collapse interior whitespace?
(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; -*- |
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 see why people prefer Flycheck over Flymake... You sure have to do a lot of work yourself.
(funcall report-fn | ||
:panic :explanation | ||
(buffer-substring | ||
(point-min) (progn (goto-char (point-min)) | ||
(line-end-position))))))))) |
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.
👍
Can you show what a panic looks like in Emacs' UI?
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.
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.
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
|
@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. |
@strager force pushed to fix a merge conflict, ill be updating the README later tonight |
test/test-lsp-server.cpp
Outdated
::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); |
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.
Blocking: uri
and version
changed to string8_view
. This is the cause of your build failures:
::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"); |
Signed-off-by: wagner riffel <[email protected]>
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]>
Signed-off-by: wagner riffel <[email protected]>
Signed-off-by: wagner riffel <[email protected]>
Signed-off-by: wagner riffel <[email protected]>
Signed-off-by: wagner riffel <[email protected]>
adds support for eglot, lsp-mode and flymake
use
--stdin
flag in flycheckstill missing update in README documentation, that's a WIP.