From 51cd63ca7707d3820074356b798ab143c38076f5 Mon Sep 17 00:00:00 2001 From: gameloader Date: Fri, 13 Sep 2024 12:21:24 +0800 Subject: [PATCH] big update change from packer to lazy and other --- init.lua | 6 +- lazy-lock.json | 60 +++++++++ lua/autocmd.lua | 3 +- lua/basic.lua | 1 - lua/keybindings.lua | 189 ++++++++++++-------------- lua/lsp/config/astro.lua | 1 + lua/lsp/init.lua | 7 +- lua/plugin-config/dashboard.lua | 13 +- lua/plugin-config/gp.lua | 52 ++++---- lua/plugin-config/iron.lua | 40 ++++++ lua/plugin-config/lua_line.lua | 3 +- lua/plugin-config/toggleterm.lua | 4 +- lua/plugin-config/whichkey.lua | 71 ---------- lua/plugin.lua | 37 ++++++ lua/plugins.lua | 221 ------------------------------- lua/plugins/list.lua | 98 ++++++++++++++ lua/plugins/whichkey.lua | 19 +++ 17 files changed, 381 insertions(+), 444 deletions(-) create mode 100644 lazy-lock.json create mode 100644 lua/lsp/config/astro.lua create mode 100644 lua/plugin-config/iron.lua delete mode 100644 lua/plugin-config/whichkey.lua create mode 100644 lua/plugin.lua delete mode 100644 lua/plugins.lua create mode 100644 lua/plugins/list.lua create mode 100644 lua/plugins/whichkey.lua diff --git a/init.lua b/init.lua index 6478646..403ae5e 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ require("basic").load_default_options() -require("plugins") +require("plugin") require("keybindings") @@ -8,7 +8,6 @@ require("keybindings") require("plugin-config/buffer_line") require("plugin-config/treesitter") require("plugin-config/telescope") -require("plugin-config/whichkey") require("plugin-config/comment") require("plugin-config/vimtex") require("plugin-config/mason") @@ -17,7 +16,7 @@ require("plugin-config/notify") require("plugin-config/nvim-autopairs") require("plugin-config/lua_snip") require("plugin-config/table-mode") -require("plugin-config/gp") +-- require("plugin-config/gp") require("plugin-config/mkdnflow") require("plugin-config/project") -- require("plugin-config/alpha") @@ -29,6 +28,7 @@ require("plugin-config/jaq") require("plugin-config/toggleterm") require("plugin-config/indent-blankline") require("plugin-config/lazygit") +require("plugin-config/iron") require("autocmd") require("lsp") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..40d5106 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,60 @@ +{ + "AdvancedNewFile.nvim": { "branch": "main", "commit": "9b4576dcf916d848148241e7269c9cd78f299b22" }, + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, + "bufferline.nvim": { "branch": "main", "commit": "243893ba9d5d1049dd451a25cab32ec7f8f67bcf" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, + "cmp-omni": { "branch": "main", "commit": "4ef610bbd85a5ee4e97e09450c0daecbdc60de86" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" }, + "dressing.nvim": { "branch": "master", "commit": "c5775a888adbc50652cb370073fcfec963eca93e" }, + "everforest": { "branch": "master", "commit": "93b89630861a4c8a1be07bc54f6d53487acb2e57" }, + "flutter-tools.nvim": { "branch": "main", "commit": "ea1d398f543a54ba95357c3b8bb9d6f68eaec36c" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "gp.nvim": { "branch": "main", "commit": "f4cbbf489fb621ae8f4e512c38ae234ce1157fa7" }, + "hop.nvim": { "branch": "v2", "commit": "90db1b2c61b820e230599a04fedcd2679e64bd07" }, + "indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" }, + "iron.nvim": { "branch": "master", "commit": "e6b78ec1bc56eab63b3a9112d348b3d79836b672" }, + "jaq-nvim": { "branch": "master", "commit": "236296aae555657487d1bb4d066cbde9d79d8cd4" }, + "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, + "lazygit.nvim": { "branch": "main", "commit": "2432b447483f42ff2e18b2d392cb2bb27e495c08" }, + "live-command.nvim": { "branch": "main", "commit": "79f89a2e3472e69fe00d4df50605e323d30f2d09" }, + "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, + "lspkind-nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "material.nvim": { "branch": "main", "commit": "ac8f02e97e359b7d258c0a00ec0949fe880790ad" }, + "mini.nvim": { "branch": "main", "commit": "5c72e4d74e05f50325641e5fa921fca97a24cb13" }, + "mkdnflow.nvim": { "branch": "main", "commit": "d459bd7ce68910272038ed037c028180161fd14d" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "80dc74d081823649809f78370fa5b204aa9a853a" }, + "neocodeium": { "branch": "main", "commit": "d2c968ce714cbab1de99dd254e0baa412e4aec92" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-autopairs": { "branch": "master", "commit": "fd2badc24e675f947162a16c124d395bde80dbd6" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-dap": { "branch": "master", "commit": "90616ae6ae40053103dc66872886fc26b94c70c8" }, + "nvim-dap-ui": { "branch": "master", "commit": "1c351e4e417d4691da12948b6ecf966936a56d28" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "3497eb39bf413a57ab5b7e7e2e192683e462148c" }, + "nvim-lspconfig": { "branch": "master", "commit": "bb682c167a0878338b4313b55538953d1c039085" }, + "nvim-luapad": { "branch": "master", "commit": "176686eb616a5ada5dfc748f2b5109194bbe8a71" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-treesitter": { "branch": "master", "commit": "4af16a10b7f1e79275f712a1c6dcf725d301a303" }, + "nvim-web-devicons": { "branch": "master", "commit": "9154484705968658e9aab2b894d1b2a64bf9f83d" }, + "persistent-breakpoints.nvim": { "branch": "main", "commit": "4b199b1dcfd136cac8b0fa9c8dbbdeb81463f7a9" }, + "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "c5a14e0550699a7db575805cdb9ddc969ba0f1f5" }, + "telescope.nvim": { "branch": "master", "commit": "927c10f748e49c543b2d544c321a1245302ff324" }, + "toggleterm.nvim": { "branch": "main", "commit": "48be57eaba817f038d61bbf64d2c597f578c0827" }, + "vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" }, + "vimtex": { "branch": "master", "commit": "539a203f19531c6b9d2d1b093ee8911fb7050bbc" }, + "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" } +} diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 5c7833d..b875bd5 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -17,11 +17,10 @@ end function set_colorscheme() local colorschemes = vim.fn.getcompletion("", "color") - local desired_colorscheme = "material" + local desired_colorscheme = "material-lighter" if vim.tbl_contains(colorschemes, desired_colorscheme) then vim.cmd("colorscheme " .. desired_colorscheme) - vim.g.material_style = "lighter" else vim.cmd("colorscheme default") end diff --git a/lua/basic.lua b/lua/basic.lua index ae34b43..3669461 100644 --- a/lua/basic.lua +++ b/lua/basic.lua @@ -66,7 +66,6 @@ M.load_default_options = function() -- set leaderkey to space mapleader = " ", maplocalleader = "\\", - copilot_node_command = "~/.nodenv/versions/16.17.0/bin/node", codeium_filetypes = { tex = false, }, diff --git a/lua/keybindings.lua b/lua/keybindings.lua index 9835d6f..1e60dcd 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -8,10 +8,18 @@ local wk = require("which-key") -- basic operation for write and quit -- 文件写入退出基本操作 -wk.register({ - ["s"] = { ":w!", "Save File" }, - ["q"] = { ":qa", "Quit All" }, - ["S"] = { ":wa", "Save All" }, +wk.add({ + { "s", ":w!", desc = "Save File" }, + { "q", ":qa", desc = "Quit All" }, + { "S", ":wa", desc = "Save All" }, +}) + +-- iron related +wk.add({ + { "i", group = "Iron" }, + { "il", "lua require('iron.core').send_line()", desc = "Send line" }, + { "if", "lua require('iron.core').send_file()", desc = "Send file" }, + { "ic", "lua require('iron.core').send_until_cursor()", desc = "Send to cursor" }, }) -- lsp 回调快捷键设置 @@ -34,33 +42,29 @@ end map("n", ",", ":Jaq", opt) -- markdown related --- markdown 相关 -wk.register({ - ["m"] = { ":MarkdownPreview", "Markdown preview" }, +wk.add({ + { "m", ":MarkdownPreview", desc = "Markdown preview" }, }) -- git related --- git 相关 -wk.register({ - ["g"] = { ":LazyGit", "Open lazygit" }, -}) --- file related --- 文件相关操作 -wk.register({ - [""] = { "", "Last file" }, +wk.add({ + { "g", ":LazyGit", desc = "Open lazygit" }, }) -wk.register({ - ["f"] = { - name = "+File", - p = { ":Telescope projects", "Open project" }, - r = { ":Telescope oldfiles", "Recent files" }, - b = { ":Telescope file_browser", "File browser" }, - n = { ":AdvancedNewFile", "New file" }, - s = { ":Telescope live_grep", "Search in project" }, - f = { ":Telescope find_files", "Search file" }, - c = { ":source $MYVIMRC", "Reload config file" }, - }, +-- file related +wk.add({ + { "", "", desc = "Last file" }, +}) + +wk.add({ + { "f", group = "File" }, + { "fp", ":Telescope projects", desc = "Open project" }, + { "fr", ":Telescope oldfiles", desc = "Recent files" }, + { "fb", ":Telescope file_browser", desc = "File browser" }, + { "fn", ":AdvancedNewFile", desc = "New file" }, + { "fs", ":Telescope live_grep", desc = "Search in project" }, + { "ff", ":Telescope find_files", desc = "Search file" }, + { "fc", ":source $MYVIMRC", desc = "Reload config file" }, }) -- jk map to esc @@ -68,19 +72,16 @@ wk.register({ map("i", "jk", "", opt) -- window operate by which-key --- 窗口操作(使用which-key快捷键设置) -wk.register({ - ["w"] = { - name = "+Window", - h = { "h", "To left" }, - j = { "j", "To up" }, - k = { "k", "To down" }, - l = { "l", "To right" }, - s = { ":sp", "Split window" }, - v = { ":vsplit", "Vsplit window" }, - d = { ":close", "Close window" }, - o = { ":only", "Close others" }, - }, +wk.add({ + { "w", group = "Window" }, + { "wh", "h", desc = "To left" }, + { "wj", "j", desc = "To up" }, + { "wk", "k", desc = "To down" }, + { "wl", "l", desc = "To right" }, + { "ws", ":sp", desc = "Split window" }, + { "wv", ":vsplit", desc = "Vsplit window" }, + { "wd", ":close", desc = "Close window" }, + { "wo", ":only", desc = "Close others" }, }) -- base operation for visual mode @@ -91,15 +92,6 @@ map("v", ">", ">gv", opt) -- neoTree map("n", "T", ":NeoTreeFocusToggle", opt) --- Packer -wk.register({ - ["p"] = { - name = "+Packer", - i = { ":PackerSync", "PackerSync" }, - s = { ":PackerStatus", "PackerStatus" }, - c = { ":PackerClean", "PackerClean" }, - }, -}) -- 定义开关quickfix窗口的函数 @@ -121,32 +113,37 @@ local function toggle_quickfix() end -- Bufferline and buffer related -wk.register({ - ["b"] = { - name = "+Buffer", - k = { ":bd!", "Kill buffer" }, - o = { ":BufferLineCloseRight:BufferLineCloseLeft", "Close other buffer" }, - b = { ":Telescope buffers", "Open buffers" }, - n = { ":ls", "Buffer numbers" }, - c = { ":noh", "Cancel highlight" }, - C = { ":call setqflist([], 'r')", "Clear quickfix" }, - q = { - function() - toggle_quickfix() - end, - "Toggle quickfix", - }, - s = { ":Telescope current_buffer_fuzzy_find", "Searching in buffer" }, - }, -}) -wk.register({ - ["j"] = { ":HopLineStart", "Quick jump line" }, +wk.add({ + { "b", group = "Buffer" }, + { "bk", ":bd!", desc = "Kill buffer" }, + { "bo", ":BufferLineCloseRight:BufferLineCloseLeft", desc = "Close other buffer" }, + { "bb", ":Telescope buffers", desc = "Open buffers" }, + { "bn", ":ls", desc = "Buffer numbers" }, + { "bc", ":noh", desc = "Cancel highlight" }, + { "bC", ":call setqflist([], 'r')", desc = "Clear quickfix" }, + { "bq", function() toggle_quickfix() end, desc = "Toggle quickfix" }, + { "bs", ":Telescope current_buffer_fuzzy_find", desc = "Searching in buffer" }, }) --- 快速切换主题 -wk.register({ - ["c"] = { ":Telescope colorscheme", "Quick change colortheme" }, +wk.add({ + { "j", ":HopLineStart", desc = "Quick jump line" }, }) + +wk.add({ + { "c", group = "ChatGPT" }, + { "cb", ":%GpAppend", desc = "gpt response by buffer" }, +}) + +-- use gp to interact with chatgpt to write code +map("v", "r", ":'<,'>GpRewrite", opt) +map("v", "a", ":'<,'>GpAppend", opt) + + +-- 快速切换主题 +-- wk.register({ +-- ["c"] = { ":Telescope colorscheme", "Quick change colortheme" }, +-- }) + map("n", "", "za", opt) -- insert 模式下ctrl a e跳转开头结尾 map("i", "", "I", opt) @@ -160,18 +157,25 @@ map("i", "", ":BufferLineCyclePrev", opt) map("i", "", ":BufferLineCycleNext", opt) -- Mason -wk.register({ - ["l"] = { - name = "+Lsp", - i = { ":LspInstall", "Install lsp" }, - I = { ":MasonInstall ", "Install any" }, - r = { ":LspRestart", "Lsp restart" }, - m = { ":Mason", "Mason info" }, - u = { ":MasonUninstall", "Uninstall lsp" }, - U = { ":MasonUninstallAll", "Unistall all" }, - l = { ":LspInfo", "Lsp infos" }, - R = { vim.lsp.buf.rename, "Buffer var rename" }, - }, +wk.add({ + { "l", group = "Lsp" }, + { "li", ":LspInstall", desc = "Install lsp" }, + { "lI", ":MasonInstall ", desc = "Install any" }, + { "lr", ":LspRestart", desc = "Lsp restart" }, + { "lm", ":Mason", desc = "Mason info" }, + { "lu", ":MasonUninstall", desc = "Uninstall lsp" }, + { "lU", ":MasonUninstallAll", desc = "Unistall all" }, + { "ll", ":LspInfo", desc = "Lsp infos" }, + { "lR", vim.lsp.buf.rename, desc = "Buffer var rename" }, +}) + +-- dap keymaps +wk.add({ + { "d", group = "Debug" }, + { "dr", ":lua require('dap').continue()", desc = "Start debug" }, + { "db", ":lua require('dap').toggle_breakpoint()", desc = "Set breakpoint" }, + { "dc", ":lua require('dap').clear_breakpoints()", desc = "Clear breakpoint" }, + { "de", ":lua require'dap'.close():lua require'dap'.terminate():lua require'dap.repl'.close():lua require'dapui'.close():DapVirtualTextDisableo", desc = "Stop debug" }, }) -- cmpeletion keys @@ -198,24 +202,6 @@ pluginKeys.cmp = function(cmp) } end --- dap keymaps -wk.register({ - ["d"] = { - name = "+Debug", - r = { ":lua require('dap').continue()", "Start debug" }, - b = { ":lua require('dap').toggle_breakpoint()", "Set breakpoint" }, - c = { ":lua require('dap').clear_breakpoints()", "Clear breakpoint" }, - e = { - ":lua require'dap'.close()" - .. ":lua require'dap'.terminate()" - .. ":lua require'dap.repl'.close()" - .. ":lua require'dapui'.close()" - .. ":DapVirtualTextDisable" - .. "o", - "Stop debug", - }, - }, -}) map("i", "", ":lua require'dap'.continue()", opt) map("n", "", ":lua require'dap'.step_into()", opt) map("n", "", ":lua require'dap'.step_over()", opt) @@ -245,6 +231,7 @@ function SetKeybinds() ["c"] = { ":FlutterCopyProfilerUrl", "FlutterCopyProfilerUrl" }, ["w"] = { ":FlutterDevTools", "FlutterDevTools" }, }, opts) + -- elseif fileTy == "sh" then -- wk.register({ -- ["W"] = { ":w", "test write" }, diff --git a/lua/lsp/config/astro.lua b/lua/lsp/config/astro.lua new file mode 100644 index 0000000..723c978 --- /dev/null +++ b/lua/lsp/config/astro.lua @@ -0,0 +1 @@ +return require("lsp.config.basic_config") diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 451d4e2..cd5632e 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -8,21 +8,22 @@ local servers = { lua_ls = require("lsp.config.lua"), -- lua/lsp/config/lua.lua clangd = require("lsp.config.clangd"), gopls = require("lsp.config.gopls"), + astro = require("lsp.config.astro"), -- eslint = require("lsp.config.eslint"), -- r_language_server = require("lsp.config.r"), -- csharp_ls = require("lsp.config.csharp"), omnisharp = require("lsp.config.csharp"), -- bashls = require("lsp.config.bash"), - pyright = require("lsp.config.pyright"), + -- pyright = require("lsp.config.pyright"), marksman = require("lsp.config.marksman"), pylsp = require("lsp.config.pylsp"), -- texlab = require("lsp.config.texlab"), - volar = require("lsp.config.vue"), + -- volar = require("lsp.config.vue"), -- html = require("lsp.config.html"), -- cssls = require("lsp.config.css"), -- emmet_ls = require("lsp.config.emmet"), -- jsonls = require("lsp.config.json"), - tsserver = require("lsp.config.ts"), + ts_ls = require("lsp.config.ts"), -- rust_analyzer = require("lsp.config.rust"), -- yamlls = require("lsp.config.yamlls"), -- remark_ls = require("lsp.config.markdown"), diff --git a/lua/plugin-config/dashboard.lua b/lua/plugin-config/dashboard.lua index 40b7638..14a0a08 100644 --- a/lua/plugin-config/dashboard.lua +++ b/lua/plugin-config/dashboard.lua @@ -1,21 +1,10 @@ local db = require("dashboard") local function foot() - -- local total_plugins = #vim.tbl_keys(packer_plugins) - local function get_table_size(t) - local count = 0 - for _, __ in pairs(t) do - count = count + 1 - end - return count - end - - local opt, start = require("packer.plugin_utils").list_installed_plugins() - local plugin_count = get_table_size(opt) + get_table_size(start) local datetime = os.date(" %d-%m-%Y  %H:%M:%S") local version = vim.version() local nvim_version_info = "  v" .. version.major .. "." .. version.minor .. "." .. version.patch - return datetime .. "  " .. plugin_count .. " plugins" .. nvim_version_info + return datetime .. nvim_version_info end db.setup({ diff --git a/lua/plugin-config/gp.lua b/lua/plugin-config/gp.lua index a095d9a..a6c08fd 100644 --- a/lua/plugin-config/gp.lua +++ b/lua/plugin-config/gp.lua @@ -1,8 +1,8 @@ local conf = { -- required openai api key - openai_api_key = os.getenv("OPENAI_API_KEY"), + openai_api_key = "", -- api endpoint (you can change this to azure endpoint) - openai_api_endpoint = "https://api.openai.com/v1/chat/completions", + openai_api_endpoint = "https://api1.zhtec.xyz/v1/chat/completions", -- openai_api_endpoint = "https://$URL.openai.azure.com/openai/deployments/{{model}}/chat/completions?api-version=2023-03-15-preview", -- prefix for all commands cmd_prefix = "Gp", @@ -13,7 +13,7 @@ local conf = { -- directory for storing chat files chat_dir = vim.fn.stdpath("data"):gsub("/$", "") .. "/gp/chats", -- chat model (string with model name or table with model name and parameters) - chat_model = { model = "gpt-4", temperature = 1.1, top_p = 1 }, + chat_model = { model = "gpt-4o", temperature = 1.1, top_p = 1 }, -- chat model system prompt (use this to specify the persona/role of the AI) chat_system_prompt = "You are a general AI assistant.", -- chat custom instructions (not visible in the chat but prepended to model prompt) @@ -90,32 +90,32 @@ local conf = { whisper_tempo = "1.75", -- example hook functions (see Extend functionality section in the README) - hooks = { - InspectPlugin = function(plugin, params) - print(string.format("Plugin structure:\n%s", vim.inspect(plugin))) - print(string.format("Command params:\n%s", vim.inspect(params))) - end, + -- hooks = { + -- InspectPlugin = function(plugin, params) + -- print(string.format("Plugin structure:\n%s", vim.inspect(plugin))) + -- print(string.format("Command params:\n%s", vim.inspect(params))) + -- end, - -- GpImplement rewrites the provided selection/range based on comments in the code - Implement = function(gp, params) - local template = "Having following from {{filename}}:\n\n" - .. "```{{filetype}}\n{{selection}}\n```\n\n" - .. "Please rewrite this code according to the comment instructions." - .. "\n\nRespond only with the snippet of finalized code:" + -- GpImplement rewrites the provided selection/range based on comments in the code + -- Implement = function(gp, params) + -- local template = "Having following from {{filename}}:\n\n" + -- .. "```{{filetype}}\n{{selection}}\n```\n\n" + -- .. "Please rewrite this code according to the comment instructions." + -- .. "\n\nRespond only with the snippet of finalized code:" - gp.Prompt( - params, - gp.Target.rewrite, - nil, -- command will run directly without any prompting for user input - gp.config.command_model, - template, - gp.config.command_system_prompt - ) - end, + -- gp.Prompt( + -- params, + -- gp.Target.rewrite, + -- nil, -- command will run directly without any prompting for user input + -- gp.config.command_model, + -- template, + -- gp.config.command_system_prompt + -- ) + -- end, - -- your own functions can go here, see README for more examples like - -- :GpExplain, :GpUnitTests.., :GpBetterChatNew, .. - }, + -- your own functions can go here, see README for more examples like + -- :GpExplain, :GpUnitTests.., :GpBetterChatNew, .. + -- }, } -- call setup on your config diff --git a/lua/plugin-config/iron.lua b/lua/plugin-config/iron.lua new file mode 100644 index 0000000..ff5de91 --- /dev/null +++ b/lua/plugin-config/iron.lua @@ -0,0 +1,40 @@ +local iron = require("iron.core") + +iron.setup({ + config = { + -- Whether a repl should be discarded or not + scratch_repl = true, + -- Your repl definitions come here + repl_definition = { + sh = { + -- Can be a table or a function that + -- returns a table (see below) + command = { "zsh" }, + }, + python = { + command = { "ipython" }, + format = require("iron.fts.common").bracketed_paste, + }, + }, + -- How the repl window will be displayed + -- See below for more information + repl_open_cmd = require("iron.view").split("30%"), + }, + -- Iron doesn't set keymaps by default anymore. + -- You can set them here or manually add keymaps to the functions in iron.core + -- If the highlight is on, you can change how it looks + -- For the available options, check nvim_set_hl + keymaps = { + visual_send = "iv", + }, + highlight = { + italic = true, + }, + ignore_blank_lines = true, -- ignore blank lines when sending visual select lines +}) + +-- iron also has a list of commands, see :h iron-commands for all available commands +-- vim.keymap.set("n", "rs", "IronRepl") +-- vim.keymap.set("n", "rr", "IronRestart") +-- vim.keymap.set("n", "rf", "IronFocus") +-- vim.keymap.set("n", "ih", "IronHide") diff --git a/lua/plugin-config/lua_line.lua b/lua/plugin-config/lua_line.lua index 093a8ca..ecfb287 100644 --- a/lua/plugin-config/lua_line.lua +++ b/lua/plugin-config/lua_line.lua @@ -18,7 +18,6 @@ end require("lualine").setup({ options = { icons_enabled = true, - -- theme = "auto", component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { @@ -33,7 +32,7 @@ require("lualine").setup({ tabline = 1000, winbar = 1000, }, - theme = "material-nvim", + theme = "ayu_light", }, sections = { lualine_a = { "mode" }, diff --git a/lua/plugin-config/toggleterm.lua b/lua/plugin-config/toggleterm.lua index 635f698..5e05c64 100644 --- a/lua/plugin-config/toggleterm.lua +++ b/lua/plugin-config/toggleterm.lua @@ -6,8 +6,8 @@ require("toggleterm").setup({ return vim.o.columns * 0.4 end end, - open_mapping = [[]], - insert_mapping = true, + -- open_mapping = [[]], + -- insert_mapping = true, start_in_insert = true, autochdir = true, auto_scroll = false, -- automatically scroll to the bottom on terminal output diff --git a/lua/plugin-config/whichkey.lua b/lua/plugin-config/whichkey.lua deleted file mode 100644 index da0bab7..0000000 --- a/lua/plugin-config/whichkey.lua +++ /dev/null @@ -1,71 +0,0 @@ -require("which-key").setup{ - plugins = { - marks = true, -- shows a list of your marks on ' and ` - registers = true, -- shows your registers on " in NORMAL or in INSERT mode - spelling = { - enabled = false, -- enabling this will show WhichKey when pressing z= to select spelling suggestions - suggestions = 20, -- how many suggestions should be shown in the list? - }, - -- the presets plugin, adds help for a bunch of default keybindings in Neovim - -- No actual key bindings are created - presets = { - operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion - motions = true, -- adds help for motions - text_objects = true, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on - nav = true, -- misc bindings to work with windows - z = true, -- bindings for folds, spelling and others prefixed with z - g = true, -- bindings for prefixed with g - }, - }, - -- add operators that will trigger motion and text object completion - -- to enable all native operators, set the preset / operators plugin above - operators = { gc = "Comments" }, - key_labels = { - -- override the label used to display some keys. It doesn't effect WK in any other way. - -- For example: - -- [""] = "SPC", - -- [""] = "RET", - -- [""] = "TAB", - }, - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "➜", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - popup_mappings = { - scroll_down = '', -- binding to scroll down inside the popup - scroll_up = '', -- binding to scroll up inside the popup - }, - window = { - border = "none", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0 - }, - layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns - align = "left", -- align columns left, center or right - }, - ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label - hidden = { "", "", "", "", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible - triggers = "auto", -- automatically setup triggers - -- triggers = {""} -- or specify a list manually - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - -- this is mostly relevant for key maps that start with a native binding - -- most people should not need to change this - i = { "j", "k" }, - v = { "j", "k" }, - }, - -- disable the WhichKey popup for certain buf types and file types. - -- Disabled by deafult for Telescope - disable = { - buftypes = {}, - filetypes = { "TelescopePrompt" }, - }, -} diff --git a/lua/plugin.lua b/lua/plugin.lua new file mode 100644 index 0000000..fbf0c94 --- /dev/null +++ b/lua/plugin.lua @@ -0,0 +1,37 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + lazyrepo, + lazypath, + }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + { import = "plugins" }, + -- -- 插件配置放在这里 + }, + + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "" } }, + -- automatically check for plugin updates + checker = { enabled = false, frequency = 604800 }, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 3c94d0d..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,221 +0,0 @@ -return require("packer").startup(function() - -- Packer can manage itself - use("wbthomason/packer.nvim") - - -- lua 调试 - use("rafcamlet/nvim-luapad") - ------------------ themes -------------------------- - - -- use({ - -- "navarasu/onedark.nvim", - -- }) - - use("folke/tokyonight.nvim") - - use("sainnhe/everforest") - - use("marko-cerovac/material.nvim") - ----------------------------------------------------------------------------------------- - - -- a good terminal - -- 一个好的nvim内终端 - use({ "akinsho/toggleterm.nvim", tag = "*" }) - - -- make live command - -- 实时命令 - use({ "smjonas/live-command.nvim" }) - - -- lazygit support - -- 使用lazygit接口 - use("kdheepak/lazygit.nvim") - - ----------------- markdown -------------------- - -- markdown preview - -- markdown自动预览 - use({ - "iamcco/markdown-preview.nvim", - }) - - -- markdown flow and enhance - -- markdown 流程和增强 - use({ "jakewvincent/mkdnflow.nvim" }) - - -- orgmode support - -- orgmode 支持 - -- use({ "nvim-orgmode/orgmode" }) - - -- nvim-tree for file manage - -- use({ - -- "kyazdani42/nvim-tree.lua", - -- requires = "kyazdani42/nvim-web-devicons", - -- }) - - use({ - "nvim-neo-tree/neo-tree.nvim", - branch = "v2.x", - requires = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - }) - - ----------------latex------------------ - use("lervag/vimtex") - - -- vim dashboard - -- vim 开始界面 - use({ - "glepnir/dashboard-nvim", - requires = { "nvim-tree/nvim-web-devicons" }, - }) - - -- smooth neovim scroll - -- 顺滑的neovim滚动 - -- use("karb94/neoscroll.nvim") - - -- bufferline on the top - -- 顶部状态栏 - use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) - - -- treesitter - use({ - "nvim-treesitter/nvim-treesitter", - run = function() - require("nvim-treesitter.install").update({ with_sync = true }) - end, - }) - - --------------------- file related ------------------------------- - -- telescope - use({ - "nvim-telescope/telescope.nvim", - requires = { { "nvim-lua/plenary.nvim" } }, - }) - - -- telescope-file-browser - use({ "nvim-telescope/telescope-file-browser.nvim" }) - - -- create new file - -- 快捷创建新文件 - use("Mohammed-Taher/AdvancedNewFile.nvim") - - -- project - -- 项目管理 - use({ - "ahmedkhalf/project.nvim", - }) - - -- whick-key - use({ - "folke/which-key.nvim", - }) - - --------------------- buffer related ----------------- - - -- indent-blankline - -- 竖向加竖线显示对齐 - use({ "lukas-reineke/indent-blankline.nvim" }) - -- comment - use({ - "numToStr/Comment.nvim", - }) - - -- hop plugin - -- 快速跳转 - use({ - "phaazon/hop.nvim", - branch = "v2", -- optional but strongly recommended - }) - - -- lualine for bottom stausline - -- 底部状态栏 - use({ - "nvim-lualine/lualine.nvim", - requires = { "nvim-tree/nvim-web-devicons", opt = true }, - }) - - -- notify - -- 弹窗消息通知 - use({ - "rcarriga/nvim-notify", - }) - - -- autopairs - -- 自动补全括号 - use({ - "windwp/nvim-autopairs", - }) - - -- coderunner - -- 代码运行 - use({ "is0n/jaq-nvim" }) - - -- cmake support - -- cmake 支持 - -- use("Civitasv/cmake-tools.nvim") - - ------------------- lsp -------------------------- - -- mason for lsp dap linter and others - use({ - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", - }) - - -- null-ls for formatter and others - -- null-ls 用于格式化和其他 - use({ - "jose-elias-alvarez/null-ls.nvim", - }) - - -- flutter support - use({ - "akinsho/flutter-tools.nvim", - requires = { - "nvim-lua/plenary.nvim", - "stevearc/dressing.nvim", -- optional for vim.ui.select - }, - }) - -- -- 补全引擎 - use("hrsh7th/nvim-cmp") - -- Snippet 引擎 - use({ "L3MON4D3/LuaSnip" }) - use("hrsh7th/vim-vsnip") - -- 补全源 - use("hrsh7th/cmp-vsnip") - use({ "ray-x/lsp_signature.nvim" }) - use({ "saadparwaiz1/cmp_luasnip" }) - use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp } - use("hrsh7th/cmp-buffer") -- { name = 'buffer' }, - use("hrsh7th/cmp-path") -- { name = 'path' } - use("hrsh7th/cmp-omni") -- { name = 'omni' } - use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' } - use("hrsh7th/cmp-nvim-lsp-signature-help") -- { name = 'nvim_lsp_signature_help' } - -- 常见编程语言代码段 - use("rafamadriz/friendly-snippets") - -- UI 增强 - use("onsails/lspkind-nvim") - -- copilot 增强 - -- use("github/copilot.vim") - -- Remove the `use` here if you're using folke/lazy.nvim. - use({ - "Exafunction/codeium.vim", - }) - ------------------- repl ---------------------- - use({ "hkupty/iron.nvim" }) - - ------------------- dap ----------------------- - -- dap for neovim - -- dap ui和适配器 - use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap", "theHamsta/nvim-dap-virtual-text" } }) - - -- persistent breakpoints - -- 持久化断点 - use({ "Weissle/persistent-breakpoints.nvim" }) - - ------------------ gpt ----------------------- - -- gpt for coding - -- gpt辅助代码 - use("robitx/gp.nvim") -end) diff --git a/lua/plugins/list.lua b/lua/plugins/list.lua new file mode 100644 index 0000000..549a945 --- /dev/null +++ b/lua/plugins/list.lua @@ -0,0 +1,98 @@ +return { + { "rafcamlet/nvim-luapad" }, + { "echasnovski/mini.nvim", version = false }, + { "sainnhe/everforest" }, + { "marko-cerovac/material.nvim" }, + { "akinsho/toggleterm.nvim", version = "*" }, + { "smjonas/live-command.nvim" }, + { "kdheepak/lazygit.nvim" }, + { + "iamcco/markdown-preview.nvim", + build = function() + vim.fn["mkdp#util#install"]() + end, + }, + { "jakewvincent/mkdnflow.nvim" }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + }, + { "lervag/vimtex" }, + { + "glepnir/dashboard-nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + { + "akinsho/bufferline.nvim", + version = "v3.*", + dependencies = "nvim-tree/nvim-web-devicons", + }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, + { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + }, + { "nvim-telescope/telescope-file-browser.nvim" }, + { "Mohammed-Taher/AdvancedNewFile.nvim" }, + { "ahmedkhalf/project.nvim" }, + { "folke/which-key.nvim" }, + { "lukas-reineke/indent-blankline.nvim" }, + { "numToStr/Comment.nvim" }, + { + "phaazon/hop.nvim", + branch = "v2", + }, + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + { "rcarriga/nvim-notify" }, + { "windwp/nvim-autopairs" }, + { "is0n/jaq-nvim" }, + { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + }, + { "jose-elias-alvarez/null-ls.nvim" }, + { + "akinsho/flutter-tools.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", + }, + }, + { "hrsh7th/nvim-cmp" }, + { "L3MON4D3/LuaSnip" }, + { "hrsh7th/vim-vsnip" }, + { "hrsh7th/cmp-vsnip" }, + { "ray-x/lsp_signature.nvim" }, + { "saadparwaiz1/cmp_luasnip" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "hrsh7th/cmp-omni" }, + { "hrsh7th/cmp-cmdline" }, + { "hrsh7th/cmp-nvim-lsp-signature-help" }, + { "rafamadriz/friendly-snippets" }, + { "onsails/lspkind-nvim" }, + { "Vigemus/iron.nvim" }, + { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "theHamsta/nvim-dap-virtual-text", + }, + }, + { "nvim-neotest/nvim-nio" }, + { "Weissle/persistent-breakpoints.nvim" }, + { "robitx/gp.nvim" }, +} diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua new file mode 100644 index 0000000..1efa468 --- /dev/null +++ b/lua/plugins/whichkey.lua @@ -0,0 +1,19 @@ +return { + { + "folke/which-key.nvim", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, + }, +}