edit plugins, change some keymaps

- remove nvim-tree
- add neo-tree
- add smart-splits
- add notify
This commit is contained in:
leafee98 2024-05-07 20:47:00 +08:00
parent 4d32d464ba
commit 534f1c8323
7 changed files with 94 additions and 57 deletions

View file

@ -1,6 +1,9 @@
-- enable read config from CWD -- enable read config from CWD
vim.o.exrc = true vim.o.exrc = true
-- enable 24-bit color for nvim-notify
vim.o.termguicolors = true
-- Disable intro message on startup, or many other plugins will -- Disable intro message on startup, or many other plugins will
-- close this message on load, which may cause a flash of intro message. -- close this message on load, which may cause a flash of intro message.
vim.opt.shortmess:append({ I = true }) vim.opt.shortmess:append({ I = true })
@ -23,20 +26,23 @@ vim.o.colorcolumn = "101"
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
vim.keymap.set("n", "\\\\", "<cmd>split<cr>", { silent = true })
vim.keymap.set("n", "||", "<cmd>vsplit<cr>", { silent = true })
vim.keymap.set("n", "\\q", "<cmd>wincmd q<cr>", { silent = true }) vim.keymap.set("n", "\\q", "<cmd>wincmd q<cr>", { silent = true })
vim.keymap.set("n", "zh", "<cmd>wincmd h<cr>", { silent = true }) vim.keymap.set("n", "<C-h>", "<cmd>wincmd h<cr>", { silent = true })
vim.keymap.set("n", "zj", "<cmd>wincmd j<cr>", { silent = true }) vim.keymap.set("n", "<C-j>", "<cmd>wincmd j<cr>", { silent = true })
vim.keymap.set("n", "zk", "<cmd>wincmd k<cr>", { silent = true }) vim.keymap.set("n", "<C-k>", "<cmd>wincmd k<cr>", { silent = true })
vim.keymap.set("n", "zl", "<cmd>wincmd l<cr>", { silent = true }) vim.keymap.set("n", "<C-l>", "<cmd>wincmd l<cr>", { silent = true })
vim.keymap.set("n", "zch", "<cmd>wincmd H<cr>", { silent = true }) vim.keymap.set("n", "<leader><C-h>", "<cmd>wincmd H<cr>", { silent = true })
vim.keymap.set("n", "zcj", "<cmd>wincmd J<cr>", { silent = true }) vim.keymap.set("n", "<leader><C-j>", "<cmd>wincmd J<cr>", { silent = true })
vim.keymap.set("n", "zck", "<cmd>wincmd K<cr>", { silent = true }) vim.keymap.set("n", "<leader><C-k>", "<cmd>wincmd K<cr>", { silent = true })
vim.keymap.set("n", "zcl", "<cmd>wincmd L<cr>", { silent = true }) vim.keymap.set("n", "<leader><C-l>", "<cmd>wincmd L<cr>", { silent = true })
vim.keymap.set("n", "zn", "<cmd>bnext<cr>", { silent = true }) vim.keymap.set("n", "]b", "<cmd>bnext<cr>", { silent = true })
vim.keymap.set("n", "zp", "<cmd>bprevious<cr>", { silent = true }) vim.keymap.set("n", "[b", "<cmd>bprevious<cr>", { silent = true })
vim.keymap.set("n", "zx", "<cmd>bdelete<cr>", { silent = true }) vim.keymap.set("n", "<leader>c", "<cmd>bdelete<cr>", { silent = true })
vim.keymap.set("n", "<leader>nh", "<cmd>nohlsearch<cr>", { silent = true }) vim.keymap.set("n", "<leader>nh", "<cmd>nohlsearch<cr>", { silent = true })

View file

@ -27,7 +27,7 @@ return {
{ {
"famiu/bufdelete.nvim", "famiu/bufdelete.nvim",
keys = { keys = {
{ "zx", "<cmd>Bdelete<cr>", mode = "n" }, { "<leader>c", "<cmd>Bdelete<cr>", mode = "n" },
}, },
}, },
{ {

View file

@ -13,10 +13,10 @@ return {
main = "bufferline", main = "bufferline",
event = "VeryLazy", event = "VeryLazy",
keys = { keys = {
{ "zn", "<cmd>BufferLineCycleNext<cr>" }, { "]b", "<cmd>BufferLineCycleNext<cr>" },
{ "zp", "<cmd>BufferLineCyclePrev<cr>" }, { "[b", "<cmd>BufferLineCyclePrev<cr>" },
{ "zcn", "<cmd>BufferLineMoveNext<cr>" }, { ">b", "<cmd>BufferLineMoveNext<cr>" },
{ "zcp", "<cmd>BufferLineMovePrev<cr>" }, { "<b", "<cmd>BufferLineMovePrev<cr>" },
}, },
opts = { opts = {
options = { options = {

View file

@ -1,41 +0,0 @@
return{
{
"nvim-tree/nvim-tree.lua",
enabled = custom.full_feature,
dependencies = {
"nvim-tree/nvim-web-devicons"
},
main = "nvim-tree",
event = "VeryLazy",
opts = {
filters = {
git_ignored = false,
},
},
keys = {
{ "<leader>t", "<cmd>NvimTreeFocus<cr>", mode = "n" },
{ "<leader>f", "<cmd>NvimTreeFindFile<cr>", mode = "n" },
},
init = function(_)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.api.nvim_create_autocmd("QuitPre", {
callback = function()
local invalid_win = {}
local wins = vim.api.nvim_list_wins()
for _, w in ipairs(wins) do
local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
if bufname:match("NvimTree_") ~= nil then
table.insert(invalid_win, w)
end
end
if #invalid_win == #wins - 1 then
-- Should quit, so we close all invalid windows.
for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end
end
end
})
end,
},
}

49
lua/plugins/neo-tree.lua Normal file
View file

@ -0,0 +1,49 @@
return {
"nvim-neo-tree/neo-tree.nvim",
dependencies = {
{ "nvim-lua/plenary.nvim", lazy = true },
{ "nvim-tree/nvim-web-devicons", lazy = true },
{ "MunifTanjim/nui.nvim", lazy = true },
},
cmd = "Neotree",
opts = function()
local git_available = vim.fn.executable("git") == 1
local get_icon = require("nvim-web-devicons").get_icon
local opts = {
enable_git_status = git_available,
auto_clean_after_session_restore = true,
close_if_last_window = true,
sources = { "filesystem", "buffers", "git_status" },
source_selector = {
winbar = true,
content_layout = "center",
sources = {
{ source = "filesystem", display_name = " 󰉓 Files " },
{ source = "buffers", display_name = " 󰈚 Bufs " },
{ source = "git_status", display_name = " 󰊢 Git " },
},
},
window = {
width = 30,
mappings = {
["[b"] = "prev_source",
["]b"] = "next_source",
}
},
}
return opts
end,
keys = {
{ "<leader>e", "<cmd>Neotree toggle<cr>", desc = "Toggle explorer"},
{
"<leader>o",
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd("p")
else
vim.cmd.Neotree("focus")
end
end,
desc = "Toggle explorer"},
},
}

8
lua/plugins/notify.lua Normal file
View file

@ -0,0 +1,8 @@
return {
"rcarriga/nvim-notify",
config = function(LazyPlugin, opts)
local notify = require("notify")
vim.notify = notify
notify.setup(opts)
end
}

View file

@ -0,0 +1,15 @@
return {
"mrjones2014/smart-splits.nvim",
event = "VeryLazy",
opts = { ignored_filetypes = { "nofile", "quickfix", "qf", "prompt" }, ignored_buftypes = { "nofile" } },
keys = {
{ "<c-h>", function() require("smart-splits").move_cursor_left() end, desc = "Move to left split" },
{ "<c-j>", function() require("smart-splits").move_cursor_down() end, desc = "Move to below split" },
{ "<c-k>", function() require("smart-splits").move_cursor_up() end, desc = "Move to above split" },
{ "<c-l>", function() require("smart-splits").move_cursor_right() end, desc = "Move to right split" },
{ "<c-up>", function() require("smart-splits").resize_up() end, desc = "Resize split up" },
{ "<c-down>", function() require("smart-splits").resize_down() end, desc = "Resize split down" },
{ "<c-left>", function() require("smart-splits").resize_left() end, desc = "Resize split left" },
{ "<c-right>", function() require("smart-splits").resize_right() end, desc = "Resize split right" },
},
}