kevinhwang91 / rnvimr

Make Ranger running in a floating window to communicate with Neovim via RPC
BSD 3-Clause "New" or "Revised" License
812 stars 17 forks source link

Enhancement: variable that contains list of regex's for hidden files (directories) #31

Closed monkoose closed 4 years ago

monkoose commented 4 years ago

I have one more enhancement to propose.

In rc.conf there is hidden_filter variable, can you add plugin variable to append it list to this hidden_filter for ranger instance that opens with rnvimr? So some directories and files like node_modules etc could be hidden by default. I don't want some directories to be hidden in my shell ranger by default, but i don't want to see them when i working on my projects.

For example let g:rnvimr_some_variable = ['^node_modules$', '\.ext$', '^some_other_dir$']

Or maybe better approach would be to respect global and local .gitignore files? But the problem is that it uses different syntax than hidden_filter regex.

kevinhwang91 commented 4 years ago

I think it's a good idea for using gitignore rather than adding an extra global variable in vimscript to hide matched files.

I found that I can use git check-ignore to check a directory or a file is in the ignored list in git or not. But I'm not sure that it works in flat under Ranger, I will try it out.

In the end, I think this is a good feature for Ranger, If I have done, I will pr to Ranger master.

monkoose commented 4 years ago

Not sure if i have understood you right, but maybe the thing you want to implement can be a performance problem, isn't it easier to find local .gitignore + global .gitignore combined, parse them and change each line of it (one ignore item per line as gitignore documentation specify it) to be acceptable for hidden_filter ranger variable?

kevinhwang91 commented 4 years ago

Not sure if i have understood you right, but maybe the thing you want to implement can be a performance problem

Use git check-ignore check a single file will cause a performance issue, but a directory will not. I have tested under chromium repo, it's a huge repo. image image

isn't it easier to find local .gitignore + global .gitignore combined, parse them and change each line of it

No, they use different rules and it's hard to be translated to each other. If using git check-ignore to check a total git project, it may crash in a huge repo.

git check-ignore cache each directory is the best solution I think.

kevinhwang91 commented 4 years ago

flat could work, but it causes a bad performance using git check-ignore in a hung repo. Maybe I should disable this feature when users use flat.

Btw, there are some bugs when enable both vcs and flat in Ranger.

monkoose commented 4 years ago

As i said previously. Its easy to strip away unneeded characters from each line in .gitignore file, so hidden_filter would accept it. Do you need some help?

Was lazy to create issue but hacks/calibrate_ueberzug() translate image outside of terminal window for me so i disabled this lines for now.

            start_x += win_info['col']
            start_y += win_info['row']

So at least i can fully see images.

monkoose commented 4 years ago

You can get list of ignored dirs and files for the project with git status --ignored. So you don't even need to process .gitignore files.

kevinhwang91 commented 4 years ago

As i said previously. Its easy to strip away unneeded characters from each line in .gitignore file, so hidden_filter would accept it. Do you need some help?

Was lazy to create issue but hacks/calibrate_ueberzug() translate image outside of terminal window for me so i disabled this lines for now.

            start_x += win_info['col']
            start_y += win_info['row']

So at least i can fully see images.

I guess this cause by your version of ueberzug, maybe checkhealth could complain something. If not, please open another issue.

kevinhwang91 commented 4 years ago

You can get list of ignored dirs and files for the project with git status --ignored. So you don't even need to process .gitignore files.

No, .gitgnore is not only in the git root. Users can use ignore file by excludesfile.

Btw, git status --ignored is slower than git check-ignore.

rule of gitignore and regex is different.

No, they use different rules and it's hard to be translated to each other.

monkoose commented 4 years ago

I guess this cause by your version of ueberzug, maybe checkhealth could complain something. If not, please open another issue.

Yes this solves it.

monkoose commented 4 years ago

Btw, git status --ignored is slower than git check-ignore.

Are you sure about this? Because it doesn't need to traverse directory tree, and just prints out ignored dirs and files (that only outside of ignored dirs).

kevinhwang91 commented 4 years ago

Btw, git status --ignored is slower than git check-ignore.

Are you sure about this? Because it doesn't need to traverse directory tree, and just prints out ignored dirs and files (that only outside of ignored dirs).

Yes, git check-ignore is faster than git status --ignored inside a single directory. But I have tested git check-ignore just now, it made me mad by the terrible performance, because changing directory will trigger git check-ignore. I will use git status --ignored to test tomorrow.

kevinhwang91 commented 4 years ago

You can try hide-git-file branch and test. If no issue I will merge this feature into master.

example config:

Plug 'kevinhwang91/rnvimr', {'branch': 'hide-git-file', 'do': 'make sync'}
let g:rnvimr_hide_git = 1

Please give me some feedback.

monkoose commented 4 years ago

I will give my feedback tomorrow.

monkoose commented 4 years ago

For now i don't see any problems, but i didn't test it in some very big repo (and i'm not sure if i want to download and test this). If you tested it and there is no impact on performace in a big repo, i think it can be merged. Maybe some big functions can be refactored like load_bit_by_bit because it is really hard to understand what is going on, but it is only if you have time to spend on this for sure.

Thank you very much, it is good feature to have in a file manager.

kevinhwang91 commented 4 years ago

I had fixed a bug about attaching the hidden file, please update the hide-git-file branch.

Performance bottleneck depends on git status. I will improve the documentation to let users know about that.

Although I can implement this feature through preprocessing and postprocessing tech to enhance load_bit_by_bit which is very bloated and slow, I copied this function from ranger directly into the rnvimr library so that I can easily improve the performance of this part in the future.

monkoose commented 4 years ago

Updated. All good.

kevinhwang91 commented 4 years ago

hide-git-file have merged into master branch. The option g:rnvimr_hide_git change to g:rnvimr_hide_gitignore. Using asynchronous callback function and cache ignored data to solve the performance issue. I think it's time to close this issue.