diff --git a/.github/workflows/lint_code.yml b/.github/workflows/lint_code.yml index 9e88fa59e..71d11c5e2 100644 --- a/.github/workflows/lint_code.yml +++ b/.github/workflows/lint_code.yml @@ -8,4 +8,4 @@ jobs: - uses: actions/checkout@v4 - uses: lunarmodules/luacheck@v1 with: - args: . --std luajit --globals vim _toggle_lazygit _buf_vtext _command_panel _flash_esc_or_noh _debugging --max-line-length 150 --no-config + args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _telescope_collections _toggle_lazygit --max-line-length 150 --no-config diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index cb0c061de..351216925 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -34,6 +34,7 @@ local core_map = { ["n|"] = map_cr("wq"):with_desc("edit: Save file and quit"), ["n|"] = map_cr("q!"):with_desc("edit: Force quit"), ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"), + ["n|bn"] = map_cu("enew"):with_noremap():with_silent():with_desc("buffer: New"), ["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), ["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), ["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), diff --git a/lua/keymap/helpers.lua b/lua/keymap/helpers.lua index b411bcd79..60d99e46f 100644 --- a/lua/keymap/helpers.lua +++ b/lua/keymap/helpers.lua @@ -11,6 +11,33 @@ _G._command_panel = function() }) end +_G._telescope_collections = function(picker_type) + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + local conf = require("telescope.config").values + local finder = require("telescope.finders") + local pickers = require("telescope.pickers") + picker_type = picker_type or {} + + local collections = vim.tbl_keys(require("search.tabs").collections) + pickers + .new(picker_type, { + prompt_title = "Telescope Collections", + finder = finder.new_table({ results = collections }), + sorter = conf.generic_sorter(picker_type), + attach_mappings = function(bufnr) + actions.select_default:replace(function() + actions.close(bufnr) + local selection = action_state.get_selected_entry() + require("search").open({ collection = selection[1] }) + end) + + return true + end, + }) + :find() +end + _G._flash_esc_or_noh = function() local flash_active, state = pcall(function() return require("flash.plugins.char").state diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index a77f0b54f..2efa33eb8 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -89,50 +89,12 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("tool: Toggle command panel"), - ["n|u"] = map_callback(function() - require("telescope").extensions.undo.undo() + ["n|f"] = map_callback(function() + _telescope_collections(require("telescope.themes").get_dropdown()) end) :with_noremap() :with_silent() - :with_desc("edit: Show undo history"), - ["n|fp"] = map_callback(function() - require("telescope").extensions.projects.projects({}) - end) - :with_noremap() - :with_silent() - :with_desc("find: Project"), - ["n|fr"] = map_callback(function() - require("telescope").extensions.frecency.frecency({}) - end) - :with_noremap() - :with_silent() - :with_desc("find: File by frecency"), - ["n|fw"] = map_callback(function() - require("telescope").extensions.live_grep_args.live_grep_args() - end) - :with_noremap() - :with_silent() - :with_desc("find: Word in project"), - ["n|fe"] = map_cu("Telescope oldfiles"):with_noremap():with_silent():with_desc("find: File by history"), - ["n|ff"] = map_cu("Telescope find_files"):with_noremap():with_silent():with_desc("find: File in project"), - ["n|fc"] = map_callback(function() - require("telescope.builtin").colorscheme({ enable_preview = true }) - end) - :with_noremap() - :with_silent() - :with_desc("ui: Change colorscheme for current session"), - ["n|bn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"), - ["n|fg"] = map_cu("Telescope git_files") - :with_noremap() - :with_silent() - :with_desc("find: file in git project"), - ["n|fz"] = map_cu("Telescope zoxide list") - :with_noremap() - :with_silent() - :with_desc("edit: Change current directory by zoxide"), - ["n|fb"] = map_cu("Telescope buffers"):with_noremap():with_silent():with_desc("find: Buffer opened"), - ["nv|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), - ["n|fd"] = map_cu("Telescope persisted"):with_noremap():with_silent():with_desc("find: Session"), + :with_desc("tool: Open Telescope"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/editor/colorizer.lua b/lua/modules/configs/editor/colorizer.lua deleted file mode 100644 index efee45019..000000000 --- a/lua/modules/configs/editor/colorizer.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function() - require("modules.utils").load_plugin("colorizer", {}) -end diff --git a/lua/modules/configs/editor/highlight-colors.lua b/lua/modules/configs/editor/highlight-colors.lua new file mode 100644 index 000000000..06a0f6acd --- /dev/null +++ b/lua/modules/configs/editor/highlight-colors.lua @@ -0,0 +1,31 @@ +return function() + require("modules.utils").load_plugin("nvim-highlight-colors", { + render = "background", + enable_hex = true, + enable_short_hex = true, + enable_rgb = true, + enable_hsl = true, + enable_var_usage = true, + enable_named_colors = false, + enable_tailwind = false, + -- Exclude filetypes or buftypes from highlighting + exclude_filetypes = { + "alpha", + "bigfile", + "dap-repl", + "fugitive", + "git", + "notify", + "NvimTree", + "Outline", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + exclude_buftypes = { + "nofile", + "prompt", + "terminal", + }, + }) +end diff --git a/lua/modules/configs/tool/search.lua b/lua/modules/configs/tool/search.lua new file mode 100644 index 000000000..e01f50437 --- /dev/null +++ b/lua/modules/configs/tool/search.lua @@ -0,0 +1,130 @@ +return function() + local builtin = require("telescope.builtin") + local extensions = require("telescope").extensions + + require("modules.utils").load_plugin("search", { + collections = { + file = { + initial_tab = 1, + tabs = { + { + name = "Files", + tele_func = function(opts) + opts = opts or {} + if vim.fn.isdirectory(".git") == 1 then + builtin.git_files(opts) + else + builtin.find_files(opts) + end + end, + }, + { + name = "Frecency", + tele_func = function() + extensions.frecency.frecency() + end, + }, + { + name = "Oldfiles", + tele_func = function() + builtin.oldfiles() + end, + }, + }, + }, + live_grep = { + initial_tab = 1, + tabs = { + { + name = "Word in project", + tele_func = function() + extensions.live_grep_args.live_grep_args() + end, + }, + { + name = "Word under cursor", + tele_func = function(opts) + opts = opts or {} + builtin.grep_string(opts) + end, + }, + }, + }, + git = { + initial_tab = 1, + tabs = { + { + name = "Branches", + tele_func = function() + builtin.git_branches() + end, + }, + { + name = "Commits", + tele_func = function() + builtin.git_commits() + end, + }, + { + name = "Commit content", + tele_func = function() + extensions.advanced_git_search.search_log_content() + end, + }, + { + name = "Diff current file with commit", + tele_func = function() + extensions.advanced_git_search.diff_commit_file() + end, + }, + }, + }, + workspace = { + initial_tab = 1, + tabs = { + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, + { + name = "Sessions", + tele_func = function() + extensions.persisted.persisted() + end, + }, + { + name = "Projects", + tele_func = function() + extensions.projects.projects({}) + end, + }, + { + name = "Zoxide", + tele_func = function() + extensions.zoxide.list() + end, + }, + }, + }, + misc = { + initial_tab = 1, + tabs = { + { + name = "Colorschemes", + tele_func = function() + builtin.colorscheme({ enable_preview = true }) + end, + }, + { + name = "Undo History", + tele_func = function() + extensions.undo.undo() + end, + }, + }, + }, + }, + }) +end diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua index d8fdddd44..71884d085 100644 --- a/lua/modules/configs/tool/telescope.lua +++ b/lua/modules/configs/tool/telescope.lua @@ -64,7 +64,6 @@ return function() }, live_grep_args = { auto_quoting = true, -- enable/disable auto-quoting - -- define mappings, e.g. mappings = { -- extend mappings i = { [""] = lga_actions.quote_prompt(), @@ -74,18 +73,19 @@ return function() }, undo = { side_by_side = true, - mappings = { -- this whole table is the default + mappings = { i = { - -- IMPORTANT: Note that telescope-undo must be available when telescope is configured if - -- you want to use the following actions. This means installing as a dependency of - -- telescope in it's `requirements` and loading this extension from there instead of - -- having the separate plugin definition as outlined above. See issue #6. [""] = require("telescope-undo.actions").yank_additions, [""] = require("telescope-undo.actions").yank_deletions, [""] = require("telescope-undo.actions").restore, }, }, }, + advanced_git_search = { + diff_plugin = "diffview", + git_flags = { "-c", "delta.side-by-side=true" }, + entry_default_author_or_date = "author", -- one of "author" or "date" + }, }, }) @@ -98,4 +98,5 @@ return function() require("telescope").load_extension("zoxide") require("telescope").load_extension("persisted") require("telescope").load_extension("aerial") + require("telescope").load_extension("advanced_git_search") end diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index 73b273351..b25003e12 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -63,9 +63,14 @@ editor["smoka7/hop.nvim"] = { } editor["tzachar/local-highlight.nvim"] = { lazy = true, - event = { "CursorHold", "CursorHoldI" }, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, config = require("editor.local-highlight"), } +editor["brenoprata10/nvim-highlight-colors"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.highlight-colors"), +} editor["romainl/vim-cool"] = { lazy = true, event = { "CursorMoved", "InsertEnter" }, @@ -109,10 +114,6 @@ editor["nvim-treesitter/nvim-treesitter"] = { "windwp/nvim-ts-autotag", config = require("editor.autotag"), }, - { - "NvChad/nvim-colorizer.lua", - config = require("editor.colorizer"), - }, { "hiphish/rainbow-delimiters.nvim", config = require("editor.rainbow_delims"), diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 2d8b9555d..75d5b5112 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -78,18 +78,31 @@ tool["nvim-telescope/telescope.nvim"] = { cmd = "Telescope", config = require("tool.telescope"), dependencies = { - { "nvim-tree/nvim-web-devicons" }, { "nvim-lua/plenary.nvim" }, + { "nvim-tree/nvim-web-devicons" }, + { "jvgrootveld/telescope-zoxide" }, { "debugloop/telescope-undo.nvim" }, + { "nvim-telescope/telescope-frecency.nvim" }, + { "nvim-telescope/telescope-live-grep-args.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "FabianWirth/search.nvim", + config = require("tool.search"), + }, { "ahmedkhalf/project.nvim", event = { "CursorHold", "CursorHoldI" }, config = require("tool.project"), }, - { "jvgrootveld/telescope-zoxide" }, - { "nvim-telescope/telescope-frecency.nvim" }, - { "nvim-telescope/telescope-live-grep-args.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "aaronhallaert/advanced-git-search.nvim", + cmd = { "AdvancedGitSearch" }, + dependencies = { + "tpope/vim-rhubarb", + "tpope/vim-fugitive", + "sindrets/diffview.nvim", + }, + }, }, }