Skip to content

Commit

Permalink
fix: auto apply formatter args set in user/configs/formatters.
Browse files Browse the repository at this point in the history
Signed-off-by: ayamir <[email protected]>
  • Loading branch information
ayamir committed Nov 1, 2023
1 parent 6dfd8d6 commit 9634038
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lua/modules/configs/completion/null-ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ return function()
local null_ls = require("null-ls")
local btns = null_ls.builtins

---Return formatter args required by `extra_args`
---@param formatter_name string
---@return table|nil
local function formatter_args(formatter_name)
local ok, args = pcall(require, "user.configs.formatters." .. formatter_name)
if not ok then
ok, args = pcall(require, "completion.formatters." .. formatter_name)
end
if not ok then
args = nil
end
return args
end

-- Please set additional flags for the supported servers here
-- Don't specify any config here if you are using the default one.
local sources = {
btns.formatting.clang_format.with({
filetypes = { "c", "cpp" },
extra_args = require("completion.formatters.clang_format"),
extra_args = formatter_args("clang_format"),
}),
btns.formatting.prettier.with({
filetypes = {
Expand Down
Empty file.

0 comments on commit 9634038

Please sign in to comment.