diff --git a/.luarc.json b/.luarc.json index 89ea967..2cfe8ae 100644 --- a/.luarc.json +++ b/.luarc.json @@ -7,7 +7,8 @@ "checkThirdParty": false, "library": [ "${3rd}/luv/library", - "${3rd}/busted/library" + "${3rd}/busted/library", + "${3rd}/lazy/library" ] }, "diagnostics": { diff --git a/lazy-lock.json b/lazy-lock.json index 19df643..5b5c4c2 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -12,15 +12,17 @@ "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, + "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "gitsigns.nvim": { "branch": "main", "commit": "2038c666bd9d8a0b7349a0b6ee00dc83104b9ecf" }, "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, "markview.nvim": { "branch": "main", "commit": "301e431c7b618235f5447d54465c70934bd33668" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "50bf3871b539896bd0650b882f6e6b467cc1c1eb" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, @@ -28,6 +30,7 @@ "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-dap": { "branch": "master", "commit": "9e848e09a697ee95302a3ef2dd43fd6eb709e570" }, + "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, @@ -48,6 +51,7 @@ "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/config/options.lua b/lua/config/options.lua index af5361a..5b7d4e3 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -1,5 +1,12 @@ local opt = vim.opt +if vim.tbl_flatten then + local iter_flatten = function(t) + return vim.iter(t):flatten(math.huge):totable() + end + vim.tbl_flatten = iter_flatten +end + opt.number = true opt.relativenumber = true opt.tabstop = 4 diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..ad0ce02 --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,79 @@ +return { + { + "mfussenegger/nvim-dap", + event = "VeryLazy", + config = function() + local dap = require("dap") + vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "DAP toggle breakpoint" }) + vim.keymap.set("n", "dC", dap.continue, { desc = "DAP continue" }) + vim.keymap.set("n", "dx", dap.terminate, { desc = "DAP terminate" }) + vim.keymap.set("n", "dr", dap.step_over, { desc = "DAP step over" }) + vim.keymap.set("n", "di", dap.step_into, { desc = "DAP step into" }) + vim.keymap.set("n", "dO", dap.step_out, { desc = "DAP step out" }) + + dap.configurations.rust = { + { + name = "Launch", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + }, + } + end, + }, + { + "rcarriga/nvim-dap-ui", + event = "VeryLazy", + dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, + opts = {}, + config = function(_, opts) + local dap = require("dap") + local dapui = require("dapui") + dapui.setup(opts) + + 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-python", + event = "VeryLazy", + dependencies = { "mfussenegger/nvim-dap" }, + config = function() + require("dap-python").setup("python") + end, + }, + { + "mxsdev/nvim-dap-vscode-js", + event = "VeryLazy", + dependencies = { "mfussenegger/nvim-dap" }, + opts = { + adapters = { "pwa-node", "pwa-chrome" }, + }, + }, + { + "leoluz/nvim-dap-go", + event = "VeryLazy", + dependencies = { "mfussenegger/nvim-dap" }, + opts = {}, + }, + { + "jay-babu/mason-nvim-dap.nvim", + event = "VeryLazy", + dependencies = { "williamboman/mason.nvim", "mfussenegger/nvim-dap" }, + opts = { + ensure_installed = { "codelldb" }, + }, + }, +} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 44c77fa..94814d7 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -30,4 +30,58 @@ return { event = "VeryLazy", opts = {}, }, + { + "folke/flash.nvim", + event = "VeryLazy", + opts = {}, + 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", + }, + }, + }, + { + "mbbill/undotree", + cmd = "UndotreeToggle", + keys = { + { "u", "UndotreeToggle", desc = "Toggle Undotree" }, + }, + }, } diff --git a/lua/plugins/tools.lua b/lua/plugins/tools.lua index 37e0e78..22dd681 100644 --- a/lua/plugins/tools.lua +++ b/lua/plugins/tools.lua @@ -35,7 +35,7 @@ return { "stevearc/conform.nvim", event = "BufWritePre", opts = { - format_on_save = { timeout_ms = 2000, lsp_fallback = true }, + format_on_save = { timeout_ms = 500, lsp_fallback = true }, formatters_by_ft = { lua = { "stylua" }, javascript = { "prettier" }, @@ -55,7 +55,6 @@ return { }, { "mfussenegger/nvim-lint", - event = { "BufReadPost", "BufWritePost" }, config = function() local lint = require("lint") lint.linters_by_ft = { @@ -69,6 +68,7 @@ return { } vim.api.nvim_create_autocmd({ "BufWritePost", "BufReadPost" }, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), callback = function() lint.try_lint() end, @@ -89,56 +89,6 @@ return { cmd = "ToggleTerm", opts = { size = 12, shade_terminals = true }, }, - { - "mfussenegger/nvim-dap", - event = "VeryLazy", - config = function() - local dap = require("dap") - vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "DAP toggle breakpoint" }) - vim.keymap.set("n", "dC", dap.continue, { desc = "DAP continue" }) - vim.keymap.set("n", "dx", dap.terminate, { desc = "DAP terminate" }) - vim.keymap.set("n", "dr", dap.step_over, { desc = "DAP step over" }) - vim.keymap.set("n", "di", dap.step_into, { desc = "DAP step into" }) - vim.keymap.set("n", "dO", dap.step_out, { desc = "DAP step out" }) - end, - }, - { - "rcarriga/nvim-dap-ui", - event = "VeryLazy", - dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, - opts = {}, - config = function(_, opts) - local dap = require("dap") - local dapui = require("dapui") - dapui.setup(opts) - - 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-python", - event = "VeryLazy", - dependencies = { "mfussenegger/nvim-dap" }, - config = function() - require("dap-python").setup("python") - end, - }, - { - "mxsdev/nvim-dap-vscode-js", - event = "VeryLazy", - dependencies = { "mfussenegger/nvim-dap" }, - opts = { - adapters = { "pwa-node", "pwa-chrome" }, - }, - }, { "ThePrimeagen/harpoon", branch = "harpoon2", diff --git a/lua/themes/init.lua b/lua/themes/init.lua index b878006..2538889 100644 --- a/lua/themes/init.lua +++ b/lua/themes/init.lua @@ -2,15 +2,8 @@ local palettes = require("themes.palettes") local M = {} -local function strip_alpha(hex) - if #hex == 9 then - return hex:sub(1, 7) - end - return hex -end - local function hex_to_rgb(hex) - hex = strip_alpha(hex):gsub("#", "") + hex = palettes.strip_alpha(hex):gsub("#", "") return tonumber(hex:sub(1, 2), 16), tonumber(hex:sub(3, 4), 16), tonumber(hex:sub(5, 6), 16) end @@ -41,24 +34,24 @@ function M.apply(name) vim.g.colors_name = name local c = { - bg = strip_alpha(p.background), - fg = strip_alpha(p.foreground), - bg_alt = strip_alpha(p.color8), - fg_alt = strip_alpha(p.color15), - comment = strip_alpha(p.color8), - red = strip_alpha(p.color1), - green = strip_alpha(p.color2), - yellow = strip_alpha(p.color3), - orange = strip_alpha(p.color4), - purple = strip_alpha(p.color5), - blue = strip_alpha(p.color6), - cyan = strip_alpha(p.color6), - bright_red = strip_alpha(p.color9), - bright_green = strip_alpha(p.color10), - bright_yellow = strip_alpha(p.color11), - bright_orange = strip_alpha(p.color12), - bright_purple = strip_alpha(p.color13), - bright_cyan = strip_alpha(p.color14), + bg = palettes.strip_alpha(p.background), + fg = palettes.strip_alpha(p.foreground), + bg_alt = palettes.strip_alpha(p.color8), + fg_alt = palettes.strip_alpha(p.color15), + comment = palettes.strip_alpha(p.color8), + red = palettes.strip_alpha(p.color1), + green = palettes.strip_alpha(p.color2), + yellow = palettes.strip_alpha(p.color3), + orange = palettes.strip_alpha(p.color4), + purple = palettes.strip_alpha(p.color5), + blue = palettes.strip_alpha(p.color6), + cyan = palettes.strip_alpha(p.color6), + bright_red = palettes.strip_alpha(p.color9), + bright_green = palettes.strip_alpha(p.color10), + bright_yellow = palettes.strip_alpha(p.color11), + bright_orange = palettes.strip_alpha(p.color12), + bright_purple = palettes.strip_alpha(p.color13), + bright_cyan = palettes.strip_alpha(p.color14), } set_hl("Normal", { fg = c.fg, bg = c.bg }) @@ -253,12 +246,10 @@ M.names = vim.tbl_keys(palettes) vim.api.nvim_create_user_command("Theme", function(opts) M.apply(opts.args) - pcall(function() - local lualine_ok, lualine = pcall(require, "lualine") - if lualine_ok then - lualine.setup({ options = { theme = require("themes.lualine").theme(opts.args) } }) - end - end) + local lualine_ok, lualine = pcall(require, "lualine") + if lualine_ok then + lualine.setup({ options = { theme = require("themes.lualine").theme(opts.args) } }) + end end, { nargs = 1, complete = function() diff --git a/lua/themes/lualine.lua b/lua/themes/lualine.lua index 7f302f8..753356e 100644 --- a/lua/themes/lualine.lua +++ b/lua/themes/lualine.lua @@ -1,12 +1,5 @@ local palettes = require("themes.palettes") -local function strip_alpha(hex) - if #hex == 9 then - return hex:sub(1, 7) - end - return hex -end - local M = {} function M.theme(name) @@ -17,14 +10,14 @@ function M.theme(name) end local c = { - bg = strip_alpha(p.background), - fg = strip_alpha(p.foreground), - bg_alt = strip_alpha(p.color8), - comment = strip_alpha(p.color8), - red = strip_alpha(p.color1), - green = strip_alpha(p.color2), - yellow = strip_alpha(p.color3), - cyan = strip_alpha(p.color6), + bg = palettes.strip_alpha(p.background), + fg = palettes.strip_alpha(p.foreground), + bg_alt = palettes.strip_alpha(p.color8), + comment = palettes.strip_alpha(p.color8), + red = palettes.strip_alpha(p.color1), + green = palettes.strip_alpha(p.color2), + yellow = palettes.strip_alpha(p.color3), + cyan = palettes.strip_alpha(p.color6), } return { diff --git a/lua/themes/palettes.lua b/lua/themes/palettes.lua index a0186f3..cfbe883 100644 --- a/lua/themes/palettes.lua +++ b/lua/themes/palettes.lua @@ -1,4 +1,4 @@ -return { +local M = { x = { color0 = "#0a0a0a", color1 = "#fc618d", @@ -260,3 +260,12 @@ return { foreground = "#f7f1ff", }, } + +function M.strip_alpha(hex) + if #hex == 9 then + return hex:sub(1, 7) + end + return hex +end + +return M