diff --git a/nvim/init.lua b/nvim/init.lua index 357040b..fc386ee 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -22,6 +22,7 @@ if fn.has('nvim') == 0 then return end + -- Ensure packer installed local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then diff --git a/nvim/lua/config/nvim-tree.lua b/nvim/lua/config/nvim-tree.lua index a811768..62319a1 100644 --- a/nvim/lua/config/nvim-tree.lua +++ b/nvim/lua/config/nvim-tree.lua @@ -1,21 +1,86 @@ -local g = vim.g local map = require('utils').map -local tree_cb = require('nvim-tree.config').nvim_tree_callback +local function open_nvim_tree(data) + -- buffer is a real file on the disk + local real_file = vim.fn.filereadable(data.file) == 1 + + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 + + if directory then + -- create a new, empty buffer + vim.cmd.enew() + + -- wipe the directory buffer + vim.cmd.bw(data.buf) + + -- change to the directory + vim.cmd.cd(data.file) + + -- open the tree + require("nvim-tree.api").tree.open() + end + + if real_file or no_name then + -- open the tree, find the file but don't focus it + require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) + end + +end + +--- autocmd with callbacks +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + +vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("NvimTreeClose", { clear = true }), + pattern = "NvimTree_*", + callback = function() + local layout = vim.api.nvim_call_function("winlayout", {}) + if layout[1] == "leaf" and + vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(layout[2]), "filetype") == "NvimTree" and + layout[3] == nil then vim.cmd("confirm quit") end + end +}) +-- +-- This function has been generated from your +-- view.mappings.list +-- view.mappings.custom_only +-- remove_keymaps +-- +-- You should add this function to your configuration and set on_attach = on_attach in the nvim-tree setup call. +-- +-- Although care was taken to ensure correctness and completeness, your review is required. +-- +-- Please check for the following issues in auto generated content: +-- "Mappings removed" is as you expect +-- "Mappings migrated" are correct +-- +-- Please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach for assistance in migrating. +-- + +local function on_attach(bufnr) + local api = require('nvim-tree.api') + + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- Mappings migrated from view.mappings.list + -- You will need to insert "your code goes here" for any mappings with a custom action_cb + vim.keymap.set('n', '', api.node.open.vertical, opts('Open: Vertical Split')) + vim.keymap.set('n', '', api.node.open.horizontal, opts('Open: Horizontal Split')) + vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) + vim.keymap.set('n', 's', api.node.open.horizontal, opts('Open: Horizontal Split')) + +end + require('nvim-tree').setup({ view = { width = 35, side = 'left', - mappings = { - list = { - { key = '', cb = tree_cb('vsplit') }, - { key = '', cb = tree_cb('split') }, - { key = 'v', cb = tree_cb('vsplit') }, - { key = 's', cb = tree_cb('split') }, - { key = '-', cb = '(choosewin)' }, - { key = '', cb = ':ToggleTerm' }, - }, - }, }, renderer = { highlight_opened_files = '1', @@ -38,17 +103,16 @@ require('nvim-tree').setup({ '.git$' }, }, - --auto_close = true, hijack_netrw = true, update_cwd = true, - open_on_setup = true, + on_attach = on_attach, }) -map('n', 'te', ':NvimTreeToggle') +-- map('n', 'te', ':NvimTreeToggle') -vim.cmd([[ -autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif -augroup nvimtree - autocmd VimEnter * lua require('nvim-tree').toggle(false, true) -augroup END -]]) +-- vim.cmd([[ +-- autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif +-- augroup nvimtree +-- autocmd VimEnter * lua require('nvim-tree').toggle(false, true) +-- augroup END +-- ]]) diff --git a/ssh/config b/ssh/config index 0743700..fe9d54c 100644 --- a/ssh/config +++ b/ssh/config @@ -26,3 +26,72 @@ Host workgit User git IdentityFile ~/.ssh/work_git.pub IdentitiesOnly yes + +Host iplc.inkisp + HostName iplc.inkisp.d0zingcat.xyz + Port 10347 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + +Host jppro.inkisp + HostName jppro.ink.d0zingcat.xyz + Port 11984 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host sh.qcloud + HostName 101.43.19.124 + Port 11984 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host bwh + HostName bwh.d0zingcat.xyz + Port 28653 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host sanjose.oracle + HostName 152.70.127.148 + Port 11984 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host hk.misaka + HostName 194.104.147.94 + Port 11984 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host myworker + HostName 64.176.46.45 + Port 11984 + User d0zingcat + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host test.destill + HostName 5.9.49.233 + Port 22 + User litang + IdentityFile ~/.ssh/work_git.pub + IdentitiesOnly yes + +Host solution.destill + HostName 138.201.206.172 + Port 22 + User solution + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes + +Host dev.collie + HostName 167.235.247.156 + Port 20234 + User litang + IdentityFile ~/.ssh/personal_git.pub + IdentitiesOnly yes