goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.84k stars 109 forks source link

How to ignore files from a certain directory? #103

Closed medwatt closed 2 years ago

medwatt commented 2 years ago

I am using the startify theme and I would like to ignore all files from a given directory. For example, since I use firenvim, I don't start the MRU to have files from /run/user/.*/firenvim'}. With startify, I was able to do this with vim.g.startify_skiplist = {'/run/user/.*/firenvim'}. How can I do that here?

goolord commented 2 years ago

atm you can redefine startify.mru_opts.ignore https://github.com/goolord/alpha-nvim/blob/main/lua/alpha/themes/startify.lua#L109-L110 and then write your own predicate on the path & extension using lua

medwatt commented 2 years ago

Thanks for the reply. I am asking because I tried to write my own but couldn't get it to work. I hope you wouldn't mind helping out.

goolord commented 2 years ago

image sure, the function you want is string.find, it would probably end up looking like this

startify.mru_opts.ignore = function (path, ext)
  local ext_ignore = { "gitcommit" }
  return (string.find(path, '/run/user/.*/firenvim')) or (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(ext_ignore, ext))
end