From 1ab675f0d1e9967592654c5c9bd63722098bbf61 Mon Sep 17 00:00:00 2001 From: WindyValley <2519087323@qq.com> Date: Fri, 8 Sep 2023 01:00:56 +0800 Subject: [PATCH 1/3] fix: Preprocess `modules_dir` to ensure successful module loading on Windows Probably for consistency with `vim.fn.stdpath`, `core.helper.path_join` uses '\' as the path separator on Windows. However, even on Windows, the path returned by `vim.fs.find` still uses `/`. This caused `pack:load_modules_packages` to error when extracting the module name from the module path. To avoid compatibility issues with other places where `core.helper.path_join` is used, only preprocess modules_path with `vim.fs.normalize` in `pack:load_modules_packages`. --- lua/core/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/core/pack.lua b/lua/core/pack.lua index 3345de3..d93d36c 100644 --- a/lua/core/pack.lua +++ b/lua/core/pack.lua @@ -5,6 +5,7 @@ pack.__index = pack function pack:load_modules_packages() local modules_dir = self.helper.path_join(self.config_path, 'lua', 'modules') + modules_dir = vim.fs.normalize(modules_dir) self.repos = {} local list = vim.fs.find('package.lua', { path = modules_dir, type = 'file', limit = 10 }) From 9fbe4d5ab2a7579ef16f18f6cbc465d121b31724 Mon Sep 17 00:00:00 2001 From: WindyValley <2519087323@qq.com> Date: Sat, 9 Sep 2023 14:53:33 +0800 Subject: [PATCH 2/3] fix & feat: replace invalid command `Telescope app` and `Telescope dotfiles` with `Telescope nvim_user_config` --- lua/modules/tools/config.lua | 1 + lua/modules/ui/config.lua | 12 ++----- .../_extensions/nvim_user_config.lua | 36 +++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 lua/telescope/_extensions/nvim_user_config.lua diff --git a/lua/modules/tools/config.lua b/lua/modules/tools/config.lua index 2048b8f..6bbe921 100644 --- a/lua/modules/tools/config.lua +++ b/lua/modules/tools/config.lua @@ -20,6 +20,7 @@ function config.telescope() }, }) require('telescope').load_extension('fzy_native') + require('telescope').load_extension('nvim_user_config') end return config diff --git a/lua/modules/ui/config.lua b/lua/modules/ui/config.lua index a2277a6..1c3751a 100644 --- a/lua/modules/ui/config.lua +++ b/lua/modules/ui/config.lua @@ -21,16 +21,10 @@ function config.dashboard() key = 'f', }, { - desc = ' Apps', - group = 'DiagnosticHint', - action = 'Telescope app', - key = 'a', - }, - { - desc = ' dotfiles', + desc = ' config', group = 'Number', - action = 'Telescope dotfiles', - key = 'd', + action = 'Telescope nvim_user_config', + key = 'c', }, }, }, diff --git a/lua/telescope/_extensions/nvim_user_config.lua b/lua/telescope/_extensions/nvim_user_config.lua new file mode 100644 index 0000000..2b0ee8d --- /dev/null +++ b/lua/telescope/_extensions/nvim_user_config.lua @@ -0,0 +1,36 @@ +local telescope = require('telescope') +local finders = require('telescope.finders') +local pickers = require('telescope.pickers') +local make_entry = require('telescope.make_entry') +local conf = require('telescope.config').values + +local config_path = vim.fn.stdpath('config') + +local config_file_list = function() + local list = {} + local p = io.popen('rg --files --ignore .git ' .. config_path) + for file in p:lines() do + table.insert(list, file) + end + return list +end + +local nvim_user_config = function(opts) + opts = opts or {} + local results = config_file_list() + + pickers + .new(opts, { + prompt_title = 'find in nvim user config files', + results_title = 'Nvim User Configs', + finder = finders.new_table({ + results = results, + entry_maker = make_entry.gen_from_file(opts), + }), + previewer = conf.file_previewer(opts), + sorter = conf.file_sorter(opts), + }) + :find() +end + +return telescope.register_extension({ exports = { nvim_user_config = nvim_user_config } }) From 7ebc99bc812bc23736e63dd09b8cb9eee989d87c Mon Sep 17 00:00:00 2001 From: WindyValley <2519087323@qq.com> Date: Sat, 9 Sep 2023 14:54:35 +0800 Subject: [PATCH 3/3] fix: update config for new dashboard --- lua/keymap/init.lua | 2 +- lua/modules/tools/package.lua | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/keymap/init.lua b/lua/keymap/init.lua index 8adec40..c9b2972 100644 --- a/lua/keymap/init.lua +++ b/lua/keymap/init.lua @@ -46,7 +46,7 @@ nmap({ { 'pu', cmd('Lazy update'), opts(noremap, silent) }, { 'pi', cmd('Lazy install'), opts(noremap, silent) }, -- dashboard - { 'n', cmd('DashboardNewFile'), opts(noremap, silent) }, + { 'n', cmd('lua require(\'dashboard\'):new_file()'), opts(noremap, silent) }, { 'ss', cmd('SessionSave'), opts(noremap, silent) }, { 'sl', cmd('SessionLoad'), opts(noremap, silent) }, -- nvimtree diff --git a/lua/modules/tools/package.lua b/lua/modules/tools/package.lua index be4581c..7427bf9 100644 --- a/lua/modules/tools/package.lua +++ b/lua/modules/tools/package.lua @@ -18,3 +18,10 @@ package({ require('hlsearch').setup() end, }) + +package({ + 'nvimdev/dbsession.nvim', + cmd = { 'SessionSave', 'SessionLoad', 'SessionDelete' }, + opts = true, +}) +