From 8623090268b944376d8bdc8eb24358237ad4e185 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Tue, 7 Nov 2023 15:30:16 -0500 Subject: [PATCH] re-organized the dir and divided the init.lua into smaller plugins files --- init.lua | 413 +---------------------------- lua/config/mappings.lua | 71 +++++ lua/config/options.lua | 22 +- lua/config/themes.lua | 8 + lua/config/utils.lua | 0 lua/custom/plugins/comments.lua | 5 + lua/custom/plugins/gitsigns.lua | 32 +++ lua/custom/plugins/indent.lua | 19 ++ lua/custom/plugins/lsp-config.lua | 22 ++ lua/custom/plugins/lualine.lua | 13 + lua/custom/plugins/monokai.lua | 7 + lua/custom/plugins/nvim-cmp.lua | 63 +++++ lua/custom/plugins/telescope.lua | 35 +++ lua/custom/plugins/tree-sitter.lua | 79 ++++++ lua/custom/plugins/which-key.lua | 4 + 15 files changed, 373 insertions(+), 420 deletions(-) create mode 100644 lua/config/mappings.lua create mode 100644 lua/config/themes.lua create mode 100644 lua/config/utils.lua create mode 100644 lua/custom/plugins/comments.lua create mode 100644 lua/custom/plugins/gitsigns.lua create mode 100644 lua/custom/plugins/indent.lua create mode 100644 lua/custom/plugins/lsp-config.lua create mode 100644 lua/custom/plugins/lualine.lua create mode 100644 lua/custom/plugins/monokai.lua create mode 100644 lua/custom/plugins/nvim-cmp.lua create mode 100644 lua/custom/plugins/telescope.lua create mode 100644 lua/custom/plugins/tree-sitter.lua create mode 100644 lua/custom/plugins/which-key.lua diff --git a/init.lua b/init.lua index 93ea9b0f..5fdc1ee4 100644 --- a/init.lua +++ b/init.lua @@ -1,12 +1,8 @@ --- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' ---import options -require('config.options') - -- Install package manager -- https://github.com/folke/lazy.nvim -- `:help lazy.nvim.txt` for more info @@ -26,262 +22,22 @@ vim.opt.rtp:prepend(lazypath) local opts = { git = { log = { '--since=3 days ago' } }, ui = { custom_keys = { false } }, - performance = { - rtp = { - disabled_plugins = { - 'gzip', - -- 'netrwPlugin', - 'tarPlugin', - 'tohtml', - 'tutor', - 'zipPlugin', - 'rplugin', - 'editorconfig', - 'matchparen', - 'matchit', - }, - }, - }, checker = { enabled = false }, + colorscheme = "monokai", } --- NOTE: Here is where you install your plugins. --- You can configure plugins using the `config` key. --- --- You can also configure plugins after the setup call, --- as they will be available in your neovim runtime. require('lazy').setup({ - -- NOTE: First, some plugins that don't require any configuration - -- Git related plugins 'tpope/vim-fugitive', 'tpope/vim-rhubarb', -- 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 & Plugin - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { - 'j-hui/fidget.nvim', - tag = 'legacy', - opts = {} - }, - - -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', - }, - }, - - { - -- Autocompletion - 'hrsh7th/nvim-cmp', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', - - -- Adds LSP completion capabilities - 'hrsh7th/cmp-nvim-lsp', - - -- Adds a number of user-friendly snippets - 'rafamadriz/friendly-snippets', - }, - }, - - -- Useful plugin to show you pending keybinds. - { - 'folke/which-key.nvim', - opts = {} - }, - { - -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) - - -- don't override the built-in and fugitive keymaps - local gs = package.loaded.gitsigns - vim.keymap.set({ 'n', 'v' }, ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) - vim.keymap.set({ 'n', 'v' }, '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" }) - end, - }, - }, - - { - 'tanvirtin/monokai.nvim', - priority = 1000, - config = function() - vim.cmd.colorscheme('monokai') - end, - }, - - -- { - -- Theme inspired by Atom - -- 'navarasu/onedark.nvim', - -- priority = 1000, - -- config = function() - -- vim.cmd.colorscheme 'onedark' - -- 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` - main = "ibl", - opts = { - indent = { - --[[ highlight = highlight ]] - char = "┆", - smart_indent_cap = true, - }, - whitespace = { - --[[ highlight = highlight, ]] - remove_blankline_trail = false, - }, - scope = { enabled = true }, - }, - }, - - -- "gc" to comment visual regions/lines - { - 'numToStr/Comment.nvim', - opts = {}, - lazy = false - }, - - -- 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. - -- 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, - }, - 'nvim-tree/nvim-web-devicons', - }, - }, - - { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - 'windwp/nvim-ts-autotag', - }, - build = ':TSUpdate', - -- setup autotag with default options - opts = { - enable = true, - }, - }, - - -- 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. - -- require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping - -- up-to-date with whatever is in the kickstart repo. - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- - -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins { import = 'custom.plugins' }, }, opts) --- [[ Basic Keymaps ]] - --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- Move lines -vim.keymap.set('v', 'J', ":m '>+1gv=gv", { silent = true }) -vim.keymap.set('v', 'K', ":m '<-2gv=gv", { silent = true }) - -vim.keymap.set('n', 'J', "mzj`z") -vim.keymap.set('n', '', "zz", { desc = "Half Page Jumping Up" }) -vim.keymap.set('n', '', "zz", { desc = "Half Page Jumping Down" }) - --- Keep search line in the middle -vim.keymap.set('n', 'n', 'nzzzv', { silent = true }) -vim.keymap.set('n', 'N', 'Nzzzv', { silent = true }) - --- Quick fix navigation -vim.keymap.set("n", "", "cnextzz") -vim.keymap.set("n", "", "cprevzz") -vim.keymap.set("n", "k", "lnextzz", { desc = "Quick Fix Nav Up" }) -vim.keymap.set("n", "j", "lprevzz", { desc = "Quick Fix Nav Down" }) - --- Copy from plus register -vim.keymap.set({ 'n', 'v' }, 'y', "\"+y", { desc = "Copy to + register" }) -vim.keymap.set('n', 'Y', "\"+Y") - --- Replace current word -vim.keymap.set("n", "s", [[:%s/\<\>//gI]], - { desc = "[S]ubstitute Current Word" }) -vim.keymap.set("n", "x", "!chmod +x %", { desc = "Set Current File to Executable", silent = true }) +require('config.options') +require('config.mappings') -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` @@ -294,115 +50,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', 'sp', function() - require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") }) -end, { desc = '[S]search [P]roject' }) -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' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' }) - --- [[ 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', 'lua', 'python', 'go', '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 }, - 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 = { - ['i'] = '@parameter.inner', - }, - swap_previous = { - ['I'] = '@parameter.inner', - }, - }, - }, -} - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. @@ -456,7 +103,7 @@ local on_attach = function(_, bufnr) augroup END ]]) end - +-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- @@ -623,55 +270,3 @@ mason_tool_installer.setup({ "revive", }, }) - - --- [[ Configure nvim-cmp ]] --- See `:help cmp` -local cmp = require 'cmp' -local luasnip = require 'luasnip' -require('luasnip.loaders.from_vscode').lazy_load() -luasnip.config.setup {} - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, -} - --- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua new file mode 100644 index 00000000..b7626fdd --- /dev/null +++ b/lua/config/mappings.lua @@ -0,0 +1,71 @@ +-- [[ Basic Keymaps ]] + +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) +vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { + expr = true, silent = true +}) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { + expr = true, silent = true +}) + +-- Move lines +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { silent = true }) +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { silent = true }) + +vim.keymap.set('n', 'J', "mzj`z") +vim.keymap.set('n', '', "zz", { desc = "Half Page Jumping Up" }) +vim.keymap.set('n', '', "zz", { desc = "Half Page Jumping Down" }) + +-- Keep search line in the middle +vim.keymap.set('n', 'n', 'nzzzv', { silent = true }) +vim.keymap.set('n', 'N', 'Nzzzv', { silent = true }) + +-- Quick fix navigation +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz", { desc = "Quick Fix Nav Up" }) +vim.keymap.set("n", "j", "lprevzz", { desc = "Quick Fix Nav Down" }) + +-- Copy from plus register +vim.keymap.set({ 'n', 'v' }, 'y', "\"+y", { desc = "Copy to + register" }) +vim.keymap.set('n', 'Y', "\"+Y") + +-- Replace current word +vim.keymap.set("n", "s", [[:%s/\<\>//gI]], + { desc = "[S]ubstitute Current Word" }) +vim.keymap.set("n", "x", "!chmod +x %", { desc = "Set Current File to Executable", silent = true }) + +-- [ telescope keymaps] +-- 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', 'sp', function() + require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") }) +end, { desc = '[S]search [P]roject' }) +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' }) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' }) + +-- [ tree-sitter keymaps ] +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) diff --git a/lua/config/options.lua b/lua/config/options.lua index 974d8a1b..ac16718e 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -1,7 +1,7 @@ local opt = vim.opt local g = vim.g local options = { - -- change cursor in insert mode + -- change cursor in insert mode guicursor = "", -- Make line numbers default @@ -75,11 +75,11 @@ local disabled_built_ins = { "gzip", "logipat", "matchit", - -- "netrw", + -- "netrw", "netrwFileHandlers", "loaded_remote_plugins", "loaded_tutor_mode_plugin", - -- "netrwPlugin", + "netrwPlugin", "netrwSettings", "rrhelper", "spellfile_plugin", @@ -127,11 +127,11 @@ opt.formatoptions = opt.formatoptions + "j" -- Auto-remove comments if possible. - "2" -- I'm not in gradeschool anymore --- opt.guicursor = { --- "n-v:block", --- "i-c-ci-ve:ver25", --- "r-cr:hor20", --- "o:hor50", --- "i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor", --- "sm:block-blinkwait175-blinkoff150-blinkon175", --- } +opt.guicursor = { + "n-v:block", + "i-c-ci-ve:ver25", + "r-cr:hor20", + "o:hor50", + "i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor", + "sm:block-blinkwait175-blinkoff150-blinkon175", +} diff --git a/lua/config/themes.lua b/lua/config/themes.lua new file mode 100644 index 00000000..36fd72cb --- /dev/null +++ b/lua/config/themes.lua @@ -0,0 +1,8 @@ +-- return { +-- Theme inspired by Atom +-- 'navarasu/onedark.nvim', +-- priority = 1000, +-- config = function() +-- vim.cmd.colorscheme 'onedark' +-- end, +-- }, diff --git a/lua/config/utils.lua b/lua/config/utils.lua new file mode 100644 index 00000000..e69de29b diff --git a/lua/custom/plugins/comments.lua b/lua/custom/plugins/comments.lua new file mode 100644 index 00000000..44766d55 --- /dev/null +++ b/lua/custom/plugins/comments.lua @@ -0,0 +1,5 @@ +return { + 'numToStr/Comment.nvim', + opts = {}, + lazy = false +} diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua new file mode 100644 index 00000000..0a64658b --- /dev/null +++ b/lua/custom/plugins/gitsigns.lua @@ -0,0 +1,32 @@ +return { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { + buffer = bufnr, desc = 'Preview git hunk' + }) + + -- don't override the built-in and fugitive keymaps + local gs = package.loaded.gitsigns + vim.keymap.set({ 'n', 'v' }, ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) + vim.keymap.set({ 'n', 'v' }, '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" }) + end, + }, +} diff --git a/lua/custom/plugins/indent.lua b/lua/custom/plugins/indent.lua new file mode 100644 index 00000000..2a83c657 --- /dev/null +++ b/lua/custom/plugins/indent.lua @@ -0,0 +1,19 @@ +return { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + main = "ibl", + opts = { + indent = { + --[[ highlight = highlight ]] + char = "┆", + smart_indent_cap = true, + }, + whitespace = { + --[[ highlight = highlight, ]] + remove_blankline_trail = false, + }, + scope = { enabled = true }, + }, +} diff --git a/lua/custom/plugins/lsp-config.lua b/lua/custom/plugins/lsp-config.lua new file mode 100644 index 00000000..af4c960a --- /dev/null +++ b/lua/custom/plugins/lsp-config.lua @@ -0,0 +1,22 @@ +return { + -- LSP Configuration & Plugin + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { + 'j-hui/fidget.nvim', + tag = 'legacy', + opts = {} + }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, +} +-- These are some example plugins that I've included in the kickstart repository. diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..82bce4ed --- /dev/null +++ b/lua/custom/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/lua/custom/plugins/monokai.lua b/lua/custom/plugins/monokai.lua new file mode 100644 index 00000000..3e172efa --- /dev/null +++ b/lua/custom/plugins/monokai.lua @@ -0,0 +1,7 @@ +return { + 'tanvirtin/monokai.nvim', + priority = 1000, + config = function() + vim.cmd.colorscheme('monokai') + end, +} diff --git a/lua/custom/plugins/nvim-cmp.lua b/lua/custom/plugins/nvim-cmp.lua new file mode 100644 index 00000000..82b81850 --- /dev/null +++ b/lua/custom/plugins/nvim-cmp.lua @@ -0,0 +1,63 @@ +return { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + require('luasnip.loaders.from_vscode').lazy_load() + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, + } + end, +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 00000000..86c3bae8 --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,35 @@ +return { + -- 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. + -- 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, + }, + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + } + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + end, +} -- See `:help telescope` and `:help telescope.setup()` diff --git a/lua/custom/plugins/tree-sitter.lua b/lua/custom/plugins/tree-sitter.lua new file mode 100644 index 00000000..8c4d51df --- /dev/null +++ b/lua/custom/plugins/tree-sitter.lua @@ -0,0 +1,79 @@ +return { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + 'windwp/nvim-ts-autotag', + }, + build = ':TSUpdate', + -- setup autotag with default options + opts = { + enable = true, + }, + config = function() + -- 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', 'lua', 'python', 'go', '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 }, + 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 = { + ['i'] = '@parameter.inner', + }, + swap_previous = { + ['I'] = '@parameter.inner', + }, + }, + }, + } + end +} diff --git a/lua/custom/plugins/which-key.lua b/lua/custom/plugins/which-key.lua new file mode 100644 index 00000000..35e24efb --- /dev/null +++ b/lua/custom/plugins/which-key.lua @@ -0,0 +1,4 @@ +return { + 'folke/which-key.nvim', + opts = {} +}