Make mini.nvim ignore git ignored files.
Based off of
31f7988420
(thanks)
This commit is contained in:
@@ -69,7 +69,38 @@ require('mini.diff').setup({ -- shows git diffs in the file
|
|||||||
style = 'sign',
|
style = 'sign',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
require('mini.files').setup() -- file browser
|
require('mini.files').setup({ -- file browser
|
||||||
|
content = {
|
||||||
|
-- Sort is faster than content.filter, since git is invoked once.
|
||||||
|
sort = function(entries)
|
||||||
|
-- Prepare the paths for sending via STDIN later.
|
||||||
|
local pats = table.concat(vim.iter(entries)
|
||||||
|
:map(function(e) return e.path end):totable(), '\n')
|
||||||
|
|
||||||
|
-- Open up the git command, where we will send the list over STDIN
|
||||||
|
local out = {}
|
||||||
|
local id = vim.fn.jobstart({ "git", "check-ignore", "--stdin" }, {
|
||||||
|
stdout_buffered = true,
|
||||||
|
on_stdout = function(_, dat) out = dat end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Return the entries if the command failed
|
||||||
|
if id < 1 then return entries end
|
||||||
|
|
||||||
|
-- Send the lines over STDIN, and await a response.
|
||||||
|
vim.fn.chansend(id, pats)
|
||||||
|
vim.fn.chanclose(id, 'stdin')
|
||||||
|
vim.fn.jobwait({ id })
|
||||||
|
|
||||||
|
-- This response is used to filter out everything that was sent back;
|
||||||
|
-- I.e. should be ignored.
|
||||||
|
return require("mini.files").detault_sort(
|
||||||
|
vim.iter(entries):filter(function(e)
|
||||||
|
return not vim.tbl_contains(out, e.path)
|
||||||
|
end):totable())
|
||||||
|
end
|
||||||
|
}
|
||||||
|
})
|
||||||
Map('n', '<leader>o', MiniFiles.open, { desc = "Open mini file browser" })
|
Map('n', '<leader>o', MiniFiles.open, { desc = "Open mini file browser" })
|
||||||
require('mini.jump').setup() -- extends f,F,t,T to work across multiple lines
|
require('mini.jump').setup() -- extends f,F,t,T to work across multiple lines
|
||||||
require('mini.cursorword').setup() -- highlight words beneath the cursor
|
require('mini.cursorword').setup() -- highlight words beneath the cursor
|
||||||
|
|||||||
Reference in New Issue
Block a user