From b3b19c488dfd8688fb3813f553b509cd87ad8462 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Wed, 18 Jan 2023 12:09:21 +0100 Subject: feat: improve lazy configuration on how loading plugins --- lua/alpha/completition/init.lua | 8 ------- lua/alpha/database.lua | 6 ----- lua/alpha/harpoon.lua | 8 +++---- lua/alpha/laravel.lua | 10 -------- lua/alpha/lsp/null-ls.lua | 4 ++-- lua/alpha/lsp/setups.lua | 1 + lua/alpha/plugins/comment.lua | 7 ++++++ lua/alpha/plugins/completition.lua | 1 - lua/alpha/plugins/dap.lua | 17 +++++++++++++ lua/alpha/plugins/database.lua | 3 ++- lua/alpha/plugins/fugitive.lua | 12 ++++++++++ lua/alpha/plugins/gitsigns.lua | 1 + lua/alpha/plugins/harpoon.lua | 1 + lua/alpha/plugins/init.lua | 30 ----------------------- lua/alpha/plugins/laravel.lua | 25 +++++++++++++++++++ lua/alpha/plugins/lsp.lua | 7 +++++- lua/alpha/plugins/mind.lua | 16 +++++++++++++ lua/alpha/plugins/neotest.lua | 1 + lua/alpha/plugins/refactoring.lua | 4 ++++ lua/alpha/plugins/rest.lua | 1 + lua/alpha/plugins/telescope.lua | 1 - lua/alpha/plugins/test.lua | 49 ++++++++++++++++++++++++++++++++++++++ lua/alpha/plugins/trouble.lua | 8 +++++++ lua/alpha/plugins/worktree.lua | 11 +++++++++ lua/alpha/telescope/mappings.lua | 5 ---- lua/alpha/telescope/setup.lua | 9 ------- 26 files changed, 168 insertions(+), 78 deletions(-) delete mode 100644 lua/alpha/laravel.lua create mode 100644 lua/alpha/plugins/comment.lua create mode 100644 lua/alpha/plugins/fugitive.lua create mode 100644 lua/alpha/plugins/laravel.lua create mode 100644 lua/alpha/plugins/mind.lua create mode 100644 lua/alpha/plugins/test.lua create mode 100644 lua/alpha/plugins/trouble.lua create mode 100644 lua/alpha/plugins/worktree.lua (limited to 'lua') diff --git a/lua/alpha/completition/init.lua b/lua/alpha/completition/init.lua index 6ac3333..dc3d73b 100644 --- a/lua/alpha/completition/init.lua +++ b/lua/alpha/completition/init.lua @@ -128,11 +128,3 @@ cmp.setup.filetype({ "sql", "mysql", "plsql" }, { { name = "buffer" }, }), }) - -cmp.setup.filetype({ "dap-repl", "dapui_watches" }, { - sources = cmp.config.sources({ - { name = "dap" }, - }, { - { name = "buffer" }, - }), -}) diff --git a/lua/alpha/database.lua b/lua/alpha/database.lua index 7715875..32121eb 100644 --- a/lua/alpha/database.lua +++ b/lua/alpha/database.lua @@ -41,9 +41,3 @@ vim.g.db_ui_icons = { connection_ok = '✓', connection_error = '✕', } - --- opening it in a new tab -vim.keymap.set('n', 'db', ':tab DBUI', {}) - --- just close the tab, but context related of the keybinding -vim.keymap.set('n', 'tq', ':tabclose') diff --git a/lua/alpha/harpoon.lua b/lua/alpha/harpoon.lua index 677a527..108737e 100644 --- a/lua/alpha/harpoon.lua +++ b/lua/alpha/harpoon.lua @@ -5,16 +5,16 @@ local terms = vim.g.harpoon_terms or 3 local quick_binds = vim.g.harpoon_quick_binds or 5 M.keymaps = { - "ss", - "sa", + {"ss"}, + {"sa"}, } for i = 1, terms do - table.insert(M.keymaps, string.format("%s", i)) + table.insert(M.keymaps, {string.format("%s", i)}) end for i = 1, quick_binds do - table.insert(M.keymaps, string.format("%s", i)) + table.insert(M.keymaps, {string.format("%s", i)}) end M.setup = function() diff --git a/lua/alpha/laravel.lua b/lua/alpha/laravel.lua deleted file mode 100644 index 99ba41c..0000000 --- a/lua/alpha/laravel.lua +++ /dev/null @@ -1,10 +0,0 @@ -local laravel = require("laravel") -local artisan = require("laravel.artisan") -local notify = require("notify") - -laravel.setup() - -vim.keymap.set("n", "ac", function() - artisan.clean_cmd_list_cache() - notify.notify("Artisan cmd list cache clean", "info", { title = "Laravel.nvim" }) -end, { noremap = true }) diff --git a/lua/alpha/lsp/null-ls.lua b/lua/alpha/lsp/null-ls.lua index f7f925c..5700fcf 100644 --- a/lua/alpha/lsp/null-ls.lua +++ b/lua/alpha/lsp/null-ls.lua @@ -1,7 +1,7 @@ local null_ls = require("null-ls") local composer = require("composer") local php_actions = require("php-code-actions") -local laravel_actions = require("laravel.code-actions") +-- local laravel_actions = require("laravel.code-actions") local sources = { null_ls.builtins.code_actions.gitsigns, @@ -23,7 +23,7 @@ if composer.query({ "require", "symfony/framework-bundle" }) ~= nil then })) elseif composer.query({ "require", "laravel/framework" }) ~= nil then table.insert(sources, null_ls.builtins.formatting.pint) - table.insert(sources, laravel_actions.relationships) + -- table.insert(sources, laravel_actions.relationships) end null_ls.setup({ diff --git a/lua/alpha/lsp/setups.lua b/lua/alpha/lsp/setups.lua index 646eec1..8744e67 100644 --- a/lua/alpha/lsp/setups.lua +++ b/lua/alpha/lsp/setups.lua @@ -45,6 +45,7 @@ return setmetatable({ }, workspace = { library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, }, telemetry = { enable = false, diff --git a/lua/alpha/plugins/comment.lua b/lua/alpha/plugins/comment.lua new file mode 100644 index 0000000..5d1831f --- /dev/null +++ b/lua/alpha/plugins/comment.lua @@ -0,0 +1,7 @@ +return { + "numToStr/Comment.nvim", + keys = { { "gcc" }, { "gbc" }, { "gc", mode = "v" }, { "gb", mode = "v" } }, + config = function() + require("Comment").setup() + end, +} diff --git a/lua/alpha/plugins/completition.lua b/lua/alpha/plugins/completition.lua index 0ab9b89..cf1a37d 100644 --- a/lua/alpha/plugins/completition.lua +++ b/lua/alpha/plugins/completition.lua @@ -7,7 +7,6 @@ return { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-cmdline", "hrsh7th/cmp-git", - "rcarriga/cmp-dap", "saadparwaiz1/cmp_luasnip", "onsails/lspkind-nvim", { "L3MON4D3/LuaSnip", version = "v1.*" }, diff --git a/lua/alpha/plugins/dap.lua b/lua/alpha/plugins/dap.lua index 6f33484..f8a7b17 100644 --- a/lua/alpha/plugins/dap.lua +++ b/lua/alpha/plugins/dap.lua @@ -6,9 +6,26 @@ return { "leoluz/nvim-dap-go", "mxsdev/nvim-dap-vscode-js", "anuvyklack/hydra.nvim", + "nvim-telescope/telescope-dap.nvim", + "rcarriga/cmp-dap", }, keys = { { "d" } }, config = function() require("alpha.dap") + local ok_telescope, telescope = pcall(require, "telescope") + if ok_telescope then + telescope.load_extension("dap") + end + + local ok_cmp, cmp = pcall(require, "cmp") + if ok_cmp then + cmp.setup.filetype({ "dap-repl", "dapui_watches" }, { + sources = cmp.config.sources({ + { name = "dap" }, + }, { + { name = "buffer" }, + }), + }) + end end } diff --git a/lua/alpha/plugins/database.lua b/lua/alpha/plugins/database.lua index 39e42a5..fceb506 100644 --- a/lua/alpha/plugins/database.lua +++ b/lua/alpha/plugins/database.lua @@ -5,7 +5,8 @@ return { "kristijanhusak/vim-dadbod-completion", "tpope/vim-dotenv", }, - config = function () + keys = {{"db", ':tab DBUI'}}, + init = function () require("alpha.database") end } diff --git a/lua/alpha/plugins/fugitive.lua b/lua/alpha/plugins/fugitive.lua new file mode 100644 index 0000000..bcf7ea8 --- /dev/null +++ b/lua/alpha/plugins/fugitive.lua @@ -0,0 +1,12 @@ +return { + "tpope/vim-fugitive", + keys = { + {"ga", ":Git fetch --all -p"}, + {"gl", ":Git pull"}, + }, + cmd = { "G", "Git" }, + config = function () + vim.keymap.set("n", "gdh", ":diffget //2", nil) + vim.keymap.set("n", "gdl", ":diffget //3", nil) + end +} diff --git a/lua/alpha/plugins/gitsigns.lua b/lua/alpha/plugins/gitsigns.lua index 12a1840..524da78 100644 --- a/lua/alpha/plugins/gitsigns.lua +++ b/lua/alpha/plugins/gitsigns.lua @@ -6,6 +6,7 @@ return { config = function() local gitsigns = require("gitsigns") gitsigns.setup({ + trouble = false, on_attach = function(bufnr) vim.keymap.set('n', 'hs', gitsigns.stage_hunk, { buffer = bufnr }) vim.keymap.set('n', 'hu', gitsigns.undo_stage_hunk, { buffer = bufnr }) diff --git a/lua/alpha/plugins/harpoon.lua b/lua/alpha/plugins/harpoon.lua index 8a4ecc6..b410c8e 100644 --- a/lua/alpha/plugins/harpoon.lua +++ b/lua/alpha/plugins/harpoon.lua @@ -4,6 +4,7 @@ return { "nvim-lua/plenary.nvim", "nvim-lua/popup.nvim", }, + keys = require('alpha.harpoon').keymaps, config = function () require("alpha.harpoon").setup() end diff --git a/lua/alpha/plugins/init.lua b/lua/alpha/plugins/init.lua index 334cb01..5fb4f25 100644 --- a/lua/alpha/plugins/init.lua +++ b/lua/alpha/plugins/init.lua @@ -13,42 +13,12 @@ return { require("nvim-projectconfig").setup() end, }, - { - "ThePrimeagen/git-worktree.nvim", - config = function() - require("git-worktree").setup({}) - end, - }, - { - "folke/trouble.nvim", - dependencies = "kyazdani42/nvim-web-devicons", - }, - "vim-test/vim-test", "rcarriga/nvim-notify", - "Raimondi/delimitMate", "lukas-reineke/indent-blankline.nvim", - "tpope/vim-surround", "tpope/vim-repeat", - "tpope/vim-fugitive", "tpope/vim-rhubarb", "tpope/vim-dotenv", "tpope/vim-eunuch", - { - "numToStr/Comment.nvim", - config = function() - require("Comment").setup() - end, - }, - { - "phaazon/mind.nvim", - branch = "v2.2", - dependencies = { "nvim-lua/plenary.nvim" }, - }, - - { "adalessa/laravel.nvim", dev = false }, - - "adalessa/composer.nvim", - "adalessa/php-code-actions.nvim", } diff --git a/lua/alpha/plugins/laravel.lua b/lua/alpha/plugins/laravel.lua new file mode 100644 index 0000000..0082653 --- /dev/null +++ b/lua/alpha/plugins/laravel.lua @@ -0,0 +1,25 @@ +return { + "adalessa/laravel.nvim", + dependencies = { + "rcarriga/nvim-notify", + "adalessa/composer.nvim", + }, + cmd = {"Sali", "Artisan", "Composer"}, + keys = {{"pa", function () + require("telescope").extensions.laravel.laravel() + end}}, + config = function() + local laravel = require("laravel") + local artisan = require("laravel.artisan") + local notify = require("notify") + + laravel.setup() + + vim.keymap.set("n", "ac", function() + artisan.clean_cmd_list_cache() + notify.notify("Artisan cmd list cache clean", "info", { title = "Laravel.nvim" }) + end, { noremap = true }) + + require("telescope").load_extension("laravel") + end +} diff --git a/lua/alpha/plugins/lsp.lua b/lua/alpha/plugins/lsp.lua index ac07faf..c7da38a 100644 --- a/lua/alpha/plugins/lsp.lua +++ b/lua/alpha/plugins/lsp.lua @@ -2,7 +2,12 @@ return { "neovim/nvim-lspconfig", dependencies = { "hrsh7th/cmp-nvim-lsp-signature-help", - "jose-elias-alvarez/null-ls.nvim", + { + "jose-elias-alvarez/null-ls.nvim", + dependencies = { + "adalessa/php-code-actions.nvim", + } + }, "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", diff --git a/lua/alpha/plugins/mind.lua b/lua/alpha/plugins/mind.lua new file mode 100644 index 0000000..70c0e23 --- /dev/null +++ b/lua/alpha/plugins/mind.lua @@ -0,0 +1,16 @@ +return { + "phaazon/mind.nvim", + branch = "v2.2", + dependencies = { "nvim-lua/plenary.nvim" }, + cmd = { "MindOpenMain", "MindOpenProject" }, + config = function() + local dirs = {} + if vim.fn.isdirectory("/mnt/nas/alpha/mind/data") == 1 then + dirs = { + state_path = "/mnt/nas/alpha/mind/mind.json", + data_dir = "/mnt/nas/alpha/mind/data", + } + end + require('mind').setup({ persistence = dirs }) + end +} diff --git a/lua/alpha/plugins/neotest.lua b/lua/alpha/plugins/neotest.lua index 2cecb60..5a332be 100644 --- a/lua/alpha/plugins/neotest.lua +++ b/lua/alpha/plugins/neotest.lua @@ -1,5 +1,6 @@ return { "nvim-neotest/neotest", + enabled = false, dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter", diff --git a/lua/alpha/plugins/refactoring.lua b/lua/alpha/plugins/refactoring.lua index c8bf7fc..349cc63 100644 --- a/lua/alpha/plugins/refactoring.lua +++ b/lua/alpha/plugins/refactoring.lua @@ -4,7 +4,11 @@ return { { "nvim-lua/plenary.nvim" }, { "nvim-treesitter/nvim-treesitter" }, }, + keys = { { "rr", function() + require("telescope").extensions.refactoring.refactors() + end, mode = { "n", "v" } } }, config = function() require("refactoring").setup({}) + require("telescope").load_extension("refactoring") end } diff --git a/lua/alpha/plugins/rest.lua b/lua/alpha/plugins/rest.lua index a0ec729..7b60a9d 100644 --- a/lua/alpha/plugins/rest.lua +++ b/lua/alpha/plugins/rest.lua @@ -1,6 +1,7 @@ return { "NTBBloodbath/rest.nvim", dependencies = { "nvim-lua/plenary.nvim" }, + ft = "http", config = function() local rest_nvim = require("rest-nvim") diff --git a/lua/alpha/plugins/telescope.lua b/lua/alpha/plugins/telescope.lua index ba6ae58..52d7b8b 100644 --- a/lua/alpha/plugins/telescope.lua +++ b/lua/alpha/plugins/telescope.lua @@ -6,7 +6,6 @@ return { { "nvim-telescope/telescope-fzy-native.nvim" }, { "kyazdani42/nvim-web-devicons" }, { "nvim-telescope/telescope-file-browser.nvim" }, - { "nvim-telescope/telescope-dap.nvim" }, { "nvim-telescope/telescope-ui-select.nvim" }, { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, }, diff --git a/lua/alpha/plugins/test.lua b/lua/alpha/plugins/test.lua new file mode 100644 index 0000000..7fcabc9 --- /dev/null +++ b/lua/alpha/plugins/test.lua @@ -0,0 +1,49 @@ +return { + "vim-test/vim-test", + keys = {{"t"}}, + dependencies = { + "anuvyklack/hydra.nvim", + }, + config = function() + local hydra = require("hydra") + + vim.g["test#preserve_screen"] = 1 + + vim.cmd([[ + let test#php#pest#executable = './vendor/bin/sail test' + let test#strategy = 'neovim' + let test#neovim#term_position = 'vert' + let g:test#preserve_screen = 1 +]] ) + + local hint = [[ + Vim Tests + _n_: Near test _f_: Current file _s_: Test Suit ^ + _l_: Test Last _g_: Visit + ^ ^ __ ^ +]] + + hydra({ + name = "vimtest", + hint = hint, + mode = "n", + config = { + color = "teal", + invoke_on_body = true, + hint = { + border = "rounded", + position = "bottom", + } + }, + body = "t", + heads = { + { "n", ":TestNearest" }, + { "f", ":TestFile" }, + { "s", ":TestSuit" }, + { "l", ":TestLast" }, + { "g", ":TestVisit" }, + { '', nil, { exit = true } } + } + }) + end +} diff --git a/lua/alpha/plugins/trouble.lua b/lua/alpha/plugins/trouble.lua new file mode 100644 index 0000000..b3ed1c9 --- /dev/null +++ b/lua/alpha/plugins/trouble.lua @@ -0,0 +1,8 @@ +return { + "folke/trouble.nvim", + dependencies = "kyazdani42/nvim-web-devicons", + keys = { { "oo", "TroubleToggle" } }, + config = function() + require("trouble").setup() + end +} diff --git a/lua/alpha/plugins/worktree.lua b/lua/alpha/plugins/worktree.lua new file mode 100644 index 0000000..bd7c923 --- /dev/null +++ b/lua/alpha/plugins/worktree.lua @@ -0,0 +1,11 @@ +return { + "ThePrimeagen/git-worktree.nvim", + keys = { + { "gt", function() require("telescope").extensions.git_worktree.git_worktrees() end }, + { "gn", function() require("telescope").extensions.git_worktree.create_git_worktree() end }, + }, + config = function() + require("git-worktree").setup({}) + require("telescope").load_extension("git_worktree") + end, +} diff --git a/lua/alpha/telescope/mappings.lua b/lua/alpha/telescope/mappings.lua index eab56fd..42d2c4b 100644 --- a/lua/alpha/telescope/mappings.lua +++ b/lua/alpha/telescope/mappings.lua @@ -23,8 +23,6 @@ vim.api.nvim_set_keymap("c", "", "(TelescopeFuzzyCommandSearch)" map_tele("pp", "project_files") map_tele("gc", "branches") -map_tele("gt", "worktree") -map_tele("gn", "worktree_create") map_tele("pw", "grep_word") map_tele("ps", "grep_string") map_tele("pf", "projectionist") @@ -37,10 +35,7 @@ map_tele("bp", "file_browser") map_tele("gs", "git_status") map_tele("ve", "diagnostics") map_tele("fp", "my_plugins") -map_tele("rr", "refactor", {}, nil, {"n", "v"}) map_tele("po", "api_specs") - -map_tele("pa", "laravel_commands") map_tele("pm", "gateway") return map_tele diff --git a/lua/alpha/telescope/setup.lua b/lua/alpha/telescope/setup.lua index e569db7..627eaed 100644 --- a/lua/alpha/telescope/setup.lua +++ b/lua/alpha/telescope/setup.lua @@ -159,16 +159,7 @@ require("telescope").setup({ }, }, }) -_ = require("telescope").load_extension("dap") _ = require("telescope").load_extension("notify") _ = require("telescope").load_extension("file_browser") --- makes the selection like lsp code actions in telescope _ = require("telescope").load_extension("ui-select") _ = require("telescope").load_extension("fzf") -_ = require("telescope").load_extension("git_worktree") --- _ = require("telescope").load_extension "neoclip" --- _ = require("telescope").load_extension "frecency" --- _ = require("telescope").load_extension "smart_history" --- _ = require("telescope").load_extension("projectionist") -_ = require("telescope").load_extension("laravel") -_ = require("telescope").load_extension("refactoring") -- cgit v1.2.3