From 93a0a4f9883a4aedf16fe20de8165488dec987cf Mon Sep 17 00:00:00 2001 From: mathijs-bakker Date: Sun, 24 Aug 2025 13:15:59 +0200 Subject: [PATCH] resolved merge conflicts --- README.md | 2 + doc/hide-files-in-file-explores.md | 92 ++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 doc/hide-files-in-file-explores.md diff --git a/README.md b/README.md index 177789e..f19598b 100644 --- a/README.md +++ b/README.md @@ -184,3 +184,5 @@ You should configure indentation properly. It's recommend adding an [`.editorconfig`](./.editorconfig) to your project. For more info: `:help godotdev-indent` +## Hints/Tips +- [Hide Godot related files in file explorers]("doc/hide-files-in-file-explores.md") diff --git a/doc/hide-files-in-file-explores.md b/doc/hide-files-in-file-explores.md new file mode 100644 index 0000000..d064f2a --- /dev/null +++ b/doc/hide-files-in-file-explores.md @@ -0,0 +1,92 @@ +# File Explorers: hide Godot files + +## mini.files + +The filtering option doesn't work as expected in mini.files. Somehow the filtering system is broken. + +This monkey patch approach is working because it intercepts the buffer content at the right moment - after mini.files has processed it but before it's displayed, so the plugin doesn't detect any "user modifications" that would trigger the synchronization warning. + +[mini.files](https://github.com/echasnovski/mini.files) + +```lua +return { + 'echasnovski/mini.files', + keys = { + { + '-', + function() + require('mini.files').open() + end, + desc = 'Open MiniFiles', + }, + }, + config = function() + local original_set_lines = vim.api.nvim_buf_set_lines + + local filter_godot_files = function(lines) + local filtered = {} + local godot_patterns = { + '%.uid[/]?$', -- .uid files + '%.import[/]?$', -- .import files + '^%.godot[/]?$', -- .godot directory + '^%.mono[/]?$', -- .mono directory + 'godot.*%.tmp$', -- godot temp files + } + + for _, line in ipairs(lines) do + local should_include = true + for _, pattern in ipairs(godot_patterns) do + if line:match(pattern) then + should_include = false + break + end + end + if should_include then + table.insert(filtered, line) + end + end + return filtered + end + + require('mini.files').setup { + content = { + filter = function(fs_entry) + return true + end, -- Use our custom filtering instead + }, + mappings = { + close = 'q', + go_in = 'l', + go_in_plus = 'L', + go_out = 'h', + go_out_plus = 'H', + reset = '', + reveal_cwd = '@', + show_help = 'g?', + synchronize = '=', + trim_left = '<', + trim_right = '>', + }, + options = { + permanent_delete = true, + use_as_default_explorer = true, + }, + windows = { + max_number = math.huge, + preview = false, + width_focus = 50, + width_nofocus = 15, + width_preview = 25, + }, + } + + vim.api.nvim_buf_set_lines = function(buf_id, start, end_idx, strict_indexing, lines) + local bufname = vim.api.nvim_buf_get_name(buf_id) + if bufname:match 'minifiles://' and type(lines) == 'table' then + lines = filter_godot_files(lines) + end + return original_set_lines(buf_id, start, end_idx, strict_indexing, lines) + end + end, +} +```