From c25d4ec182b4f9e56e2844bf5956ca2bc5d516e1 Mon Sep 17 00:00:00 2001 From: js0ny Date: Tue, 8 Apr 2025 18:30:49 +0100 Subject: [PATCH] feat(nvim): Change picker to FzfLua --- tools/nvim/lua/plugins/appearance.lua | 86 +++++++++---------- tools/nvim/lua/plugins/fileutils.lua | 34 ++++---- .../plugins/lang/markdown/obsidian-nvim.lua | 22 ++++- tools/nvim/lua/plugins/lang/org.lua | 12 +-- tools/nvim/lua/plugins/lazy-nvim.lua | 4 +- tools/nvim/lua/plugins/misc.lua | 7 +- tools/nvim/lua/plugins/mod/avante-nvim.lua | 13 +-- tools/nvim/lua/plugins/mod/fzf.lua | 24 ++++++ tools/nvim/lua/plugins/mod/snacks-nvim.lua | 6 +- tools/nvim/lua/plugins/mod/telescope.lua | 2 +- 10 files changed, 128 insertions(+), 82 deletions(-) diff --git a/tools/nvim/lua/plugins/appearance.lua b/tools/nvim/lua/plugins/appearance.lua index f0a2d18..3ba6ab5 100644 --- a/tools/nvim/lua/plugins/appearance.lua +++ b/tools/nvim/lua/plugins/appearance.lua @@ -32,9 +32,9 @@ return { opts = { variant = "dawn", }, - cmd = "Telescope colorscheme", + cmd = "FzfLua colorschemes", }, - { "rebelot/kanagawa.nvim", cmd = "Telescope colorscheme" }, + { "rebelot/kanagawa.nvim", cmd = "FzfLua colorschemes" }, { -- Modern Status Line "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, @@ -43,55 +43,55 @@ return { require("plugins.mod.lualine") end, }, - { -- Breadcrumb - "Bekaboo/dropbar.nvim", - dependencies = { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - }, - opts = {}, - keys = { - { - "+", - function() - require("dropbar.api").pick() - end, - desc = "Pick symbols in winbar", - }, - { - "[;", - function() - require("dropbar.api").goto_context_start() - end, - desc = "Go to start of current context", - }, - { - "];", - function() - require("dropbar.api").select_next_context() - end, - desc = "Select next context", - }, - }, - }, + -- { -- Breadcrumb + -- "Bekaboo/dropbar.nvim", + -- dependencies = { + -- "nvim-telescope/telescope-fzf-native.nvim", + -- build = "make", + -- }, + -- opts = {}, + -- keys = { + -- { + -- "+", + -- function() + -- require("dropbar.api").pick() + -- end, + -- desc = "Pick symbols in winbar", + -- }, + -- { + -- "[;", + -- function() + -- require("dropbar.api").goto_context_start() + -- end, + -- desc = "Go to start of current context", + -- }, + -- { + -- "];", + -- function() + -- require("dropbar.api").select_next_context() + -- end, + -- desc = "Select next context", + -- }, + -- }, + -- }, { import = "plugins.mod.bufferline" }, -- Buffer Top Bar - { -- Git Blames, Changes + { -- Git Blames, Changes "lewis6991/gitsigns.nvim", opts = { current_line_blame = true, }, event = "BufReadPre", keys = { - { "gb", "Gitsigns blame", desc = "Blame file" }, - { "gd", "Gitsigns diffthis", desc = "Diff file" }, + { "gb", "Gitsigns blame", desc = "Blame file" }, + { "gd", "Gitsigns diffthis", desc = "Diff file" }, { "gB", "Gitsigns toggle_current_line_blame", desc = "Toggle line blame" }, }, }, - { -- Highlight and navigate between TODOs - "folke/todo-comments.nvim", - cmd = { "TodoTelescope" }, - event = "BufRead", - opts = {}, - dependencies = { "nvim-lua/plenary.nvim" }, - }, + -- { -- Highlight and navigate between TODOs + -- "folke/todo-comments.nvim", + -- cmd = { "TodoTelescope" }, + -- event = "BufRead", + -- opts = {}, + -- dependencies = { "nvim-lua/plenary.nvim" }, + -- }, } diff --git a/tools/nvim/lua/plugins/fileutils.lua b/tools/nvim/lua/plugins/fileutils.lua index 5f18020..d78119a 100644 --- a/tools/nvim/lua/plugins/fileutils.lua +++ b/tools/nvim/lua/plugins/fileutils.lua @@ -11,23 +11,23 @@ return { }, }, -- { import = "plugins.mod.nvim-tree" }, - { import = "plugins.mod.telescope" }, - -- { import = "plugins.mod.fzf" }, - { - "ahmedkhalf/project.nvim", - event = "VeryLazy", - opts = { - detection_methods = { "lsp", "pattern" }, - patterns = { ".git", "Makefile", "package.json" }, - sync_root_with_cwd = true, - silent_chdir = true, - scope_chdir = "global", - }, - config = function() - require("telescope").load_extension("projects") - end, - dependencies = { "nvim-telescope/telescope.nvim" }, - }, + -- { import = "plugins.mod.telescope" }, + { import = "plugins.mod.fzf" }, + -- { + -- "ahmedkhalf/project.nvim", + -- event = "VeryLazy", + -- opts = { + -- detection_methods = { "lsp", "pattern" }, + -- patterns = { ".git", "Makefile", "package.json" }, + -- sync_root_with_cwd = true, + -- silent_chdir = true, + -- scope_chdir = "global", + -- }, + -- config = function() + -- require("telescope").load_extension("projects") + -- end, + -- dependencies = { "nvim-telescope/telescope.nvim" }, + -- }, -- { -- "NeogitOrg/neogit", -- config = true, diff --git a/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua b/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua index befc64a..584c96a 100644 --- a/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua +++ b/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua @@ -1,5 +1,5 @@ return { - "epwalsh/obsidian.nvim", + "obsidian-nvim/obsidian.nvim", version = "*", -- recommended, use latest release instead of latest commit -- lazy = false, ft = "markdown", @@ -38,11 +38,15 @@ return { -- "BufReadPre path/to/my-vault/*.md", -- "BufNewFile path/to/my-vault/*.md", -- }, + keys = { + { "fo", "ObsidianQuickSwitch", desc = "Obsidian: Quick Switch" }, + }, dependencies = { -- Required. "nvim-lua/plenary.nvim", -- see below for full list of optional dependencies 👇 + "ibhagwan/fzf-lua", }, opts = { workspaces = { @@ -53,11 +57,18 @@ return { }, completion = { nvim_cmp = false, + blink = true, min_chars = 2, }, ui = { enable = false, }, + daily_notes = { + folder = "_Global/Periodic", + date_format = "%Y-%m-%d", + default_tags = { "daily" }, + template = nil, + }, -- see below for full list of options 👇 attachments = { img_folder = "_Global/Assets", @@ -65,5 +76,14 @@ return { return string.format("%s-", os.time()) end, }, + mappings = { + [""] = { + action = function() + require("obsidian").util.smart_action() + end, + opts = { buffer = true, expr = true }, + }, + }, + new_notes_location = "current_dir", }, } diff --git a/tools/nvim/lua/plugins/lang/org.lua b/tools/nvim/lua/plugins/lang/org.lua index 76d0175..a74c3d4 100644 --- a/tools/nvim/lua/plugins/lang/org.lua +++ b/tools/nvim/lua/plugins/lang/org.lua @@ -2,8 +2,8 @@ return { { "nvim-orgmode/orgmode", dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-orgmode/telescope-orgmode.nvim", + -- "nvim-telescope/telescope.nvim", + -- "nvim-orgmode/telescope-orgmode.nvim", "nvim-orgmode/org-bullets.nvim", "Saghen/blink.cmp", }, @@ -65,11 +65,11 @@ return { }, }) - require("telescope").setup() - require("telescope").load_extension("orgmode") + -- require("telescope").setup() + -- require("telescope").load_extension("orgmode") -- vim.keymap.set("n", "r", require("telescope").extensions.orgmode.refile_heading) - vim.keymap.set("n", "oP", require("telescope").extensions.orgmode.search_headings) - vim.keymap.set("n", "op", "Telescope find_files cwd=~/OrgFiles") + -- vim.keymap.set("n", "oP", require("telescope").extensions.orgmode.search_headings) + vim.keymap.set("n", "op", "FzfLua files cwd=~/OrgFiles") -- vim.keymap.set("n", "li", require("telescope").extensions.orgmode.insert_link) end, }, diff --git a/tools/nvim/lua/plugins/lazy-nvim.lua b/tools/nvim/lua/plugins/lazy-nvim.lua index c1396ee..f511aca 100644 --- a/tools/nvim/lua/plugins/lazy-nvim.lua +++ b/tools/nvim/lua/plugins/lazy-nvim.lua @@ -6,7 +6,7 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, + { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() @@ -19,4 +19,4 @@ vim.opt.rtp:prepend(lazypath) -- loading lazy.nvim so that mappings are correct. -- This is also a good place to setup other settings (vim.opt) vim.g.mapleader = " " -vim.g.maplocalleader = "" +vim.g.maplocalleader = "\\" diff --git a/tools/nvim/lua/plugins/misc.lua b/tools/nvim/lua/plugins/misc.lua index 3514978..cb9db10 100644 --- a/tools/nvim/lua/plugins/misc.lua +++ b/tools/nvim/lua/plugins/misc.lua @@ -1,6 +1,6 @@ return { - { "nvim-lua/plenary.nvim", lazy = true }, - { "wakatime/vim-wakatime", lazy = false }, + { "nvim-lua/plenary.nvim", lazy = true }, + { "wakatime/vim-wakatime", lazy = false }, { import = "plugins.mod.toggleterm" }, { import = "plugins.mod.which-keys-nvim" }, { import = "plugins.mod.copilot-lua" }, @@ -14,7 +14,8 @@ return { lazy = true, -- event = "VeryLazy", dependencies = { - "nvim-telescope/telescope.nvim", + -- "nvim-telescope/telescope.nvim", + "ibhagwan/fzf-lua", "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", }, diff --git a/tools/nvim/lua/plugins/mod/avante-nvim.lua b/tools/nvim/lua/plugins/mod/avante-nvim.lua index 9e8ea29..90b0d6b 100644 --- a/tools/nvim/lua/plugins/mod/avante-nvim.lua +++ b/tools/nvim/lua/plugins/mod/avante-nvim.lua @@ -8,10 +8,10 @@ return { -- for example provider = "openai", openai = { - endpoint = "https://yunwu.ai/v1", + endpoint = "https://aihubmix.com/v1", model = "claude-3-7-sonnet-20250219", -- your desired model (or use gpt-4o, etc.) - timeout = 30000, -- timeout in milliseconds - temperature = 0, -- adjust if needed + timeout = 30000, -- timeout in milliseconds + temperature = 0, -- adjust if needed max_tokens = 4096, -- reasoning_effort = "high" -- only supported for "o" models }, @@ -25,10 +25,11 @@ return { "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", --- The below dependencies are optional, - "nvim-telescope/telescope.nvim", -- for file_selector provider telescope - "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions + -- "nvim-telescope/telescope.nvim", -- for file_selector provider telescope + "ibhagwan/fzf-lua", + "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons - "zbirenbaum/copilot.lua", -- for providers='copilot' + "zbirenbaum/copilot.lua", -- for providers='copilot' { -- support for image pasting "HakonHarnes/img-clip.nvim", diff --git a/tools/nvim/lua/plugins/mod/fzf.lua b/tools/nvim/lua/plugins/mod/fzf.lua index dc149e3..45507c1 100644 --- a/tools/nvim/lua/plugins/mod/fzf.lua +++ b/tools/nvim/lua/plugins/mod/fzf.lua @@ -2,5 +2,29 @@ return { "ibhagwan/fzf-lua", -- optional for icon support dependencies = { "nvim-tree/nvim-web-devicons" }, + cmd = "FzfLua", + keys = { + { "", "FzfLua files", desc = "Find Files" }, + { "fc", "FzfLua files cwd=~/.config/nvim", desc = "Edit configs" }, + { "/", "FzfLua live_grep", desc = "Grep Files" }, + { ";", "FzfLua", desc = "Show Telescope Commands" }, + { "ui", "FzfLua colorschemes", desc = "Change colorscheme" }, + -- find_files { "pp", "FzfLua projects", desc = "Listfind_files all Projects" }, + { "pd", "FzfLua zoxide", desc = "List recent directories" }, + -- { "pg", "FzfLua projects", desc = "List all Git Projects" }, + { "ps", "FzfLua session-lens", desc = "List all sessions" }, + { "gs", "FzfLua git_status", desc = "Git Status" }, + { "gt", "FzfLua git_branches", desc = "Git Branches" }, + { "gc", "FzfLua git_commits", desc = "Show commits" }, + { "fb", "FzfLua buffers", desc = "List Buffers" }, + { "ff", "FzfLua fd", desc = "Find Files" }, + { "fh", "FzfLua oldfiles", desc = "Recent Files" }, + { "ce", "FzfLua diagnostics", desc = "Navigate errors/warnings" }, + { "cs", "FzfLua treesitter", desc = "Search symbols" }, + { "cS", "FzfLua grep_string", desc = "Search current symbol" }, + { "bB", "FzfLua buffers", desc = "List Buffers" }, + { "fl", ":FzfLua filetypes", desc = "Set Filetype/Lang to ..." }, + { "R", "FzfLua resume", desc = "Resume FzfLua" }, + }, opts = {}, } diff --git a/tools/nvim/lua/plugins/mod/snacks-nvim.lua b/tools/nvim/lua/plugins/mod/snacks-nvim.lua index 82d1b09..998cb6c 100644 --- a/tools/nvim/lua/plugins/mod/snacks-nvim.lua +++ b/tools/nvim/lua/plugins/mod/snacks-nvim.lua @@ -11,14 +11,14 @@ return { enabled = true, preset = { keys = { - { key = "p", icon = "󰈞 ", desc = "查找项目", action = "Telescope projects" }, - { key = "h", icon = " ", desc = "历史文件", action = "Telescope oldfiles" }, + -- { key = "p", icon = "󰈞 ", desc = "查找项目", action = "Telescope projects" }, + { key = "h", icon = " ", desc = "历史文件", action = "FzfLua oldfiles" }, { key = "l", icon = " ", desc = "加载会话", action = "SessionSearch" }, { key = "c", icon = " ", desc = "转到设置", - action = "Telescope find_files cwd=~/.config/nvim", + action = "FzfLua files cwd=~/.config/nvim", }, { key = "q", icon = "󱊷 ", desc = "退出", action = "qa" }, }, diff --git a/tools/nvim/lua/plugins/mod/telescope.lua b/tools/nvim/lua/plugins/mod/telescope.lua index e55145d..6a5d4ca 100644 --- a/tools/nvim/lua/plugins/mod/telescope.lua +++ b/tools/nvim/lua/plugins/mod/telescope.lua @@ -33,7 +33,7 @@ return { { "fc", "Telescope find_files cwd=~/.config/nvim", desc = "Edit configs" }, { "/", "Telescope live_grep", desc = "Grep Files" }, { ";", "Telescope", desc = "Show Telescope Commands" }, - { "ui", "Telescope colorscheme", desc = "Change colorscheme" }, + { "ui", "FzfLua colorscheme", desc = "Change colorscheme" }, { "pp", "Telescope projects", desc = "List all Projects" }, { "pg", "Telescope projects", desc = "List all Git Projects" }, { "ps", "Telescope session-lens", desc = "List all sessions" },