mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-15 16:51:33 +00:00
modify
This commit is contained in:
@ -6,3 +6,224 @@
|
||||
--
|
||||
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
|
||||
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
|
||||
-- 封装设置文件类型的函数
|
||||
|
||||
local function set_filetype(patterns, filetype)
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
autocmd({ "BufNewFile", "BufRead" }, {
|
||||
pattern = patterns,
|
||||
callback = function()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_option(buf, "filetype", filetype)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- 设置 markdown 高亮用于 mdx 文件
|
||||
set_filetype({ "*.mdx" }, "markdown")
|
||||
|
||||
-- 设置 env 文件为 sh 类型
|
||||
set_filetype({ ".env.example", ".env.local", ".env.development", ".env.production" }, "sh")
|
||||
|
||||
-- 设置终端相关选项
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
autocmd({ "TermOpen" }, {
|
||||
callback = function()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_option(buf, "relativenumber", false)
|
||||
vim.api.nvim_buf_set_option(buf, "number", false)
|
||||
end,
|
||||
})
|
||||
|
||||
-- 解析 .gitignore 文件
|
||||
local function parse_gitignore()
|
||||
local gitignore_path = vim.fn.findfile(".gitignore", ".;")
|
||||
if gitignore_path == "" then
|
||||
return {}
|
||||
end
|
||||
local rules = {}
|
||||
local file = io.open(gitignore_path, "r")
|
||||
if file then
|
||||
for line in file:lines() do
|
||||
line = line:gsub("^%s*(.-)%s*$", "%1")
|
||||
if line ~= "" and not line:match("^#") then
|
||||
table.insert(rules, line)
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
return rules
|
||||
end
|
||||
-- 检查文件是否匹配 .gitignore 规则
|
||||
local function matches_gitignore(file_path, rules)
|
||||
local path_sep = package.config:sub(1, 1)
|
||||
for _, rule in ipairs(rules) do
|
||||
local pattern = "^" .. rule:gsub("%.", "%%."):gsub("%*", ".*"):gsub("%?", ".") .. "$"
|
||||
if file_path:match(pattern) then
|
||||
return true
|
||||
end
|
||||
-- 处理目录匹配
|
||||
if rule:sub(-1) == path_sep then
|
||||
pattern = "^" .. rule:gsub("%.", "%%."):gsub("%*", ".*"):gsub("%?", ".")
|
||||
if file_path:match(pattern) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
-- 自动更新磁盘上更改的文件,可跳过某些目录
|
||||
local skip_dirs = { "" } -- 手动指定要跳过检测的目录列表
|
||||
local gitignore_rules = parse_gitignore()
|
||||
autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
|
||||
callback = function()
|
||||
if vim.fn.mode() == "c" or vim.fn.bufexists("[Command Line]") then
|
||||
return
|
||||
end
|
||||
local bufname = vim.api.nvim_buf_get_name(0)
|
||||
for _, dir in ipairs(skip_dirs) do
|
||||
if string.find(bufname, dir, 1, true) then
|
||||
return -- 如果文件在手动跳过的目录中,不进行检测
|
||||
end
|
||||
end
|
||||
if matches_gitignore(bufname, gitignore_rules) then
|
||||
return -- 如果文件匹配 .gitignore 规则,不进行检测
|
||||
end
|
||||
vim.cmd("checktime")
|
||||
end,
|
||||
})
|
||||
|
||||
-- 文件更改后的通知
|
||||
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 和 o,不延续注释
|
||||
+ "r" -- 按回车键时延续注释
|
||||
end,
|
||||
})
|
||||
|
||||
-- 复制文本后高亮显示
|
||||
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
|
||||
autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = "*",
|
||||
})
|
||||
|
||||
-- 恢复光标位置
|
||||
autocmd("BufReadPost", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
local line = vim.fn.line("'\"")
|
||||
local filetype = vim.bo.filetype
|
||||
if
|
||||
line > 1
|
||||
and line <= vim.fn.line("$")
|
||||
and filetype ~= "commit"
|
||||
and vim.fn.index({ "xxd", "gitrebase" }, filetype) == -1
|
||||
then
|
||||
vim.cmd('normal! g`"')
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 函数:获取窗口栏路径
|
||||
local function get_winbar_path()
|
||||
return vim.fn.expand("%:.")
|
||||
end
|
||||
|
||||
-- 函数:获取主机名,添加错误日志
|
||||
local function get_hostname()
|
||||
local hostname = vim.fn.systemlist("hostname")
|
||||
if #hostname > 0 then
|
||||
return hostname[1]
|
||||
else
|
||||
vim.notify("Failed to get hostname", vim.log.levels.ERROR)
|
||||
return "unknown"
|
||||
end
|
||||
end
|
||||
|
||||
-- 函数:更新指定缓冲区的窗口栏
|
||||
local function update_winbar(bufnr)
|
||||
bufnr = bufnr or vim.api.nvim_get_current_buf()
|
||||
local old_buf = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_set_current_buf(bufnr)
|
||||
local home_replaced = get_winbar_path()
|
||||
if home_replaced == "" then
|
||||
return
|
||||
end
|
||||
-- local buffer_count = get_buffer_count()
|
||||
local ft = vim.bo.filetype
|
||||
local hostname = get_hostname()
|
||||
local winbar
|
||||
|
||||
if ft == "NvimTree" then
|
||||
winbar = "RUA"
|
||||
else
|
||||
local winbar_prefix = "%#WinBar1#%m "
|
||||
local winbar_suffix = "%*%=%#WinBar2#" .. hostname
|
||||
winbar = winbar_prefix .. "%#WinBar1#" .. home_replaced .. winbar_suffix
|
||||
end
|
||||
|
||||
-- vim.opt.winbar = winbar
|
||||
-- 检查缓冲区是否支持设置 winbar
|
||||
if vim.api.nvim_buf_is_valid(bufnr) then
|
||||
vim.api.nvim_buf_set_option(bufnr, "winbar", winbar)
|
||||
end
|
||||
-- 检查 old_buf 是否有效
|
||||
if vim.api.nvim_buf_is_valid(old_buf) then
|
||||
vim.api.nvim_set_current_buf(old_buf)
|
||||
end
|
||||
end
|
||||
|
||||
-- 自动命令:在 BufEnter 和 WinEnter 事件时更新窗口栏
|
||||
autocmd({ "BufEnter", "WinEnter" }, {
|
||||
callback = function(args)
|
||||
update_winbar(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
-- 启动时更新所有现有缓冲区的窗口栏
|
||||
local all_buffers = vim.api.nvim_list_bufs()
|
||||
for _, buf in ipairs(all_buffers) do
|
||||
if vim.api.nvim_buf_is_valid(buf) then
|
||||
update_winbar(buf)
|
||||
end
|
||||
end
|
||||
|
||||
-- 大文件检测
|
||||
local aug = vim.api.nvim_create_augroup("buf_large", { clear = true })
|
||||
autocmd({ "BufReadPre" }, {
|
||||
callback = function()
|
||||
local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())
|
||||
local ok, stats = pcall(vim.loop.fs_stat, bufname)
|
||||
local large_file_size = 100 * 1024 -- 100 KB
|
||||
|
||||
if ok and stats and stats.size > large_file_size then
|
||||
vim.b.large_buf = true
|
||||
vim.opt_local.foldmethod = "manual"
|
||||
vim.opt_local.spell = false
|
||||
else
|
||||
vim.b.large_buf = false
|
||||
end
|
||||
end,
|
||||
group = aug,
|
||||
pattern = "*",
|
||||
})
|
||||
|
||||
-- 在 Vim 退出前保存会话
|
||||
-- autocmd("VimLeavePre", {
|
||||
-- command = ":SessionSave",
|
||||
-- })
|
||||
|
@ -1,3 +1,28 @@
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
-- Add any additional keymaps here
|
||||
local map = LazyVim.safe_keymap_set
|
||||
|
||||
-- terminal
|
||||
map("t", "<C-x>", "<c-\\><c-n>")
|
||||
-- map("n", "<leader>tt", ":term<CR>", { desc = "Open new terminal" })
|
||||
|
||||
-- buffers
|
||||
-- map("n", "<S-l>", "<CMD>bn<CR>")
|
||||
-- map("n", "<S-h>", "<CMD>bp<CR>")
|
||||
map("n", "<leader>x", "<CMD>bd<CR>")
|
||||
-- map("n", "<C-s>", "<CMD>w<CR>")
|
||||
map("n", "<leader>la", "<CMD>%bd|e#|bd#<CR>")
|
||||
|
||||
-- tabs
|
||||
map("n", "<leader>tc", ":tabclose<CR>", { desc = "Close current tab" })
|
||||
map("n", "<leader>tn", ":tabnew<CR>", { desc = "New tab" })
|
||||
|
||||
-- search
|
||||
map("v", "<leader>ss", ":s/\\%V", { desc = "Search and replace in visual selection" })
|
||||
|
||||
-- copy
|
||||
-- map({ "n", "v" }, "y", '"+y', { desc = "Copy to system clipboard" })
|
||||
|
||||
-- lsp
|
||||
map("n", "gh", "<CMD>lua vim.lsp.buf.hover()<CR>")
|
||||
|
15
lua/config/usercmd.lua
Normal file
15
lua/config/usercmd.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local user_command = vim.api.nvim_create_user_command
|
||||
|
||||
-- 定义 Difft 命令
|
||||
user_command("Difft", function()
|
||||
vim.cmd("windo diffthis")
|
||||
end, {
|
||||
desc = "windo Diffthis",
|
||||
})
|
||||
|
||||
-- 定义 Diffo 命令
|
||||
user_command("Diffo", function()
|
||||
vim.cmd("windo diffoff")
|
||||
end, {
|
||||
desc = "windo Diffoff",
|
||||
})
|
3
lua/plugins/disabled.lua
Normal file
3
lua/plugins/disabled.lua
Normal file
@ -0,0 +1,3 @@
|
||||
return {
|
||||
{ "akinsho/bufferline.nvim", enabled = false },
|
||||
}
|
@ -1,197 +0,0 @@
|
||||
-- since this is just an example spec, don't actually load anything here and return an empty spec
|
||||
-- stylua: ignore
|
||||
if true then return {} end
|
||||
|
||||
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
|
||||
--
|
||||
-- In your plugin files, you can:
|
||||
-- * add extra plugins
|
||||
-- * disable/enabled LazyVim plugins
|
||||
-- * override the configuration of LazyVim plugins
|
||||
return {
|
||||
-- add gruvbox
|
||||
{ "ellisonleao/gruvbox.nvim" },
|
||||
|
||||
-- Configure LazyVim to load gruvbox
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "gruvbox",
|
||||
},
|
||||
},
|
||||
|
||||
-- change trouble config
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
-- opts will be merged with the parent spec
|
||||
opts = { use_diagnostic_signs = true },
|
||||
},
|
||||
|
||||
-- disable trouble
|
||||
{ "folke/trouble.nvim", enabled = false },
|
||||
|
||||
-- override nvim-cmp and add cmp-emoji
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = { "hrsh7th/cmp-emoji" },
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, { name = "emoji" })
|
||||
end,
|
||||
},
|
||||
|
||||
-- change some telescope options and a keymap to browse plugin files
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
keys = {
|
||||
-- add a keymap to browse plugin files
|
||||
-- stylua: ignore
|
||||
{
|
||||
"<leader>fp",
|
||||
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
|
||||
desc = "Find Plugin File",
|
||||
},
|
||||
},
|
||||
-- change some options
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = { prompt_position = "top" },
|
||||
sorting_strategy = "ascending",
|
||||
winblend = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add pyright to lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- pyright will be automatically installed with mason and loaded with lspconfig
|
||||
pyright = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add tsserver and setup with typescript.nvim instead of lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"jose-elias-alvarez/typescript.nvim",
|
||||
init = function()
|
||||
require("lazyvim.util").lsp.on_attach(function(_, buffer)
|
||||
-- stylua: ignore
|
||||
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
|
||||
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
|
||||
end)
|
||||
end,
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- tsserver will be automatically installed with mason and loaded with lspconfig
|
||||
tsserver = {},
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
||||
setup = {
|
||||
-- example to setup with typescript.nvim
|
||||
tsserver = function(_, opts)
|
||||
require("typescript").setup({ server = opts })
|
||||
return true
|
||||
end,
|
||||
-- Specify * to use this function as a fallback for any server
|
||||
-- ["*"] = function(server, opts) end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
|
||||
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
|
||||
-- add more treesitter parsers
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
|
||||
-- would overwrite `ensure_installed` with the new value.
|
||||
-- If you'd rather extend the default config, use the code below instead:
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
-- add tsx and treesitter
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
"tsx",
|
||||
"typescript",
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- the opts function can also be used to change the default opts:
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sections.lualine_x, {
|
||||
function()
|
||||
return "😄"
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- or you can return new options to override all the defaults
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
return {
|
||||
--[[add your custom lualine config here]]
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- use mini.starter instead of alpha
|
||||
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
|
||||
|
||||
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
|
||||
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||
|
||||
-- add any tools you want to have installed below
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"flake8",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
8
lua/plugins/flash.lua
Normal file
8
lua/plugins/flash.lua
Normal file
@ -0,0 +1,8 @@
|
||||
return {
|
||||
"folke/flash.nvim",
|
||||
enabled = false,
|
||||
keys = {
|
||||
-- disable the default flash keymap
|
||||
{ "s", mode = { "n", "x", "o" }, false },
|
||||
},
|
||||
}
|
38
lua/plugins/hop.lua
Normal file
38
lua/plugins/hop.lua
Normal file
@ -0,0 +1,38 @@
|
||||
return {
|
||||
"phaazon/hop.nvim",
|
||||
branch = "v2",
|
||||
keys = {
|
||||
{
|
||||
"f",
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
|
||||
end,
|
||||
desc = "Hop motion search in current line after cursor",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
{
|
||||
"F",
|
||||
function()
|
||||
local hop = require("hop")
|
||||
local directions = require("hop.hint").HintDirection
|
||||
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
|
||||
end,
|
||||
desc = "Hop motion search in current line before cursor",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
{
|
||||
"<leader><leader>",
|
||||
function()
|
||||
local hop = require("hop")
|
||||
hop.hint_words({ current_line_only = false })
|
||||
end,
|
||||
desc = "Hop motion search words after cursor",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
keys = "etovxqpdygfblzhckisuran",
|
||||
},
|
||||
}
|
26
lua/plugins/lualine.lua
Normal file
26
lua/plugins/lualine.lua
Normal file
@ -0,0 +1,26 @@
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
opts = {
|
||||
options = {
|
||||
-- theme = "catppuccin",
|
||||
-- theme = "lackluster",
|
||||
-- theme = "rei",
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
},
|
||||
extensions = { "quickfix", "trouble", "mason", "lazy", "nvim-tree" },
|
||||
sections = {
|
||||
lualine_x = {
|
||||
{ "encoding" },
|
||||
{ "fileformat" },
|
||||
{ "filetype" },
|
||||
},
|
||||
-- lualine_y = {
|
||||
-- { "progress", color = { bg = "#de9aa3", fg = "#000000" } },
|
||||
-- },
|
||||
-- lualine_z = {
|
||||
-- { "location", color = { bg = "#eac8c7" } },
|
||||
-- },
|
||||
},
|
||||
},
|
||||
}
|
5
lua/plugins/mason-workaround.lua
Normal file
5
lua/plugins/mason-workaround.lua
Normal file
@ -0,0 +1,5 @@
|
||||
-- https://github.com/LazyVim/LazyVim/issues/6039#issuecomment-2856227817
|
||||
return {
|
||||
{ "mason-org/mason.nvim", version = "^1.0.0" },
|
||||
{ "mason-org/mason-lspconfig.nvim", version = "^1.0.0" },
|
||||
}
|
8
lua/plugins/nvim-lspconfig.lua
Normal file
8
lua/plugins/nvim-lspconfig.lua
Normal file
@ -0,0 +1,8 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function()
|
||||
local keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
-- disable a keymap
|
||||
keys[#keys + 1] = { "K", false }
|
||||
end,
|
||||
}
|
83
lua/plugins/oil.lua
Normal file
83
lua/plugins/oil.lua
Normal file
@ -0,0 +1,83 @@
|
||||
return {
|
||||
"stevearc/oil.nvim",
|
||||
keys = {
|
||||
{ "-", "<CMD>Oil<CR>", desc = "Open parent directory" },
|
||||
{
|
||||
"_",
|
||||
function()
|
||||
require("oil").open(vim.fn.getcwd())
|
||||
end,
|
||||
desc = "Open parent directory",
|
||||
},
|
||||
},
|
||||
cmd = { "Oil" },
|
||||
-- lazy = false,
|
||||
event = "VimEnter",
|
||||
-- dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("oil").setup({
|
||||
default_file_explorer = true,
|
||||
delete_to_trash = false,
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
columns = {
|
||||
"icon",
|
||||
"permissions",
|
||||
"size",
|
||||
"mtime",
|
||||
},
|
||||
keymaps = {
|
||||
["g?"] = "actions.show_help",
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-s>"] = false,
|
||||
--[[ ["<C-h>"] = { "actions.select", opts = { horizontal = true } }, ]]
|
||||
["<C-h>"] = false,
|
||||
["<C-t>"] = { "actions.select", opts = { tab = true } },
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = false,
|
||||
["q"] = "actions.close",
|
||||
["<C-l>"] = false,
|
||||
["<C-r>"] = { "actions.refresh" },
|
||||
["-"] = "actions.parent",
|
||||
["_"] = "actions.open_cwd",
|
||||
["`"] = "actions.cd",
|
||||
["~"] = { "actions.cd", opts = { scope = "tab" } },
|
||||
["gs"] = "actions.change_sort",
|
||||
["gx"] = "actions.open_external",
|
||||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
-- Mappings can be a string
|
||||
-- ["~"] = "<cmd>edit $HOME<CR>",
|
||||
-- Mappings can be a function
|
||||
-- ["gd"] = function()
|
||||
-- require("oil").set_columns({ "icon", "permissions", "size", "mtime" })
|
||||
-- end,
|
||||
-- You can pass additional opts to vim.keymap.set by using
|
||||
-- a table with the mapping as the first element.
|
||||
["<leader>ff"] = {
|
||||
function()
|
||||
require("telescope.builtin").find_files({
|
||||
cwd = require("oil").get_current_dir(),
|
||||
})
|
||||
end,
|
||||
mode = "n",
|
||||
nowait = true,
|
||||
desc = "Find files in the current directory",
|
||||
},
|
||||
["<leader>fw"] = {
|
||||
function()
|
||||
require("telescope.builtin").live_grep({
|
||||
cwd = require("oil").get_current_dir(),
|
||||
})
|
||||
end,
|
||||
mode = "n",
|
||||
nowait = true,
|
||||
desc = "Find files in the current directory",
|
||||
},
|
||||
},
|
||||
skip_confirm_for_simple_edits = true,
|
||||
watch_for_changes = true,
|
||||
})
|
||||
end,
|
||||
}
|
26
lua/plugins/snacks.lua
Normal file
26
lua/plugins/snacks.lua
Normal file
@ -0,0 +1,26 @@
|
||||
return {
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
-- https://github.com/folke/snacks.nvim/discussions/860#discussioncomment-12027395
|
||||
picker = {
|
||||
sources = {
|
||||
explorer = {
|
||||
layout = {
|
||||
layout = {
|
||||
position = "right",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
layouts = {
|
||||
sidebar = {
|
||||
layout = {
|
||||
layout = {
|
||||
position = "right",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user