nvim-tree

官方说明

https://github.com/nvim-tree/nvim-tree.lua#mappings

官方快捷手册

:h nvim-tree-mappings

我的配置

最新配置更新在github

local M = {}
function M.config()

    -- if nvim-tree is last buffer close it gracefully
    local modifiedBufs = function(bufs)
        local t = 0
        for k,v in pairs(bufs) do
            if v.name:match("NvimTree_") == nil then
                t = t + 1
            end
        end
        return t
    end

    vim.api.nvim_create_autocmd("BufEnter", {
        nested = true,
        callback = function()
            if #vim.api.nvim_list_wins() == 1 and
            vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil and
            modifiedBufs(vim.fn.getbufinfo({bufmodified = 1})) == 0 then
                vim.cmd "quit"                                          
            end                                                         
        end                                                             
    })                                                                  
    require 'nvim-tree'.setup {                                         
        disable_netrw        = true,
        hijack_netrw         = true,                                    
        open_on_setup        = true,                                    
        auto_reload_on_write = true,                                    
        hijack_cursor        = false,                                   
        filters              = {                                        
            dotfiles = true                                             
        },                                                              
        git                  = {                                        
            enable = true,                                              
            ignore = true,                                              
            timeout = 500,                                              
        },                                                              
        view                 = {                                        
            adaptive_size = true,                                             
            hide_root_folder = false,                                   
            side = 'left',                                              
            mappings = {                                                
                custom_only = true,                                     
                list = {                                                
                    { key = "<TAB>", action = "preview"},               
                    { key = "o", action = "edit"},                      
                    { key = "v", action = "vsplit"},                    
                    { key = "c", action = "copy"},
                    { key = "p", action = "paste"},
                    { key = "a", action = "create"},
                    { key = "d", action = "remove"},
                    { key = "r", action = "rename"},
                    { key = "R", action = "refresh"},
                    { key = "H", action = "toggle_dotfiles"}
                 }
             }
         },
     }
 end
 
 return M                                                    

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容