From 5e6c1d45b933325f59f1d6931b1f20da9b657f03 Mon Sep 17 00:00:00 2001 From: Alexander Navarro Date: Thu, 20 Apr 2023 11:38:58 -0400 Subject: [PATCH] refactor nvim plugins structure --- config/nvim/init.lua | 97 ------------------- config/nvim/lua/aleidk/plugins/blankline.lua | 8 ++ config/nvim/lua/aleidk/plugins/init.lua | 59 +---------- config/nvim/lua/aleidk/plugins/lualine.lua | 13 +++ config/nvim/lua/aleidk/plugins/telescope.lua | 65 +++++++++++++ config/nvim/lua/aleidk/plugins/treesitter.lua | 69 +++++++++++++ 6 files changed, 160 insertions(+), 151 deletions(-) create mode 100644 config/nvim/lua/aleidk/plugins/blankline.lua create mode 100644 config/nvim/lua/aleidk/plugins/lualine.lua create mode 100644 config/nvim/lua/aleidk/plugins/telescope.lua create mode 100644 config/nvim/lua/aleidk/plugins/treesitter.lua diff --git a/config/nvim/init.lua b/config/nvim/init.lua index e898172..ad174bc 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -26,102 +26,5 @@ require("aleidk.keymaps") require("aleidk.autocmds") require("aleidk.IDE") --- [[ 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", "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({ - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { "c", "cpp", "go", "lua", "python", "rust", "tsx", "typescript", "vimdoc", "vim" }, - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - highlight = { enable = true }, - indent = { enable = true, disable = { "python" } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = "", - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["aa"] = "@parameter.outer", - ["ia"] = "@parameter.inner", - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - }, - swap = { - enable = true, - swap_next = { - ["a"] = "@parameter.inner", - }, - swap_previous = { - ["A"] = "@parameter.inner", - }, - }, - }, -}) - -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/config/nvim/lua/aleidk/plugins/blankline.lua b/config/nvim/lua/aleidk/plugins/blankline.lua new file mode 100644 index 0000000..6f32c53 --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/blankline.lua @@ -0,0 +1,8 @@ +return { + -- Add indentation guides even on blank lines + "lukas-reineke/indent-blankline.nvim", + opts = { + char = "┊", + show_trailing_blankline_indent = false, + }, +} diff --git a/config/nvim/lua/aleidk/plugins/init.lua b/config/nvim/lua/aleidk/plugins/init.lua index 7390452..8869638 100644 --- a/config/nvim/lua/aleidk/plugins/init.lua +++ b/config/nvim/lua/aleidk/plugins/init.lua @@ -8,8 +8,6 @@ return { -- Detect tabstop and shiftwidth automatically "tpope/vim-sleuth", - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. { -- LSP Configuration & Plugins "neovim/nvim-lspconfig", @@ -33,8 +31,11 @@ return { dependencies = { "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip" }, }, - -- Useful plugin to show you pending keybinds. - { "folke/which-key.nvim", opts = {} }, + { + -- Useful plugin to show you pending keybinds. + "folke/which-key.nvim", + opts = {}, + }, { -- Theme inspired by Atom @@ -45,59 +46,9 @@ return { end, }, - { - -- Set lualine as statusline - "nvim-lualine/lualine.nvim", - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = false, - theme = "onedark", - component_separators = "|", - section_separators = "", - }, - }, - }, - - { - -- Add indentation guides even on blank lines - "lukas-reineke/indent-blankline.nvim", - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` - opts = { - char = "┊", - show_trailing_blankline_indent = false, - }, - }, - -- "gc" to comment visual regions/lines { "numToStr/Comment.nvim", opts = {} }, - -- Fuzzy Finder (files, lsp, etc) - { "nvim-telescope/telescope.nvim", version = "*", dependencies = { "nvim-lua/plenary.nvim" } }, - - -- Fuzzy Finder Algorithm which requires local dependencies to be built. - -- Only load if `make` is available. Make sure you have the system - -- requirements installed. - { - "nvim-telescope/telescope-fzf-native.nvim", - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. - build = "make", - cond = function() - return vim.fn.executable("make") == 1 - end, - }, - - { - -- Highlight, edit, and navigate code - "nvim-treesitter/nvim-treesitter", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - build = ":TSUpdate", - }, - -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. diff --git a/config/nvim/lua/aleidk/plugins/lualine.lua b/config/nvim/lua/aleidk/plugins/lualine.lua new file mode 100644 index 0000000..f9c97a2 --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/lualine.lua @@ -0,0 +1,13 @@ +return { + -- Set lualine as statusline + "nvim-lualine/lualine.nvim", + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = "onedark", + component_separators = "|", + section_separators = "", + }, + }, +} diff --git a/config/nvim/lua/aleidk/plugins/telescope.lua b/config/nvim/lua/aleidk/plugins/telescope.lua new file mode 100644 index 0000000..824e45b --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/telescope.lua @@ -0,0 +1,65 @@ +-- Fuzzy Finder (files, lsp, etc) +return { + "nvim-telescope/telescope.nvim", + version = "*", + dependencies = { + { "nvim-lua/plenary.nvim" }, + { + -- Blazingly Fast Fuzzy Finder Algorithm for Telescope + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + cond = function() + return vim.fn.executable("make") == 1 + end, + }, + }, + opts = { + defaults = { + mappings = { + i = { + [""] = false, + [""] = false, + }, + }, + }, + }, + config = function(_, opts) + local telescope = require("telescope") + telescope.setup(opts) + + -- Enable telescope fzf native, if installed + pcall(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", "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" }) + end, +} diff --git a/config/nvim/lua/aleidk/plugins/treesitter.lua b/config/nvim/lua/aleidk/plugins/treesitter.lua new file mode 100644 index 0000000..4f4afc4 --- /dev/null +++ b/config/nvim/lua/aleidk/plugins/treesitter.lua @@ -0,0 +1,69 @@ +return { + -- Highlight, edit, and navigate code + "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + build = ":TSUpdate", + opts = { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { "c", "cpp", "go", "lua", "python", "rust", "tsx", "typescript", "vimdoc", "vim" }, + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, + highlight = { enable = true }, + indent = { enable = true, disable = { "python" } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner", + }, + swap_previous = { + ["A"] = "@parameter.inner", + }, + }, + }, + }, +}