Open xavier7179 opened 19 hours ago
"File not present", meaning this is a temp buffer that's not saved yet?
I apologize. I needed clarification in the first place. I was referring to the -style=file
option, which makes the command search for a .clang-format
file (making it possible to have project-specific formatting rules)
I think that's the default behavior given that the cwd is correct (:pwd
)
Yes, indeed it is. Nevertheless, the style
accepts a list of options that follow the file content structure. Unfortunately, there is no example of how to set them (and re-use the values of indents and tabs vs spaces that you can set with vim).
Moreover, the command accepts a --fallback-style=<string>
option that should fall back to a specific style when the file is missing. Although useful, <string>
can only be a default style and not a more complex configuration as in the -style
version. Thus, I was wondering if your plugin can handle it using an algorithmic approach...
I guess I can create an example... That might take a while.
Note that ft("foo"):fmt
can take a function, check out the tests.
https://github.com/nvimdev/guard.nvim/blob/cc8df48248eb795b71be21f7a30f08fc47a2c22d/spec/format_spec.lua#L71
If you managed to achieve what you wanted I am just going to put your solution as an example :)
Feature description
I was wondering if there is a way to configure
clang-format
so that it looks for the file first, and, if not present, it does not only apply a preferred style but also sets indentation and tabs vs. space for Vim configurations? If so, could you make an example in the documentation?