From 9cc3ec057d0ac5de12948ddf221ac2fc125d1c9e Mon Sep 17 00:00:00 2001 From: c-my Date: Wed, 26 Apr 2023 15:34:30 +0800 Subject: [PATCH] telescope: work around its fold issue && use "0.1.x" branch --- lazy-lock.json | 7 +-- lua/plugins/telescope.lua | 108 +++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index cfe8379..2fd14a4 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,12 +2,13 @@ "Comment.nvim": { "branch": "master", "commit": "a89339ffbee677ab0521a483b6dac7e2e67c907e" }, "LuaSnip": { "branch": "master", "commit": "e77fa9ad0b1f4fc6cddf54e51047e17e90c7d7ed" }, "better-escape.nvim": { "branch": "master", "commit": "426d29708064d5b1bfbb040424651c92af1f3f64" }, + "catppuccin": { "branch": "main", "commit": "dd176757cc745f71bd54c472a9f58d5f8a54661d" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "5af1bb7d722ef8a96658f01d6eb219c4cf746b32" }, "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, - "friendly-snippets": { "branch": "main", "commit": "9590ff90759488674cf97fe5d5754a0733ab37bb" }, + "friendly-snippets": { "branch": "main", "commit": "631f79e346b0b3203d2ce3eae619ca8d612e5463" }, "gitsigns.nvim": { "branch": "main", "commit": "7dfe4be94b4f84a9931098f0f0f618d055e50bd5" }, "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, "lazy.nvim": { "branch": "main", "commit": "903f0fe542fc35b74f3c09494f9c175346dfa76d" }, @@ -19,11 +20,11 @@ "nvim-cmp": { "branch": "main", "commit": "e28fb7a730b1bd425fdddfdbd3d36bb84bd77611" }, "nvim-lspconfig": { "branch": "master", "commit": "710c45bd13928c1f37ef0a714fd49b75f00d7d5e" }, "nvim-tree.lua": { "branch": "master", "commit": "bb375fb20327c49920c41d2b51c1ce2f4fe7deb3" }, - "nvim-treesitter": { "branch": "master", "commit": "75f911d01f740385f1f60b2f73266514647913b5" }, + "nvim-treesitter": { "branch": "master", "commit": "0d7da3bd7d59ffacc2fac6a52a1ba16d820f882c" }, "nvim-web-devicons": { "branch": "master", "commit": "4ec26d67d419c12a4abaea02f1b6c57b40c08d7e" }, "plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" }, "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, - "telescope.nvim": { "branch": "master", "commit": "f2645c13205abb9ee3dbcee68416645c69b863c8" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "9de317bdea2bc393074651179c4fc7f93e9b2d56" }, "toggleterm.nvim": { "branch": "main", "commit": "68fdf851c2b7901a7065ff129b77d3483419ddce" }, "tokyonight.nvim": { "branch": "main", "commit": "ab0ac67f4f32f44c3480f4b81ed90e11cb4f3763" } } \ No newline at end of file diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index fdaf9d5..669fd4e 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,79 +1,79 @@ +-- This functions is to fix a bug in telescope +-- that the fold not word if open file in telescope +-- https://github.com/nvim-telescope/telescope.nvim/issues/559#issuecomment-1221001701 +local function stopinsert(callback) + return function(prompt_bufnr) + vim.cmd.stopinsert() + vim.schedule(function() + callback(prompt_bufnr) + end) + end +end return { { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" }, cmd = "Telescope", + branch = "0.1.x", + config = function() + local actions = require("telescope.actions") + require("telescope").setup({ + + defaults = { + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + [""] = actions.close, -- As we don't use normal node in telescope + [""] = stopinsert(actions.select_default), + [""] = stopinsert(actions.select_vertical), + [""] = stopinsert(actions.select_horizontal), + [""] = stopinsert(actions.select_tab), + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + ["q"] = actions.close, + }, + }, + }, + pickers = { + colorscheme = { + enable_preview = true, + theme = "dropdown", + }, + }, + }) + end, keys = { { "ff", - "Telescope find_files ", + "Telescope find_files", desc = "Find File", }, { "fg", - "Telescope live_grep ", + "Telescope live_grep", desc = "Find Grep", }, { "fb", - "Telescope buffers ", + "Telescope buffers", desc = "Find Buffer", }, { "fh", - "Telescope help_tags ", + "Telescope help_tags", desc = "Find Help", }, - }, - opts = { - defaults = { - mappings = { - i = { - [""] = function(...) - return require("telescope.actions").move_selection_next(...) - end, - [""] = function(...) - return require("telescope.actions").move_selection_previous(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_down(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_up(...) - end, - }, - n = { - [""] = function(...) - return require("telescope.actions").move_selection_next(...) - end, - [""] = function(...) - return require("telescope.actions").move_selection_previous(...) - end, - ["q"] = function(...) - return require("telescope.actions").close(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_down(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_up(...) - end, - }, - }, - -- pickers = { - -- lsp_definitions = { - -- theme = "get_cursor", - -- }, - -- lsp_references = { - -- theme = "get_cursor", - -- }, - -- lsp_implementation = { - -- theme = "get_cursor", - -- }, - -- lsp_type_definitions = { - -- theme = "get_cursor", - -- }, - -- }, + { + "ft", + "Telescope colorscheme", + desc = "Find Theme", }, }, },