1

I have been using CoC for a few weeks now and I quite like it. Recently I started configuring the formatting options. I have put "coc.preferences.formatOnSave": true and configured .clang-format file inside my CPP project. Everything worked out of the box and my files were nicely formatted on each save.

I ran into a problem when I wanted to use a feature of clang-format-13 and the default version of clang-format on my system is 11. I looked throughout the CoC wiki and configuration options, and I couldn't find where exactly is the formatter command specified? I guess that running clang-format is a default option for cpp filetypes and that is why it worked out of the box, but I would like to change it so that clang-format-13 is run on each save.

Note: I know I could just symlink clang-format to clang-format-13, but I would like to know how is this handled by CoC under the hood.

2
  • Did you figure this one out? Commented Oct 25, 2023 at 16:44
  • 1
    Nope, soon after I ran into this issue I decided to try out neovim (unrelated to this problem) and I used its builtin lsp system, so I'm not using CoC anymore
    – matko031
    Commented Oct 26, 2023 at 10:55

1 Answer 1

1

Formatting options may be specific per LSP. For example, haskell-language-server expects the formatter options to be set like this in your :CocConfig:

{
    "languageserver": {
        "haskell": {
            "command": "haskell-language-server-wrapper",
            "args": ["--lsp"],
            "rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
            "filetypes": ["haskell", "lhaskell"],
            "settings": {
                "formattingProvider": "fourmolu",
                "plugin" : {
                    "fourmolu" :{
                        "config": {
                            "external": true
                        }
                    }
                }
            }
        }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.