-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
wip: fix #396, #395 and #398 #409
base: master
Are you sure you want to change the base?
Changes from 6 commits
387222b
8b97ef1
15b9fd9
7646781
316e270
cb63a3b
8dda3dc
4319619
57bc1cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,81 @@ | ||||||
# Copyright (C) 2020 Matthew "strager" Glazar | ||||||
# See end of file for extended copyright information. | ||||||
|
||||||
if (QUICK_LINT_JS_EMACS) | ||||||
set(QUICK_LINT_JS_EMACS "${QUICK_LINT_JS_EMACS}") | ||||||
else () | ||||||
find_program(QUICK_LINT_JS_EMACS "emacs") | ||||||
endif () | ||||||
|
||||||
if (NOT QUICK_LINT_JS_EMACS) | ||||||
message(WARNING "Emacs not found. Skipping... ") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think this message is noisy. I'd omit it.
Suggested change
|
||||||
return () | ||||||
endif () | ||||||
|
||||||
execute_process( | ||||||
COMMAND | ||||||
${QUICK_LINT_JS_EMACS} | ||||||
-Q -batch | ||||||
--eval "(princ (format \"%s.%s\" emacs-major-version emacs-minor-version))" | ||||||
RESULT_VARIABLE EMACS_EXIT_CODE | ||||||
OUTPUT_VARIABLE EMACS_VERSION) | ||||||
|
||||||
if (NOT EMACS_EXIT_CODE EQUAL 0) | ||||||
message(WARNING "Emacs (${QUICK_LINT_JS_EMACS}) found but can't get its version. Skipping...") | ||||||
return () | ||||||
endif() | ||||||
|
||||||
if (NOT EMACS_VERSION GREATER_EQUAL 24.5) | ||||||
message(WARNING "Emacs found (${QUICK_LINT_JS_EMACS}), but version ${EMACS_VERSION} is not supported. Skipping...") | ||||||
return () | ||||||
endif () | ||||||
|
||||||
set(QUICK_LINT_JS_EMACS_FOUND TRUE) | ||||||
message(STATUS "Found Emacs: (${QUICK_LINT_JS_EMACS}) suitable version ${EMACS_VERSION} minimum required is 24.5") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Match format of similar messages in CMake:
Suggested change
|
||||||
|
||||||
macro(emacs_pkg_target NAME FILE) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I'd put this macro in plugin/emacs/CMakeLists.txt instead of here. This macro is tightly coupled to quicklintjs-pkg.el, so I think the two belong next to each other. |
||||||
cmake_parse_arguments( | ||||||
"" | ||||||
"" | ||||||
"OUTPUT" | ||||||
"" | ||||||
${ARGN}) | ||||||
|
||||||
add_custom_command( | ||||||
OUTPUT ${_OUTPUT} | ||||||
COMMAND | ||||||
${QUICK_LINT_JS_EMACS} | ||||||
-Q -batch | ||||||
-l package --eval "(package-initialize)" | ||||||
--eval "(add-to-list 'package-directory-list \"${CMAKE_CACHEFILE_DIR}\")" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why add CMAKE_CACHEFILE_DIR? What files are in the build dir that we need to expose to Emacs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's the output directory for the package, otherwise Emacs would make it somewhere on its defaults, (probably There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh. It looked like an input directory to me.
I think specifying cwd explicitly is what we should do: add_custom_command(
OUTPUT ${_OUTPUT}
COMMAND
${QUICK_LINT_JS_EMACS}
-Q -batch
-l package --eval "(package-initialize)"
--eval "(add-to-list 'package-directory-list .)"
...
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
...
) |
||||||
-l ${CMAKE_CURRENT_LIST_DIR}/quicklintjs-pkg.el | ||||||
-f quicklintjs-batch-make-pkg | ||||||
${FILE} | ||||||
DEPENDS | ||||||
${QUICK_LINT_JS_EMACS} | ||||||
${CMAKE_CURRENT_LIST_DIR}/quicklintjs-pkg.el | ||||||
${FILE} | ||||||
VERBATIM) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: This command is pretty noisy during building. Can we silence the output unless there is an error or warning?
|
||||||
|
||||||
add_custom_target(${NAME} ALL DEPENDS ${_OUTPUT}) | ||||||
endmacro () | ||||||
|
||||||
mark_as_advanced(QUICK_LINT_JS_EMACS) | ||||||
|
||||||
# quick-lint-js finds bugs in JavaScript programs. | ||||||
# Copyright (C) 2020 Matthew "strager" Glazar | ||||||
# | ||||||
# This file is part of quick-lint-js. | ||||||
# | ||||||
# quick-lint-js is free software: you can redistribute it and/or modify | ||||||
# it under the terms of the GNU General Public License as published by | ||||||
# the Free Software Foundation, either version 3 of the License, or | ||||||
# (at your option) any later version. | ||||||
# | ||||||
# quick-lint-js is distributed in the hope that it will be useful, | ||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
# GNU General Public License for more details. | ||||||
# | ||||||
# You should have received a copy of the GNU General Public License | ||||||
# along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,13 +4,54 @@ | |||||
cmake_minimum_required(VERSION 3.10) | ||||||
include(GNUInstallDirs) | ||||||
|
||||||
install( | ||||||
FILES flycheck-quicklintjs.el | ||||||
FILES lsp-quicklintjs.el | ||||||
FILES eglot-quicklintjs.el | ||||||
FILES flymake-quicklintjs.el | ||||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp" | ||||||
) | ||||||
find_package(QuickLintJsEmacs) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Spelling:
Suggested change
|
||||||
|
||||||
if (QUICK_LINT_JS_EMACS_FOUND) | ||||||
emacs_pkg_target(emacs-plugin-quicklintjs | ||||||
${CMAKE_CURRENT_LIST_DIR}/quicklintjs.el 0.0.1 | ||||||
OUTPUT quicklintjs-0.0.1) | ||||||
|
||||||
emacs_pkg_target(emacs-plugin-flycheck-quicklintjs | ||||||
${CMAKE_CURRENT_LIST_DIR}/flycheck-quicklintjs.el 0.0.1 | ||||||
OUTPUT flycheck-quicklintjs-0.0.1) | ||||||
|
||||||
emacs_pkg_target(emacs-plugin-flymake-quicklintjs | ||||||
${CMAKE_CURRENT_LIST_DIR}/flymake-quicklintjs.el 0.0.1 | ||||||
OUTPUT flymake-quicklintjs-0.0.1) | ||||||
|
||||||
emacs_pkg_target(emacs-plugin-eglot-quicklintjs | ||||||
${CMAKE_CURRENT_LIST_DIR}/eglot-quicklintjs.el 0.0.1 | ||||||
OUTPUT eglot-quicklintjs-0.0.1) | ||||||
|
||||||
emacs_pkg_target(emacs-plugin-lsp-quicklintjs | ||||||
${CMAKE_CURRENT_LIST_DIR}/lsp-quicklintjs.el 0.0.1 | ||||||
OUTPUT lsp-quicklintjs-0.0.1) | ||||||
|
||||||
add_dependencies(emacs-plugin-flycheck-quicklintjs | ||||||
emacs-plugin-quicklintjs) | ||||||
add_dependencies(emacs-plugin-flymake-quicklintjs | ||||||
emacs-plugin-quicklintjs) | ||||||
add_dependencies(emacs-plugin-eglot-quicklintjs | ||||||
emacs-plugin-quicklintjs) | ||||||
add_dependencies(emacs-plugin-lsp-quicklintjs | ||||||
emacs-plugin-quicklintjs) | ||||||
|
||||||
install( | ||||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/quicklintjs-0.0.1 | ||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp/elpa) | ||||||
install( | ||||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/flycheck-quicklintjs-0.0.1 | ||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp/elpa) | ||||||
install( | ||||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/flymake-quicklintjs-0.0.1 | ||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp/elpa) | ||||||
install( | ||||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/eglot-quicklintjs-0.0.1 | ||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp/elpa) | ||||||
install( | ||||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lsp-quicklintjs-0.0.1 | ||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp/elpa) | ||||||
endif () | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need five separate packages? Could we make just one package? Seems simpler to make one package IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, to use what emacs calls "multi-file" packages, it would require There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
CMake provides a tool to create
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @strager i made the change to use a tar archive as a single package, besides that it feel clunky, it's discouraged by package archives, do you think the last "problem" in this list applies here? i do think. https://github.com/melpa/melpa/blob/5d49574/CONTRIBUTING.org#fixing-typical-problems There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Having multiple .el files in a package is discouraged? O_o I'm unsure if that's what the documentation actually says.
It says:
What does it mean to "look at" an .el file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In short, an .el file can be package on its own, its format something along the lines:
so when it says "look at" an .el file, is an .el file which is in this package format, when a package has multiple .el files, this format is not used, instead there should be a tar archive that contains all .el files along with a magic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we should do one of two things:
I'm happy with the tar if it's already implemented and if it makes developing the plugin easier for us. |
||||||
|
||||||
# quick-lint-js finds bugs in JavaScript programs. | ||||||
# Copyright (C) 2020 Matthew "strager" Glazar | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
;;; eglot-quicklintjs.el --- Eglot support for quick-lint-js -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (C) 2020 Matthew "strager" Glazar | ||
|
||
;; Version: 0.0.1 | ||
;; Author: Wagner Riffel <[email protected]> | ||
;; URL: https://quick-lint-js.com | ||
;; Keywords: languages, tools | ||
;; Package-Requires: ((quicklintjs "0.0.1") (eglot "1.7") (emacs "26.1")) | ||
|
||
;; This file is part of quick-lint-js. | ||
;; | ||
;; quick-lint-js is free software: you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
;; | ||
;; quick-lint-js is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
;; | ||
;; You should have received a copy of the GNU General Public License | ||
;; along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
|
||
;; Eglot support for quick-lint-js. | ||
|
@@ -19,44 +42,13 @@ | |
;;; Code: | ||
|
||
(require 'eglot) | ||
(require 'quicklintjs) | ||
|
||
(defgroup eglot-quicklintjs nil | ||
"quick-lint-js Eglot integration." | ||
:group 'eglot-quicklintjs | ||
:link '(url-link :tag "Website" "https://quick-lint-js.com")) | ||
|
||
(defcustom eglot-quicklintjs-program "quick-lint-js" | ||
"Path to quick-lint-js program to run." | ||
:group 'eglot-quicklintjs | ||
:type 'stringp) | ||
|
||
(defcustom eglot-quicklintjs-args nil | ||
"Arguments to quick-lint-js." | ||
:group 'eglot-quicklintjs | ||
:type '(repeat string)) | ||
|
||
(add-to-list 'eglot-server-programs `(js-mode . (,eglot-quicklintjs-program | ||
"--lsp-server" | ||
,@eglot-quicklintjs-args))) | ||
;;;###autoload | ||
(with-eval-after-load 'eglot | ||
(add-to-list 'eglot-server-programs `(js-mode . ,(quicklintjs-find-program | ||
"--lsp-server")))) | ||
|
||
(provide 'eglot-quicklintjs) | ||
|
||
;; quick-lint-js finds bugs in JavaScript programs. | ||
;; Copyright (C) 2020 Matthew Glazar | ||
;; | ||
;; This file is part of quick-lint-js. | ||
;; | ||
;; quick-lint-js is free software: you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
;; | ||
;; quick-lint-js is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
;; | ||
;; You should have received a copy of the GNU General Public License | ||
;; along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; eglot-quicklintjs.el ends here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
;;; flycheck-quicklintjs --- quick-lint-js Flycheck support -*- lexical-binding: t; -*- | ||
;;; flycheck-quicklintjs.el --- quick-lint-js Flycheck support -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (C) 2020 Matthew "strager" Glazar | ||
|
||
;; Version: 0.0.1 | ||
;; Author: Wagner Riffel <[email protected]> | ||
;; URL: https://quick-lint-js.com | ||
;; Keywords: languages, tools | ||
;; Package-Requires: ((quicklintjs "0.0.1") (flycheck "32-cvs") (emacs "24.5")) | ||
|
||
;; This file is part of quick-lint-js. | ||
;; | ||
;; quick-lint-js is free software: you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
;; | ||
;; quick-lint-js is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
;; | ||
;; You should have received a copy of the GNU General Public License | ||
;; along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
|
||
|
@@ -35,19 +58,10 @@ | |
;;; Code: | ||
|
||
(require 'flycheck) | ||
|
||
(defgroup flycheck-quicklintjs nil | ||
"quick-lint-js Flycheck integration." | ||
:prefix "flycheck-" | ||
:group 'flycheck | ||
:group 'quicklintjs | ||
:link '(url-link :tag "Website" "https://quick-lint-js.com")) | ||
|
||
(flycheck-def-args-var flycheck-quicklintjs-args javascript-quicklintjs) | ||
(flycheck-def-executable-var javascript-quicklintjs "quick-lint-js") | ||
(require 'quicklintjs) | ||
|
||
(defun flycheck-quicklintjs-parse-errors (output checker buffer) | ||
"Parse quick-lint-js alist output format from OUTPUT" | ||
"Parse CHECKER quick-lint-js alist output format from OUTPUT." | ||
(mapcar (lambda (l) | ||
(let ((region (nth 0 l)) | ||
(sev (nth 1 l)) | ||
|
@@ -60,48 +74,31 @@ | |
:id code | ||
:buffer buffer | ||
:checker checker | ||
:end-pos (cdr region)))) (car (read-from-string output)))) | ||
:end-pos (cdr region)))) | ||
(car (read-from-string output)))) | ||
|
||
(flycheck-define-checker javascript-quicklintjs | ||
;;;###autoload | ||
(flycheck-define-command-checker 'javascript-quicklintjs | ||
"quick-lint-js finds bugs in JavaScript programs. | ||
|
||
https://quick-lint-js.com" | ||
:command ("quick-lint-js" | ||
"--output-format=emacs-lisp" | ||
(eval (let ((file (buffer-file-name))) | ||
(if file | ||
`("--path-for-config-search" ,file) | ||
()))) | ||
Comment on lines
-71
to
-74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you intentionally rewrite this code in this commit? This change seems unrelated to unifying settings. (The change looks fine, though.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, I think I merged the wrong piece on a conflict, i'll revert |
||
"--stdin" | ||
(eval flycheck-quicklintjs-args)) | ||
:standard-input t | ||
:error-parser flycheck-quicklintjs-parse-errors | ||
:command (quicklintjs-find-program | ||
"--output-format=emacs-lisp" | ||
(let ((file (buffer-file-name))) | ||
(when file (concat "--path-for-config-search=" file))) | ||
"--stdin") | ||
:standard-input 't | ||
:error-parser 'flycheck-quicklintjs-parse-errors | ||
: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))))) | ||
:modes js-mode) | ||
:modes 'js-mode) | ||
|
||
(add-to-list 'flycheck-checkers 'javascript-quicklintjs t) | ||
;;;###autoload | ||
(with-eval-after-load 'flycheck | ||
(add-to-list 'flycheck-checkers 'javascript-quicklintjs t)) | ||
|
||
(provide 'flycheck-quicklintjs) | ||
|
||
;; quick-lint-js finds bugs in JavaScript programs. | ||
;; Copyright (C) 2020 Matthew "strager" Glazar | ||
;; | ||
;; This file is part of quick-lint-js. | ||
;; | ||
;; quick-lint-js is free software: you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
;; | ||
;; quick-lint-js is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
;; | ||
;; You should have received a copy of the GNU General Public License | ||
;; along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; flycheck-quicklintjs.el ends here |
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.
find_program
already checks if the program was found. No need to check yourself: