camspiers / snap

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

Adding changes to show untracked files with git file search #52

Closed beauwilliams closed 3 years ago

beauwilliams commented 3 years ago

This PR adds untracked files to the git.files producer output, to mimic the behaviour of many other git files finders which by default make untracked files searchable e.g telescope.nvim

beauwilliams commented 3 years ago

references #48

beauwilliams commented 3 years ago

I've just fixed a bug, so that when the untracked files returns an empty list, we fallback and return just tracked files.

I think this is ready to merge now. @camspiers

FYI, example if wondering what I mean --> I think this is going to be great with the new mappings api. One can have try => gitfiles else files and not ever worry about files not being searchable.

gif

beauwilliams commented 3 years ago

This is for later to work on. I have a preference that when you are in a git repo, you can be in any folder within the repo, but when we get the list from git.files, we get all files in the repo.

I have it working with this line return general(request, {args = {"ls-tree", "-r", "--full-tree", "--name-only", "HEAD"}})

But it leads to a lot of file not found errors because the pwd is not the root of the git repo so the previewer (bat/cat etc) gets upset.

The PR is ready to commit, but perhaps we can add this feature in the future too!

camspiers commented 3 years ago

Concatenating the general producers like that doesn't look right to me. Are you sure this is working?

camspiers commented 3 years ago

I think it is working just in virtue of invoking two producers. But the concatenation is just converting things the strings.

beauwilliams commented 3 years ago

I did test it and it's working for me. I can pull latest changes when I get home and give it another shot just to make sure.

I must admit I wrote this in Lua first and it was slightly more clear, then went and did it with fennel but the Lua I got back after make confuses me like it looks like it shouldn't work but it did still work. I'll double check

beauwilliams commented 3 years ago

I've just fixed the return statement nesting @camspiers sorry about that misplaced a parenthesis in the file.fnl

beauwilliams commented 3 years ago

fixed in 2da8617c4a292fefa9d60320ed3667c4cbd0780c