diff --git a/README.md b/README.md index 3980f9d..5149665 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +# ARCHIVED +Please if you are on neovim use [rnvimr](https://github.com/kevinhwang91/rnvimr) instead, which now implements full mouse support (unlike this fork, that onlyl enables neovim mousewheeel support). + +If you are on vim, refer to upstream [ranger.vim](https://github.com/francoiscabrol/ranger.vim) + Ranger.vim ========== @@ -10,11 +15,40 @@ Installation Install it with your favorite plugin manager. Example with vim-plug: - Plug 'francoiscabrol/ranger.vim' + Plug 'francoiscabrol/ranger.vim' If you use neovim, you have to add the dependency to the plugin bclose.vim: - Plug 'rbgrouleff/bclose.vim' + Plug 'rbgrouleff/bclose.vim' + +lazy.vim lua configuration example +```lua +{ + "zeioth/ranger.vim", + dependencies = {"rbgrouleff/bclose.vim"}, + cmd = { + "Ranger" + "RangerCurrentFile" + "RangerCurrentDirectory" + "RangerWorkingDirectory" + "RangerNewTab" + "RangerCurrentFileNewTab" + "RangerCurrentDirectoryNewTab" + "RangerWorkingDirectoryNewTab" + "RangerCurrentFileExistingOrNewTab" + "RangerCurrentDirectoryExistingOrNewTab" + "RangerWorkingDirectoryExistingOrNewTab" + }, + init = function() + vim.g.ranger_map_keys = 0 + + -- Change terminal and TERMCMD to enable this feature: + -- Calling a terminal from inside ranger. + vim.g.ranger_terminal = 'foot' + vim.g.ranger_command_override = 'LC_ALL=es_ES.UTF8 TERMCMD="foot -a \"scratchpad\"" ranger' + end +}, +``` How to use it ------------- diff --git a/plugin/ranger.vim b/plugin/ranger.vim index 03d5d2b..a55fa0d 100644 --- a/plugin/ranger.vim +++ b/plugin/ranger.vim @@ -67,6 +67,7 @@ if has('nvim') else call termopen(s:ranger_command . ' --choosefiles=' . s:choice_file_path . ' --selectfile="' . currentPath . '"', rangerCallback) endif + setfiletype rangervim startinsert endfunction else @@ -139,3 +140,34 @@ if !exists('g:ranger_map_keys') || g:ranger_map_keys map f :Ranger endif +"----------------------------------------------------------------------------------------------" +" HACK: Enable mouse scroll support on neovim" +" Credits: kevinhwang91 → https://github.com/kevinhwang91/rnvimr/issues/58 +"----------------------------------------------------------------------------------------------" +function s:set_mouse_with_rnvimr() abort + let n_mouse = &mouse + augroup RnvimrMouse + autocmd! + autocmd FileType rnvimr call set_mouse_with_rnvimr() + augroup end + + if match(n_mouse, '[a|h|n]') >= 0 + augroup RnvimrMouse + autocmd TermEnter,WinEnter call nvim_set_option('mouse', '') + execute printf("autocmd WinLeave call nvim_set_option('mouse', '%s')", n_mouse) + augroup END + endif + + if system('tmux display -p "#{mouse}"')[0] + augroup RnvimrMouse + autocmd TermEnter,WinEnter call system('tmux set mouse off') + autocmd WinLeave call system('tmux set mouse on') + augroup END + endif +endfunction + +if has('nvim') + augroup RnvimrMouse + autocmd FileType rangervim call set_mouse_with_rnvimr() + augroup END +endif