From 2efde35597dc6a31d43b70d2a7728b65b9f92dd5 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Fri, 4 Nov 2022 18:31:16 -0700 Subject: [PATCH] add telescope file browser --- init.vim | 1 + lua/plugins.lua | 11 ++++++++--- plugin-confs/dashboard-nvim.lua | 4 ++-- plugin-confs/telescope-file-browser.lua | 25 +++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 plugin-confs/telescope-file-browser.lua diff --git a/init.vim b/init.vim index 98fd595..0aef93d 100644 --- a/init.vim +++ b/init.vim @@ -43,6 +43,7 @@ source ~/.config/nvim/plugin-confs/presence.lua source ~/.config/nvim/plugin-confs/treesitter.lua source ~/.config/nvim/plugin-confs/whichkey.lua source ~/.config/nvim/plugin-confs/telescope.lua +source ~/.config/nvim/plugin-confs/telescope-file-browser.lua source ~/.config/nvim/plugin-confs/code_actions.lua source ~/.config/nvim/plugin-confs/goto-preview.lua diff --git a/lua/plugins.lua b/lua/plugins.lua index 209fcb3..6f2a611 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -15,7 +15,7 @@ require('packer').startup(function(use) use { "zbirenbaum/copilot.lua", - after = "lualine.nvim", + event = "VimEnter", config = function () vim.defer_fn(function() require('copilot').setup({ @@ -27,7 +27,7 @@ require('packer').startup(function(use) jump_next = "]]", accept = "", refresh = "gr", - open = "" + open = "" }, }, suggestion = { @@ -56,6 +56,7 @@ require('packer').startup(function(use) plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", server_opts_overrides = {}, }) + require("copilot.suggestion").toggle_auto_trigger() end, 100) end, } @@ -65,7 +66,7 @@ require('packer').startup(function(use) after = { "copilot.lua" }, config = function () require("copilot_cmp").setup({ - -- method = "getCompletionsCycling", + method = "getCompletionsCycling", -- formatters = { -- insert_text = require("copilot_cmp.format").remove_existing -- } @@ -146,6 +147,10 @@ require('packer').startup(function(use) use { 'nvim-telescope/telescope.nvim' } + use { + 'nvim-telescope/telescope-file-browser.nvim' + } + use { 'ojroques/nvim-lspfuzzy' } diff --git a/plugin-confs/dashboard-nvim.lua b/plugin-confs/dashboard-nvim.lua index 90ecb4d..c9a0b60 100644 --- a/plugin-confs/dashboard-nvim.lua +++ b/plugin-confs/dashboard-nvim.lua @@ -15,7 +15,7 @@ db.custom_center = { action ='SessionLoad'}, {icon = ' ', desc = 'Recently opened files ', - action = 'DashboardFindHistory', + action = 'Telescope oldfiles', shortcut = 'SPC f h'}, {icon = ' ', desc = 'Find File ', @@ -23,7 +23,7 @@ db.custom_center = { shortcut = 'SPC f f'}, {icon = ' ', desc ='File Browser ', - action = 'NvimTreeToggle', + action = 'Telescope file_browser', shortcut = 'SPC f b'}, {icon = ' ', desc = 'Find word ', diff --git a/plugin-confs/telescope-file-browser.lua b/plugin-confs/telescope-file-browser.lua new file mode 100644 index 0000000..6f99ffe --- /dev/null +++ b/plugin-confs/telescope-file-browser.lua @@ -0,0 +1,25 @@ +local fb_actions = require "telescope".extensions.file_browser.actions +require("telescope").setup { + extensions = { + file_browser = { + -- theme = "ivy", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + ["i"] = { + -- your custom insert mode mappings + [""] = fb_actions.goto_home_dir, + [""] = function(prompt_bufnr) + end + }, + ["n"] = { + -- your custom normal mode mappings + f = false, + }, + }, + }, + }, +} +-- To get telescope-file-browser loaded and working with telescope, +-- you need to call load_extension, somewhere after setup function: +require("telescope").load_extension "file_browser"