From 23ac4c6f2bc3662a4770b7157374eb9327fc7eda Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 24 Oct 2023 22:16:46 +0200 Subject: Add hardtime.lua --- lua/plugins/hardtime.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lua/plugins/hardtime.lua diff --git a/lua/plugins/hardtime.lua b/lua/plugins/hardtime.lua new file mode 100644 index 0000000..1fb58cc --- /dev/null +++ b/lua/plugins/hardtime.lua @@ -0,0 +1,19 @@ +local hardtime = require('hardtime') + +-- Function to toggle the hardtime state and echo a message +local hardtime_enabled = true + +function ToggleHardtime() + hardtime.toggle() + hardtime_enabled = not hardtime_enabled + local message = hardtime_enabled and 'hardtime on' or 'hardtime off' + vim.cmd('echo "' .. message .. '"') +end + +hardtime.setup({ + -- hardtime config here +}) + +return { + ToggleHardtime = ToggleHardtime, +} -- cgit v1.2.3 From 6afa20e4d6f4a4285ed8bbab44e8dfdd83fcb8fb Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 24 Oct 2023 22:16:55 +0200 Subject: Add hardtime.lua --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 0ab542c..da19687 100644 --- a/init.lua +++ b/init.lua @@ -95,6 +95,7 @@ local modules = { 'plugins.which-key', 'plugins.harpoon', 'plugins.leetcode', + 'plugins.hardtime', --'plugins.notify', --"plugins.modify-blend", } -- cgit v1.2.3 From 5a2d1c1b634df4b65b61b92bc8daedd77189a59c Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 24 Oct 2023 22:17:26 +0200 Subject: Moved hardtime setup to plugins.hardtime --- lua/user/pack.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 3cd66c0..6997eb7 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -237,12 +237,7 @@ return packer.startup(function(use) }, }) use('kawre/leetcode.nvim') - use({ - 'm4xshen/hardtime.nvim', - config = function() - require('hardtime').setup() - end, - }) + use('m4xshen/hardtime.nvim') use({ 'luckasRanarison/nvim-devdocs', config = function() -- cgit v1.2.3 From abecafec9de0e2e522194b403b4e963ffeb124be Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 24 Oct 2023 22:18:04 +0200 Subject: Changed a few bindings to make ;v/;h faster and better hardtime toggling --- lua/user/keys.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index d97d86d..7047ae0 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -133,7 +133,7 @@ map('n', '', ':let save_a=@a"add"ap:let @a=save_a') map('n', 'df', 'call utils#ToggleDiff()') -- Toggle Verbose -map('n', 'vt', 'call utils#VerboseToggle()') +map('n', 'uvt', 'call utils#VerboseToggle()') -- Jump List map('n', 'j', 'call utils#GotoJump()') @@ -222,7 +222,7 @@ map('n', 'z', ':call utils#ZoomToggle()') map('n', 'z', '|_') -- Toggle statusline -map('n', '', ':call utils#ToggleHiddenAll()') +map('n', 'sl', ':call utils#ToggleHiddenAll()') -- Open last closed buffer map('n', '', ':call OpenLastClosed()') @@ -437,4 +437,4 @@ map('n', 'sh', 'lua require("user.mods").Scratch("horizontal")' map('n', 'sv', 'lua require("user.mods").Scratch("vertical")') -- Hardtime -map('n', 'H', ':Hardtime toggle') +map('n', 'H', 'lua require("plugins.hardtime").ToggleHardtime()') -- cgit v1.2.3 From 467f06fd58b1be64023241cd6a138b9c81baf96e Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 24 Oct 2023 22:28:55 +0200 Subject: Install ribru17/bamboo --- lua/user/pack.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 6997eb7..2a56e19 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -252,15 +252,8 @@ return packer.startup(function(use) use('NTBBloodbath/doom-one.nvim') use('nyngwang/nvimgelion') use('projekt0n/github-nvim-theme') - use({ - 'folke/tokyonight.nvim', - config = function() - require('tokyonight').setup({ - transparent = true, - dim_inactive = false, - }) - end, - }) + use('folke/tokyonight.nvim') + use('ribru17/bamboo.nvim') -- UI use('kyazdani42/nvim-web-devicons') -- -- cgit v1.2.3 From 62497155cfb0605e193cde22d7860aed91273777 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 24 Oct 2023 22:29:13 +0200 Subject: Changed colorscheme to bamboo --- lua/user/view.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/user/view.lua b/lua/user/view.lua index 50cea8c..4bafbd0 100644 --- a/lua/user/view.lua +++ b/lua/user/view.lua @@ -4,12 +4,13 @@ vim.opt.termguicolors = true -- Available colorschemes: --- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] +-- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight bamboo ]] require('tokyonight').setup({ style = 'night', transparent = true, transparent_sidebar = true, + dim_inactive = false, styles = { sidebars = 'transparent', floats = 'transparent', @@ -17,7 +18,7 @@ require('tokyonight').setup({ }) -- Define default color scheme -local default_colorscheme = 'tokyonight' +local default_colorscheme = 'bamboo' local fallback_colorscheme = 'desert' -- Attempt to set the default color scheme -- cgit v1.2.3 From 53ee862fc3bbf7855ab557aa8e47de00ad5d6cd4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 25 Oct 2023 13:37:47 +0200 Subject: Show recent books in find_books() --- lua/plugins/telescope.lua | 64 +++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index daf50bd..8d8622f 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -374,20 +374,6 @@ function M.find_scripts() }) end ---function M.find_projects() -- aka Workspaces --- require('telescope.builtin').find_files({ --- hidden = true, --- no_ignore = true, --- prompt_title = ' Find Projects', --- path_display = { 'smart' }, --- search_dirs = { --- '~/projects', --- }, --- layout_strategy = 'horizontal', --- layout_config = { preview_width = 0.65, width = 0.75 }, --- }) ---end - function M.find_projects() local search_dir = '~/projects' pickers @@ -452,20 +438,35 @@ end function M.find_books() local search_dir = '~/documents/books' + vim.fn.jobstart('$HOME/.scripts/track-books.sh') + local recent_books_directory = vim.fn.stdpath('config') .. '/tmp/' + local recent_books_file = recent_books_directory .. 'recent_books.txt' + local search_cmd = 'find ' .. vim.fn.expand(search_dir) .. ' -type d -o -type f -maxdepth 1' + + local recent_books = vim.fn.systemlist('cat ' .. recent_books_file) + local search_results = vim.fn.systemlist(search_cmd) + + local results = {} + local recent_books_section = {} -- To store recent books separately + + for _, recent_book in ipairs(recent_books) do + table.insert(recent_books_section, 'Recent Books: ' .. recent_book) + end + + for _, search_result in ipairs(search_results) do + table.insert(results, search_result) + end + + -- Add the recent books section to the results + for _, recent_entry in ipairs(recent_books_section) do + table.insert(results, recent_entry) + end pickers .new({}, { prompt_title = 'Find Books', - finder = finders.new_oneshot_job({ - 'find', - vim.fn.expand(search_dir), - '-type', - 'd', - '-o', - '-type', - 'f', - '-maxdepth', - '1', + finder = finders.new_table({ + results = results, }), previewer = require('telescope.previewers').vim_buffer_cat.new({}), sorter = config.generic_sorter({}), @@ -474,15 +475,24 @@ function M.find_books() local entry = actions_state.get_selected_entry() if entry ~= nil then local path = entry.value + + -- Handle selecting a recent book entry separately + if vim.fn.matchstr(path, '^Recent Books: ') ~= '' then + -- Extract the path of the selected recent book + path = vim.fn.matchstr(path, '^Recent Books: (.*)$') + end + actions.close(prompt_bufnr, false) + -- Debugging statement to print the selected path + print('Selected Entry: ' .. path) + -- Determine whether it's a directory or a file local is_directory = vim.fn.isdirectory(path) if is_directory then - -- It's a directory, navigate to it - vim.fn.chdir(path) - vim.cmd('e .') + -- It's a directory, navigate to it in the current buffer + vim.cmd('e ' .. path) print('Selected directory: ' .. path) else -- It's a file, do something with it (open it, for example) -- cgit v1.2.3 From bc9e594f90e2834bd527f0058854b4127ebf2916 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 25 Oct 2023 13:38:03 +0200 Subject: Changed mapping of recent_files.pick() --- lua/user/keys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 7047ae0..53811a6 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -296,7 +296,7 @@ map('n', 'ffw', [[lua require'plugins.telescope'.find_projects()ffb', [[lua require'plugins.telescope'.find_books()]]) -- find books map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map('n', 'ffr', "lua require('telescope').extensions.recent_files.pick()") +map('n', 'frf', "lua require('telescope').extensions.recent_files.pick()") map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'f/', "lua require('telescope').extensions.file_browser.file_browser()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- cgit v1.2.3 From 0e107e029372f333f64854913fa2f67bb7c4a243 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 25 Oct 2023 13:38:23 +0200 Subject: Add epub to to intercept file open... --- lua/user/mods.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 84498bb..6d357f5 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -800,6 +800,9 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { ['pdf'] = function(buf, fpath, fname) open_in_prog(buf, fpath, fname, 'zathura') end, + ['epub'] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, 'zathura') + end, ['png'] = function(buf, fpath, fname) open_in_prog(buf, fpath, fname, 'feh') end, -- cgit v1.2.3