我使用的是香草Emacs,我安装了lsp-mode,如下所示:
(use-package lsp-mode
:init
(setq lsp-keymap-prefix "C-c l")
:commands (lsp lsp-deferred)
:config (defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
:hook (
(lsp-mode . lsp-enable-which-key-integration)
(go-mode . lsp-deferred)
(go-mode . lsp-go-install-save-hooks)
(typescript-mode . lsp-deferred)
(python-mode . lsp-deferred)
)
)对于Python,我安装了这。一切看起来都很好,但问题是我无法覆盖默认的pycodestyle设置。例如,它抱怨长行> 79,所以我尝试在项目的根目录中添加以下setup.cfg
[pycodestyle]
max-line-length=99但这没有被考虑在内,我是不是遗漏了什么?我看到了在全球范围内改变设置的可能性,但我希望在每个项目的基础上进行调整。
更新
如果pycodestyle是从终端运行的,它就会按预期的方式工作:它使用默认的行长限制进行抱怨,如果我将它增加到代码中最长的行的值,则不会。
*lsp-log*缓冲区似乎没有提供任何有意义的信息:
Command "pyls" is not present on the path.
Command "pylsp" is present on the path.
Command "pyls" is not present on the path.
Command "pylsp" is present on the path.
Found the following clients for /<some path>/sample-app/sample_app/__init__.py: (server-id pylsp, priority -1)
The following clients were selected based on priority: (server-id pylsp, priority -1)如果我执行flycheck-describe-checker命令,这是输出:
lsp is a Flycheck syntax checker.
This syntax checker checks syntax in the major mode(s)
`python-mode', `lsp-placeholder-mode', and uses a custom predicate.
Documentation:
A syntax checker using the Language Server Protocol (LSP)
provided by lsp-mode.
See https://github.com/emacs-lsp/lsp-mode.如果我通过执行命令flycheck禁用flycheck-disable-checker,那么警告就会消失,但是它会停止所有的检查。因此,似乎flycheck对不尊重setup.cfg负有责任。
https://stackoverflow.com/questions/71446079
复制相似问题