Compare commits

...

7 commits

Author SHA1 Message Date
leafee98 d27da86f40 Add mini-animate and remove neoscroll 2024-08-05 21:59:16 +08:00
leafee98 d953596443 split lualine and bufferline into two files 2024-05-09 11:58:42 +08:00
leafee98 4420707128 offset bufferline for neo-tree 2024-05-09 11:51:40 +08:00
leafee98 1d3653b791 add guess-indent 2024-05-07 21:01:23 +08:00
leafee98 1ff96d2245 remove the unconfiged dressing.nvim 2024-05-07 20:51:37 +08:00
leafee98 a10c30e139 edit gitsigns 2024-05-07 20:50:23 +08:00
leafee98 534f1c8323 edit plugins, change some keymaps
- remove nvim-tree
- add neo-tree
- add smart-splits
- add notify
2024-05-07 20:47:00 +08:00
12 changed files with 183 additions and 149 deletions

View file

@ -1,6 +1,9 @@
-- enable read config from CWD
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
-- close this message on load, which may cause a flash of intro message.
vim.opt.shortmess:append({ I = true })
@ -23,20 +26,23 @@ vim.o.colorcolumn = "101"
vim.g.mapleader = " "
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", "zh", "<cmd>wincmd h<cr>", { silent = true })
vim.keymap.set("n", "zj", "<cmd>wincmd j<cr>", { silent = true })
vim.keymap.set("n", "zk", "<cmd>wincmd k<cr>", { silent = true })
vim.keymap.set("n", "zl", "<cmd>wincmd l<cr>", { silent = true })
vim.keymap.set("n", "<C-h>", "<cmd>wincmd h<cr>", { silent = true })
vim.keymap.set("n", "<C-j>", "<cmd>wincmd j<cr>", { silent = true })
vim.keymap.set("n", "<C-k>", "<cmd>wincmd k<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", "zcj", "<cmd>wincmd J<cr>", { silent = true })
vim.keymap.set("n", "zck", "<cmd>wincmd K<cr>", { silent = true })
vim.keymap.set("n", "zcl", "<cmd>wincmd L<cr>", { silent = true })
vim.keymap.set("n", "<leader><C-h>", "<cmd>wincmd H<cr>", { silent = true })
vim.keymap.set("n", "<leader><C-j>", "<cmd>wincmd J<cr>", { silent = true })
vim.keymap.set("n", "<leader><C-k>", "<cmd>wincmd K<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", "zp", "<cmd>bprevious<cr>", { silent = true })
vim.keymap.set("n", "zx", "<cmd>bdelete<cr>", { silent = true })
vim.keymap.set("n", "]b", "<cmd>bnext<cr>", { silent = true })
vim.keymap.set("n", "[b", "<cmd>bprevious<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 })

View file

@ -7,12 +7,6 @@ return {
vim.cmd("colorscheme gruvbox-material")
end
},
{
'stevearc/dressing.nvim',
enabled = custom.full_feature,
event = "VeryLazy",
opts = { },
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
@ -27,16 +21,9 @@ return {
{
"famiu/bufdelete.nvim",
keys = {
{ "zx", "<cmd>Bdelete<cr>", mode = "n" },
{ "<leader>c", "<cmd>Bdelete<cr>", mode = "n" },
},
},
{
"karb94/neoscroll.nvim",
enabled = custom.full_feature,
main = "neoscroll",
event = "VeryLazy",
opts = { },
},
{
"dstein64/nvim-scrollview",
enabled = custom.full_feature,

View file

@ -1,80 +0,0 @@
local function my_location()
local line = vim.fn.line(".")
local line_cnt = vim.fn.line("$")
local col = vim.fn.virtcol(".")
local col_cnt = vim.fn.virtcol("$") - 1
return string.format("%3d(%d):%d(%d)", line, line_cnt, col, col_cnt)
end
return {
{
"akinsho/bufferline.nvim",
enabled = custom.full_feature,
main = "bufferline",
event = "VeryLazy",
keys = {
{ "zn", "<cmd>BufferLineCycleNext<cr>" },
{ "zp", "<cmd>BufferLineCyclePrev<cr>" },
{ "zcn", "<cmd>BufferLineMoveNext<cr>" },
{ "zcp", "<cmd>BufferLineMovePrev<cr>" },
},
opts = {
options = {
numbers = "ordinal",
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local icon = level:match("error") and "" or ""
return " " .. icon .. count
end,
separator_style = "thick",
offsets = {
{
filetype = "NvimTree",
text = "Nvim Tree",
text_align = "center",
separator = true,
},
},
persist_buffer_sort = false,
}
},
},
{
"nvim-lualine/lualine.nvim",
enabled = custom.full_feature,
dependencies = {
"nvim-tree/nvim-web-devicons",
"dokwork/lualine-ex",
"nvim-lua/plenary.nvim",
},
main = "lualine",
event = "VeryLazy",
opts = {
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "ex.lsp.single", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding" , "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { my_location },
},
inactive_sections = {
lualine_a = { },
lualine_b = { },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { my_location },
},
options = {
disabled_filetypes = {
statusline = {"NvimTree"},
winbar = {},
},
},
},
init = function(_)
vim.o.mousemoveevent = true
end,
},
}

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,
},
}

View file

@ -0,0 +1,32 @@
return {
"akinsho/bufferline.nvim",
enabled = custom.full_feature,
main = "bufferline",
event = "VeryLazy",
keys = {
{ "]b", "<cmd>BufferLineCycleNext<cr>" },
{ "[b", "<cmd>BufferLineCyclePrev<cr>" },
{ ">b", "<cmd>BufferLineMoveNext<cr>" },
{ "<b", "<cmd>BufferLineMovePrev<cr>" },
},
opts = {
options = {
numbers = "ordinal",
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local icon = level:match("error") and "" or ""
return " " .. icon .. count
end,
separator_style = "thick",
offsets = {
{
filetype = "neo-tree",
text = "neo-tree",
text_align = "center",
separator = true,
},
},
persist_buffer_sort = false,
}
},
}

View file

@ -12,13 +12,13 @@ return {
vim.keymap.set(mode, l, r, opts)
end
m("n", "<leader>hn", function()
m("n", "]h", function()
if vim.wo.diff then return "]c" end
vim.schedule(function() gs.next_hunk() end)
return "<Ignore>"
end, {expr=true})
m("n", "<leader>hp", function()
m("n", "[h", function()
if vim.wo.diff then return "[c" end
vim.schedule(function() gs.prev_hunk() end)
return "<Ignore>"
@ -31,7 +31,7 @@ return {
m("n", "<leader>hS", gs.stage_buffer)
m("n", "<leader>hu", gs.undo_stage_hunk)
m("n", "<leader>hR", gs.reset_buffer)
m("n", "<leader>hv", gs.preview_hunk)
m("n", "<leader>hp", gs.preview_hunk)
m("n", "<leader>hb", function() gs.blame_line{full=true} end)
m("n", "<leader>htb", gs.toggle_current_line_blame)
m("n", "<leader>hd", gs.diffthis)

View file

@ -0,0 +1,3 @@
return {
"NMAC427/guess-indent.nvim",
}

47
lua/plugins/lualine.lua Normal file
View file

@ -0,0 +1,47 @@
local function my_location()
local line = vim.fn.line(".")
local line_cnt = vim.fn.line("$")
local col = vim.fn.virtcol(".")
local col_cnt = vim.fn.virtcol("$") - 1
return string.format("%3d(%d):%d(%d)", line, line_cnt, col, col_cnt)
end
return {
"nvim-lualine/lualine.nvim",
enabled = custom.full_feature,
dependencies = {
"nvim-tree/nvim-web-devicons",
"dokwork/lualine-ex",
"nvim-lua/plenary.nvim",
},
main = "lualine",
event = "VeryLazy",
opts = {
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "ex.lsp.single", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding" , "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { my_location },
},
inactive_sections = {
lualine_a = { },
lualine_b = { },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { my_location },
},
options = {
disabled_filetypes = {
statusline = {"NvimTree"},
winbar = {},
},
},
extensions = { "lazy", "neo-tree", "quickfix" }
},
init = function(_)
vim.o.mousemoveevent = true
end,
}

View file

@ -0,0 +1,8 @@
return {
"echasnovski/mini.animate",
main = "mini.animate",
opt = {},
config = function()
require("mini.animate").setup()
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" },
},
}