From ad9bdf2f20ce1357c788a749117a3a5d2d3a3c01 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 3 Jun 2023 12:22:09 -0600 Subject: move some mappings into telescope config, separate fzf --- init.lua | 40 ------------------------------------ lua/plugins/init.lua | 12 ----------- lua/plugins/neo-tree.lua | 7 ++++--- lua/plugins/telescope-fzf-native.lua | 8 ++++++++ lua/plugins/telescope.lua | 36 ++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 55 deletions(-) create mode 100644 lua/plugins/telescope-fzf-native.lua create mode 100644 lua/plugins/telescope.lua diff --git a/init.lua b/init.lua index 160aef6..9bc1bbf 100644 --- a/init.lua +++ b/init.lua @@ -82,40 +82,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) - -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { @@ -191,12 +157,6 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. local nmap = function(keys, func, desc) if desc then desc = 'LSP: ' .. desc diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index b9f4cbb..9478ab5 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -74,18 +74,6 @@ return { -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, - -- Fuzzy Finder (files, lsp, etc) - { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } }, - - -- Fuzzy Finder Algorithm which requires local dependencies to be built - { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index e83de80..64b0549 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -2,9 +2,6 @@ return { 'nvim-neo-tree/neo-tree.nvim', cmd = 'Neotree', version = '*', - keys = { - { 'nt', 'Neotree toggle', desc = 'Toggle [N]eo[t]ree' }, - }, dependencies = { 'nvim-lua/plenary.nvim', 'MunifTanjim/nui.nvim', @@ -16,4 +13,8 @@ return { hijack_netrw_behavior = 'open_current', }, }, + -- keys is used for Lazy-load + keys = { + { 'nt', 'Neotree toggle', desc = 'Toggle [N]eo[t]ree' }, + }, } diff --git a/lua/plugins/telescope-fzf-native.lua b/lua/plugins/telescope-fzf-native.lua new file mode 100644 index 0000000..1fe2371 --- /dev/null +++ b/lua/plugins/telescope-fzf-native.lua @@ -0,0 +1,8 @@ +return { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + config = function() + pcall(require('telescope').load_extension, 'fzf') + return vim.fn.executable 'make' == 1 + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..d182d7c --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,36 @@ +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + opts = { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + }, + -- Best place to key keymaps in this file + config = function() + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + -- Other keybinds present for the LSP currently at init.lua + end, +} -- cgit v1.2.3-70-g09d2