Skip to content

Commit

Permalink
fix: auto apply formatter args set in user/configs/formatters (ayam…
Browse files Browse the repository at this point in the history
…ir#1051)

* fix: auto apply formatter args set in `user/configs/formatters`.

Signed-off-by: ayamir <lgt986452565@gmail.com>

* fixup:! remove redundant `pcall`.

---------

Signed-off-by: ayamir <lgt986452565@gmail.com>
  • Loading branch information
ayamir authored and Vincent Wang committed Nov 3, 2023
1 parent 8da41f7 commit 85133b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
13 changes: 12 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,23 @@ 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
args = require("completion.formatters." .. formatter_name)
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 85133b4

Please sign in to comment.