Skip to content

Examples of using a function with event loading. #1521

Answered by madelaney
madelaney asked this question in Q&A
Discussion options

You must be logged in to vote

For now, this is the solution that I came up with:

{
  'tadmccorkle/markdown.nvim',
  event = function()
      local secret_dir = '.shhhhhhhhhhh'
      local in_args = false

      local idx = 0
      while idx < vim.fn.argc() do
        ---@diagnostic disable-next-line: param-type-mismatch
        local arg = vim.fn.escape(vim.fn.fnameescape(vim.fn.argv(idx)), '.')
        if string.match(arg, secret_dir) then
          in_args = true
          break
        end
        idx = idx + 1
      end

      local dir = vim.fn.getcwd()
      if not string.find(dir, secret_dir) and not in_args then
        return {}
      end

      return {
        'BufReadPre *.md',
        'BufNewFile *.md',
 …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@madelaney
Comment options

@madelaney
Comment options

Answer selected by madelaney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants