first commit
This commit is contained in:
3
lua/plugins/auto-save.lua
Normal file
3
lua/plugins/auto-save.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
require("auto-save").setup {
|
||||
trigger_events = {"InsertLeave", "BufLeave", "BufWinLeave"},
|
||||
}
|
||||
19
lua/plugins/bufferline.lua
Normal file
19
lua/plugins/bufferline.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
require("bufferline").setup({
|
||||
options = {
|
||||
-- 使用 nvim 内置lsp
|
||||
diagnostics = "nvim_lsp",
|
||||
diagnostics_indicator = function(count, level, diagnostics_dict)
|
||||
return "("..count..")"
|
||||
end,
|
||||
always_show_bufferline = false,
|
||||
-- 左侧让出 nvim-tree 的位置
|
||||
offsets = {
|
||||
{
|
||||
filetype = "NvimTree",
|
||||
text = "File Explorer",
|
||||
highlight = "Directory",
|
||||
text_align = "left",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
42
lua/plugins/file-tree.lua
Normal file
42
lua/plugins/file-tree.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
-- disable netrw at the very start of your init.lua (strongly advised)
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
-- set termguicolors to enable highlight groups
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
-- OR setup with some options
|
||||
require("nvim-tree").setup({
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "u", action = "dir_up" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = true,
|
||||
},
|
||||
})
|
||||
|
||||
local function open_nvim_tree(data)
|
||||
-- buffer is a directory
|
||||
local directory = vim.fn.isdirectory(data.file) == 1
|
||||
|
||||
if not directory then
|
||||
return
|
||||
end
|
||||
|
||||
-- change to the directory
|
||||
vim.cmd.cd(data.file)
|
||||
|
||||
-- open the tree
|
||||
require("nvim-tree.api").tree.open()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||
92
lua/plugins/gitsigns.lua
Normal file
92
lua/plugins/gitsigns.lua
Normal file
@@ -0,0 +1,92 @@
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { text = "│" },
|
||||
change = { text = "│" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
untracked = { text = "┆" },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000, -- Disable if file is longer than this (in lines)
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = "single",
|
||||
style = "minimal",
|
||||
relative = "cursor",
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
yadm = {
|
||||
enable = false,
|
||||
},
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map("n", "]c", function()
|
||||
if vim.wo.diff then
|
||||
return "]c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
map("n", "[c", function()
|
||||
if vim.wo.diff then
|
||||
return "[c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
-- Actions
|
||||
map({ "n", "v" }, "<leader>hs", ":Gitsigns stage_hunk<CR>")
|
||||
map({ "n", "v" }, "<leader>hr", ":Gitsigns reset_hunk<CR>")
|
||||
map("n", "<leader>hS", gs.stage_buffer)
|
||||
map("n", "<leader>hu", gs.undo_stage_hunk)
|
||||
map("n", "<leader>hR", gs.reset_buffer)
|
||||
map("n", "<leader>hp", gs.preview_hunk)
|
||||
map("n", "<leader>hb", function()
|
||||
gs.blame_line({ full = true })
|
||||
end)
|
||||
map("n", "<leader>tb", gs.toggle_current_line_blame)
|
||||
map("n", "<leader>hd", gs.diffthis)
|
||||
map("n", "<leader>hD", function()
|
||||
gs.diffthis("~")
|
||||
end)
|
||||
map("n", "<leader>td", gs.toggle_deleted)
|
||||
|
||||
-- Text object
|
||||
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
||||
end,
|
||||
})
|
||||
9
lua/plugins/golang.lua
Normal file
9
lua/plugins/golang.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
require("go").setup()
|
||||
local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.go",
|
||||
callback = function()
|
||||
require("go.format").goimport()
|
||||
end,
|
||||
group = format_sync_grp,
|
||||
})
|
||||
10
lua/plugins/indent_blackline.lua
Normal file
10
lua/plugins/indent_blackline.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars:append("space:⋅")
|
||||
vim.opt.listchars:append("eol:↴")
|
||||
|
||||
require("indent_blankline").setup({
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
show_end_of_line = true,
|
||||
space_char_blankline = " ",
|
||||
})
|
||||
12
lua/plugins/leap.lua
Normal file
12
lua/plugins/leap.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
require("leap").add_default_mappings()
|
||||
require("leap").opts.highlight_unlabeled_phase_one_targets = true
|
||||
|
||||
require("flit").setup({
|
||||
keys = { f = "f", F = "F", t = "t", T = "T" },
|
||||
-- A string like "nv", "nvo", "o", etc.
|
||||
labeled_modes = "v",
|
||||
multiline = true,
|
||||
-- Like `leap`s similar argument (call-specific overrides).
|
||||
-- E.g.: opts = { equivalence_classes = {} }
|
||||
opts = {},
|
||||
})
|
||||
1
lua/plugins/line-numbers.lua
Normal file
1
lua/plugins/line-numbers.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("numbers").setup({})
|
||||
13
lua/plugins/lspsaga.lua
Normal file
13
lua/plugins/lspsaga.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
require("lspsaga").setup({
|
||||
ui = {
|
||||
colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors(),
|
||||
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
|
||||
},
|
||||
})
|
||||
|
||||
require("lsp-colors").setup({
|
||||
Error = "#db4b4b",
|
||||
Warning = "#e0af68",
|
||||
Information = "#0db9d7",
|
||||
Hint = "#10B981"
|
||||
})
|
||||
40
lua/plugins/lualine.lua
Normal file
40
lua/plugins/lualine.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "tokyonight",
|
||||
component_separators = { left = "|", right = "|" },
|
||||
section_separators = { left = "", right = "" },
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {},
|
||||
})
|
||||
33
lua/plugins/mason.lua
Normal file
33
lua/plugins/mason.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
require("mason").setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
"golangci_lint_ls",
|
||||
"tsserver",
|
||||
"volar",
|
||||
"taplo",
|
||||
"lemminx",
|
||||
"yamlls",
|
||||
"sqlls",
|
||||
"jsonls",
|
||||
"jdtls",
|
||||
"bashls",
|
||||
"cssls",
|
||||
"dockerls",
|
||||
"docker_compose_language_service",
|
||||
"eslint",
|
||||
"html",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
1
lua/plugins/notify.lua
Normal file
1
lua/plugins/notify.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.notify = require("notify")
|
||||
43
lua/plugins/null-ls.lua
Normal file
43
lua/plugins/null-ls.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.formatting.buf,
|
||||
null_ls.builtins.formatting.clang_format,
|
||||
null_ls.builtins.formatting.dart_format,
|
||||
null_ls.builtins.formatting.eslint_d,
|
||||
null_ls.builtins.formatting.fixjson,
|
||||
null_ls.builtins.formatting.gofmt,
|
||||
null_ls.builtins.formatting.goimports_reviser,
|
||||
null_ls.builtins.formatting.google_java_format,
|
||||
null_ls.builtins.formatting.markdownlint,
|
||||
null_ls.builtins.formatting.markdown_toc,
|
||||
null_ls.builtins.formatting.rustfmt,
|
||||
null_ls.builtins.formatting.shfmt,
|
||||
null_ls.builtins.formatting.taplo,
|
||||
null_ls.builtins.formatting.xmllint,
|
||||
null_ls.builtins.formatting.yamlfmt,
|
||||
-- 诊断
|
||||
null_ls.builtins.diagnostics.buf,
|
||||
null_ls.builtins.diagnostics.checkmake,
|
||||
null_ls.builtins.diagnostics.checkstyle,
|
||||
null_ls.builtins.diagnostics.clang_check,
|
||||
null_ls.builtins.diagnostics.cppcheck,
|
||||
null_ls.builtins.diagnostics.eslint_d,
|
||||
null_ls.builtins.diagnostics.gitlint,
|
||||
null_ls.builtins.diagnostics.golangci_lint,
|
||||
null_ls.builtins.diagnostics.jsonlint,
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
null_ls.builtins.diagnostics.yamllint,
|
||||
-- 动作
|
||||
null_ls.builtins.code_actions.eslint_d,
|
||||
null_ls.builtins.code_actions.gitrebase,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.code_actions.gomodifytags,
|
||||
null_ls.builtins.code_actions.shellcheck,
|
||||
null_ls.builtins.code_actions.xo,
|
||||
-- 完成
|
||||
null_ls.builtins.completion.luasnip,
|
||||
},
|
||||
})
|
||||
1
lua/plugins/telescope.lua
Normal file
1
lua/plugins/telescope.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("telescope").setup({})
|
||||
1
lua/plugins/terminal.lua
Normal file
1
lua/plugins/terminal.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("toggleterm").setup({})
|
||||
61
lua/plugins/treesitter.lua
Normal file
61
lua/plugins/treesitter.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
require("nvim-treesitter.configs").setup({
|
||||
-- A list of parser names, or "all" (the four listed parsers should always be installed)
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"css",
|
||||
"dart",
|
||||
"diff",
|
||||
"dockerfile",
|
||||
"git_rebase",
|
||||
"gitattributes",
|
||||
"gitcommit",
|
||||
"gitignore",
|
||||
"go",
|
||||
"gomod",
|
||||
"gosum",
|
||||
"gowork",
|
||||
"help",
|
||||
"html",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"rust",
|
||||
"toml",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vue",
|
||||
"yaml",
|
||||
},
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = true,
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
-- List of parsers to ignore installing (for "all")
|
||||
ignore_install = {},
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<CR>",
|
||||
node_incremental = "<CR>",
|
||||
node_decremental = "<BS>",
|
||||
scope_incremental = "<TAB>",
|
||||
},
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
||||
1
lua/plugins/trouble.lua
Normal file
1
lua/plugins/trouble.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("trouble").setup({})
|
||||
Reference in New Issue
Block a user