init: public

This commit is contained in:
2025-04-13 15:09:14 +08:00
parent 5995c2050b
commit 50247d94e8
253 changed files with 12964 additions and 567 deletions

View File

@@ -0,0 +1,26 @@
M = {
check_ts = true,
ts_config = {
lua = { "string", "source" },
javascript = { "string", "template_string" },
},
fast_wrap = {
map = '<M-e>',
chars = { '{', '[', '(', '"', "'" },
pattern = [=[[%'%"%)%>%]%)%}%,]]=],
end_key = '$',
keys = 'qwertyuiopzxcvbnmasdfghjkl',
check_comma = true,
highlight = 'Search',
highlight_grey='Comment'
},
}
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local ok, cmp = pcall(require, "cmp")
if ok then
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
end
return M

View File

@@ -0,0 +1,31 @@
local buf_kill = require("core.globals").buf_kill
M = {
highlights = {
buffer_selected = {
bold = true
}
},
options = {
diagnostics = "nvim_lsp",
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
highlight = "Directory",
text_align = "center"
},
},
close_command = function (bufnr)
buf_kill("bd", bufnr, false)
end,
right_mouse_command = function (bufnr)
buf_kill("bd", bufnr, true)
end
}
}
vim.opt.termguicolors = true
return M

View File

@@ -0,0 +1,68 @@
local cmp = require("cmp")
M = {
window = {
completion = {
border = 'rounded',
scrollbar = '',
},
documentation = {
border = 'rounded',
scrollbar = '',
},
},
formatting = {
format = require('lspkind').cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = '...',
symbol_map = { Codeium = "", }
})
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<Escape>"] = cmp.mapping.abort(),
["<Tab>"] = cmp.mapping.confirm({ select = true }),
["<Up>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, {
"i",
"s"
}),
["<Down>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, {
"i",
"s"
}),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
-- { name = "codeium" },
{ name = "path" },
}, {
{ name = "buffer" },
})
}
vim.o.wildmenu = true
vim.o.pumheight = 10
return M

View File

@@ -0,0 +1,34 @@
M = {
sources = {
friendly_snippets = true
},
history = true,
updateevents = { "TextChanged", "TextChangedI" }
}
-- vscode format
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" }
-- snipmate format
require("luasnip.loaders.from_snipmate").load()
require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" }
-- lua format
require("luasnip.loaders.from_lua").load()
require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" }
local luasnip = require("luasnip")
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
if
luasnip.session.current_nodes[vim.api.nvim_get_current_buf()]
and not luasnip.session.jump_active
then
luasnip.unlink_current()
end
end,
})
return M

View File

@@ -0,0 +1,4 @@
M = {}
return M

View File

@@ -0,0 +1,4 @@
local keymap = vim.keymap
local opt = require("core.globals").keymap_opt
keymap.set("n", "<leader>tt", ":FloatermNew<CR>", opt)

View File

@@ -0,0 +1,19 @@
M = {
signs = {
add = { text = '', color = "green" },
change = { text = '', color = "blue" },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
current_line_blame = true,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol',
delay = 0,
ignore_whitespace = false,
},
}
return M

View File

@@ -0,0 +1,15 @@
M = {
enabled = true,
indent = {
tab_char = ""
},
scope = {
enabled = true,
show_start = false,
}
}
vim.opt.list = true
return M

View File

@@ -0,0 +1,4 @@
M = {}
return M

View File

@@ -0,0 +1,88 @@
local servers = {
"lua_ls",
"pyright",
"gopls",
"clangd",
"rust_analyzer",
"ts_ls",
"jsonls",
"cssls",
"nil_ls",
"html",
}
local extra_config = {
lua_ls = {
settings = {
Lua = {
workspace = {
library = {
vim.api.nvim_get_runtime_file("", true),
"${3rd}/luv/library",
"${3rd}/luassert/library",
}
},
diagnostics = {
globals = {
"vim"
}
},
completion = {
callSnippet = "Replace"
}
}
},
},
rust_analyzer = {
settings = {
rust_analyzer = {
check = {
command = "clippy"
},
formatting = {
command = { "rustfmt" },
},
}
},
},
}
local on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = "rounded",
source = "always",
prefix = " ",
scope = "line",
}
vim.diagnostic.open_float(nil, opts)
end,
})
end
local capabilities = require("cmp_nvim_lsp").default_capabilities()
capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
local lspconfig = require("lspconfig")
for _, server in ipairs(servers) do
local extra = extra_config[server] or {}
local config = {
on_attach = on_attach,
capabilities = capabilities
}
for k, v in pairs(extra) do
config[k] = v
end
lspconfig[server].setup(config)
end
vim.diagnostic.config({
virtual_lines = true
})

View File

@@ -0,0 +1,7 @@
M = {
-- ensure_installed = require("plugins.lsp.servers")
ensure_installed = {}
}
return M

View File

@@ -0,0 +1,12 @@
M = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
}
return M

View File

@@ -0,0 +1,29 @@
-- Keymaps
local opt = require("core.globals").keymap_opt
vim.keymap.set("n", "K", vim.lsp.buf.hover, opt)
vim.keymap.set("n", "<leader>lR", vim.lsp.buf.rename, opt)
vim.diagnostic.config({
virtual_text = { spacing = 4, prefix = "" },
signs = true,
underline = true,
update_in_insert = true,
severity_sort = true,
})
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "single",
})
--[[ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "single",
focusable = false,
relative = "cursor",
}) ]]

View File

@@ -0,0 +1,6 @@
M = {}
vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>",
{ desc = "Toggle Outline" })
return M

View File

@@ -0,0 +1,15 @@
M = {
"lua_ls",
"pyright",
"gopls",
"clangd",
"rust_analyzer",
"ts_ls",
"jsonls",
"cssls",
"nil_ls",
"html",
}
return M

View File

@@ -0,0 +1,16 @@
M = {
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "rounded"
},
hint_prefix = "^ ",
toggle_key = "<C-k>",
}
vim.keymap.set({ 'n' }, '<leader>k', require('lsp_signature').toggle_float_win,
{ silent = true, noremap = true, desc = 'toggle signature' })
vim.keymap.set({ 'n' }, 'K', vim.lsp.buf.signature_help,
{ silent = true, noremap = true, desc = 'toggle signature' })
return M

View File

@@ -0,0 +1,28 @@
M = {
options = {
theme = "tokyonight"
},
sections = {
lualine_y = {
'encoding', 'fileformat', 'filetype',
},
lualine_x = {
{
require("noice").api.status.message.get_hl,
cond = require("noice").api.status.message.has,
},
{
require("noice").api.status.command.get,
cond = require("noice").api.status.command.has,
color = { fg = "#ff9e64" },
},
{
require("noice").api.status.search.get,
cond = require("noice").api.status.search.has,
color = { fg = "#ff9e64" },
},
},
},
}
return M

View File

@@ -0,0 +1,31 @@
M = {}
vim.api.nvim_create_augroup("MarkdownPreviewAuto", {})
vim.api.nvim_create_user_command("MarkdownPreviewAutoEnable", function()
vim.api.nvim_create_autocmd("BufEnter", {
group = "MarkdownPreviewAuto",
pattern = { "*.md" },
desc = "Auto enable MarkdownPreview",
callback = function()
vim.cmd("MarkdownPreview")
end,
})
vim.api.nvim_create_autocmd("BufLeave", {
group = "MarkdownPreviewAuto",
pattern = { "*.md" },
desc = "Auto disable MarkdownPreview",
callback = function()
vim.cmd("MarkdownPreviewStop")
end,
})
end, { desc = "Auto enable MarkdownPreview" })
vim.api.nvim_create_user_command("MarkdownPreviewAutoDisable",
function()
vim.api.nvim_clear_autocmds({ group = "MarkdownPreviewAuto" })
end, {}
)
return M

View File

@@ -0,0 +1,4 @@
M = {}
return M

View File

@@ -0,0 +1,21 @@
M = {
sync_root_with_cwd = true,
diagnostics = {
enable = false,
debounce_delay = 50,
show_on_dirs = true
},
filters = {
git_ignored = false
}
}
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
local opt = require("core.globals").keymap_opt
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>", opt)
vim.keymap.set("n", "<leader>te", ":NvimTreeFocus<CR>", opt)
return M

View File

@@ -0,0 +1,302 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath
})
end
vim.opt.rtp:prepend(lazypath)
package.path = package.path .. ";" .. vim.fn.stdpath("config") .. "/lua/"
local plugins = {
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
config = function()
vim.cmd.colorscheme("tokyonight-storm")
end
},
{
"nvim-lualine/lualine.nvim",
lazy = false,
dependencies = { { "nvim-tree/nvim-web-devicons", lazy = true } },
config = function()
require("lualine").setup(require("plugins.lualine"))
end
},
{
"nvim-tree/nvim-tree.lua",
lazy = false,
dependencies = { { "nvim-tree/nvim-web-devicons", lazy = true } },
config = function()
require("nvim-tree").setup(require("plugins.nvim-tree"))
end
},
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
event = "VeryLazy",
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
"nushell/tree-sitter-nu"
},
config = function()
require("nvim-treesitter.configs").setup(require("plugins.treesitter"))
end,
build = ":TSUpdate"
},
{
url = "https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
lazy = false,
event = "VeryLazy",
config = function()
require("plugins.rainbow-delimiters")
end
},
{
"lukas-reineke/indent-blankline.nvim",
lazy = false,
event = "VeryLazy",
config = function()
require("ibl").setup(require("plugins.indent-blankline"))
end
},
{
"neovim/nvim-lspconfig",
dependencies = { "hrsh7th/cmp-nvim-lsp" },
lazy = false,
config = function()
require("plugins.lsp.lspconfig")
require("plugins.lsp.others")
end
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
cmd = "Trouble",
keys = {
{
"<leader>xx",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>xX",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>cs",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>cl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>xL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>xQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
opts = {}
},
{
"MysticalDevil/inlay-hints.nvim",
event = "LspAttach",
dependencies = { "neovim/nvim-lspconfig" },
config = function()
require("inlay-hints").setup()
end
},
{
"hedyhli/outline.nvim",
event = "LspAttach",
config = function()
require("outline").setup(require("plugins.lsp.outline"))
end,
},
{
"L3MON4D3/LuaSnip",
lazy = false,
dependencies = { { "rafamadriz/friendly-snippets", lazy = true } },
build = "make install_jsregexp",
config = function()
require("luasnip").setup(require("plugins.cmp.luasnip"))
end
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
"hrsh7th/cmp-path",
"onsails/lspkind.nvim"
},
lazy = false,
config = function()
require("cmp").setup(require("plugins.cmp.cmp"))
end
},
{
"numToStr/Comment.nvim",
lazy = false,
event = "VeryLazy",
config = function()
require("Comment").setup(require("plugins.comment"))
end
},
{
"windwp/nvim-autopairs",
lazy = false,
event = "VeryLazy",
dependencies = { "hrsh7th/nvim-cmp" },
config = function()
require("nvim-autopairs").setup(require("plugins.autopairs"))
end
},
{
"akinsho/bufferline.nvim",
lazy = false,
config = function()
require("bufferline").setup(require("plugins.bufferline"))
end
},
{
"lewis6991/gitsigns.nvim",
lazy = false,
event = "VeryLazy",
config = function()
require("gitsigns").setup(require("plugins.gitsigns"))
end
},
{
"nvim-telescope/telescope.nvim",
tag = "0.1.2",
dependencies = { "nvim-lua/plenary.nvim", "BurntSushi/ripgrep" },
config = function()
require("telescope").setup(require("plugins.telescope"))
end
},
{
"alexghergh/nvim-tmux-navigation",
lazy = false,
event = "VeryLazy",
config = function()
require("nvim-tmux-navigation").setup(require("plugins.tmuxnav"))
end
},
{
"natecraddock/sessions.nvim",
lazy = false,
event = "VeryLazy",
config = function()
require("sessions").setup(require("plugins.sessions"))
end
},
{
"natecraddock/workspaces.nvim",
lazy = false,
event = "VeryLazy",
dependencies = { "nvim-telescope/telescope.nvim", "natecraddock/sessions.nvim" },
config = function()
require("workspaces").setup(require("plugins.workspaces"))
require("telescope").load_extension("workspaces")
end
},
--[[ {
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewAutoEnable", "MarkdownPreviewAutoDisable" },
ft = { "markdown" },
build = function()
vim.fn["mkdp#util#install"]()
end,
config = function()
require("plugins.markdown-preview")
end
}, ]]
--[[ {
"dhruvasagar/vim-table-mode",
lazy = true,
event = "BufEnter *.md",
config = function()
require("plugins.table-mode")
end
}, ]]
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = true, -- or `opts = {}`
},
{
"folke/noice.nvim",
lazy = false,
event = "VeryLazy",
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
},
opts = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
}
}
},
{
"voldikss/vim-floaterm",
lazy = false,
event = "VeryLazy",
config = function()
require("plugins.floaterm")
end
},
{
"folke/todo-comments.nvim",
lazy = false,
event = "VeryLazy",
opts = {},
},
{
"ojroques/nvim-osc52",
event = "BufEnter",
config = function()
require("osc52").setup({
tmux_passthrough = true
})
local function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end
vim.api.nvim_create_autocmd("TextYankPost", {callback = copy})
end
},
{
"pest-parser/pest.vim",
event = "VeryLazy",
opts = {}
}
}
local opts = {
rocks = {
enabled = false
}
}
require("lazy").setup(plugins, opts)

View File

@@ -0,0 +1,21 @@
local rainbow_delimiters = require("rainbow-delimiters")
vim.g.rainbow_delimiters = {
strategy = {
[''] = rainbow_delimiters.strategy['global'],
vim = rainbow_delimiters.strategy['local'],
},
query = {
[''] = 'rainbow-delimiters',
lua = 'rainbow-blocks',
},
highlight = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
},
}

View File

@@ -0,0 +1,10 @@
M = {
events = { "VimLeavePre" },
indent = {
tab_char = ""
},
session_filepath = vim.fn.stdpath("data") .. "/session",
}
return M

View File

@@ -0,0 +1,34 @@
M = {}
vim.g.table_mode_corner = "|"
vim.api.nvim_create_augroup("TableModeAuto", {})
vim.api.nvim_create_user_command("TableModeAutoEnable", function()
vim.api.nvim_clear_autocmds({ group = "TableModeAuto" })
vim.api.nvim_create_autocmd("BufEnter", {
group = "TableModeAuto",
pattern = { "*.md" },
desc = "Auto enable TableMode",
callback = function()
vim.cmd("TableModeEnable")
end,
})
vim.api.nvim_create_autocmd("BufWrite", {
group = "TableModeAuto",
pattern = { "*.md" },
desc = "Auto enable TableMode",
callback = function()
vim.cmd("TableModeRealign")
end,
})
end, { desc = "Auto enable TableMode" })
vim.api.nvim_create_user_command("TableModeAutoDisable",
function()
vim.api.nvim_clear_autocmds({ group = "TableModeAuto" })
end, {}
)
return M

View File

@@ -0,0 +1,45 @@
M = {
defaults = {
winblend = 50,
path_display = {
"smart",
shorten = 3
}
},
pickers = {
lsp_definitions = {
theme = "cursor",
layout_config = { width = 0.6, height = 0.3},
},
lsp_references = {
theme = "cursor",
layout_config = { width = 0.6, height = 0.3 },
},
current_buffer_fuzzy_find = {
theme = "dropdown",
layout_config = { height = 0.7, width = 0.55, preview_cutoff = 0 ,prompt_position = "top" }
},
lsp_document_symbols = {
theme = "ivy",
layout_config = { height = 0.25 }
}
},
}
local opt = require("core.globals").keymap_opt
local keymap = vim.keymap
local builtin = require('telescope.builtin')
keymap.set('n', '<leader>ff', builtin.find_files, opt)
keymap.set('n', '<leader>gf', builtin.git_files, opt)
keymap.set('n', '<leader>fg', builtin.live_grep, opt)
keymap.set('n', '<leader>fb', builtin.buffers, opt)
keymap.set('n', '<leader>fh', builtin.help_tags, opt)
-- keymap.set('n', '<leader>lD', builtin.diagnostics, opt)
keymap.set('n', '<leader>ld', builtin.lsp_definitions, opt)
keymap.set('n', '<leader>lr', builtin.lsp_references, opt)
keymap.set('n', '<leader>ls', builtin.lsp_document_symbols, opt)
keymap.set('n', '<leader>/', builtin.current_buffer_fuzzy_find, opt)
return M

View File

@@ -0,0 +1,14 @@
M = {}
local tmuxnav = require("nvim-tmux-navigation")
local keymap = vim.keymap
keymap.set("n", "<C-H>", tmuxnav.NvimTmuxNavigateLeft)
keymap.set("n", "<C-J>", tmuxnav.NvimTmuxNavigateDown)
keymap.set("n", "<C-K>", tmuxnav.NvimTmuxNavigateUp)
keymap.set("n", "<C-L>", tmuxnav.NvimTmuxNavigateRight)
keymap.set("n", "<C-\\>", tmuxnav.NvimTmuxNavigateLastActive)
keymap.set("n", "<C-Space>", tmuxnav.NvimTmuxNavigateNext)
return M

View File

@@ -0,0 +1,20 @@
M = {
auto_install = true,
parser_install_dir = "$HOME/.local/share/nvim/lazy/nvim-treesitter",
sync_install = true,
modules = {},
ignore_install = {},
highlight = { enable = true },
indent = { enable = true }
}
vim.filetype.add({
pattern = {
[".*/hypr/.*%.conf"] = "hyprlang",
[".*%.hl"] = "hyprlang"
},
})
return M

View File

@@ -0,0 +1,14 @@
M = {
hooks = {
open = function ()
require("core.globals").close_empty_buffer()
vim.cmd("enew")
vim.cmd("bufdo bd")
require("sessions").load(nil, { silent = true })
vim.cmd("NvimTreeFocus")
end
},
}
return M