Skip to content

bug: csharpier breaking api changes #699

@jacob7395

Description

@jacob7395

Neovim version (nvim -v)

v0.11.0

Describe the bug

  1. Version 1.x.x of csharpier has updated it's api so no longer works when updated.
  args = { "csharpier", "--write-stdout" }, <-- not in v1.x.x
  1. The current default config for csharpier conform is using the version installed into the dotnet cli, which is different from the version that mason installs.
  command = "dotnet", <-- mason dose not install this as part of dotnet
❯ dotnet csharpier
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-csharpier does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Instead mason put it in the path for nvim, so it can be invoed with :! csharpier. I assume both option need to be supported. Or could just add something to the readme and have users overwrite.

This config fixes the problem;

        formatters = {
            csharpier = function()
                local useDotnet = not vim.fn.executable("csharpier")

                local command = useDotnet and "dotnet csharpier" or "csharpier"

                local version_out = vim.fn.system(command .. " --version")

                vim.notify(version_out)

                --NOTE: system command returns the command as the first line of the result, need to get the version number on the final line
                local version_result = version_out[#version_out]
                local major_version = tonumber((version_out or ""):match("^(%d+)")) or 0
                local is_new = major_version >= 1

                vim.notify(tostring(is_new))

                local args = is_new and { "format", "$FILENAME" } or { "--write-stdout" }

                return {
                    command = command,
                    args = args,
                    stdin = not is_new,
                    require_cwd = false,
                }
            end,
}

I will get a PR up making the changes to csharpier config.

I am wondering if/how you want to handle the version issue?

I can clean up what I currently have but it's going to be a little hacky.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

Update to v 1.x.x of csharpier, will need to do this using the dotnet cli not mason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions