mirror of
https://github.com/DefectingCat/dotfiles
synced 2025-07-16 01:01:36 +00:00
move old nvim config to deprecated
This commit is contained in:
99
deprecated/nvim/custom/chadrc.lua
Normal file
99
deprecated/nvim/custom/chadrc.lua
Normal file
@ -0,0 +1,99 @@
|
||||
---@type ChadrcConfig
|
||||
local M = {}
|
||||
|
||||
M.ui = {
|
||||
lsp_semantic_tokens = false,
|
||||
transparency = false,
|
||||
theme = "catppuccin",
|
||||
statusline = {
|
||||
theme = "default", -- default/vscode/vscode_colored/minimal
|
||||
|
||||
-- default/round/block/arrow (separators work only for "default" statusline theme;
|
||||
-- round and block will work for the minimal theme only)
|
||||
separator_style = "round",
|
||||
overriden_modules = nil,
|
||||
},
|
||||
|
||||
tabufline = {
|
||||
lazyload = true,
|
||||
overriden_modules = nil,
|
||||
},
|
||||
|
||||
nvdash = {
|
||||
load_on_startup = true,
|
||||
|
||||
header = {
|
||||
"⣇⣿⠘⣿⣿⣿⡿⡿⣟⣟⢟⢟⢝⠵⡝⣿⡿⢂⣼⣿⣷⣌⠩⡫⡻⣝⠹⢿⣿⣷",
|
||||
"⡆⣿⣆⠱⣝⡵⣝⢅⠙⣿⢕⢕⢕⢕⢝⣥⢒⠅⣿⣿⣿⡿⣳⣌⠪⡪⣡⢑⢝⣇",
|
||||
"⡆⣿⣿⣦⠹⣳⣳⣕⢅⠈⢗⢕⢕⢕⢕⢕⢈⢆⠟⠋⠉⠁⠉⠉⠁⠈⠼⢐⢕⢽",
|
||||
"⡗⢰⣶⣶⣦⣝⢝⢕⢕⠅⡆⢕⢕⢕⢕⢕⣴⠏⣠⡶⠛⡉⡉⡛⢶⣦⡀⠐⣕⢕",
|
||||
"⡝⡄⢻⢟⣿⣿⣷⣕⣕⣅⣿⣔⣕⣵⣵⣿⣿⢠⣿⢠⣮⡈⣌⠨⠅⠹⣷⡀⢱⢕",
|
||||
"⡝⡵⠟⠈⢀⣀⣀⡀⠉⢿⣿⣿⣿⣿⣿⣿⣿⣼⣿⢈⡋⠴⢿⡟⣡⡇⣿⡇⡀⢕",
|
||||
"⡝⠁⣠⣾⠟⡉⡉⡉⠻⣦⣻⣿⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣦⣥⣿⡇⡿⣰⢗⢄",
|
||||
"⠁⢰⣿⡏⣴⣌⠈⣌⠡⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⣉⣉⣁⣄⢖⢕⢕⢕",
|
||||
"⡀⢻⣿⡇⢙⠁⠴⢿⡟⣡⡆⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣵⣵⣿",
|
||||
"⡻⣄⣻⣿⣌⠘⢿⣷⣥⣿⠇⣿⣿⣿⣿⣿⣿⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿",
|
||||
"⣷⢄⠻⣿⣟⠿⠦⠍⠉⣡⣾⣿⣿⣿⣿⣿⣿⢸⣿⣦⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟",
|
||||
"⡕⡑⣑⣈⣻⢗⢟⢞⢝⣻⣿⣿⣿⣿⣿⣿⣿⠸⣿⠿⠃⣿⣿⣿⣿⣿⣿⡿⠁⣠",
|
||||
"⡝⡵⡈⢟⢕⢕⢕⢕⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⣀⣈⠙",
|
||||
"⡝⡵⡕⡀⠑⠳⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⡠⡲⡫⡪⡪⡣",
|
||||
},
|
||||
|
||||
extended_integrations = {
|
||||
"dap",
|
||||
"hop",
|
||||
"rainbowdelimiters",
|
||||
"codeactionmenu",
|
||||
"todo",
|
||||
"trouble",
|
||||
"notify",
|
||||
},
|
||||
|
||||
buttons = {
|
||||
{ " Find File", "Spc f f", "Telescope find_files" },
|
||||
{ " Recent Files", "Spc f o", "Telescope oldfiles" },
|
||||
{ " Find Word", "Spc f w", "Telescope live_grep" },
|
||||
{ " Bookmarks", "Spc m a", "Telescope marks" },
|
||||
{ " Themes", "Spc t h", "Telescope themes" },
|
||||
{ " Mappings", "Spc c h", "NvCheatsheet" },
|
||||
},
|
||||
},
|
||||
|
||||
---@type Base46HLGroupsList
|
||||
hl_override = {
|
||||
NvDashAscii = { bg = "NONE", fg = "#85c0dc" },
|
||||
NvDashButtons = { bg = "NONE", fg = "#b4befe" },
|
||||
CursorLine = {
|
||||
bg = "#313244",
|
||||
},
|
||||
Search = {
|
||||
--[[ bg = "#89dceb", ]]
|
||||
bg = "#f5c2e7",
|
||||
},
|
||||
},
|
||||
|
||||
-- cmp themeing
|
||||
cmp = {
|
||||
icons = true,
|
||||
lspkind_text = true,
|
||||
style = "atom", -- default/flat_light/flat_dark/atom/atom_colored
|
||||
border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables
|
||||
selected_item_bg = "colored", -- colored / simple
|
||||
},
|
||||
}
|
||||
|
||||
--[[ M.gitsigns = {
|
||||
signs = {
|
||||
add = { text = " " },
|
||||
change = { text = " " },
|
||||
delete = { text = " " },
|
||||
topdelete = { text = " " },
|
||||
changedelete = { text = " " },
|
||||
untracked = { text = " " },
|
||||
},
|
||||
} ]]
|
||||
|
||||
M.plugins = "custom.plugins"
|
||||
M.mappings = require "custom.mappings"
|
||||
|
||||
return M
|
23
deprecated/nvim/custom/configs/dap.lua
Normal file
23
deprecated/nvim/custom/configs/dap.lua
Normal file
@ -0,0 +1,23 @@
|
||||
local dap = require("dap")
|
||||
|
||||
dap.adapters["pwa-node"] = {
|
||||
type = "server",
|
||||
host = "127.0.0.1",
|
||||
port = 8123,
|
||||
executable = {
|
||||
command = "js-debug-adapter",
|
||||
},
|
||||
}
|
||||
|
||||
for _, language in ipairs({ "typescript", "javascript" }) do
|
||||
dap.configurations[language] = {
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "launch",
|
||||
name = "Launch file",
|
||||
program = "${file}",
|
||||
cwd = "${workspaceFolder}",
|
||||
runtimeExecutable = "node",
|
||||
},
|
||||
}
|
||||
end
|
152
deprecated/nvim/custom/configs/lspconfig.lua
Normal file
152
deprecated/nvim/custom/configs/lspconfig.lua
Normal file
@ -0,0 +1,152 @@
|
||||
local on_attach = require("plugins.configs.lspconfig").on_attach
|
||||
local capabilities = require("plugins.configs.lspconfig").capabilities
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local util = require("lspconfig/util")
|
||||
|
||||
local function organize_imports()
|
||||
local params = {
|
||||
command = "_typescript.organizeImports",
|
||||
arguments = { vim.api.nvim_buf_get_name(0) },
|
||||
}
|
||||
vim.lsp.buf.execute_command(params)
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(server)
|
||||
if server == "rust_analyzer" then
|
||||
return nil
|
||||
end
|
||||
lspconfig[server].setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
--[[ lspconfig.rust_analyzer.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
standalone = true,
|
||||
files = {
|
||||
excludeDirs = {
|
||||
".flatpak-builder",
|
||||
"_build",
|
||||
".dart_tool",
|
||||
".flatpak-builder",
|
||||
".git",
|
||||
".gitlab",
|
||||
".gitlab-ci",
|
||||
".gradle",
|
||||
".idea",
|
||||
".next",
|
||||
".project",
|
||||
".scannerwork",
|
||||
".settings",
|
||||
".venv",
|
||||
"archetype-resources",
|
||||
"bin",
|
||||
"hooks",
|
||||
"node_modules",
|
||||
"po",
|
||||
"screenshots",
|
||||
"target",
|
||||
"out",
|
||||
"../out",
|
||||
"../node_modules",
|
||||
"../.next",
|
||||
},
|
||||
},
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
ignored = {
|
||||
["async-trait"] = { "async_trait" },
|
||||
["napi-derive"] = { "napi" },
|
||||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}) ]]
|
||||
|
||||
lspconfig.tsserver.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
preferences = {
|
||||
disableSuggestions = true,
|
||||
},
|
||||
},
|
||||
commands = {
|
||||
OrganizeImports = {
|
||||
organize_imports,
|
||||
description = "Organize Imports",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig.pylsp.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { "python" },
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
pycodestyle = {
|
||||
ignore = { "W391" },
|
||||
maxLineLength = 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig.gopls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = { "gopls" },
|
||||
cmd_env = {
|
||||
GOFLAGS = "-tags=test,e2e_test,integration_test,acceptance_test",
|
||||
},
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_dir = util.root_pattern("go.work", "go.mod", ".git"),
|
||||
settings = {
|
||||
gopls = {
|
||||
completeUnimported = true,
|
||||
usePlaceholders = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig.jsonls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
validate = { enable = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig.yamlls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
yaml = {
|
||||
schemaStore = {
|
||||
-- You must disable built-in schemaStore support if you want to use
|
||||
-- this plugin and its advanced options like `ignore`.
|
||||
enable = false,
|
||||
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
|
||||
url = "",
|
||||
},
|
||||
schemas = require("schemastore").yaml.schemas(),
|
||||
},
|
||||
},
|
||||
})
|
66
deprecated/nvim/custom/configs/null-ls.lua
Normal file
66
deprecated/nvim/custom/configs/null-ls.lua
Normal file
@ -0,0 +1,66 @@
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
local formatting = null_ls.builtins.formatting -- to setup formatters
|
||||
local diagnostics = null_ls.builtins.diagnostics -- to setup linters
|
||||
local code_actions = null_ls.builtins.code_actions
|
||||
|
||||
local eslint_condition = function(utils)
|
||||
return utils.root_has_file({
|
||||
".eslintcache",
|
||||
".eslintrc",
|
||||
".eslintrc.js",
|
||||
".eslintrc.cjs",
|
||||
".eslintrc.yaml",
|
||||
".eslintrc.yml",
|
||||
".eslintrc.json",
|
||||
})
|
||||
end
|
||||
|
||||
local opts = {
|
||||
sources = {
|
||||
-- Golang
|
||||
formatting.gofmt,
|
||||
formatting.goimports_reviser,
|
||||
formatting.golines,
|
||||
-- JavaScript
|
||||
formatting.prettierd.with({
|
||||
prefer_local = "node_modules/.bin",
|
||||
}),
|
||||
-- Lua
|
||||
formatting.stylua,
|
||||
-- XML and SVG
|
||||
--[[ formatting.xmlformat.with({
|
||||
filetypes = {
|
||||
"xml",
|
||||
"svg",
|
||||
},
|
||||
}), ]]
|
||||
-- Bash
|
||||
formatting.shfmt,
|
||||
-- sql
|
||||
diagnostics.sqlfluff.with({
|
||||
extra_args = { "--dialect", "postgres" }, -- change to your dialect
|
||||
}),
|
||||
formatting.sqlfluff.with({
|
||||
extra_args = { "--dialect", "postgres" }, -- change to your dialect
|
||||
}),
|
||||
},
|
||||
--[[ on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end, ]]
|
||||
}
|
||||
|
||||
return opts
|
21
deprecated/nvim/custom/configs/overrides.lua
Normal file
21
deprecated/nvim/custom/configs/overrides.lua
Normal file
@ -0,0 +1,21 @@
|
||||
local M = {}
|
||||
|
||||
-- git support in nvimtree
|
||||
M.nvimtree = {
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = false,
|
||||
timeout = 500,
|
||||
},
|
||||
|
||||
renderer = {
|
||||
highlight_git = true,
|
||||
icons = {
|
||||
show = {
|
||||
git = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
80
deprecated/nvim/custom/configs/rust-tools.lua
Normal file
80
deprecated/nvim/custom/configs/rust-tools.lua
Normal file
@ -0,0 +1,80 @@
|
||||
local on_attach = require("plugins.configs.lspconfig").on_attach
|
||||
local capabilities = require("plugins.configs.lspconfig").capabilities
|
||||
|
||||
local mason_registry = require "mason-registry"
|
||||
local codelldb = mason_registry.get_package "codelldb"
|
||||
local extension_path = codelldb:get_install_path() .. "/extension/"
|
||||
local codelldb_path = extension_path .. "adapter/codelldb"
|
||||
local liblldb_path = ""
|
||||
if vim.loop.os_uname().sysname:find "Windows" then
|
||||
liblldb_path = extension_path .. "lldb\\bin\\liblldb.dll"
|
||||
elseif vim.fn.has "mac" == 1 then
|
||||
liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
|
||||
else
|
||||
liblldb_path = extension_path .. "lldb/lib/liblldb.so"
|
||||
end
|
||||
|
||||
local options = {
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
standalone = true,
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
loadOutDirsFromCheck = true,
|
||||
runBuildScripts = true,
|
||||
},
|
||||
checkOnSave = {
|
||||
allFeatures = true,
|
||||
command = "clippy",
|
||||
extraArgs = { "--no-deps" },
|
||||
},
|
||||
files = {
|
||||
excludeDirs = {
|
||||
".flatpak-builder",
|
||||
"_build",
|
||||
".dart_tool",
|
||||
".flatpak-builder",
|
||||
".git",
|
||||
".gitlab",
|
||||
".gitlab-ci",
|
||||
".gradle",
|
||||
".idea",
|
||||
".next",
|
||||
".project",
|
||||
".scannerwork",
|
||||
".settings",
|
||||
".venv",
|
||||
"archetype-resources",
|
||||
"bin",
|
||||
"hooks",
|
||||
"node_modules",
|
||||
"po",
|
||||
"screenshots",
|
||||
"target",
|
||||
},
|
||||
},
|
||||
},
|
||||
check = {
|
||||
command = "clippy",
|
||||
features = "all",
|
||||
extraArgs = { "--no-deps" },
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
ignored = {
|
||||
["async-trait"] = { "async_trait" },
|
||||
["napi-derive"] = { "napi" },
|
||||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
dap = {
|
||||
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
|
||||
},
|
||||
}
|
||||
|
||||
return options
|
76
deprecated/nvim/custom/configs/rust.lua
Normal file
76
deprecated/nvim/custom/configs/rust.lua
Normal file
@ -0,0 +1,76 @@
|
||||
vim.g.rustaceanvim = function()
|
||||
local mason_registry = require("mason-registry")
|
||||
local codelldb = mason_registry.get_package("codelldb")
|
||||
local extension_path = codelldb:get_install_path() .. "/extension/"
|
||||
local codelldb_path = extension_path .. "adapter/codelldb"
|
||||
local liblldb_path = ""
|
||||
|
||||
if vim.loop.os_uname().sysname:find("Windows") then
|
||||
liblldb_path = extension_path .. "lldb\\bin\\liblldb.dll"
|
||||
elseif vim.fn.has("mac") == 1 then
|
||||
liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
|
||||
else
|
||||
liblldb_path = extension_path .. "lldb/lib/liblldb.so"
|
||||
end
|
||||
|
||||
-- keymap
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.keymap.set("n", "<leader>ca", function()
|
||||
--[[ vim.cmd.RustLsp("codeAction") -- supports rust-analyzer's grouping ]]
|
||||
vim.lsp.buf.code_action()
|
||||
end, { silent = true, buffer = bufnr })
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { silent = true, buffer = bufnr })
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { silent = true, buffer = bufnr })
|
||||
|
||||
local cfg = require("rustaceanvim.config")
|
||||
return {
|
||||
tools = {},
|
||||
server = {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
standalone = true,
|
||||
files = {
|
||||
excludeDirs = {
|
||||
".flatpak-builder",
|
||||
"_build",
|
||||
".dart_tool",
|
||||
".flatpak-builder",
|
||||
".git",
|
||||
".gitlab",
|
||||
".gitlab-ci",
|
||||
".gradle",
|
||||
".idea",
|
||||
".next",
|
||||
".project",
|
||||
".scannerwork",
|
||||
".settings",
|
||||
".venv",
|
||||
"archetype-resources",
|
||||
"bin",
|
||||
"hooks",
|
||||
"node_modules",
|
||||
"po",
|
||||
"screenshots",
|
||||
"target",
|
||||
"out",
|
||||
"../out",
|
||||
"../node_modules",
|
||||
"../.next",
|
||||
},
|
||||
},
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
ignored = {
|
||||
["async-trait"] = { "async_trait" },
|
||||
["napi-derive"] = { "napi" },
|
||||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
dap = {
|
||||
adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path),
|
||||
},
|
||||
}
|
||||
end
|
16
deprecated/nvim/custom/configs/telescope.lua
Normal file
16
deprecated/nvim/custom/configs/telescope.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local options = {
|
||||
extensions = {
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown {
|
||||
-- even more opts
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local telescope = require "telescope"
|
||||
telescope.load_extension "ui-select"
|
||||
telescope.load_extension "notify"
|
||||
telescope.load_extension "fzf"
|
||||
|
||||
return options
|
12
deprecated/nvim/custom/init.lua
Normal file
12
deprecated/nvim/custom/init.lua
Normal file
@ -0,0 +1,12 @@
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "", numhl = "DapBreakpoint", texthl = "DapBreakpoint" })
|
||||
vim.fn.sign_define("DagLogPoint", { text = "", numhl = "DapLogPoint", texthl = "DapLogPoint" })
|
||||
vim.fn.sign_define("DapStopped", { text = "", numhl = "DapStopped", texthl = "DapStopped" })
|
||||
vim.fn.sign_define(
|
||||
"DapBreakpointRejected",
|
||||
{ text = "", numhl = "DapBreakpointRejected", texthl = "DapBreakpointRejected" }
|
||||
)
|
||||
|
||||
require "custom.utils.autocmd"
|
||||
require "custom.utils.usercmd"
|
||||
require "custom.utils.options"
|
||||
require "custom.utils.neovide"
|
434
deprecated/nvim/custom/mappings.lua
Normal file
434
deprecated/nvim/custom/mappings.lua
Normal file
@ -0,0 +1,434 @@
|
||||
local M = {}
|
||||
|
||||
M.disabled = {
|
||||
n = {
|
||||
["<leader>wa"] = "",
|
||||
["<leader>wr"] = "",
|
||||
["<leader>wl"] = "",
|
||||
["<leader>wK"] = "",
|
||||
["<leader>wk"] = "",
|
||||
["<leader>cm"] = "",
|
||||
},
|
||||
}
|
||||
|
||||
M.crates = {
|
||||
plugin = true,
|
||||
n = {
|
||||
["<leader>rcu"] = {
|
||||
function()
|
||||
require("crates").upgrade_all_crates()
|
||||
end,
|
||||
"update crates",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.dap = {
|
||||
plugin = true,
|
||||
n = {
|
||||
["<leader>db"] = { "<cmd> DapToggleBreakpoint <CR>" },
|
||||
["<leader>dr"] = {
|
||||
"<cmd> DapContinue <CR>",
|
||||
"Run or continue the debugger",
|
||||
},
|
||||
["<leader>dus"] = {
|
||||
function()
|
||||
local widgets = require("dap.ui.widgets")
|
||||
local sidebar = widgets.sidebar(widgets.scopes)
|
||||
sidebar.open()
|
||||
end,
|
||||
"Open debugging sidebar",
|
||||
},
|
||||
["<leader>drr"] = {
|
||||
"<cmd> RustLsp debuggables <CR>",
|
||||
"Run rust debug on current file",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.dap_go = {
|
||||
plugin = true,
|
||||
n = {
|
||||
["<leader>dgr"] = {
|
||||
function()
|
||||
require("dap-go").debug_test()
|
||||
end,
|
||||
"Debug go test",
|
||||
},
|
||||
["<leader>dgl"] = {
|
||||
function()
|
||||
require("dap-go").debug_last()
|
||||
end,
|
||||
"Debug last go test",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.gopher = {
|
||||
plugin = true,
|
||||
n = {
|
||||
["<leader>gsj"] = {
|
||||
"<cmd> GoTagAdd json <CR>",
|
||||
"Add json struct tags",
|
||||
},
|
||||
["<leader>gsy"] = {
|
||||
"<cmd> GoTagAdd yaml <CR>",
|
||||
"Add yaml struct tags",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.lspsaga = {
|
||||
n = {
|
||||
["<C-.>"] = {
|
||||
function()
|
||||
vim.lsp.buf.code_action()
|
||||
end,
|
||||
" Code Action",
|
||||
},
|
||||
--[[ ["gf"] = {
|
||||
function()
|
||||
vim.cmd "Lspsaga lsp_finder"
|
||||
end,
|
||||
" Go to definition",
|
||||
},
|
||||
["gt"] = {
|
||||
"<CMD>Lspsaga goto_definition<CR>",
|
||||
" Go to definition",
|
||||
},
|
||||
["<leader>lp"] = {
|
||||
"<CMD>Lspsaga peek_definition<CR>",
|
||||
" Peek definition",
|
||||
}, ]]
|
||||
["gh"] = {
|
||||
function()
|
||||
--[[ vim.lsp.buf.hover() ]]
|
||||
require("pretty_hover").hover()
|
||||
end,
|
||||
" Hover lsp",
|
||||
},
|
||||
["gr"] = { "<CMD>Telescope lsp_references<CR>", " Lsp references" },
|
||||
["gd"] = { "<CMD>Telescope lsp_definitions <CR>", " Lsp definitions" },
|
||||
},
|
||||
}
|
||||
|
||||
M.rua = {
|
||||
n = {
|
||||
["<tab>"] = {
|
||||
"<CMD> tabNext <CR>",
|
||||
"Goto next tab",
|
||||
},
|
||||
["<S-tab>"] = {
|
||||
"<CMD> tabprevious <CR>",
|
||||
"Goto prev tab",
|
||||
},
|
||||
|
||||
["<S-l>"] = {
|
||||
function()
|
||||
require("nvchad.tabufline").tabuflineNext()
|
||||
end,
|
||||
"Goto next buffer",
|
||||
},
|
||||
["<S-h>"] = {
|
||||
function()
|
||||
require("nvchad.tabufline").tabuflinePrev()
|
||||
end,
|
||||
"Goto prev buffer",
|
||||
},
|
||||
["<leader>pa"] = {
|
||||
"<CMD> %bd|e#|bd# <CR>",
|
||||
"Close all other buffers",
|
||||
},
|
||||
["<C-a>"] = { "gg<S-v>G" },
|
||||
-- $ 跳到行尾不带空格
|
||||
["$"] = { "g_" },
|
||||
-- motion
|
||||
["f"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search in current line after cursor",
|
||||
},
|
||||
["F"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search in current line before cursor",
|
||||
},
|
||||
["<leader>w"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_words({ direction = directions.AFTER_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search words after cursor",
|
||||
},
|
||||
["<leader>b"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_words({ direction = directions.BEFORE_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search words before cursor",
|
||||
},
|
||||
|
||||
-- term
|
||||
["<A-o>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("horizontal")
|
||||
end,
|
||||
"Toggle horizontal term",
|
||||
},
|
||||
["<D-o>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("horizontal")
|
||||
end,
|
||||
"Toggle horizontal term",
|
||||
},
|
||||
["<D-i>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("float")
|
||||
end,
|
||||
"Toggle floating term",
|
||||
},
|
||||
["<A-u>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("vertical")
|
||||
end,
|
||||
"Toggle vertical term",
|
||||
},
|
||||
["<D-u>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("vertical")
|
||||
end,
|
||||
"Toggle vertical term",
|
||||
},
|
||||
|
||||
-- arrange buffer
|
||||
["<leader>pl"] = {
|
||||
function()
|
||||
require("nvchad.tabufline").move_buf(1)
|
||||
end,
|
||||
"Move buffer right",
|
||||
},
|
||||
["<leader>ph"] = {
|
||||
function()
|
||||
require("nvchad.tabufline").move_buf(-1)
|
||||
end,
|
||||
"Move buffer left",
|
||||
},
|
||||
|
||||
-- notify
|
||||
["<leader>un"] = {
|
||||
function()
|
||||
require("notify").dismiss({ silent = true, pending = true })
|
||||
end,
|
||||
"Dismiss all Notifications",
|
||||
},
|
||||
|
||||
-- markdown preview
|
||||
["<leader>pm"] = {
|
||||
"<cmd> MarkdownPreview <CR>",
|
||||
"Preview Markdown file",
|
||||
},
|
||||
|
||||
-- window split
|
||||
["<leader>|"] = {
|
||||
"<cmd> vs <CR>",
|
||||
"Split window vertically",
|
||||
},
|
||||
["<leader>_"] = {
|
||||
"<cmd> sp <CR>",
|
||||
"Split window horizontally",
|
||||
},
|
||||
|
||||
-- spectre search
|
||||
["<leader>ss"] = {
|
||||
'<cmd>lua require("spectre").toggle()<CR>',
|
||||
"Toggle Spectre",
|
||||
},
|
||||
["<leader>sw"] = {
|
||||
'<cmd>lua require("spectre").open_visual({select_word=true})<CR>',
|
||||
"Spectre search current word",
|
||||
},
|
||||
["<leader>sp"] = {
|
||||
'<cmd>lua require("spectre").open_file_search({select_word=true})<CR>',
|
||||
"Spectre search on current file",
|
||||
},
|
||||
},
|
||||
v = {
|
||||
["$"] = { "g_" },
|
||||
-- motion
|
||||
["f"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search in current line after cursor",
|
||||
},
|
||||
["F"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search in current line before cursor",
|
||||
},
|
||||
["<leader>w"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_words({ direction = directions.AFTER_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search words after cursor",
|
||||
},
|
||||
["<leader>b"] = {
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_words({ direction = directions.BEFORE_CURSOR, current_line_only = false })
|
||||
end,
|
||||
"Hop motion search words before cursor",
|
||||
},
|
||||
|
||||
-- spectre search
|
||||
["<leader>sw"] = {
|
||||
'<esc><cmd>lua require("spectre").open_visual()<CR>',
|
||||
"Spectre search current word",
|
||||
},
|
||||
},
|
||||
-- term
|
||||
t = {
|
||||
["<A-o>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("horizontal")
|
||||
end,
|
||||
"Toggle horizontal term",
|
||||
},
|
||||
["<D-o>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("horizontal")
|
||||
end,
|
||||
"Toggle horizontal term",
|
||||
},
|
||||
["<D-i>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("float")
|
||||
end,
|
||||
"Toggle floating term",
|
||||
},
|
||||
["<A-u>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("vertical")
|
||||
end,
|
||||
"Toggle vertical term",
|
||||
},
|
||||
["<D-u>"] = {
|
||||
function()
|
||||
require("nvterm.terminal").toggle("vertical")
|
||||
end,
|
||||
"Toggle vertical term",
|
||||
},
|
||||
--[[ ["<Esc>"] = { vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true), "Escape terminal mode" }, ]]
|
||||
},
|
||||
}
|
||||
|
||||
M.trouble = {
|
||||
n = {
|
||||
["<leader>tx"] = { "<cmd>TroubleToggle<CR>" },
|
||||
["<leader>tw"] = { "<cmd>TroubleToggle workspace_diagnostics<CR>" },
|
||||
["<leader>td"] = { "<cmd>TroubleToggle document_diagnostics<CR>" },
|
||||
["<leader>tq"] = { "<cmd>TroubleToggle quickfix<CR>" },
|
||||
["<leader>tl"] = { "<cmd>TroubleToggle loclist<CR>" },
|
||||
["gR"] = { "<cmd>TroubleToggle lsp_references<CR>" },
|
||||
},
|
||||
}
|
||||
|
||||
M.telescope = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
["<leader>gm"] = { "<cmd> Telescope git_commits <CR>", "Git commits" },
|
||||
["<leader>gd"] = { "<cmd> DiffviewOpen <CR>", "Open diff view" },
|
||||
["<leader>gg"] = { "<cmd> LazyGit <CR>", "Open LazyGit" },
|
||||
["<leader>gf"] = { "<cmd> LazyGitFilterCurrentFile <CR>", "Open LazyGit fitler current file" },
|
||||
["<leader>gh"] = { "<cmd> DiffviewFileHistory % <CR>", "Open current file history" },
|
||||
["<leader>gc"] = { "<cmd> DiffviewClose <CR>", "Close Diffview" },
|
||||
["<leader>fc"] = {
|
||||
function()
|
||||
require("telescope.builtin").command_history()
|
||||
end,
|
||||
"Search command history",
|
||||
},
|
||||
["<leader>fr"] = {
|
||||
function()
|
||||
require("telescope.builtin").resume()
|
||||
end,
|
||||
"Resume last search",
|
||||
},
|
||||
["<leader>ft"] = {
|
||||
function()
|
||||
require("telescope.builtin").filetypes()
|
||||
end,
|
||||
"Set current filetype",
|
||||
},
|
||||
["<leader>fd"] = {
|
||||
function()
|
||||
require("telescope.builtin").diagnostics()
|
||||
end,
|
||||
"Find Diagnostics",
|
||||
},
|
||||
["<leader>fn"] = {
|
||||
function()
|
||||
require("telescope").extensions.notify.notify()
|
||||
end,
|
||||
"View notify history",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.whichkey = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
["<leader>K"] = {
|
||||
function()
|
||||
vim.cmd("WhichKey")
|
||||
end,
|
||||
"Which-key all keymaps",
|
||||
},
|
||||
["<leader>k"] = {
|
||||
function()
|
||||
local input = vim.fn.input("WhichKey: ")
|
||||
vim.cmd("WhichKey " .. input)
|
||||
end,
|
||||
"Which-key query lookup",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.lspconfig = {
|
||||
plugin = true,
|
||||
|
||||
--[[ n = {
|
||||
["<leader>ca"] = {
|
||||
function()
|
||||
vim.ui.select(vim.lsp.buf.code_action)
|
||||
end,
|
||||
"LSP code action",
|
||||
},
|
||||
}, ]]
|
||||
n = {
|
||||
["<leader>co"] = {
|
||||
"<cmd> OrganizeImports <CR>",
|
||||
"Organize imports",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
480
deprecated/nvim/custom/plugins.lua
Normal file
480
deprecated/nvim/custom/plugins.lua
Normal file
@ -0,0 +1,480 @@
|
||||
local cmp = require("cmp")
|
||||
|
||||
local overrides = require("custom.configs.overrides")
|
||||
|
||||
local plugins = {
|
||||
{
|
||||
"NvChad/nvcommunity",
|
||||
{ import = "nvcommunity.git.diffview" },
|
||||
{ import = "nvcommunity.git.lazygit" },
|
||||
{ import = "nvcommunity.lsp.prettyhover" },
|
||||
},
|
||||
|
||||
-- LSP, formatter, linter
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
require("plugins.configs.lspconfig")
|
||||
require("custom.configs.lspconfig")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
require("mason-nvim-dap").setup({
|
||||
ensure_installed = {
|
||||
"codelldb",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jay-babu/mason-null-ls.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
require("mason-null-ls").setup({
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"prettierd",
|
||||
"ymlfmt",
|
||||
"shellharden",
|
||||
"shfmt",
|
||||
"goimports",
|
||||
"goimports-reviser",
|
||||
"golines",
|
||||
"gopls",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"html",
|
||||
"volar",
|
||||
"tsserver",
|
||||
"tailwindcss",
|
||||
"eslint",
|
||||
"cssls",
|
||||
"cssmodules_ls",
|
||||
"jsonls",
|
||||
"yamlls",
|
||||
"docker_compose_language_service",
|
||||
"dockerls",
|
||||
"bashls",
|
||||
"clangd",
|
||||
"lemminx",
|
||||
},
|
||||
automatic_installation = true,
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("mason-lspconfig").setup(opts)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
-- defaults
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"lua",
|
||||
-- web dev
|
||||
"html",
|
||||
"css",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"tsx",
|
||||
"json",
|
||||
"vue",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"jsdoc",
|
||||
"scss",
|
||||
-- low level
|
||||
"rust",
|
||||
"toml",
|
||||
"go",
|
||||
"gomod",
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
highlight = {
|
||||
disable = function(_, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvimtools/none-ls.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
return require("custom.configs.null-ls")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
||||
},
|
||||
opts = function()
|
||||
---@diagnostic disable-next-line: different-requires
|
||||
local M = require("plugins.configs.cmp")
|
||||
M.completion.completeopt = "menu,menuone,noselect"
|
||||
M.mapping["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
})
|
||||
table.insert(M.sources, { name = "crates" })
|
||||
-- original LazyVim kind icon formatter
|
||||
local format_kinds = M.formatting.format
|
||||
M.formatting.format = function(entry, item)
|
||||
format_kinds(entry, item) -- add icons
|
||||
return require("tailwindcss-colorizer-cmp").formatter(entry, item)
|
||||
end
|
||||
return M
|
||||
end,
|
||||
},
|
||||
-- rust
|
||||
{
|
||||
"mrcjkb/rustaceanvim",
|
||||
version = "^4", -- Recommended
|
||||
ft = "rust",
|
||||
config = function()
|
||||
require("custom.configs.rust")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"saecki/crates.nvim",
|
||||
ft = { "toml" },
|
||||
config = function(_, opts)
|
||||
local crates = require("crates")
|
||||
crates.setup(opts)
|
||||
require("cmp").setup.buffer({
|
||||
sources = { { name = "crates" } },
|
||||
})
|
||||
crates.show()
|
||||
require("core.utils").load_mappings("crates")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"rust-lang/rust.vim",
|
||||
ft = "rust",
|
||||
init = function()
|
||||
vim.g.rustfmt_autosave = 1
|
||||
end,
|
||||
},
|
||||
-- golang
|
||||
{
|
||||
"olexsmir/gopher.nvim",
|
||||
ft = "go",
|
||||
config = function(_, opts)
|
||||
require("gopher").setup(opts)
|
||||
end,
|
||||
build = function()
|
||||
vim.cmd([[silent! GoInstallDeps]])
|
||||
end,
|
||||
},
|
||||
{
|
||||
"dreamsofcode-io/nvim-dap-go",
|
||||
ft = "go",
|
||||
dependencies = "mfussenegger/nvim-dap",
|
||||
config = function(_, opts)
|
||||
require("dap-go").setup(opts)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"b0o/schemastore.nvim",
|
||||
},
|
||||
|
||||
-- debug
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
event = "VeryLazy",
|
||||
dependencies = "mfussenegger/nvim-dap",
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
require("dapui").setup()
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
config = function()
|
||||
require("custom.configs.dap")
|
||||
require("core.utils").load_mappings("dap")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
lazy = false,
|
||||
config = function(_, opts)
|
||||
require("nvim-dap-virtual-text").setup(opts)
|
||||
end,
|
||||
},
|
||||
|
||||
-- telescope, code action ui
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
opts = function()
|
||||
require("custom.configs.telescope")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-ui-select.nvim",
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
build =
|
||||
"cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
|
||||
},
|
||||
{
|
||||
"nvim-pack/nvim-spectre",
|
||||
event = "BufRead",
|
||||
},
|
||||
-- motion, UI and others
|
||||
{
|
||||
"phaazon/hop.nvim",
|
||||
branch = "v2", -- optional but strongly recommended
|
||||
config = function()
|
||||
-- you can configure Hop the way you like here; see :h hop-config
|
||||
local hop = require("hop")
|
||||
hop.setup({ keys = "etovxqpdygfblzhckisuran" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"smoka7/multicursors.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"smoka7/hydra.nvim",
|
||||
},
|
||||
opts = {
|
||||
hint_config = false,
|
||||
},
|
||||
cmd = { "MCstart", "MCvisual", "MCclear", "MCpattern", "MCvisualPattern", "MCunderCursor" },
|
||||
keys = {
|
||||
{
|
||||
mode = { "v", "n" },
|
||||
"<Leader>m",
|
||||
--[[ "<C-n>", ]]
|
||||
"<cmd>MCstart<cr>",
|
||||
desc = "Create a selection for selected text or word under the cursor",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"jxnblk/vim-mdx-js",
|
||||
},
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"windwp/nvim-ts-autotag",
|
||||
dependencies = "nvim-treesitter/nvim-treesitter",
|
||||
config = function()
|
||||
require("nvim-ts-autotag").setup({})
|
||||
end,
|
||||
lazy = true,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"kylechui/nvim-surround",
|
||||
version = "*", -- Use for stability; omit to use `main` branch for the latest features
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("nvim-surround").setup({})
|
||||
end,
|
||||
},
|
||||
-- comment string
|
||||
{
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
},
|
||||
{
|
||||
"numToStr/Comment.nvim",
|
||||
opts = {
|
||||
pre_hook = function(ctx)
|
||||
local U = require("Comment.utils")
|
||||
|
||||
local location = nil
|
||||
if ctx.ctype == U.ctype.block then
|
||||
location = require("ts_context_commentstring.utils").get_cursor_location()
|
||||
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
|
||||
location = require("ts_context_commentstring.utils").get_visual_start_location()
|
||||
end
|
||||
|
||||
return require("ts_context_commentstring.internal").calculate_commentstring({
|
||||
key = ctx.ctype == U.ctype.line and "__default" or "__multiline",
|
||||
location = location,
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
-- term
|
||||
{
|
||||
"NvChad/nvterm",
|
||||
config = function()
|
||||
require("nvterm").setup({
|
||||
terminals = {
|
||||
type_opts = {
|
||||
float = {
|
||||
relative = "editor",
|
||||
row = 0.1,
|
||||
col = 0.1,
|
||||
width = 0.8,
|
||||
height = 0.8,
|
||||
border = "rounded",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
-- ui
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
opts = {
|
||||
fps = 120,
|
||||
render = "wrapped-compact",
|
||||
stages = "slide",
|
||||
top_down = false,
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"rcarriga/nvim-notify",
|
||||
},
|
||||
opts = {
|
||||
lsp = {
|
||||
message = {
|
||||
enabled = true,
|
||||
},
|
||||
progress = {
|
||||
enabled = false,
|
||||
},
|
||||
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
["vim.lsp.util.stylize_markdown"] = true,
|
||||
["cmp.entry.get_documentation"] = true,
|
||||
},
|
||||
hover = {
|
||||
enabled = false,
|
||||
},
|
||||
signature = {
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
-- you can enable a preset for easier configuration
|
||||
presets = {
|
||||
bottom_search = true, -- use a classic bottom cmdline for search
|
||||
command_palette = true, -- position the cmdline and popupmenu together
|
||||
long_message_to_split = true, -- long messages will be sent to a split
|
||||
inc_rename = false, -- enables an input dialog for inc-rename.nvim
|
||||
lsp_doc_border = true, -- add a border to hover docs and signature help
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
cmd = { "TroubleToggle", "Trouble", "TroubleRefresh" },
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"NvChad/nvim-colorizer.lua",
|
||||
opts = {
|
||||
user_default_options = {
|
||||
tailwind = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
event = "BufReadPost",
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"chikko80/error-lens.nvim",
|
||||
event = "BufRead",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
},
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
event = "BufRead",
|
||||
},
|
||||
{
|
||||
"iamcco/markdown-preview.nvim",
|
||||
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
|
||||
ft = { "markdown" },
|
||||
build = function()
|
||||
vim.fn["mkdp#util#install"]()
|
||||
end,
|
||||
},
|
||||
-- git
|
||||
{
|
||||
"sindrets/diffview.nvim",
|
||||
opts = {
|
||||
enhanced_diff_hl = true,
|
||||
view = {
|
||||
merge_tool = {
|
||||
layout = "diff3_mixed",
|
||||
disable_diagnostics = true,
|
||||
},
|
||||
},
|
||||
keymaps = {
|
||||
view = {
|
||||
["<tab>"] = false,
|
||||
},
|
||||
file_panel = {
|
||||
["<tab>"] = false,
|
||||
},
|
||||
file_history_panel = {
|
||||
["<tab>"] = false,
|
||||
},
|
||||
option_panel = {
|
||||
["<tab>"] = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
--[[ overrides ]]
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
opts = overrides.nvimtree,
|
||||
},
|
||||
}
|
||||
|
||||
return plugins
|
100
deprecated/nvim/custom/utils/autocmd.lua
Normal file
100
deprecated/nvim/custom/utils/autocmd.lua
Normal file
@ -0,0 +1,100 @@
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- set markdown highlight for mdx file
|
||||
autocmd({ "BufNewFile", "BufRead" }, {
|
||||
pattern = { "*.mdx" },
|
||||
callback = function()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Disbale diagnostic for files in node_modules
|
||||
autocmd({ "BufNewFile", "BufRead" }, {
|
||||
pattern = { "**/node_modules/**", "node_modules", "/node_modules/*" },
|
||||
callback = function()
|
||||
vim.diagnostic.disable(0)
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd("FileType", {
|
||||
desc = "Close NvimTree before quit nvim",
|
||||
pattern = { "NvimTree" },
|
||||
callback = function(args)
|
||||
autocmd("VimLeavePre", {
|
||||
callback = function()
|
||||
vim.api.nvim_buf_delete(args.buf, { force = true })
|
||||
return true
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd("BufEnter", {
|
||||
desc = "Close nvim if NvimTree is only running buffer",
|
||||
command = [[if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif]],
|
||||
})
|
||||
|
||||
-- Automatically update changed file in Vim
|
||||
-- Triger `autoread` when files changes on disk
|
||||
-- https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
|
||||
-- https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
|
||||
-- autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
|
||||
-- command = [[silent! if mode() != 'c' && !bufexists("[Command Line]") | checktime | endif]],
|
||||
-- })
|
||||
|
||||
-- Notification after file change
|
||||
-- https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
|
||||
autocmd("FileChangedShellPost", {
|
||||
command = [[echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]],
|
||||
})
|
||||
|
||||
---- 用o换行不要延续注释
|
||||
local myAutoGroup = vim.api.nvim_create_augroup("myAutoGroup", {
|
||||
clear = true,
|
||||
})
|
||||
autocmd("BufEnter", {
|
||||
group = myAutoGroup,
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.opt.formatoptions = vim.opt.formatoptions
|
||||
- "o" -- O and o, don't continue comments
|
||||
+ "r" -- But do continue when pressing enter.
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight on yank
|
||||
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
|
||||
autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = "*",
|
||||
})
|
||||
|
||||
-- Remove all trailing whitespace on save
|
||||
-- autocmd("BufWritePre", {
|
||||
-- command = [[:%s/\s\+$//e]],
|
||||
-- group = augroup("TrimWhiteSpaceGrp", { clear = true }),
|
||||
--})
|
||||
|
||||
-- conform.nvim auto save
|
||||
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
-- pattern = "*",
|
||||
-- callback = function(args)
|
||||
-- require("conform").format { bufnr = args.buf }
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- nvim-lint
|
||||
-- require('lint').linters_by_ft = {
|
||||
-- javascript = {"eslint"},
|
||||
-- typescript = {"eslint"},
|
||||
-- }
|
||||
--
|
||||
-- vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
-- callback = function()
|
||||
-- require("lint").try_lint()
|
||||
-- end,
|
||||
-- })
|
42
deprecated/nvim/custom/utils/neovide.lua
Normal file
42
deprecated/nvim/custom/utils/neovide.lua
Normal file
@ -0,0 +1,42 @@
|
||||
local opt = vim.opt
|
||||
|
||||
-- Helper function for transparency formatting
|
||||
local alpha = function()
|
||||
return string.format("%x", math.floor(255 * (vim.g.transparency or 0.8)))
|
||||
end
|
||||
|
||||
if vim.g.neovide then
|
||||
local function set_ime(args)
|
||||
if args.event:match "Enter$" then
|
||||
vim.g.neovide_input_ime = true
|
||||
else
|
||||
vim.g.neovide_input_ime = false
|
||||
end
|
||||
end
|
||||
|
||||
local ime_input = vim.api.nvim_create_augroup("ime_input", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "InsertEnter", "InsertLeave" }, {
|
||||
group = ime_input,
|
||||
pattern = "*",
|
||||
callback = set_ime,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CmdlineEnter", "CmdlineLeave" }, {
|
||||
group = ime_input,
|
||||
pattern = "[/\\?]",
|
||||
callback = set_ime,
|
||||
})
|
||||
|
||||
opt.guifont = "JetBrainsMono Nerd Font:h16"
|
||||
-- g:neovide_transparency should be 0 if you want to unify transparency of content and title bar.
|
||||
--[[ vim.g.neovide_transparency = 0 ]]
|
||||
--[[ vim.g.transparency = 0.91 ]]
|
||||
--[[ vim.g.neovide_background_color = "#0f1117" .. alpha() ]]
|
||||
vim.g.neovide_floating_blur_amount_x = 2.0
|
||||
vim.g.neovide_floating_blur_amount_y = 2.0
|
||||
vim.g.neovide_hide_mouse_when_typing = true
|
||||
vim.g.neovide_refresh_rate = 120
|
||||
vim.g.neovide_confirm_quit = true
|
||||
vim.g.neovide_input_macos_alt_is_meta = true
|
||||
end
|
15
deprecated/nvim/custom/utils/options.lua
Normal file
15
deprecated/nvim/custom/utils/options.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local opt = vim.opt
|
||||
|
||||
vim.g.dap_virtual_text = true
|
||||
vim.wo.relativenumber = true
|
||||
vim.wo.wrap = false
|
||||
-- opt.iskeyword:append("-")
|
||||
opt.foldmethod = "expr"
|
||||
opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
opt.foldlevel = 20
|
||||
opt.ignorecase = true
|
||||
opt.wildignore:append { "*/node_modules/*" }
|
||||
opt.clipboard:append { "unnamedplus" }
|
||||
opt.iskeyword:append "-"
|
||||
opt.termguicolors = true -- True color support
|
||||
opt.autoindent = true --- Good auto indent
|
184
deprecated/nvim/custom/utils/styled.lua
Normal file
184
deprecated/nvim/custom/utils/styled.lua
Normal file
@ -0,0 +1,184 @@
|
||||
local M = {}
|
||||
|
||||
local tbl = {}
|
||||
|
||||
function tbl.contains(_tbl, value)
|
||||
for _, current in pairs(_tbl) do
|
||||
if current == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function M.directives()
|
||||
local function is_one_line(range)
|
||||
return range[1] == range[3]
|
||||
end
|
||||
|
||||
local function is_range_empty_or_invalid(range)
|
||||
if range[3] < range[1] or (is_one_line(range) and range[4] <= range[2]) then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function make_subranges_between_children_like(node, predicate)
|
||||
local content = { { node:range() } }
|
||||
|
||||
for child in node:iter_children() do
|
||||
if predicate(child) then
|
||||
local child_range = { child:range() }
|
||||
local last_content_range = content[#content]
|
||||
local first_part = {
|
||||
last_content_range[1],
|
||||
last_content_range[2],
|
||||
child_range[1],
|
||||
child_range[2],
|
||||
}
|
||||
local second_part = {
|
||||
child_range[3],
|
||||
child_range[4],
|
||||
last_content_range[3],
|
||||
last_content_range[4],
|
||||
}
|
||||
if is_range_empty_or_invalid(first_part) then
|
||||
if not is_range_empty_or_invalid(second_part) then
|
||||
content[#content] = second_part
|
||||
end
|
||||
elseif is_range_empty_or_invalid(second_part) then
|
||||
content[#content] = first_part
|
||||
else
|
||||
content[#content] = first_part
|
||||
content[#content + 1] = second_part
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return content
|
||||
end
|
||||
|
||||
local directives = vim.treesitter.query.list_directives()
|
||||
if not tbl.contains(directives, "inject_without_named_children!") then
|
||||
vim.treesitter.query.add_directive("inject_without_named_children!", function(
|
||||
match,
|
||||
_, --[[ pattern ]]
|
||||
_, --[[ bufnr ]]
|
||||
predicate,
|
||||
metadata
|
||||
)
|
||||
local node = match[predicate[2]]
|
||||
metadata.content = make_subranges_between_children_like(node, function(child)
|
||||
return child:named()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
if not tbl.contains(directives, "inject_without_children!") then
|
||||
vim.treesitter.query.add_directive("inject_without_children!", function(
|
||||
match,
|
||||
_, --[[ pattern ]]
|
||||
_, --[[ bufnr ]]
|
||||
predicate,
|
||||
metadata
|
||||
)
|
||||
local node = match[predicate[2]]
|
||||
metadata.content = make_subranges_between_children_like(node, function(_)
|
||||
return true
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
M.ecma_injections = [[
|
||||
(comment) @jsdoc
|
||||
(comment) @comment
|
||||
(regex_pattern) @regex
|
||||
|
||||
; =============================================================================
|
||||
; languages
|
||||
|
||||
; {lang}`<{lang}>`
|
||||
(call_expression
|
||||
function: ((identifier) @language)
|
||||
arguments: ((template_string) @content
|
||||
(#offset! @content 0 1 0 -1)
|
||||
(#inject_without_children! @content)))
|
||||
|
||||
; gql`<graphql>`
|
||||
(call_expression
|
||||
function: ((identifier) @_name
|
||||
(#eq? @_name "gql"))
|
||||
arguments: ((template_string) @graphql
|
||||
(#offset! @graphql 0 1 0 -1)
|
||||
(#inject_without_children! @graphql)))
|
||||
|
||||
; hbs`<glimmer>`
|
||||
(call_expression
|
||||
function: ((identifier) @_name
|
||||
(#eq? @_name "hbs"))
|
||||
arguments: ((template_string) @glimmer
|
||||
(#offset! @glimmer 0 1 0 -1)
|
||||
(#inject_without_children! @glimmer)))
|
||||
|
||||
; =============================================================================
|
||||
; styled-components
|
||||
|
||||
; styled.div`<css>`
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
object: (identifier) @_name
|
||||
(#eq? @_name "styled"))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)
|
||||
(#inject_without_children! @css)))
|
||||
|
||||
; styled(Component)`<css>`
|
||||
(call_expression
|
||||
function: (call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "styled"))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)
|
||||
(#inject_without_children! @css)))
|
||||
|
||||
; styled.div.attrs({ prop: "foo" })`<css>`
|
||||
(call_expression
|
||||
function: (call_expression
|
||||
function: (member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @_name
|
||||
(#eq? @_name "styled"))))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)
|
||||
(#inject_without_children! @css)))
|
||||
|
||||
; styled(Component).attrs({ prop: "foo" })`<css>`
|
||||
(call_expression
|
||||
function: (call_expression
|
||||
function: (member_expression
|
||||
object: (call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "styled"))))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)
|
||||
(#inject_without_children! @css)))
|
||||
|
||||
; createGlobalStyle`<css>`
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "createGlobalStyle")
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)
|
||||
(#inject_without_children! @css)))
|
||||
]]
|
||||
|
||||
function M.queries()
|
||||
vim.treesitter.query.set("javascript", "injections", M.ecma_injections)
|
||||
vim.treesitter.query.set("typescript", "injections", M.ecma_injections)
|
||||
vim.treesitter.query.set("tsx", "injections", M.ecma_injections)
|
||||
end
|
||||
|
||||
return M
|
13
deprecated/nvim/custom/utils/usercmd.lua
Normal file
13
deprecated/nvim/custom/utils/usercmd.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local user_command = vim.api.nvim_create_user_command
|
||||
|
||||
-- Copy file path
|
||||
user_command("Cppath", function()
|
||||
local path = vim.fn.expand "%:p"
|
||||
vim.fn.setreg("+", path)
|
||||
vim.notify('Copied "' .. path .. '" to the clipboard!')
|
||||
end, {})
|
||||
user_command("CpRelPath", function()
|
||||
local path = vim.fn.expand "%"
|
||||
vim.fn.setreg("+", path)
|
||||
vim.notify('Copied "' .. path .. '" to the clipboard!')
|
||||
end, {})
|
Reference in New Issue
Block a user