Closed NickHu closed 5 months ago
What is the information from :ConformInfo
?
Log file: /home/nick/.repro/state/nvim/conform.log
Formatters for this buffer:
ocp-indent ready (ocaml) /nix/store/kxyvrkc322fk2cmwyrfs2kdc37im5rb8-ocp-indent-1.8.1/bin/ocp-indent
ocamlformat ready (ocaml) /nix/store/bsp4gasg8qvzfk9p7igwc236hsq2s8xf-ocamlformat-0.26.1/bin/ocamlformat
Other formatters:
What I was trying to get from that was contents from the logfile, which will show up in the :ConformInfo
window. If there truly is no log contents in that window, and as you say the log file is completely empty, then something is horribly wrong.
Using the minimal repro file, ensure that the log level is set to DEBUG, reproduce this behavior, and then check the log file. Is it empty? Is it present? Is it not there at all? Are there any other files in that directory? Do you have any error messages in Neovim?
Yes, it really is empty. No error messages, and formatting works as expected if I just don't pass the argument, i.e. replace the final line with
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
Of course, this doesn't achieve what I want, which is to select a specific formatter on formatexpr (ocamlformat).
(In doing so, conform.log has the following.
17:39:17[INFO] Run ocp-indent on /tmp/conform.nvim/foo.ml
17:39:17[DEBUG] Run command: { "ocp-indent" }
17:39:17[DEBUG] ocp-indent exited with code 0
)
Ah, I think I got it. The formatexpr
is specified as vimscript, not lua. Try this:
vim.o.formatexpr = "v:lua.require'conform'.formatexpr({ 'formatters': [ 'ocamlformat' ]})"
Bingo! That's great, thanks. Perhaps this should be noted in the documentation/with an example.
Neovim version (nvim -v)
NVIM v0.9.5
Operating system/version
NixOS unstable
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
<empty>
Describe the bug
Selecting a specific configured formatter via
conform.formatexpr({ formatters = { 'myformatter' } })
does not work, even thoughconform.format({ formatters = { 'myformatter' } })
does.What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
nvim -u repro.lua
gqG
Expected Behavior
ocamlformat
runs, i.e. the same effect of running:lua require'conform'.format({formatters = {'ocamlformat'}})
which works fine. Should work on ranges too.However, what I actually get is equal to the result of
gwG
, which suggests that somehow the option is not passed correctly via settingformatexpr
.Minimal example file
Minimal init.lua
Additional context
I want to use both
ocp-indent
andocamlformat
; the latter is more aggressive, so I don't want it triggering automatically on save, only manually viaformatexpr
.