在emacs中,如何让js-beautify使用editorconfig

我看到js-beautify的REAMD里面支持editorconfig的选项,但是我在.jsbeautifyrc文件里面加入editorconfig: true,还是不起作用,在这个文件中加入别的都会起作用。

如果你用的是原生 Emacs ,参考 GitHub - editorconfig/editorconfig-emacs: EditorConfig plugin for Emacs 配置

如果是 Spacemacs,在 .spacemacs 中的 dotspacemacs-additional-packages 中添加 editorconfig, 在 .spacemacs 中的 docspacemacs/user-config 中加入 (editorconfig-mode 1)。

1 个赞

你好,我就是这样设置的,但是js-beautify并没有使用editorconfig啊

spacemacs 这样设置了 但是没起作用

如果还有看到这个帖子的朋友,我告知一下,这个问题已经解决了。 以前不能使用的问题,原因是js-beautify虽然可以读取.editorconfigrc,但是不能读取pipe的内容,也就是说,只能是.editorconfigrc这个文件才行,但是emacs中插件web-beautify,使用的是pipe的内容:

(defun web-beautify-get-shell-command (program)
  "Join PROGRAM with the constant js-beautify args."
  (mapconcat 'identity (append (list program) web-beautify-args) " "))

后来js-beautify的作者加入了editorconfig pipe支持,现在这个问题已经解决了。

1 个赞

我没试过web-beautify 我是希望像clang-format那样对文件格式format,但是我在user-config中添加了(editorconfig-mode 1) ,spacemacshg中也显示了editorconfig-mode 但是代码并没有format。