mhartington / formatter.nvim

MIT License
1.37k stars 144 forks source link

Can't format veirlog files by verible-verilog-format #225

Open kdurant opened 1 year ago

kdurant commented 1 year ago
            verilog = {
                function()
                    return {
                        exe = "verible-verilog-format",
                        args = { "--indentation_spaces 4", vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) },
                        stdin = true,
                    }
                end,
            },

    vim.api.nvim_create_autocmd({ "BufWritePost" }, {
        pattern = { "*.h", "*.hpp", "*.c", "*.cpp", "*.py", "*.lua", "*.v", "CMakeLists.txt" },
        command = "FormatWrite",
    })
JamesDevlin5 commented 1 year ago

Change that to this:

            verilog = {
                function()
                    return {
                        exe = "verible-verilog-format",
                        args = { "--indentation_spaces 4", "-" },
                        stdin = true,
                    }
                end,
            },

    vim.api.nvim_create_autocmd({ "BufWritePost" }, {
        pattern = { "*.h", "*.hpp", "*.c", "*.cpp", "*.py", "*.lua", "*.v", "CMakeLists.txt" },
        command = "FormatWrite",
    })

You shouldn't be giving the filename and setting the stdin flag, it should be one or the other. The above method uses standard input.