camspiers / snap

A fast finder system for neovim.
The Unlicense
481 stars 16 forks source link

Pass arguments to git.file with try fallback #62

Closed yujinyuz closed 3 years ago

yujinyuz commented 3 years ago

I currently have this in my config

  local snap = require('snap')
  local file = snap.config.file:with{reverse = false, consumer = 'fzf'}
  local vimgrep = snap.config.vimgrep:with{
    reverse = false,
    consumer = 'fzf',
    limit = 50000,
  }

snap.maps {
  {'<leader>ss', file {prompt = 'Files', try = {'git.file', 'ripgrep.file'}}}
}

How can I pass arguments to git.file?

git ls-files --cached --others --exclude-standard
bangedorrunt commented 3 years ago

@yujinyuz you can take reference from here

snap.maps {
  {"<Leader>ss", file {
    try = {
      snap.get'producer.git.file'.args({'your args'}),
      'ripgrep.file'
    }
  }
yujinyuz commented 3 years ago

@babygau thanks. I just tried it but I get this error

packer.nvim: Error running config for snap: [string "..."]:0: attempt to index a function value

Edit:

Here's my config

      local snap = require('snap')
      local file = snap.config.file:with{reverse = false, consumer = 'fzf'}
      local vimgrep = snap.config.vimgrep:with{
        reverse = false,
        consumer = 'fzf',
        limit = 50000,
      }

      snap.maps {
        {
          '<leader>ss', file {
            try = {
              snap.get'producer.git.file'.args({'--cached', '--others'}),
              'ripgrep.file',
            }
          },
        },
    }
camspiers commented 3 years ago

I don't think git.file supports adding arbitrary arguments yet, though it should. I can take a look

camspiers commented 3 years ago

Closed in: https://github.com/camspiers/snap/commit/2da8617c4a292fefa9d60320ed3667c4cbd0780c

yujinyuz commented 3 years ago

Thanks.

Does this mean I have to also include ls-files to the args? Something like tihs?

snap.maps {
        {
          '<leader>ss', file {
            try = {
              snap.get'producer.git.file'.args({'ls-files', '--cached', '--others'}),
              'ripgrep.file',
            }
          },
        },
camspiers commented 3 years ago

ls-files should be defaulted in and you are just adding the extras. Thanks for logging the issue btw!

yujinyuz commented 3 years ago

@camspiers Welcome! Also thanks for the immediate fix for this