From 4dca5f301cb7ae26d983b71229514a18519ef22a Mon Sep 17 00:00:00 2001 From: OrionPax Date: Thu, 22 Aug 2024 11:53:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 2 +- lua/custom/plugins/bufferline.lua | 2 ++ lua/custom/plugins/chinese-prettier.lua | 3 ++ lua/custom/plugins/init.lua | 5 ---- lua/custom/plugins/jump.lua | 15 ++++++++++ lua/custom/plugins/keymaps.lua | 6 ++++ lua/custom/plugins/markdown-preview.lua | 9 ++++++ lua/custom/plugins/mini.lua | 38 +++++++++++++++++++++++++ lua/custom/plugins/noice.lua | 16 +++++++++++ lua/custom/plugins/statusline.lua | 18 ++++++++++++ lua/custom/plugins/text-replace.lua | 8 ++++++ lua/custom/plugins/translation.lua | 21 ++++++++++++++ 12 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 lua/custom/plugins/bufferline.lua create mode 100644 lua/custom/plugins/chinese-prettier.lua delete mode 100644 lua/custom/plugins/init.lua create mode 100644 lua/custom/plugins/jump.lua create mode 100644 lua/custom/plugins/keymaps.lua create mode 100644 lua/custom/plugins/markdown-preview.lua create mode 100644 lua/custom/plugins/mini.lua create mode 100644 lua/custom/plugins/noice.lua create mode 100644 lua/custom/plugins/statusline.lua create mode 100644 lua/custom/plugins/text-replace.lua create mode 100644 lua/custom/plugins/translation.lua diff --git a/init.lua b/init.lua index 220d3045..b748ab77 100644 --- a/init.lua +++ b/init.lua @@ -892,7 +892,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua new file mode 100644 index 00000000..d45da895 --- /dev/null +++ b/lua/custom/plugins/bufferline.lua @@ -0,0 +1,2 @@ +-- tab 页签 +return { 'akinsho/bufferline.nvim', version = '*', dependencies = 'nvim-tree/nvim-web-devicons', opts = {} } \ No newline at end of file diff --git a/lua/custom/plugins/chinese-prettier.lua b/lua/custom/plugins/chinese-prettier.lua new file mode 100644 index 00000000..7cbf7721 --- /dev/null +++ b/lua/custom/plugins/chinese-prettier.lua @@ -0,0 +1,3 @@ +-- 中文格式化,中英文之间添加空格 +-- NOTE: 使用 `:Pangu` 进行格式化 +return { 'hotoo/pangu.vim', ft = { 'markdown' } } \ No newline at end of file diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8..00000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} diff --git a/lua/custom/plugins/jump.lua b/lua/custom/plugins/jump.lua new file mode 100644 index 00000000..3b7199fd --- /dev/null +++ b/lua/custom/plugins/jump.lua @@ -0,0 +1,15 @@ +-- 快速跳转 +return { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = {}, + -- stylua: ignore + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + }, +} \ No newline at end of file diff --git a/lua/custom/plugins/keymaps.lua b/lua/custom/plugins/keymaps.lua new file mode 100644 index 00000000..892df950 --- /dev/null +++ b/lua/custom/plugins/keymaps.lua @@ -0,0 +1,6 @@ +-- 使用 Shift + j/k 代替 Ctrl + d/u + +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') + +return {} diff --git a/lua/custom/plugins/markdown-preview.lua b/lua/custom/plugins/markdown-preview.lua new file mode 100644 index 00000000..9056b572 --- /dev/null +++ b/lua/custom/plugins/markdown-preview.lua @@ -0,0 +1,9 @@ +-- Markdown 预览 +return { + 'iamcco/markdown-preview.nvim', + build = 'cd app && npm install', + ft = 'markdown', + config = function() + vim.g.mkdp_auto_start = 1 + end, +} \ No newline at end of file diff --git a/lua/custom/plugins/mini.lua b/lua/custom/plugins/mini.lua new file mode 100644 index 00000000..7ff88f51 --- /dev/null +++ b/lua/custom/plugins/mini.lua @@ -0,0 +1,38 @@ +-- Mini 全家桶 +return { + 'echasnovski/mini.nvim', + config = function() + -- 可视化显示缩进范围 + require('mini.indentscope').setup() + + -- 自动配对 + require('mini.pairs').setup() + + -- 启动界面 + require('mini.starter').setup() + + -- 小地图 + local map = require 'mini.map' + + map.setup { + integrations = { + map.gen_integration.builtin_search(), + map.gen_integration.gitsigns(), + map.gen_integration.diagnostic(), + }, + symbols = { + encode = map.gen_encode_symbols.dot '4x2', + }, + } + + vim.keymap.set('n', 'tm', map.toggle, { desc = '[T]oggle [M]ap' }) + + vim.cmd [[autocmd User MiniStarterOpened + \ lua vim.keymap.set( + \ 'n', + \ '', + \ 'lua MiniStarter.eval_current_item(); MiniMap.open()', + \ { buffer = true } + \ )]] + end, +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua new file mode 100644 index 00000000..e677b8d7 --- /dev/null +++ b/lua/custom/plugins/noice.lua @@ -0,0 +1,16 @@ +-- 取代 messages, cmdline 和 popupmenu +return { + 'folke/noice.nvim', + event = 'VeryLazy', + opts = { + -- add any options here + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + 'MunifTanjim/nui.nvim', + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + -- 'rcarriga/nvim-notify', + }, +} \ No newline at end of file diff --git a/lua/custom/plugins/statusline.lua b/lua/custom/plugins/statusline.lua new file mode 100644 index 00000000..770554a5 --- /dev/null +++ b/lua/custom/plugins/statusline.lua @@ -0,0 +1,18 @@ +-- 状态栏 +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + options = { + theme = 'palenight', + component_separators = '', + section_separators = { left = '', right = '' }, + }, + sections = { + lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, + lualine_z = { + { 'location', separator = { right = '' }, left_padding = 2 }, + }, + }, + }, +} diff --git a/lua/custom/plugins/text-replace.lua b/lua/custom/plugins/text-replace.lua new file mode 100644 index 00000000..e872cf48 --- /dev/null +++ b/lua/custom/plugins/text-replace.lua @@ -0,0 +1,8 @@ +-- 文本替换 +return { + 'nvim-pack/nvim-spectre', + event = 'BufRead', + opts = {}, +} + +-- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/translation.lua b/lua/custom/plugins/translation.lua new file mode 100644 index 00000000..6879a694 --- /dev/null +++ b/lua/custom/plugins/translation.lua @@ -0,0 +1,21 @@ +-- 翻译 +-- NOTE: 弹出窗中 `g?` 查看操作帮助 +return { + 'potamides/pantran.nvim', + config = function() + local pantran = require 'pantran' + pantran.setup { + default_engine = 'google', + engines = { + google = { + fallback = { + default_source = 'auto', + default_target = 'zh', + }, + }, + }, + } + + vim.keymap.set('x', 't', pantran.motion_translate, { noremap = true, silent = true, expr = true, desc = '[T]ranslate' }) + end, +} \ No newline at end of file