From 3fe07c88efd607ccb64127a332d36a910f647a04 Mon Sep 17 00:00:00 2001 From: "Jacob E. Tuz Poot" Date: Mon, 26 Sep 2022 18:29:39 -0500 Subject: [PATCH 1/9] feat: add buffer mapping for gitsigns --- lua/core/mappings.lua | 133 +++++++++++++++++++++++++++++++++ lua/plugins/configs/others.lua | 4 + 2 files changed, 137 insertions(+) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 3d9df51..2c83041 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -404,4 +404,137 @@ M.blankline = { }, } +M.gitsigns = { + plugin = true, + + n = { + -- Navigation + ["]c"] = { + function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + require("gitsigns").next_hunk() + end) + return "" + end, + "Jump to next hunk", + opts = { expr = true }, + }, + ["[c"] = { + function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + require("gitsigns").prev_hunk() + end) + return "" + end, + "Jump to prev hunk", + opts = { expr = true }, + }, + + -- Actions + ["hs"] = { + function() + require("gitsigns").stage_hunk() + end, + "Stage hunk", + }, + ["hr"] = { + function() + require("gitsigns").reset_hunk() + end, + "Reset hunk", + }, + ["hS"] = { + function() + require("gitsigns").stage_buffer() + end, + "Stage buffer", + }, + ["hu"] = { + function() + require("gitsigns").undo_stage_hunk() + end, + "Undo stage hunk", + }, + ["hR"] = { + function() + require("gitsigns").reset_buffer() + end, + "Reset buffer", + }, + ["hp"] = { + function() + require("gitsigns").preview_hunk() + end, + "Preview hunk", + }, + ["hb"] = { + function() + package.loaded.gitsigns.blame_line { full = true } + end, + "Blame line", + }, + ["tb"] = { + function() + require("gitsigns").toggle_current_line_blame() + end, + "Toggle current line blame", + }, + ["td"] = { + function() + require("gitsigns").toggle_deleted() + end, + "Toggle deleted", + }, + ["hd"] = { + function() + require("gitsigns").diffthis() + end, + "Diff against the index", + }, + ["hD"] = { + function() + require("gitsigns").diffthis "~" + end, + "Diff against the last commit", + }, + }, + v = { + -- Actions + ["hs"] = { + function() + require("gitsigns").stage_hunk() + end, + "Stage hunk", + }, + ["hr"] = { + function () + require("gitsigns").reset_hunk() + end, + "Reset hunk", + }, + }, + x = { + ["ih"] = { + function () + require("gitsigns").select_hunk() + end, + "Reset hunk", + }, + }, + o = { + ["ih"] = { + function () + require("gitsigns").select_hunk() + end, + "Reset hunk", + }, + }, +} + return M diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index 462c44b..4b7508a 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -1,6 +1,7 @@ local M = {} local load_override = require("core.utils").load_override +local utils = require "core.utils" M.autopairs = function() local present1, autopairs = pcall(require, "nvim-autopairs") @@ -145,6 +146,9 @@ M.gitsigns = function() topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, }, + on_attach = function (bufnr) + utils.load_mappings("gitsigns", { buffer = bufnr }) + end } options = load_override(options, "lewis6991/gitsigns.nvim") From 9eebb9198c830faccc9cfa65f1cb8143c940eeda Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 30 Sep 2022 09:39:35 +0530 Subject: [PATCH 2/9] add arg to make telescope search through symlink dirs #1609 --- lua/plugins/configs/telescope.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua index 03e1467..b01abc0 100644 --- a/lua/plugins/configs/telescope.lua +++ b/lua/plugins/configs/telescope.lua @@ -12,6 +12,7 @@ local options = { defaults = { vimgrep_arguments = { "rg", + "-L", "--color=never", "--no-heading", "--with-filename", From adc3130e8362c7b14d22b53402fb7c0b72a60d00 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 30 Sep 2022 09:53:47 +0530 Subject: [PATCH 3/9] reduce loc --- lua/core/lazy_load.lua | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/lua/core/lazy_load.lua b/lua/core/lazy_load.lua index ae7480f..cbb82f9 100644 --- a/lua/core/lazy_load.lua +++ b/lua/core/lazy_load.lua @@ -58,23 +58,8 @@ M.packer_cmds = { "PackerLoad", } -M.treesitter_cmds = { - "TSInstall", - "TSBufEnable", - "TSBufDisable", - "TSEnable", - "TSDisable", - "TSModuleInfo", -} - -M.mason_cmds = { - "Mason", - "MasonInstall", - "MasonInstallAll", - "MasonUninstall", - "MasonUninstallAll", - "MasonLog", -} +M.treesitter_cmds = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" } +M.mason_cmds = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" } M.gitsigns = function() autocmd({ "BufRead" }, { From 21e9e3cb097e1084089e7954ecade8be6503d4d8 Mon Sep 17 00:00:00 2001 From: Dhruvin Shah Date: Thu, 29 Sep 2022 16:23:40 -0400 Subject: [PATCH 4/9] config(cmp): correcting completeopt setup From the neovim doc, In Vimscript: `set completeopt=menu,menuone,noselect` In Lua using `vim.o`: `vim.o.completeopt = 'menu,menuone,noselect'` In Lua using `vim.opt`: `vim.opt.wildignore = { 'menu', 'menuoune', 'noselect' }` --- lua/plugins/configs/cmp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index 2b69b6b..0779579 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -6,7 +6,7 @@ end require("base46").load_highlight "cmp" -vim.opt.completeopt = "menuone,noselect" +vim.o.completeopt = "menu,menuone,noselect" local function border(hl_name) return { From 1f34e72aff11342581ba8f9da8bb265b43101c43 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 4 Oct 2022 06:37:48 +0530 Subject: [PATCH 5/9] keep some gitsigns mappings only | rm 0.7v related stuff --- lua/core/mappings.lua | 89 ++++--------------------------- lua/core/options.lua | 7 --- lua/plugins/configs/lspconfig.lua | 11 +--- lua/plugins/init.lua | 6 +-- 4 files changed, 14 insertions(+), 99 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 2c83041..184a8c1 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -229,7 +229,7 @@ M.lspconfig = { ["fm"] = { function() - vim.lsp.buf.formatting {} + vim.lsp.buf.format { async = true } end, "lsp formatting", }, @@ -408,7 +408,7 @@ M.gitsigns = { plugin = true, n = { - -- Navigation + -- Navigation through hunks ["]c"] = { function() if vim.wo.diff then @@ -422,6 +422,7 @@ M.gitsigns = { "Jump to next hunk", opts = { expr = true }, }, + ["[c"] = { function() if vim.wo.diff then @@ -437,103 +438,33 @@ M.gitsigns = { }, -- Actions - ["hs"] = { - function() - require("gitsigns").stage_hunk() - end, - "Stage hunk", - }, - ["hr"] = { + ["rh"] = { function() require("gitsigns").reset_hunk() end, "Reset hunk", }, - ["hS"] = { - function() - require("gitsigns").stage_buffer() - end, - "Stage buffer", - }, - ["hu"] = { - function() - require("gitsigns").undo_stage_hunk() - end, - "Undo stage hunk", - }, - ["hR"] = { - function() - require("gitsigns").reset_buffer() - end, - "Reset buffer", - }, - ["hp"] = { + + ["ph"] = { function() require("gitsigns").preview_hunk() end, "Preview hunk", }, - ["hb"] = { + + ["gb"] = { function() - package.loaded.gitsigns.blame_line { full = true } + package.loaded.gitsigns.blame_line() end, "Blame line", }, - ["tb"] = { - function() - require("gitsigns").toggle_current_line_blame() - end, - "Toggle current line blame", - }, + ["td"] = { function() require("gitsigns").toggle_deleted() end, "Toggle deleted", }, - ["hd"] = { - function() - require("gitsigns").diffthis() - end, - "Diff against the index", - }, - ["hD"] = { - function() - require("gitsigns").diffthis "~" - end, - "Diff against the last commit", - }, - }, - v = { - -- Actions - ["hs"] = { - function() - require("gitsigns").stage_hunk() - end, - "Stage hunk", - }, - ["hr"] = { - function () - require("gitsigns").reset_hunk() - end, - "Reset hunk", - }, - }, - x = { - ["ih"] = { - function () - require("gitsigns").select_hunk() - end, - "Reset hunk", - }, - }, - o = { - ["ih"] = { - function () - require("gitsigns").select_hunk() - end, - "Reset hunk", - }, }, } diff --git a/lua/core/options.lua b/lua/core/options.lua index c2a8832..a097cd7 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -2,18 +2,11 @@ local opt = vim.opt local g = vim.g local config = require("core.utils").load_config() -g.vim_version = vim.version().minor g.nvchad_theme = config.ui.theme g.toggle_theme_icon = "  " g.transparency = config.ui.transparency g.theme_switcher_loaded = false --- use filetype.lua instead of filetype.vim. it's enabled by default in neovim 0.8 (nightly) -if g.vim_version < 8 then - g.did_load_filetypes = 0 - g.do_filetype_lua = 1 -end - opt.laststatus = 3 -- global statusline opt.showmode = false diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 0c16830..2f87926 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -13,15 +13,8 @@ local utils = require "core.utils" -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) - if vim.g.vim_version > 7 then - -- nightly - client.server_capabilities.documentFormattingProvider = false - client.server_capabilities.documentRangeFormattingProvider = false - else - -- stable - client.resolved_capabilities.document_formatting = false - client.resolved_capabilities.document_range_formatting = false - end + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false utils.load_mappings("lspconfig", { buffer = bufnr }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 1cc7f82..778efd5 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -217,9 +217,7 @@ if present then -- load packer init options local init_options = require("plugins.configs.others").packer_init() init_options = require("core.utils").load_override(init_options, "wbthomason/packer.nvim") - packer.init(init_options) - for _, v in pairs(plugins) do - packer.use(v) - end + packer.init(init_options) + packer.startup { plugins } end From 017508282499c499426489d281c473e2045d9030 Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 6 Oct 2022 05:41:05 +0530 Subject: [PATCH 6/9] avoid flooding mason.nvim binaries path --- lua/plugins/configs/mason.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/plugins/configs/mason.lua b/lua/plugins/configs/mason.lua index b330bda..c713847 100644 --- a/lua/plugins/configs/mason.lua +++ b/lua/plugins/configs/mason.lua @@ -16,6 +16,8 @@ vim.api.nvim_create_autocmd("Filetype", { local options = { ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + PATH = "skip", + ui = { icons = { package_pending = " ", From cdc970a9e446172298d5cf6c19542b08bddc9b1f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 8 Oct 2022 19:09:13 +0200 Subject: [PATCH 7/9] Add coc-settings.json to .gitignore One might decide to install coc.nvim which requires to maintain a custom configuration at the root of the `nvim` folder (created with the command `:CocConfig`). It is recommend to ignore the file to avoid update conflicts as NvChad does not ship coc.nvim. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index de45666..5b992b0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ plugin custom spell ftplugin +coc-settings.json From 08e675b356536d953b7f1ac233346368d1265c5c Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sun, 9 Oct 2022 16:35:27 +0200 Subject: [PATCH 8/9] Add .luarc.json to .gitignore Using `coc-lua` with `coc.nvim` will produce a `.luarc.json` when editing own custom configs that should be excluded from NvChad, since NvChad does not maintain its own `.luarc.json` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5b992b0..2de440a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ custom spell ftplugin coc-settings.json +.luarc.json From 28db7c752ea7337d866b88d56bc6327fd53a4dfd Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Mon, 24 Oct 2022 08:56:34 +0530 Subject: [PATCH 9/9] Update README.md --- .github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index 90783f6..12484e8 100644 --- a/.github/README.md +++ b/.github/README.md @@ -21,7 +21,7 @@ src="https://img.shields.io/github/license/NvChad/NvChad?style=flat-square&logo=GNU&label=License&color=df967f" alt="License" /> -[![Neovim Minimum Version](https://img.shields.io/badge/Neovim-0.7.0-blueviolet.svg?style=flat-square&logo=Neovim&color=90E59A&logoColor=white)](https://github.com/neovim/neovim) +[![Neovim Minimum Version](https://img.shields.io/badge/Neovim-0.8.0-blueviolet.svg?style=flat-square&logo=Neovim&color=90E59A&logoColor=white)](https://github.com/neovim/neovim) [![GitHub Issues](https://img.shields.io/github/issues/NvChad/NvChad.svg?style=flat-square&label=Issues&color=d77982)](https://github.com/NvChad/NvChad/issues) [![Discord](https://img.shields.io/discord/869557815780470834?color=738adb&label=Discord&logo=discord&logoColor=white&style=flat-square)](https://discord.gg/gADmkJb9Fb) [![Matrix](https://img.shields.io/badge/Matrix-40aa8b.svg?style=flat-square&logo=Matrix&logoColor=white)](https://matrix.to/#/#nvchad:matrix.org)