nvim-tree

2022-10-19  本文已影响0人  sarto

官方说明

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                                                    

上一篇 下一篇

猜你喜欢

热点阅读