diff --git a/lua/dotvim/core/package.lua b/lua/dotvim/core/package.lua index 186badd7..1b714fad 100644 --- a/lua/dotvim/core/package.lua +++ b/lua/dotvim/core/package.lua @@ -115,7 +115,7 @@ function M.load_package(name) return loaded_packages[name] end - local module = require(name) + local module = require(("dotvim.packages.%s"):format(name)) if module == nil then vim.notify("Failed to load package module: " .. name, vim.log.levels.WARN) return nil diff --git a/lua/dotvim/legacy/packages/lsp/init.lua b/lua/dotvim/legacy/packages/lsp/init.lua deleted file mode 100644 index 11084108..00000000 --- a/lua/dotvim/legacy/packages/lsp/init.lua +++ /dev/null @@ -1,83 +0,0 @@ ----@type dora.lib -local lib = require("dora.lib") - ----@type dora.core.package.PackageOption -return { - name = "dora.packages.lsp", - deps = { - "dora.packages.coding", - }, - plugins = lib.tbl.flatten_array { - require("dora.packages.lsp.plugins.nvim-lspconfig"), - require("dora.packages.lsp.plugins.lspkind"), - require("dora.packages.lsp.plugins.glance"), - }, - setup = function() - ---@type dora.config.lsp - local lsp = require("dora.config.lsp") - - ---@param buffer number - local function create_lsp_autocmds(buffer) - -- display diagnostic win on CursorHold - vim.api.nvim_create_autocmd("CursorHold", { - buffer = buffer, - callback = lsp.methods.open_diagnostic, - }) - end - - ---@param buffer? number - local function setup_lsp_keymaps(buffer) - ---comment normal map - ---@param lhs string - ---@param rhs any - ---@param desc string - local nmap = function(lhs, rhs, desc) - vim.keymap.set("n", lhs, rhs, { desc = desc, buffer = buffer }) - end - - nmap("gD", lsp.methods.declaration, "goto-declaration") - - nmap("gd", lsp.methods.definitions, "goto-definition") - - nmap("gt", lsp.methods.type_definitions, "goto-type-definition") - - if buffer ~= nil then - local current_k_map = vim.fn.mapcheck("K", "n") - -- empty or contains "nvim/runtime" - if current_k_map == "" or current_k_map:find("nvim/runtime") ~= nil then - nmap("K", lsp.methods.show_hover, "show-hover") - end - else - nmap("K", lsp.methods.show_hover, "show-hover") - end - - nmap("gi", lsp.methods.implementations, "goto-impl") - - nmap("gR", lsp.methods.rename, "rename-symbol") - - nmap("ga", lsp.methods.code_action, "code-action") - - nmap("gr", lsp.methods.references, "inspect-references") - - nmap("[c", lsp.methods.prev_diagnostic, "previous-diagnostic") - - nmap("]c", lsp.methods.next_diagnostic, "next-diagnostic") - end - - -- if in vscode environment, create key bindings globally, else only create - -- keybindings on lsp enabled buffers - if vim.g.vscode then - setup_lsp_keymaps() - else - lib.vim.on_lsp_attach(function(_, buffer) - local exists, value = - pcall(vim.api.nvim_buf_get_var, buffer, "_dora_lsp_attached") - if not exists or not value then - create_lsp_autocmds(buffer) - setup_lsp_keymaps(buffer) - vim.api.nvim_buf_set_var(buffer, "_dora_lsp_attached", true) - end - end) - end - end, -} diff --git a/lua/dotvim/packages/base/init.lua b/lua/dotvim/pkgs/base/init.lua similarity index 82% rename from lua/dotvim/packages/base/init.lua rename to lua/dotvim/pkgs/base/init.lua index 9c692268..107c163c 100644 --- a/lua/dotvim/packages/base/init.lua +++ b/lua/dotvim/pkgs/base/init.lua @@ -3,14 +3,14 @@ local Utils = require("dotvim.utils") ---@type dotvim.core.package.PackageOption return { - name = "dotvim.packages.base", + name = "base", setup = function() - require("dotvim.packages.base.setup.options") - require("dotvim.packages.base.setup.keymaps") - require("dotvim.packages.base.setup.autocmds") + require("dotvim.pkgs.base.setup.options") + require("dotvim.pkgs.base.setup.keymaps") + require("dotvim.pkgs.base.setup.autocmds") end, plugins = Utils.tbl.flatten_array { - require("dotvim.packages.base.plugins.init"), + require("dotvim.pkgs.base.plugins.init"), { "folke/lazy.nvim", lazy = true }, { "dstein64/vim-startuptime", diff --git a/lua/dotvim/packages/base/plugins/init.lua b/lua/dotvim/pkgs/base/plugins/init.lua similarity index 72% rename from lua/dotvim/packages/base/plugins/init.lua rename to lua/dotvim/pkgs/base/plugins/init.lua index 10608e5a..2d248e50 100644 --- a/lua/dotvim/packages/base/plugins/init.lua +++ b/lua/dotvim/pkgs/base/plugins/init.lua @@ -10,6 +10,6 @@ return { keys = { { "J", "(jplus)", mode = { "n", "v" }, noremap = false } }, gui = "all", }, - require("dotvim.packages.base.plugins.mason"), - require("dotvim.packages.base.plugins.toggleterm"), + require("dotvim.pkgs.base.plugins.mason"), + require("dotvim.pkgs.base.plugins.toggleterm"), } diff --git a/lua/dotvim/packages/base/plugins/mason.lua b/lua/dotvim/pkgs/base/plugins/mason.lua similarity index 100% rename from lua/dotvim/packages/base/plugins/mason.lua rename to lua/dotvim/pkgs/base/plugins/mason.lua diff --git a/lua/dotvim/packages/base/plugins/toggleterm.lua b/lua/dotvim/pkgs/base/plugins/toggleterm.lua similarity index 100% rename from lua/dotvim/packages/base/plugins/toggleterm.lua rename to lua/dotvim/pkgs/base/plugins/toggleterm.lua diff --git a/lua/dotvim/packages/base/setup/autocmds.lua b/lua/dotvim/pkgs/base/setup/autocmds.lua similarity index 100% rename from lua/dotvim/packages/base/setup/autocmds.lua rename to lua/dotvim/pkgs/base/setup/autocmds.lua diff --git a/lua/dotvim/packages/base/setup/keymaps.lua b/lua/dotvim/pkgs/base/setup/keymaps.lua similarity index 100% rename from lua/dotvim/packages/base/setup/keymaps.lua rename to lua/dotvim/pkgs/base/setup/keymaps.lua diff --git a/lua/dotvim/packages/base/setup/options.lua b/lua/dotvim/pkgs/base/setup/options.lua similarity index 100% rename from lua/dotvim/packages/base/setup/options.lua rename to lua/dotvim/pkgs/base/setup/options.lua diff --git a/lua/dotvim/packages/base/setup/shared.lua b/lua/dotvim/pkgs/base/setup/shared.lua similarity index 100% rename from lua/dotvim/packages/base/setup/shared.lua rename to lua/dotvim/pkgs/base/setup/shared.lua diff --git a/lua/dotvim/packages/lsp/init.lua b/lua/dotvim/pkgs/lsp/init.lua similarity index 91% rename from lua/dotvim/packages/lsp/init.lua rename to lua/dotvim/pkgs/lsp/init.lua index ce94c0fb..38f142d2 100644 --- a/lua/dotvim/packages/lsp/init.lua +++ b/lua/dotvim/pkgs/lsp/init.lua @@ -1,7 +1,11 @@ ---@type dotvim.core.package.PackageOption local M = { - name = "dotvim.packages.lsp", - plugins = {}, + name = "lsp", + plugins = { + require("dotvim.pkgs.lsp.plugins.nvim-lspconfig"), + require("dotvim.pkgs.lsp.plugins.lspkind"), + require("dotvim.pkgs.lsp.plugins.glance"), + }, } local methods = require("dotvim.core.lsp.methods") diff --git a/lua/dotvim/packages/lsp/methods.lua b/lua/dotvim/pkgs/lsp/methods.lua similarity index 100% rename from lua/dotvim/packages/lsp/methods.lua rename to lua/dotvim/pkgs/lsp/methods.lua diff --git a/lua/dotvim/packages/lsp/plugins/glance.lua b/lua/dotvim/pkgs/lsp/plugins/glance.lua similarity index 100% rename from lua/dotvim/packages/lsp/plugins/glance.lua rename to lua/dotvim/pkgs/lsp/plugins/glance.lua diff --git a/lua/dotvim/packages/lsp/plugins/lspkind.lua b/lua/dotvim/pkgs/lsp/plugins/lspkind.lua similarity index 100% rename from lua/dotvim/packages/lsp/plugins/lspkind.lua rename to lua/dotvim/pkgs/lsp/plugins/lspkind.lua diff --git a/lua/dotvim/packages/lsp/plugins/nvim-lspconfig.lua b/lua/dotvim/pkgs/lsp/plugins/nvim-lspconfig.lua similarity index 100% rename from lua/dotvim/packages/lsp/plugins/nvim-lspconfig.lua rename to lua/dotvim/pkgs/lsp/plugins/nvim-lspconfig.lua diff --git a/lua/dotvim/packages/theme/init.lua b/lua/dotvim/pkgs/theme/init.lua similarity index 60% rename from lua/dotvim/packages/theme/init.lua rename to lua/dotvim/pkgs/theme/init.lua index ac46d2fd..fa2e9978 100644 --- a/lua/dotvim/packages/theme/init.lua +++ b/lua/dotvim/pkgs/theme/init.lua @@ -1,8 +1,8 @@ ---@type dotvim.core.package.PackageOption return { - name = "dotvim.packages.theme", + name = "theme", plugins = { - require("dotvim.packages.theme.plugins.catppuccin"), + require("dotvim.pkgs.theme.plugins.catppuccin"), }, setup = function() vim.cmd("colorscheme catppuccino") diff --git a/lua/dotvim/packages/theme/plugins/catppuccin.lua b/lua/dotvim/pkgs/theme/plugins/catppuccin.lua similarity index 100% rename from lua/dotvim/packages/theme/plugins/catppuccin.lua rename to lua/dotvim/pkgs/theme/plugins/catppuccin.lua