├── LICENSE ├── README.md ├── init.lua └── lua └── plugins ├── code.lua ├── colorscheme.lua ├── configs ├── cmp.lua ├── lspconfig.lua ├── mason.lua ├── null-ls.lua ├── others.lua └── treesitter.lua ├── custom.lua ├── edit.lua ├── init.lua └── ui.lua /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DreamNvim 2 | 3 | This repository holds the base Neovim configuration of Dreams of Code, for use in videos as a starting point in tutorials 4 | 5 | ## Installation 6 | 7 | ### Backup 8 | 9 | if you have an existing neovim configuration, first back this up and clean out your neovim cache. 10 | 11 | ``` 12 | mv ~/.config/nvim ~/.config/nvim-backup 13 | rm -rf ~/.local/share/nvim 14 | ``` 15 | 16 | ### Install 17 | 18 | To install this configuration on Linux & macOS, run the following command: 19 | 20 | ``` 21 | git clone git@github.com:dreamsofcode-io/DreamNvim.git ~/.config/nvim 22 | ``` 23 | 24 | Then, open up neovim in order to download and install the base configuration packages. 25 | 26 | ## Modifying 27 | 28 | ### Custom Plugins 29 | 30 | All custom plugins shown in videos should be added to the `lua/custom/plugins.lua` file. 31 | 32 | ## Backwards Compatibility 33 | 34 | Each video will have a branch associated with it that will lock the configuration to the time that video was released. 35 | 36 | There is no guarantee that these will work forever, especially as neovim develops. 37 | 38 | ## Contribution 39 | 40 | Please feel free to contribute to this configuration. 41 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | -- Set leader key 2 | vim.g.mapleader = " " 3 | vim.g.maplocalleader = " " 4 | 5 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" 6 | local firstload = not vim.loop.fs_stat(lazypath) 7 | if firstload then 8 | vim.fn.system({ 9 | "git", 10 | "clone", 11 | "--filter=blob:none", 12 | "https://github.com/folke/lazy.nvim.git", 13 | "--branch=stable", -- latest stable release 14 | lazypath, 15 | }) 16 | end 17 | 18 | vim.opt.rtp:prepend(lazypath) 19 | 20 | -- Set highlight on search 21 | vim.o.hlsearch = false 22 | 23 | -- Make line numbers default 24 | vim.wo.number = true 25 | 26 | vim.o.tabstop = 2 -- A TAB character looks like 2 spaces 27 | vim.o.expandtab = true -- Pressing the TAB key will insert spaces instead of a TAB character 28 | vim.o.softtabstop = 2 -- Number of spaces inserted instead of a TAB character 29 | vim.o.shiftwidth = 2 -- Number of spaces inserted when indenting 30 | 31 | -- Enable mouse mode 32 | vim.o.mouse = "a" 33 | 34 | -- Sync clipboard between OS and Neovim. 35 | -- Remove this option if you want your OS clipboard to remain independent. 36 | -- See `:help 'clipboard'` 37 | vim.o.clipboard = "unnamedplus" 38 | 39 | -- Enable break indent 40 | vim.o.breakindent = true 41 | 42 | -- Save undo history 43 | vim.o.undofile = true 44 | 45 | -- Case-insensitive searching UNLESS \C or capital in search 46 | vim.o.ignorecase = true 47 | vim.o.smartcase = true 48 | 49 | -- Keep signcolumn as auto. Set this to 'yes' if you want it enabled 50 | vim.wo.signcolumn = "auto" 51 | 52 | -- Decrease update time 53 | vim.o.updatetime = 250 54 | vim.o.timeoutlen = 300 55 | 56 | -- Set completeopt to have a better completion experience 57 | vim.o.completeopt = "menuone,noselect" 58 | 59 | -- Set terminal gui colors to true 60 | vim.o.termguicolors = true 61 | 62 | -- add binaries installed by mason.nvim to path 63 | local is_windows = vim.loop.os_uname().sysname == "Windows_NT" 64 | vim.env.PATH = vim.fn.stdpath("data") .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH 65 | 66 | require("lazy").setup("plugins") 67 | 68 | if firstload then 69 | vim.schedule(function() 70 | vim.cmd("MasonInstallAll") 71 | 72 | local packages = {} 73 | for k, v in pairs(vim.g.mason_binaries_list) do 74 | packages[k] = v 75 | end 76 | 77 | local installed = {} 78 | 79 | require("mason-registry"):on("package:install:success", function(pkg) 80 | table.insert(installed, pkg.name) 81 | 82 | if #installed == #packages then 83 | vim.schedule(function() 84 | vim.api.nvim_buf_delete(0, { force = true }) 85 | vim.api.nvim_buf_delete(0, { force = true }) 86 | vim.cmd("echo '' | redraw") 87 | end) 88 | end 89 | end) 90 | end) 91 | end 92 | -------------------------------------------------------------------------------- /lua/plugins/code.lua: -------------------------------------------------------------------------------- 1 | -- Plugins that are related to coding. Such as lsp 2 | -- or language specific. 3 | return { 4 | { 5 | "neovim/nvim-lspconfig", 6 | event = "VeryLazy", 7 | config = function() 8 | require("plugins.configs.lspconfig") 9 | end, 10 | }, 11 | { 12 | "williamboman/mason.nvim", 13 | cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" }, 14 | opts = function() 15 | return require("plugins.configs.mason") 16 | end, 17 | config = function(_, opts) 18 | require("mason").setup(opts) 19 | 20 | vim.api.nvim_create_user_command("MasonInstallAll", function() 21 | if opts.ensure_installed then 22 | vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) 23 | end 24 | end, {}) 25 | 26 | vim.g.mason_binaries_list = opts.ensure_installed 27 | end, 28 | }, 29 | { 30 | "numToStr/Comment.nvim", 31 | keys = { 32 | { "gcc", mode = "n", desc = "Comment toggle current line" }, 33 | { "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, 34 | { "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, 35 | { "gbc", mode = "n", desc = "Comment toggle current block" }, 36 | { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, 37 | { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, 38 | }, 39 | init = function() 40 | local wk = require("which-key") 41 | wk.register({ 42 | ["/"] = { 43 | function() 44 | require("Comment.api").toggle.linewise.current() 45 | end, 46 | "Toggle comment", 47 | }, 48 | }, { 49 | prefix = "", 50 | mode = "n", 51 | }) 52 | wk.register({ 53 | ["/"] = { 54 | "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", 55 | "Toggle comment", 56 | }, 57 | }, { 58 | prefix = "", 59 | mode = "v", 60 | }) 61 | end, 62 | config = function(_, opts) 63 | require("Comment").setup(opts) 64 | end, 65 | }, 66 | { 67 | "nvim-treesitter/nvim-treesitter", 68 | event = { "BufReadPost", "BufNewFile" }, 69 | cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, 70 | build = ":TSUpdate", 71 | dependencies = { 72 | "apple/pkl-neovim", 73 | }, 74 | opts = function() 75 | return require("plugins.configs.treesitter") 76 | end, 77 | config = function(_, opts) 78 | require("nvim-treesitter.configs").setup(opts) 79 | end, 80 | }, 81 | { 82 | "hrsh7th/nvim-cmp", 83 | event = "InsertEnter", 84 | dependencies = { 85 | { 86 | -- snippet plugin 87 | "L3MON4D3/LuaSnip", 88 | dependencies = "rafamadriz/friendly-snippets", 89 | opts = { history = true, updateevents = "TextChanged,TextChangedI" }, 90 | config = function(_, opts) 91 | require("plugins.configs.others").luasnip(opts) 92 | end, 93 | }, 94 | 95 | -- autopairing of (){}[] etc 96 | { 97 | "windwp/nvim-autopairs", 98 | opts = { 99 | fast_wrap = {}, 100 | disable_filetype = { "TelescopePrompt", "vim" }, 101 | }, 102 | config = function(_, opts) 103 | require("nvim-autopairs").setup(opts) 104 | 105 | -- setup cmp for autopairs 106 | local cmp_autopairs = require("nvim-autopairs.completion.cmp") 107 | require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) 108 | end, 109 | }, 110 | "saadparwaiz1/cmp_luasnip", 111 | "hrsh7th/cmp-nvim-lua", 112 | "hrsh7th/cmp-nvim-lsp", 113 | "hrsh7th/cmp-buffer", 114 | "hrsh7th/cmp-path", 115 | }, 116 | opts = function() 117 | return require("plugins.configs.cmp") 118 | end, 119 | config = function(_, opts) 120 | require("cmp").setup(opts) 121 | end, 122 | }, 123 | { 124 | "nvimtools/none-ls.nvim", 125 | opts = function() 126 | return require("plugins.configs.null-ls") 127 | end, 128 | }, 129 | { 130 | "saecki/crates.nvim", 131 | ft = { "rust", "toml" }, 132 | config = function(_, opts) 133 | local crates = require("crates") 134 | crates.setup(opts) 135 | crates.show() 136 | end, 137 | }, 138 | } 139 | -------------------------------------------------------------------------------- /lua/plugins/colorscheme.lua: -------------------------------------------------------------------------------- 1 | -- Use this file for any colorschemes that you wish to install. 2 | -- Comes with catppuccin by default. 3 | return { 4 | { 5 | "catppuccin/nvim", 6 | name = "catppuccin", 7 | priority = 1000, 8 | config = function() 9 | vim.cmd([[colorscheme catppuccin]]) 10 | end, 11 | }, 12 | } 13 | -------------------------------------------------------------------------------- /lua/plugins/configs/cmp.lua: -------------------------------------------------------------------------------- 1 | local cmp = require "cmp" 2 | 3 | local cmp_ui = { 4 | icons = true, 5 | lspkind_text = true, 6 | style = "default", -- default/flat_light/flat_dark/atom/atom_colored 7 | border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables 8 | selected_item_bg = "simple", -- colored / simple 9 | } 10 | local cmp_style = cmp_ui.style 11 | 12 | local field_arrangement = { 13 | atom = { "kind", "abbr", "menu" }, 14 | atom_colored = { "kind", "abbr", "menu" }, 15 | } 16 | 17 | local formatting_style = { 18 | -- default fields order i.e completion word + item.kind + item.kind icons 19 | fields = field_arrangement[cmp_style] or { "abbr", "kind", "menu" }, 20 | 21 | format = function(_, item) 22 | --jlocal icons = require "nvchad.icons.lspkind" 23 | local icon = "" --(cmp_ui.icons and icons[item.kind]) or "" 24 | 25 | if cmp_style == "atom" or cmp_style == "atom_colored" then 26 | icon = " " .. icon .. " " 27 | item.menu = cmp_ui.lspkind_text and " (" .. item.kind .. ")" or "" 28 | item.kind = icon 29 | else 30 | icon = cmp_ui.lspkind_text and (" " .. icon .. " ") or icon 31 | item.kind = string.format("%s %s", icon, cmp_ui.lspkind_text and item.kind or "") 32 | end 33 | 34 | return item 35 | end, 36 | } 37 | 38 | local function border(hl_name) 39 | return { 40 | { "╭", hl_name }, 41 | { "─", hl_name }, 42 | { "╮", hl_name }, 43 | { "│", hl_name }, 44 | { "╯", hl_name }, 45 | { "─", hl_name }, 46 | { "╰", hl_name }, 47 | { "│", hl_name }, 48 | } 49 | end 50 | 51 | local options = { 52 | completion = { 53 | completeopt = "menu,menuone", 54 | }, 55 | 56 | window = { 57 | completion = { 58 | side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0, 59 | winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None", 60 | scrollbar = false, 61 | }, 62 | documentation = { 63 | border = border "CmpDocBorder", 64 | winhighlight = "Normal:CmpDoc", 65 | }, 66 | }, 67 | snippet = { 68 | expand = function(args) 69 | require("luasnip").lsp_expand(args.body) 70 | end, 71 | }, 72 | 73 | --formatting = formatting_style, 74 | 75 | mapping = { 76 | [""] = cmp.mapping.select_prev_item(), 77 | [""] = cmp.mapping.select_next_item(), 78 | [""] = cmp.mapping.scroll_docs(-4), 79 | [""] = cmp.mapping.scroll_docs(4), 80 | [""] = cmp.mapping.complete(), 81 | [""] = cmp.mapping.close(), 82 | [""] = cmp.mapping.confirm { 83 | behavior = cmp.ConfirmBehavior.Insert, 84 | select = true, 85 | }, 86 | [""] = cmp.mapping(function(fallback) 87 | if cmp.visible() then 88 | cmp.select_next_item() 89 | elseif require("luasnip").expand_or_jumpable() then 90 | vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") 91 | else 92 | fallback() 93 | end 94 | end, { 95 | "i", 96 | "s", 97 | }), 98 | [""] = cmp.mapping(function(fallback) 99 | if cmp.visible() then 100 | cmp.select_prev_item() 101 | elseif require("luasnip").jumpable(-1) then 102 | vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") 103 | else 104 | fallback() 105 | end 106 | end, { 107 | "i", 108 | "s", 109 | }), 110 | }, 111 | sources = { 112 | { name = "nvim_lsp" }, 113 | { name = "luasnip" }, 114 | { name = "buffer" }, 115 | { name = "nvim_lua" }, 116 | { name = "path" }, 117 | { name = "crates" }, 118 | }, 119 | } 120 | 121 | if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then 122 | options.window.completion.border = border "CmpBorder" 123 | end 124 | 125 | return { 126 | sources = { 127 | { name = "nvim_lsp" }, 128 | { name = "buffer" }, 129 | { name = "path" }, 130 | { name = "luasnip" }, 131 | { name = "nvim_lua" }, 132 | }, 133 | snippet = { 134 | expand = function(args) 135 | require("luasnip").lsp_expand(args.body) 136 | end, 137 | }, 138 | mapping = { 139 | [""] = cmp.mapping.select_prev_item(), 140 | [""] = cmp.mapping.select_next_item(), 141 | [""] = cmp.mapping.scroll_docs(-4), 142 | [""] = cmp.mapping.scroll_docs(4), 143 | [""] = cmp.mapping.complete(), 144 | [""] = cmp.mapping.close(), 145 | [""] = cmp.mapping.confirm { 146 | behavior = cmp.ConfirmBehavior.Insert, 147 | select = true, 148 | }, 149 | [""] = cmp.mapping(function(fallback) 150 | if cmp.visible() then 151 | cmp.select_next_item() 152 | elseif require("luasnip").expand_or_jumpable() then 153 | vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") 154 | else 155 | fallback() 156 | end 157 | end, { 158 | "i", 159 | "s", 160 | }), 161 | [""] = cmp.mapping(function(fallback) 162 | if cmp.visible() then 163 | cmp.select_prev_item() 164 | elseif require("luasnip").jumpable(-1) then 165 | vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") 166 | else 167 | fallback() 168 | end 169 | end, { 170 | "i", 171 | "s", 172 | }), 173 | }, 174 | } 175 | -------------------------------------------------------------------------------- /lua/plugins/configs/lspconfig.lua: -------------------------------------------------------------------------------- 1 | local lspconfig = require("lspconfig") 2 | 3 | lspconfig.lua_ls.setup({ 4 | settings = { 5 | Lua = { 6 | diagnostics = { 7 | globals = { "vim" }, 8 | disable = { "different-requires" }, 9 | }, 10 | }, 11 | }, 12 | }) 13 | 14 | lspconfig.rust_analyzer.setup({ 15 | cargo = { 16 | features = { "all" }, 17 | }, 18 | }) 19 | 20 | lspconfig.gopls.setup({ 21 | filetypes = { "go", "gomod", "gowork", "gotmpl" }, 22 | }) 23 | -------------------------------------------------------------------------------- /lua/plugins/configs/mason.lua: -------------------------------------------------------------------------------- 1 | return { 2 | ensure_installed = { 3 | "gofumpt", 4 | "goimports", 5 | "golines", 6 | "gopls", 7 | "lua-language-server", 8 | "rust-analyzer", 9 | "rustfmt", 10 | "stylua", 11 | }, 12 | } 13 | -------------------------------------------------------------------------------- /lua/plugins/configs/null-ls.lua: -------------------------------------------------------------------------------- 1 | local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) 2 | local null_ls = require("null-ls") 3 | 4 | return { 5 | sources = { 6 | null_ls.builtins.formatting.gofumpt, 7 | null_ls.builtins.formatting.golines, 8 | null_ls.builtins.formatting.goimports, 9 | null_ls.builtins.formatting.stylua, 10 | }, 11 | on_attach = function(client, bufnr) 12 | if client.supports_method("textDocument/formatting") then 13 | vim.api.nvim_clear_autocmds({ 14 | group = augroup, 15 | buffer = bufnr, 16 | }) 17 | vim.api.nvim_create_autocmd("BufWritePre", { 18 | group = augroup, 19 | buffer = bufnr, 20 | callback = function() 21 | vim.lsp.buf.format({ bufnr = bufnr }) 22 | end, 23 | }) 24 | end 25 | end, 26 | } 27 | -------------------------------------------------------------------------------- /lua/plugins/configs/others.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | M.blankline = { 4 | indentLine_enabled = 1, 5 | filetype_exclude = { 6 | "help", 7 | "terminal", 8 | "lazy", 9 | "lspinfo", 10 | "TelescopePrompt", 11 | "TelescopeResults", 12 | "mason", 13 | "nvdash", 14 | "nvcheatsheet", 15 | "", 16 | }, 17 | buftype_exclude = { "terminal" }, 18 | show_trailing_blankline_indent = false, 19 | show_first_indent_level = false, 20 | show_current_context = true, 21 | show_current_context_start = false, 22 | } 23 | 24 | M.luasnip = function(opts) 25 | require("luasnip").config.set_config(opts) 26 | 27 | -- vscode format 28 | require("luasnip.loaders.from_vscode").lazy_load() 29 | require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } 30 | 31 | -- snipmate format 32 | require("luasnip.loaders.from_snipmate").load() 33 | require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } 34 | 35 | -- lua format 36 | require("luasnip.loaders.from_lua").load() 37 | require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } 38 | 39 | vim.api.nvim_create_autocmd("InsertLeave", { 40 | callback = function() 41 | if 42 | require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] 43 | and not require("luasnip").session.jump_active 44 | then 45 | require("luasnip").unlink_current() 46 | end 47 | end, 48 | }) 49 | end 50 | 51 | M.gitsigns = { 52 | signs = { 53 | add = { text = "│" }, 54 | change = { text = "│" }, 55 | delete = { text = "󰍵" }, 56 | topdelete = { text = "‾" }, 57 | changedelete = { text = "~" }, 58 | untracked = { text = "│" }, 59 | }, 60 | } 61 | 62 | return M 63 | -------------------------------------------------------------------------------- /lua/plugins/configs/treesitter.lua: -------------------------------------------------------------------------------- 1 | return { 2 | ensure_installed = { 3 | "go", 4 | "lua", 5 | "rust", 6 | }, 7 | highlight = { 8 | enable = true, 9 | use_languagetree = true, 10 | }, 11 | indent = { enable = true }, 12 | } 13 | -------------------------------------------------------------------------------- /lua/plugins/custom.lua: -------------------------------------------------------------------------------- 1 | local plugins = {} 2 | return plugins 3 | -------------------------------------------------------------------------------- /lua/plugins/edit.lua: -------------------------------------------------------------------------------- 1 | -- File is used for any editing based plugins 2 | -- Contains vim-sleuth, which is used for automatic identations 3 | -- trim.nvim which is used for automatically trimming whitespace 4 | return { 5 | { 6 | "tpope/vim-sleuth", 7 | event = "VeryLazy", 8 | }, 9 | { 10 | "cappyzawa/trim.nvim", 11 | event = "VeryLazy", 12 | opts = { 13 | ft_blocklist = {"markdown"}, 14 | }, 15 | }, 16 | } 17 | -------------------------------------------------------------------------------- /lua/plugins/init.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { "folke/lazy.nvim", version = "*" }, 3 | "nvim-lua/plenary.nvim", 4 | "christoomey/vim-tmux-navigator", 5 | } 6 | -------------------------------------------------------------------------------- /lua/plugins/ui.lua: -------------------------------------------------------------------------------- 1 | -- Use this file for any UI based plugins 2 | -- Contains telescope, icons, lualine & whichkey 3 | return { 4 | { 5 | "nvim-telescope/telescope.nvim", 6 | dependencies = { "nvim-treesitter/nvim-treesitter" }, 7 | cmd = "Telescope", 8 | init = function() 9 | local builtin = require('telescope.builtin') 10 | local wk = require('which-key') 11 | wk.register({ 12 | ['ff'] = { builtin.find_files, "Find File" }, 13 | ['fb'] = { builtin.buffers, "Find Buffer" }, 14 | ['fg'] = { builtin.live_grep, "Find with Grep" }, 15 | ['fh'] = { builtin.help_tags, "Find Help" }, 16 | ['fn'] = { ":Telescope file_browser path=%:p:h select_buffer=true", "File Browser" }, 17 | }, { prefix = "" }) 18 | end, 19 | opts = function() 20 | return { 21 | defaults = { 22 | vimgrep_arguments = { 23 | "rg", 24 | "-L", 25 | "--color=never", 26 | "--no-heading", 27 | "--with-filename", 28 | "--line-number", 29 | "--column", 30 | "--smart-case", 31 | }, 32 | previewer = true, 33 | file_previewer = require 'telescope.previewers'.vim_buffer_cat.new, 34 | grep_previewer = require 'telescope.previewers'.vim_buffer_vimgrep.new, 35 | qflist_previewer = require 'telescope.previewers'.vim_buffer_qflist.new, 36 | }, 37 | extensions = { 38 | file_browser = { 39 | theme = "ivy", 40 | hijack_netrw = true, 41 | }, 42 | }, 43 | extensions_list = { 44 | "file_browser", 45 | }, 46 | } 47 | end, 48 | config = function(_, opts) 49 | local telescope = require "telescope" 50 | telescope.setup(opts) 51 | 52 | -- load extensions 53 | for _, ext in ipairs(opts.extensions_list) do 54 | telescope.load_extension(ext) 55 | end 56 | end, 57 | }, 58 | { 59 | "nvim-telescope/telescope-file-browser.nvim", 60 | dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } 61 | }, 62 | { 63 | 'nvim-tree/nvim-web-devicons', 64 | }, 65 | { 66 | 'nvim-lualine/lualine.nvim', 67 | dependencies = { 'nvim-tree/nvim-web-devicons' }, 68 | event = "VeryLazy", 69 | opts = { 70 | options = { 71 | icons_enabled = true, 72 | theme = 'auto', 73 | component_separators = '|', 74 | section_separators = { left = '', right = '' }, 75 | }, 76 | }, 77 | }, 78 | -- Only load whichkey after all the gui 79 | { 80 | "folke/which-key.nvim", 81 | keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, 82 | cmd = "WhichKey", 83 | config = function(_, opts) 84 | local wk = require('which-key') 85 | wk.setup(opts) 86 | wk.register({ 87 | ['f'] = { name = "Find" }, 88 | }, { prefix = "" }) 89 | end, 90 | }, 91 | } 92 | --------------------------------------------------------------------------------