Skip to content

feat(api): Ability to configure via setup() function #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

mrjones2014
Copy link

Resolves #11

local cfg_handler = require('guard.filetype')(ft)
for key, cfg in pairs(ft_config) do
if key == 'lint' then
if vim.tbl_islist(cfg) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these codes are duplicated .

 if vim.tbl_islist(cfg) then
          for _, linter_cfg in ipairs(cfg) do
            cfg_handler = cfg_handler:lint(linter_cfg)
          end
        else
          cfg_handler = cfg_handler:lint(cfg)
        end

We can only need to handle one case (table). Reduce if jump instructions. you know. The cpu can't handle the jump instruction of if correctly lol

function as_table(t)
  return vim.tbl_islist(t) and t or {t}
end

then it can be for _, linter_cfg in ipairs(as_table(cfg) do . and same as other check like fmt append can we write a function like this make these code simple ?

cfg_handler:register(key, cfg)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw thanks for pr.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed some changes -- let me know if it looks okay now!

@glepnir
Copy link
Member

glepnir commented Jul 18, 2023

thanks I had add this support and add you in commit message close.

@glepnir glepnir closed this Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to configure declaratively with table values
2 participants