Conflicting formatters? #617
-
I feel like I must be missing something obvious, but I'm trying to configure two javascript formatters to run, and I can't seem to get them both to run. I can run one, or I can run the other, but when I attempt to run them both, all formatters stop working. Then to top it off, adding "debug=true" to the null_ls setup doesn't seem to move the log level from "warn", either. My setup is fairly simple: null_ls = require('null-ls')
local lint = null_ls.builtins.diagnostics
local fix = null_ls.builtins.formatting
null_ls.setup {
debug = true,
sources = {
-- all filetypes
fix.trim_newlines,
fix.trim_whitespace,
-- javascript
lint.standardjs,
fix.prettier,
fix.standardjs,
-- python
fix.black,
lint.flake8,
fix.reorder_python_imports,
},
} Working on python files, I see that both black and reorder-python-imports runs, as well as the trim-newlines and trim-whitespace. However, on javascript files, no formatters run, not even trim-{newlines,whitespace}. Unless I comment out one or the other of fix.prettier or fix.standardjs. Then the everything else runs as expected. Also, when I run NullLsInfo, it tells me that the current logging level is "warn" ... but shouldn't it be "debug"? I am not seeing anything helpful in the logs at the warn level. The only thing I can think of is that standardjs is the name of both a formatter as well as a diagnostic, but since I can run both of those just fine when I have prettier commented out, I don't expect that's the problem. Any advice? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
So the log level display is a bug that should be fixed by 6d90daf. Using your config, I can correctly see the debug output when running console.log( "hi" )
Running
The end result correctly reflects the output from running |
Beta Was this translation helpful? Give feedback.
So the log level display is a bug that should be fixed by 6d90daf. Using your config, I can correctly see the debug output when running
:NullLsLog
or directly opening the file. That output is showing that all of your defined formatters are running in sequence on a JavaScript file. For example, given the following content (including the trailing newlines):Running
vim.lsp.buf.formatting()
with your config results in the following debug output: