ProgrammingRainbow / NvChad-2.5

How to install and configure NvChad
https://www.youtube.com/playlist?list=PLO02jwa2ZaiCwXNyaB_9GrPX4UnaXgXcM
The Unlicense
67 stars 5 forks source link

Use table.unpack to append/prepend args #3

Open ericwomer opened 1 week ago

ericwomer commented 1 week ago

If you do

lint.linters.luacheck.args = {
    "--globals",
    "love",
    "vim",
    table.unpack(lint.linters.luacheck.args),
}

You don't have to write out all of the default settings along with your custom settings.

Depending on how big the default settings are for specific plugins/apps it may be shorter to type them out, but with luacheck it seems simpler to append to the table then to write everything out by hand.

extra_args seems like its supposed to be a solution but it seems ignored in this case, which is why everyone else's fixes seem like not. The "--" I assume is bash for end of parameters as noted here

If you prefer an option saving the args previous before setting it you can do it with a variable via something like

local saved_args = lint.linters.luacheck.args

lint.linters.luacheck.args = {
    "--globals",
    "love",
    "vim",
    table.unpack(saved_args),
}

Though this is something that should be handled internally for the most part inside of NvChads configs.

ProgrammingRainbow commented 1 week ago

So is this not a bug? Just optimization?

local linter_args = lint.linters.luacheck.args or {}

local new_args = {
    "--globals",
    "love",
    "vim",
}

vim.list_extend(linter_args, new_args)

or unpack

lint.linters.luacheck.args = {
    unpack(lint.linters.luacheck.args),
    "--globals",
    "love",
    "vim",
}
ProgrammingRainbow commented 1 week ago

All the version seem to work just fine. But i do see the value of appending to the defaults.