Open ahmedelgabri opened 3 weeks ago
I usually use _private
or .private
, so for me it would be useful as well, currently I am doing it in my nvim-config to not load selected plugins.
I think a good way to resolve this cases would be with something like none-ls.nvim in the utils file, this is useful with none-ls
for example to not use luacheck
if selene.toml
is in the root. In supermaven's case checking for root wouldn't be necessary.
Creating a condition
entry on the plugin's config like this (rough concept):
local files = {
{ ft = { "bash", "javascript", ... }, ignore = { "foo", "_private", ".private", ... },
...
}
require("supermaven-nvim").setup({
-- condition would need to return a boolean
condition = function(util)
return util.file_matches(files)
end,
})
---@class FilesToMatch
---@field ft string? | string[]?
---@field ignore string | string[]
---@param files FilesToMatch[]
---@return boolean
util.file_matches = function(files)
-- check if `files.ft` is specified, if not just check filename with `files.match`
-- check current filetype within or some of `files.ft`
-- check current filename contains or some of `files.ignore`
end
[!NOTE] This could be more user friendly with more thought into it and some feedback.
Looks good. But I'd personally start with just adding an option that takes a function that returns a Boolean without the utils. And leave the logic for the consumer. if later there is a demand for such utils you can add it.
That is a great idea, a nice place to start. Thanks for the feedback.
@ahmedelgabri I made this quick demo and added this to my config:
require("supermaven-nvim").setup({
condition = function()
return vim.fn.expand(":t:r") ~= "api"
end
})
I am thinking if its better to default condition to false
, and check if condition is true to stop. Right now its defaulting to true
.
I am thinking if its better to default condition to
false
, and check if condition is true to stop. Right now its defaulting totrue
.
Agree, the default should be false
, true
should mean disable the plugin.
@ahmedelgabri I made the changes in the PR above if you want to try them out.
ignore_filetypes
currently is limited to filetypes, but in some cases, I want to disable the plugin from running on some specific files. For example, some shellscript files that contains some secrets, token, etc…If I add
bash = true
inignore_filetypes
then this will disable it for all bash files. I don't want this. I want to be able to do something like this instead