From dfd0e00c05c28f35693eee82501298cccc953ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sat, 16 Sep 2023 13:34:12 +0200 Subject: [PATCH] New nvim plugins --- .config/nvim/lua/config/keymaps.lua | 11 +++-- .config/nvim/lua/plugins/dadbod.lua | 41 ++++++++++++++++ .config/nvim/lua/plugins/devdocs.lua | 39 +++++++++++++++ .config/nvim/lua/plugins/git-worktree.lua | 17 +++++++ .config/nvim/lua/plugins/harpoon.lua | 25 ++++++++++ .config/nvim/lua/plugins/refactor.lua | 15 +++++- .config/nvim/lua/plugins/telescope-lazy.lua | 9 ++++ .../nvim/lua/plugins/telescope-luasnip.lua | 9 ++++ .config/nvim/lua/plugins/telescope-zoxide.lua | 9 ++++ .config/nvim/lua/plugins/ufo.lua.bak | 47 +++++++++++++++++++ .config/nvim/lua/plugins/urlview.lua | 12 +++++ .config/nvim/lua/plugins/which-key.lua | 3 ++ .gitignore | 2 +- 13 files changed, 233 insertions(+), 6 deletions(-) create mode 100644 .config/nvim/lua/plugins/dadbod.lua create mode 100644 .config/nvim/lua/plugins/devdocs.lua create mode 100644 .config/nvim/lua/plugins/git-worktree.lua create mode 100644 .config/nvim/lua/plugins/harpoon.lua create mode 100644 .config/nvim/lua/plugins/telescope-lazy.lua create mode 100644 .config/nvim/lua/plugins/telescope-luasnip.lua create mode 100644 .config/nvim/lua/plugins/telescope-zoxide.lua create mode 100644 .config/nvim/lua/plugins/ufo.lua.bak create mode 100644 .config/nvim/lua/plugins/urlview.lua diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index a649ac25..4a9d073c 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -68,7 +68,14 @@ map( map("n", "T", ":Telescope floaterm", { desc = "Terminals" }) +map("n", "sz", ":Telescope zoxide list", { desc = "Zoxide" }) + +map("n", "sL", ":Telescope luasnip", { desc = "Snippets (Luasnip)" }) + +map("n", "sp", ":Telescope lazy", { desc = "Plugins (Lazy)" }) + map("n", "si", ":Telescope import", { desc = "Imports" }) + map( "n", "ft", @@ -142,10 +149,6 @@ vim.api.nvim_set_keymap( { silent = true, noremap = true, desc = "Install New Dependency" } ) -vim.keymap.set({ "n", "x" }, "cR", function() - require("telescope").extensions.refactoring.refactors() -end, { noremap = true, silent = true, desc = "Refactor" }) - vim.keymap.set("n", "", "zz") vim.keymap.set("n", "", "zz") diff --git a/.config/nvim/lua/plugins/dadbod.lua b/.config/nvim/lua/plugins/dadbod.lua new file mode 100644 index 00000000..dcebb09c --- /dev/null +++ b/.config/nvim/lua/plugins/dadbod.lua @@ -0,0 +1,41 @@ +return { + { + "tpope/vim-dadbod", + dependencies = { + "kristijanhusak/vim-dadbod-ui", + "kristijanhusak/vim-dadbod-completion", + }, + opts = { + db_competion = function() + require("cmp").setup.buffer({ sources = { { name = "vim-dadbod-completion" } } }) + end, + }, + config = function(_, opts) + vim.g.db_ui_save_location = vim.fn.stdpath("config") .. require("plenary.path").path.sep .. "db_ui" + + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "sql", + }, + command = [[setlocal omnifunc=vim_dadbod_completion#omni]], + }) + + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "sql", + "mysql", + "plsql", + }, + callback = function() + vim.schedule(opts.db_completion) + end, + }) + end, + keys = { + { "Dt", "DBUIToggle", desc = "Toggle UI" }, + { "Df", "DBUIFindBuffer", desc = "Find Buffer" }, + { "Dr", "DBUIRenameBuffer", desc = "Rename Buffer" }, + { "Dq", "DBUILastQueryInfo", desc = "Last Query Info" }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/devdocs.lua b/.config/nvim/lua/plugins/devdocs.lua new file mode 100644 index 00000000..7f1439c4 --- /dev/null +++ b/.config/nvim/lua/plugins/devdocs.lua @@ -0,0 +1,39 @@ +return { + { + "luckasRanarison/nvim-devdocs", + cmd = { + "DevdocsFetch", + "DevdocsInstall", + "DevdocsUninstall", + "DevdocsOpen", + "DevdocsOpenFloat", + "DevdocsOpenCurrent", + "DevdocsOpenCurrentFloat", + "DevdocsUpdate", + "DevdocsUpdateAll", + }, + opts = { + ensure_installed = { + "css", + "html", + "javascript", + "lua-5.4", + "python-3.11", + "react", + "typescript", + "angular", + "bash", + "fish-3.6", + "git", + "go", + "rust", + "sass", + "vue-3", + "docker", + "markdown", + "svelte", + "tailwindcss", + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/git-worktree.lua b/.config/nvim/lua/plugins/git-worktree.lua new file mode 100644 index 00000000..93a9dab6 --- /dev/null +++ b/.config/nvim/lua/plugins/git-worktree.lua @@ -0,0 +1,17 @@ +return { + { + "ThePrimeagen/git-worktree.nvim", + opts = {}, + config = function() + require("telescope").load_extension("git_worktree") + end, + dependencies = { + "nvim-telescope/telescope.nvim", + }, + --stylua: ignore + keys = { + {"gwm", function() require("telescope").extensions.git_worktree.git_worktrees() end, desc = "Manage Worktrees"}, + {"gwc", function() require("telescope").extensions.git_worktree.create_git_worktree() end, desc = "Create Worktree"}, + }, + }, +} diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua new file mode 100644 index 00000000..cf06cf38 --- /dev/null +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -0,0 +1,25 @@ +return { + { + "ThePrimeagen/harpoon", + --stylua: ignore + keys = { + { "'", function() require("harpoon.mark").add_file() end, desc = "Add File" }, + { "0", "Telescope harpoon marks", desc = "Harpoon" }, + { "1", function() require("harpoon.ui").nav_file(1) end, desc = "File 1" }, + { "2", function() require("harpoon.ui").nav_file(2) end, desc = "File 2" }, + { "3", function() require("harpoon.ui").nav_file(3) end, desc = "File 3" }, + { "4", function() require("harpoon.ui").nav_file(4) end, desc = "File 4" }, + { "5", function() require("harpoon.ui").nav_file(5) end, desc = "File 5" }, + { "6", function() require("harpoon.ui").nav_file(6) end, desc = "File 6" }, + }, + opts = { + globalsettings = { + save_on_toggle = true, + enter_on_sendcmd = true, + }, + }, + setup = function() + require("telescope").load_extension("harpoon") + end, + }, +} diff --git a/.config/nvim/lua/plugins/refactor.lua b/.config/nvim/lua/plugins/refactor.lua index b7edef42..305c5dca 100644 --- a/.config/nvim/lua/plugins/refactor.lua +++ b/.config/nvim/lua/plugins/refactor.lua @@ -1,7 +1,6 @@ return { { "ThePrimeagen/refactoring.nvim", - event = "BufRead", requires = { { "nvim-lua/plenary.nvim" }, { "nvim-treesitter/nvim-treesitter" }, @@ -9,5 +8,19 @@ return { config = function() require("refactoring").setup() end, + -- stylua: ignore + keys = { + { "Rs", function() require("telescope").extensions.refactoring.refactors() end, mode = { "v" }, desc = "Refactor Options", }, + { "cRi", function() require("refactoring").refactor("Inline Variable") end, mode = {"n","v"}, desc = "Inline Variable" }, + { "cRb", function() require('refactoring').refactor('Exract Block') end, mode = {"n"}, desc = "Extract Block" }, + { "cRf", function() require('refactoring').refactor('Exract Block To File') end, mode = {"n"}, desc = "Extract Block to File" }, + { "cRP", function() require('refactoring').debug.printf({below = false}) end, mode = {"n"}, desc = "Debug Print" }, + { "cRp", function() require('refactoring').debug.print_var({normal = true}) end, mode = {"n"}, desc = "Debug Print Variable" }, + { "cRc", function() require('refactoring').debug.cleanup({}) end, mode = {"n"}, desc = "Debug Cleanup" }, + { "cRf", function() require('refactoring').refactor('Extract Function') end, mode = {"v"}, desc = "Extract Function" }, + { "cRF", function() require('refactoring').refactor('Extract Function to File') end, mode = {"v"}, desc = "Extract Function to File" }, + { "cRx", function() require('refactoring').refactor('Extract Variable') end, mode = {"v"}, desc = "Extract Variable" }, + { "cRp", function() require('refactoring').debug.print_var({}) end, mode = {"v"}, desc = "Debug Print Variable" }, + }, }, } diff --git a/.config/nvim/lua/plugins/telescope-lazy.lua b/.config/nvim/lua/plugins/telescope-lazy.lua new file mode 100644 index 00000000..e20fbacb --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-lazy.lua @@ -0,0 +1,9 @@ +return { + { + "tsakirist/telescope-lazy.nvim", + event = "VeryLazy", + config = function() + require("telescope").load_extension("lazy") + end, + }, +} diff --git a/.config/nvim/lua/plugins/telescope-luasnip.lua b/.config/nvim/lua/plugins/telescope-luasnip.lua new file mode 100644 index 00000000..3aa7f18e --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-luasnip.lua @@ -0,0 +1,9 @@ +return { + { + "benfowler/telescope-luasnip.nvim", + event = "VeryLazy", + config = function() + require("telescope").load_extension("luasnip") + end, + }, +} diff --git a/.config/nvim/lua/plugins/telescope-zoxide.lua b/.config/nvim/lua/plugins/telescope-zoxide.lua new file mode 100644 index 00000000..04accb06 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-zoxide.lua @@ -0,0 +1,9 @@ +return { + { + "jvgrootveld/telescope-zoxide", + event = "VeryLazy", + config = function() + require("telescope").load_extension("zoxide") + end, + }, +} diff --git a/.config/nvim/lua/plugins/ufo.lua.bak b/.config/nvim/lua/plugins/ufo.lua.bak new file mode 100644 index 00000000..a997cb18 --- /dev/null +++ b/.config/nvim/lua/plugins/ufo.lua.bak @@ -0,0 +1,47 @@ +return { + { + "kevinhwang91/nvim-ufo", + dependencies = { + "kevinhwang91/promise-async", + { + "luukvbaal/statuscol.nvim", + config = function() + local builtin = require("statuscol.builtin") + require("statuscol").setup({ + relculright = true, + segments = { + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + }, + }) + end, + }, + }, + --stylua: ignore + keys = { + { "zc" }, + { "zo" }, + { "zC" }, + { "zO" }, + { "za" }, + { "zA" }, + { "zr", function() require("ufo").openFoldsExceptKinds() end, desc = "Open Folds Except Kinds", }, + { "zR", function() require("ufo").openAllFolds() end, desc = "Open All Folds", }, + { "zM", function() require("ufo").closeAllFolds() end, desc = "Close All Folds", }, + { "zm", function() require("ufo").closeFoldsWith() end, desc = "Close Folds With", }, + { "zp", function() + local winid = require('ufo').peekFoldedLinesUnderCursor() + if not winid then + vim.lsp.buf.hover() + end + end, desc = "Peek Fold", }, + }, + opts = { + fold_virt_text_handler = handler, + }, + config = function(_, opts) + require("ufo").setup(opts) + end, + }, +} diff --git a/.config/nvim/lua/plugins/urlview.lua b/.config/nvim/lua/plugins/urlview.lua new file mode 100644 index 00000000..c4fb6783 --- /dev/null +++ b/.config/nvim/lua/plugins/urlview.lua @@ -0,0 +1,12 @@ +return { + { + "axieax/urlview.nvim", + cmd = { "UrlView" }, + keys = { { "su", "UrlView", desc = "Search Urls" } }, + config = function() + require("urlview").setup({ + default_picker = "telescope", + }) + end, + }, +} diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua index ffea88fe..89043b79 100644 --- a/.config/nvim/lua/plugins/which-key.lua +++ b/.config/nvim/lua/plugins/which-key.lua @@ -25,6 +25,9 @@ return { ["cc"] = { name = "+compile" }, ["cp"] = { name = "+packages" }, ["gd"] = { name = "+diff" }, + ["gw"] = { name = "+worktrees" }, + ["cR"] = { name = "+refactor" }, + ["D"] = { name = "+database" }, }, }, config = function(_, opts) diff --git a/.gitignore b/.gitignore index 479e3942..48dabb8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -~/.config/nvim/lazy-lock.json +.config/nvim/lazy-lock.json