From e868fab1f26919fe48bb44feae5f4056d50c2627 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 25 Sep 2023 12:25:09 +0530 Subject: [PATCH 01/68] add options for term module win resize vals --- lua/core/default_config.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 639916a..2114eab 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -75,12 +75,15 @@ M.ui = { cheatsheet = { theme = "grid" }, -- simple/grid lsp = { - -- show function signatures i.e args as you type signature = { disabled = false, - silent = true, -- silences 'no signature help available' message from appearing + silent = true, -- silences 'no signature help available' message }, }, + + term = { + sizes = { sp = 0.3, vsp = 0.2 }, + }, } M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file -- 2.40.1 From 92b7f38e8392c43cff8844714025fa3e330227f3 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 25 Sep 2023 12:28:05 +0530 Subject: [PATCH 02/68] rm nvterm & use ui.term related mappings --- lua/core/mappings.lua | 110 ++++++++++++++++++++++-------------------- lua/plugins/init.lua | 11 ----- 2 files changed, 58 insertions(+), 63 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index dde5bfc..ae44e7e 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -292,70 +292,76 @@ M.telescope = { }, } -M.nvterm = { - plugin = true, - - t = { - -- toggle in terminal mode - [""] = { - function() - require("nvterm.terminal").toggle "float" - end, - "Toggle floating term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "horizontal" - end, - "Toggle horizontal term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "vertical" - end, - "Toggle vertical term", - }, - }, - +M.terminal = { n = { - -- toggle in normal mode - [""] = { - function() - require("nvterm.terminal").toggle "float" - end, - "Toggle floating term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "horizontal" - end, - "Toggle horizontal term", - }, - - [""] = { - function() - require("nvterm.terminal").toggle "vertical" - end, - "Toggle vertical term", - }, - - -- new + -- spawn new terms ["h"] = { function() - require("nvterm.terminal").new "horizontal" + require("nvchad.term").new { pos = "sp", size = 0.3 } end, "New horizontal term", }, ["v"] = { function() - require("nvterm.terminal").new "vertical" + require("nvchad.term").new { pos = "vsp", size = 0.3 } end, "New vertical term", }, + + -- toggle terms + [""] = { + function() + require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } + end, + "New vertical term", + }, + + [""] = { + function() + require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } + end, + "New vertical term", + }, + + [""] = { + function() + require("nvchad.term").toggle { pos = "float", id = "floatTerm" } + end, + "Toggleable Floating term", + }, + }, + + -- toggle terms in terminal mode + t = { + [""] = { + function() + local win = vim.api.nvim_get_current_win() + vim.api.nvim_win_close(win, true) + end, + "close term in terminal mode", + }, + + [""] = { + function() + require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } + end, + "New vertical term", + }, + + [""] = { + function() + require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } + end, + "New vertical term", + }, + + [""] = { + function() + require("nvchad.term").toggle { pos = "float", id = "floatTerm" } + end, + "Toggleable Floating term", + }, }, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index a517851..1567a64 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -18,17 +18,6 @@ local default_plugins = { lazy = false, }, - { - "NvChad/nvterm", - init = function() - require("core.utils").load_mappings "nvterm" - end, - config = function(_, opts) - require "base46.term" - require("nvterm").setup(opts) - end, - }, - { "NvChad/nvim-colorizer.lua", init = function() -- 2.40.1 From d9b3980e6265e692c979e51d483193d9272ca5d1 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 25 Sep 2023 12:33:22 +0530 Subject: [PATCH 03/68] update ui plugin branch --- lua/plugins/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 1567a64..fb9065b 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -14,7 +14,7 @@ local default_plugins = { { "NvChad/ui", - branch = "v2.0", + branch = "v3.0", lazy = false, }, -- 2.40.1 From 1b20da0115438b6b4b7ab540902dc6867fa190e6 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 26 Sep 2023 11:28:45 +0530 Subject: [PATCH 04/68] update version in core/default_config.lua --- lua/core/default_config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 2114eab..1a565a7 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -1,7 +1,7 @@ local M = {} M.options = { - nvchad_branch = "v2.0", + nvchad_branch = "v3.0", } M.ui = { -- 2.40.1 From 17a8959bea6afdedb38a4c64848f80ea3dabaed3 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 26 Sep 2023 18:32:15 +0530 Subject: [PATCH 05/68] add option for term auto_insert --- lua/core/default_config.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 1a565a7..9c9bad1 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -83,6 +83,9 @@ M.ui = { term = { sizes = { sp = 0.3, vsp = 0.2 }, + behavior = { + auto_insert = true, + }, }, } -- 2.40.1 From d58ec3f55d34fe9339e0d0eb8645e5bbbaba234e Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 26 Sep 2023 18:51:34 +0530 Subject: [PATCH 06/68] properly disable lsp signature https://github.com/NvChad/ui/pull/188#issuecomment-1735510051 --- lua/core/default_config.lua | 3 ++- lua/plugins/configs/lspconfig.lua | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 9c9bad1..75763e7 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -13,7 +13,6 @@ M.ui = { theme_toggle = { "onedark", "one_light" }, theme = "onedark", -- default theme transparency = false, - lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens -- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations extended_integrations = {}, -- these aren't compiled by default, ex: "alpha", "notify" @@ -79,6 +78,8 @@ M.ui = { disabled = false, silent = true, -- silences 'no signature help available' message }, + + semantic_tokens = false, }, term = { diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 18e84ad..61d80ca 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -12,11 +12,15 @@ M.on_attach = function(client, bufnr) utils.load_mappings("lspconfig", { buffer = bufnr }) - if client.server_capabilities.signatureHelpProvider then + -- signature stuff + local conf = utils.load_config().ui.lsp + + if conf.signature and client.server_capabilities.signatureHelpProvider then require("nvchad.signature").setup(client) end - if not utils.load_config().ui.lsp_semantic_tokens and client.supports_method "textDocument/semanticTokens" then + -- semanticTokens + if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then client.server_capabilities.semanticTokensProvider = nil end end -- 2.40.1 From 1afbaef5c7c36cf24cf6b2fd9712310c8358736e Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 26 Sep 2023 20:41:19 +0530 Subject: [PATCH 07/68] properly disable lsp signature --- lua/core/default_config.lua | 6 +----- lua/plugins/configs/lspconfig.lua | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 75763e7..69d6c01 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -74,11 +74,7 @@ M.ui = { cheatsheet = { theme = "grid" }, -- simple/grid lsp = { - signature = { - disabled = false, - silent = true, -- silences 'no signature help available' message - }, - + signature = true, semantic_tokens = false, }, diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 61d80ca..5b636ad 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -2,27 +2,27 @@ dofile(vim.g.base46_cache .. "lsp") require "nvchad.lsp" local M = {} -local utils = require "core.utils" -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) - client.server_capabilities.documentFormattingProvider = false - client.server_capabilities.documentRangeFormattingProvider = false - - utils.load_mappings("lspconfig", { buffer = bufnr }) - - -- signature stuff + local utils = require "core.utils" local conf = utils.load_config().ui.lsp - if conf.signature and client.server_capabilities.signatureHelpProvider then - require("nvchad.signature").setup(client) - end - -- semanticTokens if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then client.server_capabilities.semanticTokensProvider = nil end + + -- signature + if conf.signature and client.server_capabilities.signatureHelpProvider then + require("nvchad.signature").setup(client, bufnr) + end + + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false + + utils.load_mappings("lspconfig", { buffer = bufnr }) end M.capabilities = vim.lsp.protocol.make_client_capabilities() -- 2.40.1 From cb18b424b91376bdeb10ed950306a507d43e3dbe Mon Sep 17 00:00:00 2001 From: siduck Date: Wed, 27 Sep 2023 06:14:48 +0530 Subject: [PATCH 08/68] misc --- lua/plugins/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index fb9065b..3f76ffd 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -16,6 +16,9 @@ local default_plugins = { "NvChad/ui", branch = "v3.0", lazy = false, + config = function() + require "nvchad" + end, }, { -- 2.40.1 From 4a8fb6915750d5ffd9ab0a31c2e30dc53dabf65e Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 28 Sep 2023 07:22:02 +0530 Subject: [PATCH 09/68] lspconfig file: place default conf in a function This will make sure that whenever the onattach or capabilities is pulled from the default lspconfig file, thosse dofile etc code ( which is now in defautls func ) wont be called , like before. --- lua/plugins/configs/lspconfig.lua | 45 ++++++++++++++++--------------- lua/plugins/init.lua | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 5b636ad..a605c7e 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,10 +1,6 @@ -dofile(vim.g.base46_cache .. "lsp") -require "nvchad.lsp" - local M = {} -- export on_attach & capabilities for custom lspconfigs - M.on_attach = function(client, bufnr) local utils = require "core.utils" local conf = utils.load_config().ui.lsp @@ -45,27 +41,32 @@ M.capabilities.textDocument.completion.completionItem = { }, } -require("lspconfig").lua_ls.setup { - on_attach = M.on_attach, - capabilities = M.capabilities, +M.defaults = function() + dofile(vim.g.base46_cache .. "lsp") + require "nvchad.lsp" - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand "$VIMRUNTIME/lua"] = true, - [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, - [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true, - [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, + require("lspconfig").lua_ls.setup { + on_attach = M.on_attach, + capabilities = M.capabilities, + + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true, + [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, }, - maxPreload = 100000, - preloadFileSize = 10000, }, }, - }, -} + } +end return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3f76ffd..3070c1a 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -133,7 +133,7 @@ local default_plugins = { require("core.utils").lazy_load "nvim-lspconfig" end, config = function() - require "plugins.configs.lspconfig" + require("plugins.configs.lspconfig").defaults() end, }, -- 2.40.1 From f48ff142f03d75f885f518711f47a8696fd76165 Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 28 Sep 2023 11:22:12 +0530 Subject: [PATCH 10/68] migrate to blankline v3.0 ( breaking change ) --- lua/plugins/configs/others.lua | 20 ++------------------ lua/plugins/init.lua | 8 +++++--- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index dafd5a4..fea5af2 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -2,24 +2,8 @@ local M = {} local utils = require "core.utils" M.blankline = { - indentLine_enabled = 1, - filetype_exclude = { - "help", - "terminal", - "lazy", - "lspinfo", - "TelescopePrompt", - "TelescopeResults", - "mason", - "nvdash", - "nvcheatsheet", - "", - }, - buftype_exclude = { "terminal" }, - show_trailing_blankline_indent = false, - show_first_indent_level = false, - show_current_context = true, - show_current_context_start = true, + indent = { highlight = "IblChar" }, + scope = { highlight = "IblScopeChar" }, } M.luasnip = function(opts) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3070c1a..0e8f84e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -6,7 +6,7 @@ local default_plugins = { { "NvChad/base46", - branch = "v2.0", + branch = "v3.0", build = function() require("base46").load_all_highlights() end, @@ -49,7 +49,6 @@ local default_plugins = { { "lukas-reineke/indent-blankline.nvim", - version = "2.20.7", init = function() require("core.utils").lazy_load "indent-blankline.nvim" end, @@ -59,7 +58,10 @@ local default_plugins = { config = function(_, opts) require("core.utils").load_mappings "blankline" dofile(vim.g.base46_cache .. "blankline") - require("indent_blankline").setup(opts) + + local hooks = require "ibl.hooks" + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) + require("ibl").setup(opts) end, }, -- 2.40.1 From 47e9ce90ff07db8b20a4c7afae30210c0747525f Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 1 Oct 2023 11:15:23 +0530 Subject: [PATCH 11/68] use slim chars for blankline indent also enable indent markers in nvimtree --- lua/plugins/configs/nvimtree.lua | 2 +- lua/plugins/configs/others.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/configs/nvimtree.lua index b4a8aee..c54248e 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/configs/nvimtree.lua @@ -36,7 +36,7 @@ local options = { highlight_opened_files = "none", indent_markers = { - enable = false, + enable = true, }, icons = { diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index fea5af2..9e01f8d 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -2,8 +2,8 @@ local M = {} local utils = require "core.utils" M.blankline = { - indent = { highlight = "IblChar" }, - scope = { highlight = "IblScopeChar" }, + indent = { char = "│", highlight = "IblChar" }, + scope = { char = "│", highlight = "IblScopeChar" }, } M.luasnip = function(opts) -- 2.40.1 From 0d2265aa37f9da5dfcc3308ac2a4a13d5b96ec2a Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 2 Oct 2023 13:49:24 +0530 Subject: [PATCH 12/68] rm outdated link from readme --- .github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index bdc89d8..192aa3c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -113,7 +113,7 @@ A fuzzy file finder, picker, sorter, previewer and much more: If you like NvChad and would like to support & appreciate it via donation then I'll gladly accept it. [![kofi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/siduck) -[![paypal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/siduck76) +[![paypal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/siduck13) [![buymeacoffee](https://img.shields.io/badge/Buy_Me_A_Coffee-FFDD00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/siduck) [![patreon](https://img.shields.io/badge/Patreon-F96854?style=for-the-badge&logo=patreon&logoColor=white)](https://www.patreon.com/siduck) -- 2.40.1 From 5261eb330b2fe012b9f5d54302f3741e91c22992 Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Thu, 28 Sep 2023 11:33:45 +0530 Subject: [PATCH 13/68] Rm outdated info in readme --- .github/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/README.md b/.github/README.md index 192aa3c..8f3ec47 100644 --- a/.github/README.md +++ b/.github/README.md @@ -88,8 +88,7 @@ A fuzzy file finder, picker, sorter, previewer and much more: - Many beautiful themes, theme toggler by our [base46 plugin](https://github.com/NvChad/base46) - Inbuilt terminal toggling & management with [Nvterm](https://github.com/NvChad/nvterm) -- NvChad updater, hide & unhide terminal buffers with [NvChad extensions](https://github.com/NvChad/extensions) -- Lightweight & performant ui plugin with [NvChad UI](https://github.com/NvChad/ui) It provides statusline modules, tabufline ( tabs + buffer manager) , beautiful cheatsheets and much more! +- Lightweight & performant ui plugin with [NvChad UI](https://github.com/NvChad/ui) It provides statusline modules, tabufline ( tabs + buffer manager) , beautiful cheatsheets, NvChad updater, hide & unhide terminal buffers, theme switcher and much more! - File navigation with [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua) - Beautiful and configurable icons with [nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) - Git diffs and more with [gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim) -- 2.40.1 From ed18649e94b58a2855d43e9356c56433d207f683 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 9 Oct 2023 17:13:11 +0530 Subject: [PATCH 14/68] statusline: dont reload if theme is custom this will prevent auto-reload of statusline , good for non custom statusline users --- lua/core/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 19804e1..6f396ac 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -93,8 +93,10 @@ autocmd("BufWritePost", { vim.g.transparency = config.ui.transparency -- statusline - require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme) - vim.opt.statusline = "%!v:lua.require('nvchad.statusline." .. config.ui.statusline.theme .. "').run()" + if config.ui.statusline.theme ~= "custom" then + require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme) + vim.opt.statusline = "%!v:lua.require('nvchad.statusline." .. config.ui.statusline.theme .. "').run()" + end -- tabufline if config.ui.tabufline.enabled then -- 2.40.1 From 5748536742f630808d05b28be54f370f67eb1cc7 Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Mon, 16 Oct 2023 07:24:14 +0530 Subject: [PATCH 15/68] performance: avoid reloading config table #2360 (#2444) * performance: avoid reloading config (#2360) * performance: avoid reloading config * Rm outdated info in readme --------- Co-authored-by: Sidhanth Rathod * update nvchad load_config result path * update branch names --------- Co-authored-by: georgejean --- lua/core/bootstrap.lua | 2 +- lua/core/init.lua | 7 ++----- lua/core/utils.lua | 4 ++-- lua/nvconfig.lua | 2 ++ lua/plugins/configs/cmp.lua | 2 +- lua/plugins/configs/lspconfig.lua | 3 +-- lua/plugins/init.lua | 6 +++--- 7 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 lua/nvconfig.lua diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index c1bab90..20e056e 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -18,7 +18,7 @@ M.lazy = function(install_path) M.echo " Compiling base46 theme to bytecode ..." local base46_repo = "https://github.com/NvChad/base46" - shell_call { "git", "clone", "--depth", "1", "-b", "v2.0", base46_repo, lazy_path } + shell_call { "git", "clone", "--depth", "1", "-b", "v3.0", base46_repo, lazy_path } vim.opt.rtp:prepend(lazy_path) require("base46").compile() diff --git a/lua/core/init.lua b/lua/core/init.lua index 6f396ac..61de98f 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,12 +1,9 @@ local opt = vim.opt local g = vim.g -local config = require("core.utils").load_config() -------------------------------------- globals ----------------------------------------- -g.nvchad_theme = config.ui.theme g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" g.toggle_theme_icon = "  " -g.transparency = config.ui.transparency -------------------------------------- options ------------------------------------------ opt.laststatus = 3 -- global statusline @@ -83,11 +80,11 @@ autocmd("BufWritePost", { local app_name = vim.env.NVIM_APPNAME and vim.env.NVIM_APPNAME or "nvim" local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".") + require("plenary.reload").reload_module "nvconfig" require("plenary.reload").reload_module "base46" require("plenary.reload").reload_module(module) - require("plenary.reload").reload_module "custom.chadrc" - config = require("core.utils").load_config() + local config = require "nvconfig" vim.g.nvchad_theme = config.ui.theme vim.g.transparency = config.ui.transparency diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 8b2a03d..96fe103 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -7,7 +7,7 @@ M.load_config = function() if chadrc_path then local chadrc = dofile(chadrc_path) - + config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) config = merge_tb("force", config, chadrc) config.mappings.disabled = nil @@ -74,7 +74,7 @@ M.load_mappings = function(section, mapping_opt) end end - local mappings = require("core.utils").load_config().mappings + local mappings = require("nvconfig").mappings if type(section) == "string" then mappings[section]["plugin"] = nil diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua new file mode 100644 index 0000000..df0d4a4 --- /dev/null +++ b/lua/nvconfig.lua @@ -0,0 +1,2 @@ +-- check default config at core/default_config.lua +return require("core.utils").load_config() diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index 19868b6..4af9ed2 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -2,7 +2,7 @@ local cmp = require "cmp" dofile(vim.g.base46_cache .. "cmp") -local cmp_ui = require("core.utils").load_config().ui.cmp +local cmp_ui = require("nvconfig").ui.cmp local cmp_style = cmp_ui.style local field_arrangement = { diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index a605c7e..df7f05b 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -3,14 +3,13 @@ local M = {} -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) local utils = require "core.utils" - local conf = utils.load_config().ui.lsp + local conf = require "nvconfig" -- semanticTokens if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then client.server_capabilities.semanticTokensProvider = nil end - -- signature if conf.signature and client.server_capabilities.signatureHelpProvider then require("nvchad.signature").setup(client, bufnr) end diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 0e8f84e..2b1b478 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -6,7 +6,7 @@ local default_plugins = { { "NvChad/base46", - branch = "v3.0", + branch = "test", build = function() require("base46").load_all_highlights() end, @@ -14,7 +14,7 @@ local default_plugins = { { "NvChad/ui", - branch = "v3.0", + branch = "test", lazy = false, config = function() require "nvchad" @@ -258,7 +258,7 @@ local default_plugins = { }, } -local config = require("core.utils").load_config() +local config = require "nvconfig" if #config.plugins > 0 then table.insert(default_plugins, { import = config.plugins }) -- 2.40.1 From 445d32c19f7eb5ed1b09fc4f63f7f8f0cc666a7e Mon Sep 17 00:00:00 2001 From: umlx5h <20206121+umlx5h@users.noreply.github.com> Date: Mon, 16 Oct 2023 23:36:34 +0900 Subject: [PATCH 16/68] Add CTRL-w key to whichkey lazyloading (#2446) --- lua/plugins/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 2b1b478..4d5abd9 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -246,7 +246,7 @@ local default_plugins = { -- Only load whichkey after all the gui { "folke/which-key.nvim", - keys = { "", "", '"', "'", "`", "c", "v", "g" }, + keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, init = function() require("core.utils").load_mappings "whichkey" end, -- 2.40.1 From 35ee0bc81de45c4ad0a870a4a5ad22d393b89f21 Mon Sep 17 00:00:00 2001 From: KorigamiK <72932688+KorigamiK@users.noreply.github.com> Date: Mon, 16 Oct 2023 17:02:31 +0530 Subject: [PATCH 17/68] Fix unreachable mappings for the lsp (#2443) --- lua/core/mappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index ae44e7e..f6e9728 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -193,7 +193,7 @@ M.lspconfig = { "LSP references", }, - ["f"] = { + ["lf"] = { function() vim.diagnostic.open_float { border = "rounded" } end, -- 2.40.1 From cb27ae0ed17b86c1ffe5553710cb0355dff8c216 Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Tue, 17 Oct 2023 15:25:13 +0530 Subject: [PATCH 18/68] update branch names for ui/base46 plugin --- lua/plugins/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 4d5abd9..31a6283 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -6,7 +6,7 @@ local default_plugins = { { "NvChad/base46", - branch = "test", + branch = "v3.0", build = function() require("base46").load_all_highlights() end, @@ -14,7 +14,7 @@ local default_plugins = { { "NvChad/ui", - branch = "test", + branch = "v3.0", lazy = false, config = function() require "nvchad" -- 2.40.1 From cc3289639b1507c19556e6e922f9adc9d51d4d31 Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Tue, 24 Oct 2023 06:45:17 +0530 Subject: [PATCH 19/68] Breaking Change for base46 extended_integrations | Improve syntax (#2459) * performance: avoid reloading config (#2360) * performance: avoid reloading config * Rm outdated info in readme --------- Co-authored-by: Sidhanth Rathod * update nvchad load_config result path * Update utils.lua * update branch names * Fix unreachable mappings for the lsp (#2443) * add option for base46 integrations * rm nvchad_theme global * use correct conf path in lspconfig --------- Co-authored-by: georgejean Co-authored-by: KorigamiK <72932688+KorigamiK@users.noreply.github.com> --- lua/core/default_config.lua | 24 +++++++++++++++++++++--- lua/core/init.lua | 3 --- lua/plugins/configs/lspconfig.lua | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 69d6c01..c44b1b0 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -14,9 +14,6 @@ M.ui = { theme = "onedark", -- default theme transparency = false, - -- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations - extended_integrations = {}, -- these aren't compiled by default, ex: "alpha", "notify" - -- cmp themeing cmp = { icons = true, @@ -92,4 +89,25 @@ M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startu M.mappings = require "core.mappings" +M.base46 = { + integrations = { + "blankline", + "cmp", + "defaults", + "devicons", + "git", + "lsp", + "mason", + "nvchad_updater", + "nvcheatsheet", + "nvdash", + "nvimtree", + "statusline", + "syntax", + "tbline", + "telescope", + "whichkey", + }, +} + return M diff --git a/lua/core/init.lua b/lua/core/init.lua index 61de98f..8b5d9ce 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -86,9 +86,6 @@ autocmd("BufWritePost", { local config = require "nvconfig" - vim.g.nvchad_theme = config.ui.theme - vim.g.transparency = config.ui.transparency - -- statusline if config.ui.statusline.theme ~= "custom" then require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index df7f05b..5c6027c 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -3,8 +3,8 @@ local M = {} -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) local utils = require "core.utils" - local conf = require "nvconfig" - + local conf = require("nvconfig").ui.lsp + -- semanticTokens if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then client.server_capabilities.semanticTokensProvider = nil -- 2.40.1 From ccdf0dda11d8eeba008b2f6b060aacafd11d8ba2 Mon Sep 17 00:00:00 2001 From: Panos Sakkos Date: Fri, 27 Oct 2023 03:33:43 +0300 Subject: [PATCH 20/68] Ignore .DS_Store files (#2463) Ignores macos .DS_Store files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ce3274d..d8a93d9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ coc-settings.json .luarc.json lazy-lock.json after +**/.DS_Store -- 2.40.1 From da85f7fbcd97c2290359d4a55db49f1384dc527b Mon Sep 17 00:00:00 2001 From: TheFedaikin Date: Sun, 22 Oct 2023 15:52:38 +0300 Subject: [PATCH 21/68] feat(mappings): make a cmd to remove flickering (#2456) --- lua/core/mappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index f6e9728..fff878b 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -16,7 +16,7 @@ M.general = { }, n = { - [""] = { ":noh ", "Clear highlights" }, + [""] = { " noh ", "Clear highlights" }, -- switch between windows [""] = { "h", "Window left" }, [""] = { "l", "Window right" }, -- 2.40.1 From 48f1bb702dece58376f030b57a178c28a441262e Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 28 Oct 2023 09:34:28 +0530 Subject: [PATCH 22/68] include loading of treesitter hlgroups --- lua/core/default_config.lua | 1 + lua/plugins/init.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index c44b1b0..1a79f3c 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -104,6 +104,7 @@ M.base46 = { "nvimtree", "statusline", "syntax", + "treesitter", "tbline", "telescope", "whichkey", diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 31a6283..3dd6904 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -77,6 +77,7 @@ local default_plugins = { end, config = function(_, opts) dofile(vim.g.base46_cache .. "syntax") + dofile(vim.g.base46_cache .. "treesitter") require("nvim-treesitter.configs").setup(opts) end, }, -- 2.40.1 From a88c68f911b6975d42145b45e4ff507859b68cdd Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 31 Oct 2023 05:43:02 +0530 Subject: [PATCH 23/68] set cursorlineopt=number #865 --- lua/core/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/core/init.lua b/lua/core/init.lua index 8b5d9ce..e1b9558 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -11,6 +11,7 @@ opt.showmode = false opt.clipboard = "unnamedplus" opt.cursorline = true +opt.cursorlineopt = 'number' -- Indenting opt.expandtab = true -- 2.40.1 From 37c328ab2a05086d1cac9e0acc810050b293e445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=8A=E5=8A=A0=E6=97=AD=20=28Max=20Chuang=29?= <76544194+madmaxieee@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:36:16 +0800 Subject: [PATCH 24/68] fix typo (#2483) --- lua/core/bootstrap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index 20e056e..b95f1ce 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -32,7 +32,7 @@ M.lazy = function(install_path) -- install plugins require "plugins" - -- mason packages & show post_boostrap screen + -- mason packages & show post_bootstrap screen require "nvchad.post_install"() end -- 2.40.1 From ffa83d57f03340390421828c485faafed73d2187 Mon Sep 17 00:00:00 2001 From: Gean Marroquin Date: Sun, 12 Nov 2023 23:27:03 -0500 Subject: [PATCH 25/68] remove Search, IncSearch and CurSearch highlights from cmp windows (#2490) --- 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 4af9ed2..9b669a8 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -52,7 +52,7 @@ local options = { window = { completion = { side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0, - winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel", + winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None", scrollbar = false, }, documentation = { -- 2.40.1 From bfd0ea7dcd99e70ecc0d2282a17d779c3e48ec71 Mon Sep 17 00:00:00 2001 From: Vitor Boschi da Silva Date: Fri, 8 Dec 2023 12:21:09 -0300 Subject: [PATCH 26/68] [feat] Make gitsigns init function async (#2538) * [feat] Make gitsigns init function async This function is running git and also initializing a shell, which can be a relatively slow operation. By leveraging the jobs api, we run the command in background, reducing the time it takes for the buffer to be available to the user. It also uses the list format for the job, which allow us to bypass the shell entirely. * performance: use uv.cwd() instead of fn.expand benchmarked luv's cwd and it seems to be 20x faster than the expand function --------- Co-authored-by: Sidhanth Rathod --- lua/plugins/init.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3dd6904..b352c91 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -91,13 +91,18 @@ local default_plugins = { vim.api.nvim_create_autocmd({ "BufRead" }, { group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }), callback = function() - vim.fn.system("git -C " .. '"' .. vim.fn.expand "%:p:h" .. '"' .. " rev-parse") - if vim.v.shell_error == 0 then - vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" - vim.schedule(function() - require("lazy").load { plugins = { "gitsigns.nvim" } } - end) - end + vim.fn.jobstart({"git", "-C", vim.loop.cwd(), "rev-parse"}, + { + on_exit = function(_, return_code) + if return_code == 0 then + vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" + vim.schedule(function() + require("lazy").load { plugins = { "gitsigns.nvim" } } + end) + end + end + } + ) end, }) end, -- 2.40.1 From d7798fb74a13d4f16f3ac5aff0cca1e185182471 Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 24 Dec 2023 16:32:04 +0530 Subject: [PATCH 27/68] remove telescope fzf extension #2571 --- lua/plugins/configs/telescope.lua | 2 +- lua/plugins/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua index 91c1d3a..0df500e 100644 --- a/lua/plugins/configs/telescope.lua +++ b/lua/plugins/configs/telescope.lua @@ -49,7 +49,7 @@ local options = { }, }, - extensions_list = { "themes", "terms", "fzf" }, + extensions_list = { "themes", "terms" }, extensions = { fzf = { fuzzy = true, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index b352c91..b844ec4 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -229,7 +229,7 @@ local default_plugins = { { "nvim-telescope/telescope.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter", { "nvim-telescope/telescope-fzf-native.nvim", build = "make" } }, + dependencies = { "nvim-treesitter/nvim-treesitter" }, cmd = "Telescope", init = function() require("core.utils").load_mappings "telescope" -- 2.40.1 From a439de385bc00c0061d9750dd992b29a8cbb780e Mon Sep 17 00:00:00 2001 From: siduck Date: Wed, 27 Dec 2023 19:49:31 +0530 Subject: [PATCH 28/68] check for empty/nil mason ensure_installed table #2580 --- lua/plugins/init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index b844ec4..fe74af7 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -128,7 +128,9 @@ local default_plugins = { -- custom nvchad cmd to install all mason binaries listed vim.api.nvim_create_user_command("MasonInstallAll", function() - vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) + if opts.ensure_installed and #opts.ensure_installed > 0 then + vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) + end end, {}) vim.g.mason_binaries_list = opts.ensure_installed -- 2.40.1 From 0333185bfc98aa6f3b728f59c4c08cfa39142587 Mon Sep 17 00:00:00 2001 From: Grigorii Khvatskii Date: Tue, 2 Jan 2024 06:42:34 -0500 Subject: [PATCH 29/68] Add support for non-interactive bootstrapping (#2528) https://github.com/NvChad/NvChad/pull/2528#issuecomment-1834599074 --------- Co-authored-by: Sidhanth Rathod --- lua/core/bootstrap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index b95f1ce..50a8484 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -40,7 +40,7 @@ M.gen_chadrc_template = function() local path = fn.stdpath "config" .. "/lua/custom" if fn.isdirectory(path) ~= 1 then - local input = fn.input "Do you want to install example custom config? (y/N): " + local input = vim.env.NVCHAD_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): " if input:lower() == "y" then M.echo "Cloning example custom config repo..." -- 2.40.1 From b2e2b15b4532186cf11fcdb7dc1d6c1714f94e9f Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 28 Jan 2024 21:33:38 +0530 Subject: [PATCH 30/68] fix editorConfig indent opts not applying on certain fts #2633 --- lua/core/init.lua | 25 +++++++++++++++++++- lua/core/utils.lua | 30 +----------------------- lua/plugins/configs/lspconfig.lua | 5 +--- lua/plugins/init.lua | 38 ++++--------------------------- 4 files changed, 31 insertions(+), 67 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index e1b9558..50045cf 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -11,7 +11,7 @@ opt.showmode = false opt.clipboard = "unnamedplus" opt.cursorline = true -opt.cursorlineopt = 'number' +opt.cursorlineopt = "number" -- Indenting opt.expandtab = true @@ -104,6 +104,29 @@ autocmd("BufWritePost", { end, }) +-- user event that loads after UIEnter + only if file buf is there +vim.api.nvim_create_autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, { + group = vim.api.nvim_create_augroup("NvFilePost", { clear = true }), + callback = function(args) + local file = vim.api.nvim_buf_get_name(args.buf) + local buftype = vim.api.nvim_buf_get_option(args.buf, "buftype") + + if not vim.g.ui_entered and args.event == "UIEnter" then + vim.g.ui_entered = true + end + + if file ~= "" and buftype ~= "nofile" and vim.g.ui_entered then + vim.api.nvim_exec_autocmds("User", { pattern = "FilePost", modeline = false }) + vim.api.nvim_del_augroup_by_name "NvFilePost" + + vim.schedule(function() + vim.api.nvim_exec_autocmds("FileType", {}) + require("editorconfig").config(args.buf) + end, 0) + end + end, +}) + -------------------------------------- commands ------------------------------------------ local new_cmd = vim.api.nvim_create_user_command diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 96fe103..6f4dfae 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -7,7 +7,7 @@ M.load_config = function() if chadrc_path then local chadrc = dofile(chadrc_path) - + config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) config = merge_tb("force", config, chadrc) config.mappings.disabled = nil @@ -87,32 +87,4 @@ M.load_mappings = function(section, mapping_opt) end) end -M.lazy_load = function(plugin) - vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, { - group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}), - callback = function() - local file = vim.fn.expand "%" - local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= "" - - if condition then - vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin) - - -- dont defer for treesitter as it will show slow highlighting - -- This deferring only happens only when we do "nvim filename" - if plugin ~= "nvim-treesitter" then - vim.schedule(function() - require("lazy").load { plugins = plugin } - - if plugin == "nvim-lspconfig" then - vim.cmd "silent! do FileType" - end - end, 0) - else - require("lazy").load { plugins = plugin } - end - end - end, - }) -end - return M diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 5c6027c..55dac4d 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -4,7 +4,7 @@ local M = {} M.on_attach = function(client, bufnr) local utils = require "core.utils" local conf = require("nvconfig").ui.lsp - + -- semanticTokens if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then client.server_capabilities.semanticTokensProvider = nil @@ -14,9 +14,6 @@ M.on_attach = function(client, bufnr) require("nvchad.signature").setup(client, bufnr) end - client.server_capabilities.documentFormattingProvider = false - client.server_capabilities.documentRangeFormattingProvider = false - utils.load_mappings("lspconfig", { buffer = bufnr }) end diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index fe74af7..26e9ba0 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -23,9 +23,7 @@ local default_plugins = { { "NvChad/nvim-colorizer.lua", - init = function() - require("core.utils").lazy_load "nvim-colorizer.lua" - end, + event = "User FilePost", config = function(_, opts) require("colorizer").setup(opts) @@ -49,9 +47,7 @@ local default_plugins = { { "lukas-reineke/indent-blankline.nvim", - init = function() - require("core.utils").lazy_load "indent-blankline.nvim" - end, + event = "User FilePost", opts = function() return require("plugins.configs.others").blankline end, @@ -67,9 +63,7 @@ local default_plugins = { { "nvim-treesitter/nvim-treesitter", - init = function() - require("core.utils").lazy_load "nvim-treesitter" - end, + event = { "BufReadPost", "BufNewFile" }, cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, build = ":TSUpdate", opts = function() @@ -85,27 +79,7 @@ local default_plugins = { -- git stuff { "lewis6991/gitsigns.nvim", - ft = { "gitcommit", "diff" }, - init = function() - -- load gitsigns only when a git file is opened - vim.api.nvim_create_autocmd({ "BufRead" }, { - group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }), - callback = function() - vim.fn.jobstart({"git", "-C", vim.loop.cwd(), "rev-parse"}, - { - on_exit = function(_, return_code) - if return_code == 0 then - vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" - vim.schedule(function() - require("lazy").load { plugins = { "gitsigns.nvim" } } - end) - end - end - } - ) - end, - }) - end, + event = "User FilePost", opts = function() return require("plugins.configs.others").gitsigns end, @@ -139,9 +113,7 @@ local default_plugins = { { "neovim/nvim-lspconfig", - init = function() - require("core.utils").lazy_load "nvim-lspconfig" - end, + event = "User FilePost", config = function() require("plugins.configs.lspconfig").defaults() end, -- 2.40.1 From 59082a8f28c8f33ee3cca5ac6932c15b5a3c53e8 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 2 Feb 2024 09:11:04 +0530 Subject: [PATCH 31/68] add float opts for term feature --- lua/core/default_config.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 1a79f3c..da49f21 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -77,6 +77,14 @@ M.ui = { term = { sizes = { sp = 0.3, vsp = 0.2 }, + float = { + relative = "editor", + row = 0.3, + col = 0.25, + width = 0.5, + height = 0.4, + border = "single", + }, behavior = { auto_insert = true, }, -- 2.40.1 From 56cc2d757a67a074f73a26e3871c630317366c2c Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 17 Feb 2024 06:31:11 +0530 Subject: [PATCH 32/68] reload editorconfig on User FilePost event only if enabled #2672 --- lua/core/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 50045cf..59eaf75 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -121,7 +121,10 @@ vim.api.nvim_create_autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, { vim.schedule(function() vim.api.nvim_exec_autocmds("FileType", {}) - require("editorconfig").config(args.buf) + + if vim.g.editorconfig then + require("editorconfig").config(args.buf) + end end, 0) end end, -- 2.40.1 From ddef3aa1727a7f3f4bbd94609825dc197510cc2b Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 19 Feb 2024 20:39:38 +0530 Subject: [PATCH 33/68] add default hlgroup for term wins --- lua/core/default_config.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index da49f21..0ee9467 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -19,8 +19,6 @@ M.ui = { icons = true, lspkind_text = true, style = "default", -- default/flat_light/flat_dark/atom/atom_colored - border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables - selected_item_bg = "colored", -- colored / simple }, telescope = { style = "borderless" }, -- borderless / bordered @@ -76,6 +74,7 @@ M.ui = { }, term = { + hl = "Normal:term,WinSeparator:WinSeparator", sizes = { sp = 0.3, vsp = 0.2 }, float = { relative = "editor", -- 2.40.1 From 9414658e35ede3dce3ec56323e748b1d1a609e01 Mon Sep 17 00:00:00 2001 From: Jhon Vidal Date: Thu, 22 Feb 2024 22:28:59 -0400 Subject: [PATCH 34/68] fix: mapping update for new version of indent-blankline plugin (#2683) * fix: mapping update for new version of indent-blankline plugin obsolete function, correcting for the new version of said indent-blankline plugin * improve blankline mapping --------- Co-authored-by: Sidhanth Rathod --- lua/core/mappings.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index fff878b..93118be 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -391,14 +391,19 @@ M.blankline = { n = { ["cc"] = { function() - local ok, start = require("indent_blankline.utils").get_current_context( - vim.g.indent_blankline_context_patterns, - vim.g.indent_blankline_use_treesitter_scope - ) + local config = { scope = {} } + config.scope.exclude = { language = {}, node_type = {} } + config.scope.include = { node_type = {} } - if ok then - vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 }) - vim.cmd [[normal! _]] + local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) + + if node then + local start_row, _, end_row, _ = node:range() + + if start_row ~= end_row then + vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) + vim.api.nvim_feedkeys("_", "n", true) + end end end, -- 2.40.1 From 4b1bca5303f39adf7d664a2fa25d720f210bf1ad Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 25 Feb 2024 08:43:48 +0530 Subject: [PATCH 35/68] clean mapping syntax --- init.lua | 6 +- lua/core/init.lua | 9 + lua/core/mappings.lua | 631 +++++++----------------------- lua/core/utils.lua | 78 +--- lua/plugins/configs/gitsigns.lua | 26 ++ lua/plugins/configs/lspconfig.lua | 23 +- lua/plugins/configs/luasnip.lua | 23 ++ lua/plugins/configs/others.lua | 50 --- lua/plugins/init.lua | 24 +- 9 files changed, 244 insertions(+), 626 deletions(-) create mode 100644 lua/plugins/configs/gitsigns.lua create mode 100644 lua/plugins/configs/luasnip.lua delete mode 100644 lua/plugins/configs/others.lua diff --git a/init.lua b/init.lua index 21f0b6f..44b5eab 100644 --- a/init.lua +++ b/init.lua @@ -6,8 +6,6 @@ if custom_init_path then dofile(custom_init_path) end -require("core.utils").load_mappings() - local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" -- bootstrap lazy.nvim! @@ -19,3 +17,7 @@ end dofile(vim.g.base46_cache .. "defaults") vim.opt.rtp:prepend(lazypath) require "plugins" + +vim.schedule(function() + require "core.mappings" +end, 0) diff --git a/lua/core/init.lua b/lua/core/init.lua index 59eaf75..8087d6a 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -136,3 +136,12 @@ local new_cmd = vim.api.nvim_create_user_command new_cmd("NvChadUpdate", function() require "nvchad.updater"() end, {}) + +--------------------------------------- globals ------------------------------------------- +vim.g.whichkey_maps = true +vim.g.blankline_maps = true +vim.g.terminal_maps = true +vim.g.telescope_maps = true +vim.g.nvimtree_maps = true +vim.g.comment_maps = true +vim.g.tabufline_maps = true diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 93118be..228c2d5 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,479 +1,152 @@ --- n, v, i, t = mode names - -local M = {} - -M.general = { - i = { - -- go to beginning and end - [""] = { "^i", "Beginning of line" }, - [""] = { "", "End of line" }, - - -- navigate within insert mode - [""] = { "", "Move left" }, - [""] = { "", "Move right" }, - [""] = { "", "Move down" }, - [""] = { "", "Move up" }, - }, - - n = { - [""] = { " noh ", "Clear highlights" }, - -- switch between windows - [""] = { "h", "Window left" }, - [""] = { "l", "Window right" }, - [""] = { "j", "Window down" }, - [""] = { "k", "Window up" }, - - -- save - [""] = { " w ", "Save file" }, - - -- Copy all - [""] = { " %y+ ", "Copy whole file" }, - - -- line numbers - ["n"] = { " set nu! ", "Toggle line number" }, - ["rn"] = { " set rnu! ", "Toggle relative number" }, - - -- Allow moving the cursor through wrapped lines with j, k, and - -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ - -- empty mode is same as using :map - -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour - ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - - -- new buffer - ["b"] = { " enew ", "New buffer" }, - ["ch"] = { " NvCheatsheet ", "Mapping cheatsheet" }, - - ["fm"] = { - function() - vim.lsp.buf.format { async = true } - end, - "LSP formatting", - }, - }, - - t = { - [""] = { vim.api.nvim_replace_termcodes("", true, true, true), "Escape terminal mode" }, - }, - - v = { - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - ["<"] = { ""] = { ">gv", "Indent line" }, - }, - - x = { - ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - -- Don't copy the replaced text after pasting in visual mode - -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste - ["p"] = { 'p:let @+=@0:let @"=@0', "Dont copy replaced text", opts = { silent = true } }, - }, -} - -M.tabufline = { - plugin = true, - - n = { - -- cycle through buffers - [""] = { - function() - require("nvchad.tabufline").tabuflineNext() - end, - "Goto next buffer", - }, - - [""] = { - function() - require("nvchad.tabufline").tabuflinePrev() - end, - "Goto prev buffer", - }, - - -- close buffer + hide terminal buffer - ["x"] = { - function() - require("nvchad.tabufline").close_buffer() - end, - "Close buffer", - }, - }, -} - -M.comment = { - plugin = true, - - -- toggle comment in both modes - n = { - ["/"] = { - function() - require("Comment.api").toggle.linewise.current() - end, - "Toggle comment", - }, - }, - - v = { - ["/"] = { - "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", - "Toggle comment", - }, - }, -} - -M.lspconfig = { - plugin = true, - - -- See ` :help vim.lsp.*` for documentation on any of the below functions - - n = { - ["gD"] = { - function() - vim.lsp.buf.declaration() - end, - "LSP declaration", - }, - - ["gd"] = { - function() - vim.lsp.buf.definition() - end, - "LSP definition", - }, - - ["K"] = { - function() - vim.lsp.buf.hover() - end, - "LSP hover", - }, - - ["gi"] = { - function() - vim.lsp.buf.implementation() - end, - "LSP implementation", - }, - - ["ls"] = { - function() - vim.lsp.buf.signature_help() - end, - "LSP signature help", - }, - - ["D"] = { - function() - vim.lsp.buf.type_definition() - end, - "LSP definition type", - }, - - ["ra"] = { - function() - require("nvchad.renamer").open() - end, - "LSP rename", - }, - - ["ca"] = { - function() - vim.lsp.buf.code_action() - end, - "LSP code action", - }, - - ["gr"] = { - function() - vim.lsp.buf.references() - end, - "LSP references", - }, - - ["lf"] = { - function() - vim.diagnostic.open_float { border = "rounded" } - end, - "Floating diagnostic", - }, - - ["[d"] = { - function() - vim.diagnostic.goto_prev { float = { border = "rounded" } } - end, - "Goto prev", - }, - - ["]d"] = { - function() - vim.diagnostic.goto_next { float = { border = "rounded" } } - end, - "Goto next", - }, - - ["q"] = { - function() - vim.diagnostic.setloclist() - end, - "Diagnostic setloclist", - }, - - ["wa"] = { - function() - vim.lsp.buf.add_workspace_folder() - end, - "Add workspace folder", - }, - - ["wr"] = { - function() - vim.lsp.buf.remove_workspace_folder() - end, - "Remove workspace folder", - }, - - ["wl"] = { - function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, - "List workspace folders", - }, - }, - - v = { - ["ca"] = { - function() - vim.lsp.buf.code_action() - end, - "LSP code action", - }, - }, -} - -M.nvimtree = { - plugin = true, - - n = { - -- toggle - [""] = { " NvimTreeToggle ", "Toggle nvimtree" }, - - -- focus - ["e"] = { " NvimTreeFocus ", "Focus nvimtree" }, - }, -} - -M.telescope = { - plugin = true, - - n = { - -- find - ["ff"] = { " Telescope find_files ", "Find files" }, - ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", "Find all" }, - ["fw"] = { " Telescope live_grep ", "Live grep" }, - ["fb"] = { " Telescope buffers ", "Find buffers" }, - ["fh"] = { " Telescope help_tags ", "Help page" }, - ["fo"] = { " Telescope oldfiles ", "Find oldfiles" }, - ["fz"] = { " Telescope current_buffer_fuzzy_find ", "Find in current buffer" }, - - -- git - ["cm"] = { " Telescope git_commits ", "Git commits" }, - ["gt"] = { " Telescope git_status ", "Git status" }, - - -- pick a hidden term - ["pt"] = { " Telescope terms ", "Pick hidden term" }, - - -- theme switcher - ["th"] = { " Telescope themes ", "Nvchad themes" }, - - ["ma"] = { " Telescope marks ", "telescope bookmarks" }, - }, -} - -M.terminal = { - n = { - -- spawn new terms - ["h"] = { - function() - require("nvchad.term").new { pos = "sp", size = 0.3 } - end, - "New horizontal term", - }, - - ["v"] = { - function() - require("nvchad.term").new { pos = "vsp", size = 0.3 } - end, - "New vertical term", - }, - - -- toggle terms - [""] = { - function() - require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } - end, - "New vertical term", - }, - - [""] = { - function() - require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } - end, - "New vertical term", - }, - - [""] = { - function() - require("nvchad.term").toggle { pos = "float", id = "floatTerm" } - end, - "Toggleable Floating term", - }, - }, - - -- toggle terms in terminal mode - t = { - [""] = { - function() - local win = vim.api.nvim_get_current_win() - vim.api.nvim_win_close(win, true) - end, - "close term in terminal mode", - }, - - [""] = { - function() - require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } - end, - "New vertical term", - }, - - [""] = { - function() - require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } - end, - "New vertical term", - }, - - [""] = { - function() - require("nvchad.term").toggle { pos = "float", id = "floatTerm" } - end, - "Toggleable Floating term", - }, - }, -} - -M.whichkey = { - plugin = true, - - n = { - ["wK"] = { - function() - vim.cmd "WhichKey" - end, - "Which-key all keymaps", - }, - ["wk"] = { - function() - local input = vim.fn.input "WhichKey: " - vim.cmd("WhichKey " .. input) - end, - "Which-key query lookup", - }, - }, -} - -M.blankline = { - plugin = true, - - n = { - ["cc"] = { - function() - local config = { scope = {} } - config.scope.exclude = { language = {}, node_type = {} } - config.scope.include = { node_type = {} } - - local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) - - if node then - local start_row, _, end_row, _ = node:range() - - if start_row ~= end_row then - vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) - vim.api.nvim_feedkeys("_", "n", true) - end - end - end, - - "Jump to current context", - }, - }, -} - -M.gitsigns = { - plugin = true, - - n = { - -- Navigation through hunks - ["]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 - ["rh"] = { - function() - require("gitsigns").reset_hunk() - end, - "Reset hunk", - }, - - ["ph"] = { - function() - require("gitsigns").preview_hunk() - end, - "Preview hunk", - }, - - ["gb"] = { - function() - package.loaded.gitsigns.blame_line() - end, - "Blame line", - }, - - ["td"] = { - function() - require("gitsigns").toggle_deleted() - end, - "Toggle deleted", - }, - }, -} - -return M +local map = vim.keymap.set + +map("i", "", "^i", { desc = "Beginning of line | general" }) +map("i", "", "", { desc = "End of line | general" }) +map("i", "", "", { desc = "Move left | general" }) +map("i", "", "", { desc = "Move right | general" }) +map("i", "", "", { desc = "Move down | general" }) +map("i", "", "", { desc = "Move up | general" }) + +map("n", "", "noh", { desc = "Clear highlights | general" }) +map("n", "", "h", { desc = "Window left | general" }) +map("n", "", "l", { desc = "Window right | general" }) +map("n", "", "j", { desc = "Window down | general" }) +map("n", "", "k", { desc = "Window up | general" }) +map("n", "", "w", { desc = "Save file | general" }) +map("n", "", "%y+", { desc = "Copy whole file | general" }) +map("n", "n", "set nu!", { desc = "Toggle line number | general" }) +map("n", "rn", "set rnu!", { desc = "Toggle relative number | general" }) +map("n", "b", "enew", { desc = "New buffer | general" }) +map("n", "ch", "NvCheatsheet", { desc = "Mapping cheatsheet | general" }) + +map("n", "fm", function() + vim.lsp.buf.format { async = true } +end, { desc = "LSP formatting | lsp" }) + +vim.keymap.set("n", "lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) +vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) + +-- Mappings for terminal mode +map( + "t", + "", + vim.api.nvim_replace_termcodes("", true, true, true), + { desc = "Escape terminal mode | general" } +) + +-- Mappings for M.tabufline +if vim.g.tabufline_maps then + map("n", "", function() + require("nvchad.tabufline").tabuflineNext() + end, { desc = "Goto next buffer | tabufline" }) + + map("n", "", function() + require("nvchad.tabufline").tabuflinePrev() + end, { desc = "Goto prev buffer | tabufline" }) + + map("n", "x", function() + require("nvchad.tabufline").close_buffer() + end, { desc = "Close buffer | tabufline" }) +end + +if vim.g.comment_maps then + map("n", "/", function() + require("Comment.api").toggle.linewise.current() + end, { desc = "Toggle comment | comment" }) + + map( + "v", + "/", + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + { desc = "Toggle comment | comment" } + ) +end + +if vim.g.nvimtree_maps then + map("n", "", "NvimTreeToggle", { desc = "Toggle nvimtree | nvimtree" }) + map("n", "e", "NvimTreeFocus", { desc = "Focus nvimtree | nvimtree" }) +end + +if vim.g.telescope_maps then + map("n", "fw", "Telescope live_grep", { desc = "Live grep | telescope" }) + map("n", "fb", "Telescope buffers", { desc = "Find buffers | telescope" }) + map("n", "fh", "Telescope help_tags", { desc = "Help page | telescope" }) + map("n", "fo", "Telescope oldfiles", { desc = "Find oldfiles | telescope" }) + + map( + "n", + "fz", + "Telescope current_buffer_fuzzy_find", + { desc = "Find in current buffer | telescope" } + ) + + map("n", "cm", "Telescope git_commits", { desc = "Git commits | telescope" }) + map("n", "gt", "Telescope git_status", { desc = "Git status | telescope" }) + map("n", "pt", "Telescope terms", { desc = "Pick hidden term | telescope" }) + map("n", "th", "Telescope themes", { desc = "Nvchad themes | telescope" }) + + map("n", "ff", "Telescope find_files", { desc = "Find files | telescope" }) + map( + "n", + "fa", + "Telescope find_files follow=true no_ignore=true hidden=true", + { desc = "Find all | telescope" } + ) +end + +-- Mappings for M.terminal +if vim.g.terminal_maps then + map("n", "h", function() + require("nvchad.term").new { pos = "sp", size = 0.3 } + end, { desc = "New horizontal term | terminal" }) + + map("n", "v", function() + require("nvchad.term").new { pos = "vsp", size = 0.3 } + end, { desc = "New vertical term | terminal" }) + + map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } + end, { desc = "Toggleable vertical term | terminal" }) + + map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } + end, { desc = "New horizontal term | terminal" }) + + map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "float", id = "floatTerm" } + end, { desc = "Toggleable Floating term | terminal" }) + + map("t", "", function() + local win = vim.api.nvim_get_current_win() + vim.api.nvim_win_close(win, true) + end, { desc = "Close term in terminal mode | terminal" }) +end + +if vim.g.whichkey_maps then + map("n", "wK", ":WhichKey ", { desc = "Which-key all keymaps | whichkey" }) + + map("n", "wk", function() + vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") + end, { desc = "Which-key query lookup | whichkey" }) +end + +if vim.g.blankline_maps then + map("n", "cc", function() + local config = { scope = {} } + config.scope.exclude = { language = {}, node_type = {} } + config.scope.include = { node_type = {} } + local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) + + if node then + local start_row, _, end_row, _ = node:range() + if start_row ~= end_row then + vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) + vim.api.nvim_feedkeys("_", "n", true) + end + end + end, { desc = "Jump to current context | blankline" }) +end + +require "custom.mappings" diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 6f4dfae..34213a4 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -1,90 +1,14 @@ local M = {} -local merge_tb = vim.tbl_deep_extend M.load_config = function() local config = require "core.default_config" local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] if chadrc_path then - local chadrc = dofile(chadrc_path) - - config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) - config = merge_tb("force", config, chadrc) - config.mappings.disabled = nil + config = vim.tbl_deep_extend("force", config, dofile(chadrc_path)) end return config end -M.remove_disabled_keys = function(chadrc_mappings, default_mappings) - if not chadrc_mappings then - return default_mappings - end - - -- store keys in a array with true value to compare - local keys_to_disable = {} - for _, mappings in pairs(chadrc_mappings) do - for mode, section_keys in pairs(mappings) do - if not keys_to_disable[mode] then - keys_to_disable[mode] = {} - end - section_keys = (type(section_keys) == "table" and section_keys) or {} - for k, _ in pairs(section_keys) do - keys_to_disable[mode][k] = true - end - end - end - - -- make a copy as we need to modify default_mappings - for section_name, section_mappings in pairs(default_mappings) do - for mode, mode_mappings in pairs(section_mappings) do - mode_mappings = (type(mode_mappings) == "table" and mode_mappings) or {} - for k, _ in pairs(mode_mappings) do - -- if key if found then remove from default_mappings - if keys_to_disable[mode] and keys_to_disable[mode][k] then - default_mappings[section_name][mode][k] = nil - end - end - end - end - - return default_mappings -end - -M.load_mappings = function(section, mapping_opt) - vim.schedule(function() - local function set_section_map(section_values) - if section_values.plugin then - return - end - - section_values.plugin = nil - - for mode, mode_values in pairs(section_values) do - local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {}) - for keybind, mapping_info in pairs(mode_values) do - -- merge default + user opts - local opts = merge_tb("force", default_opts, mapping_info.opts or {}) - - mapping_info.opts, opts.mode = nil, nil - opts.desc = mapping_info[2] - - vim.keymap.set(mode, keybind, mapping_info[1], opts) - end - end - end - - local mappings = require("nvconfig").mappings - - if type(section) == "string" then - mappings[section]["plugin"] = nil - mappings = { mappings[section] } - end - - for _, sect in pairs(mappings) do - set_section_map(sect) - end - end) -end - return M diff --git a/lua/plugins/configs/gitsigns.lua b/lua/plugins/configs/gitsigns.lua new file mode 100644 index 0000000..27f3105 --- /dev/null +++ b/lua/plugins/configs/gitsigns.lua @@ -0,0 +1,26 @@ +local options = { + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "󰍵" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "│" }, + }, + + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function opts(desc) + return { buffer = bufnr, desc = desc } + end + + local map = vim.keymap.set + + map("n", "rh", gs.reset_hunk, opts "Reset Hunk") + map("n", "ph", gs.preview_hunk, opts "Preview Hunk") + map("n", "gb", gs.blame_line, opts "Blame Line") + end, +} + +return options diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 55dac4d..5a7d5bd 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,8 +1,8 @@ local M = {} +local map = vim.keymap.set -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) - local utils = require "core.utils" local conf = require("nvconfig").ui.lsp -- semanticTokens @@ -14,7 +14,26 @@ M.on_attach = function(client, bufnr) require("nvchad.signature").setup(client, bufnr) end - utils.load_mappings("lspconfig", { buffer = bufnr }) + local function opts(desc) + return { buffer = bufnr, desc = desc } + end + + map("n", "gD", vim.lsp.buf.declaration, opts "Go to declaration | lsp") + map("n", "gd", vim.lsp.buf.definition, opts "Go to definition | lsp") + map("n", "K", vim.lsp.buf.hover, opts "Show hover information | lsp") + map("n", "gi", vim.lsp.buf.implementation, opts "Go to implementation | lsp") + map("n", "", vim.lsp.buf.signature_help, opts "Show signature help | lsp") + map("n", "wa", vim.lsp.buf.add_workspace_folder, opts "Add workspace folder | lsp") + map("n", "wr", vim.lsp.buf.remove_workspace_folder, opts "Remove workspace folder | lsp") + + map("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts "List workspace folders | lsp") + + map("n", "D", vim.lsp.buf.type_definition, opts "Go to type definition | lsp") + map("n", "rn", vim.lsp.buf.rename, opts "Rename symbol | lsp") + map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Code action | lsp") + map("n", "gr", vim.lsp.buf.references, opts "Show references | lsp") end M.capabilities = vim.lsp.protocol.make_client_capabilities() diff --git a/lua/plugins/configs/luasnip.lua b/lua/plugins/configs/luasnip.lua new file mode 100644 index 0000000..f40672d --- /dev/null +++ b/lua/plugins/configs/luasnip.lua @@ -0,0 +1,23 @@ +-- vscode format +require("luasnip.loaders.from_vscode").lazy_load() +require("luasnip.loaders.from_vscode").lazy_load { paths = "your path!" } +require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } + +-- snipmate format +require("luasnip.loaders.from_snipmate").load() +require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } + +-- lua format +require("luasnip.loaders.from_lua").load() +require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } + +vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, +}) diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua deleted file mode 100644 index 9e01f8d..0000000 --- a/lua/plugins/configs/others.lua +++ /dev/null @@ -1,50 +0,0 @@ -local M = {} -local utils = require "core.utils" - -M.blankline = { - indent = { char = "│", highlight = "IblChar" }, - scope = { char = "│", highlight = "IblScopeChar" }, -} - -M.luasnip = function(opts) - require("luasnip").config.set_config(opts) - - -- vscode format - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } - - -- snipmate format - require("luasnip.loaders.from_snipmate").load() - require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } - - -- lua format - require("luasnip.loaders.from_lua").load() - require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } - - vim.api.nvim_create_autocmd("InsertLeave", { - callback = function() - if - require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] - and not require("luasnip").session.jump_active - then - require("luasnip").unlink_current() - end - end, - }) -end - -M.gitsigns = { - signs = { - add = { text = "│" }, - change = { text = "│" }, - delete = { text = "󰍵" }, - topdelete = { text = "‾" }, - changedelete = { text = "~" }, - untracked = { text = "│" }, - }, - on_attach = function(bufnr) - utils.load_mappings("gitsigns", { buffer = bufnr }) - end, -} - -return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 26e9ba0..21f9578 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -48,11 +48,11 @@ local default_plugins = { { "lukas-reineke/indent-blankline.nvim", event = "User FilePost", - opts = function() - return require("plugins.configs.others").blankline - end, + opts = { + indent = { char = "│", highlight = "IblChar" }, + scope = { char = "│", highlight = "IblScopeChar" }, + }, config = function(_, opts) - require("core.utils").load_mappings "blankline" dofile(vim.g.base46_cache .. "blankline") local hooks = require "ibl.hooks" @@ -81,7 +81,7 @@ local default_plugins = { "lewis6991/gitsigns.nvim", event = "User FilePost", opts = function() - return require("plugins.configs.others").gitsigns + return require("plugins.configs.gitsigns") end, config = function(_, opts) dofile(vim.g.base46_cache .. "git") @@ -130,7 +130,8 @@ local default_plugins = { dependencies = "rafamadriz/friendly-snippets", opts = { history = true, updateevents = "TextChanged,TextChangedI" }, config = function(_, opts) - require("plugins.configs.others").luasnip(opts) + require("luasnip").config.set_config(opts) + require "plugins.configs.luasnip" end, }, @@ -178,7 +179,7 @@ local default_plugins = { { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, }, init = function() - require("core.utils").load_mappings "comment" + vim.g.comment_maps = true end, config = function(_, opts) require("Comment").setup(opts) @@ -189,9 +190,6 @@ local default_plugins = { { "nvim-tree/nvim-tree.lua", cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - init = function() - require("core.utils").load_mappings "nvimtree" - end, opts = function() return require "plugins.configs.nvimtree" end, @@ -205,9 +203,6 @@ local default_plugins = { "nvim-telescope/telescope.nvim", dependencies = { "nvim-treesitter/nvim-treesitter" }, cmd = "Telescope", - init = function() - require("core.utils").load_mappings "telescope" - end, opts = function() return require "plugins.configs.telescope" end, @@ -227,9 +222,6 @@ local default_plugins = { { "folke/which-key.nvim", keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, - init = function() - require("core.utils").load_mappings "whichkey" - end, cmd = "WhichKey", config = function(_, opts) dofile(vim.g.base46_cache .. "whichkey") -- 2.40.1 From ce6e3d19a76430227c548947a69550a1ed1eccfa Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 25 Feb 2024 19:42:50 +0530 Subject: [PATCH 36/68] rm useless util function --- lua/core/default_config.lua | 121 --------------------------------- lua/core/mappings.lua | 2 +- lua/core/utils.lua | 14 ---- lua/nvconfig.lua | 129 +++++++++++++++++++++++++++++++++++- 4 files changed, 128 insertions(+), 138 deletions(-) delete mode 100644 lua/core/default_config.lua delete mode 100644 lua/core/utils.lua diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua deleted file mode 100644 index 0ee9467..0000000 --- a/lua/core/default_config.lua +++ /dev/null @@ -1,121 +0,0 @@ -local M = {} - -M.options = { - nvchad_branch = "v3.0", -} - -M.ui = { - ------------------------------- base46 ------------------------------------- - -- hl = highlights - hl_add = {}, - hl_override = {}, - changed_themes = {}, - theme_toggle = { "onedark", "one_light" }, - theme = "onedark", -- default theme - transparency = false, - - -- cmp themeing - cmp = { - icons = true, - lspkind_text = true, - style = "default", -- default/flat_light/flat_dark/atom/atom_colored - }, - - telescope = { style = "borderless" }, -- borderless / bordered - - ------------------------------- nvchad_ui modules ----------------------------- - statusline = { - theme = "default", -- default/vscode/vscode_colored/minimal - -- default/round/block/arrow separators work only for default statusline theme - -- round and block will work for minimal theme only - separator_style = "default", - overriden_modules = nil, - }, - - -- lazyload it when there are 1+ buffers - tabufline = { - show_numbers = false, - enabled = true, - lazyload = true, - overriden_modules = nil, - }, - - -- nvdash (dashboard) - nvdash = { - load_on_startup = false, - - header = { - " ▄ ▄ ", - " ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ ", - " █ ▄ █▄█ ▄▄▄ █ █▄█ █ █ ", - " ▄▄ █▄█▄▄▄█ █▄█▄█▄▄█▄▄█ █ ", - " ▄ █▄▄█ ▄ ▄▄ ▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ", - " █▄▄▄▄ ▄▄▄ █ ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ █ ▄", - "▄ █ █▄█ █▄█ █ █ █▄█ █ █▄█ ▄▄▄ █ █", - "█▄█ ▄ █▄▄█▄▄█ █ ▄▄█ █ ▄ █ █▄█▄█ █", - " █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █▄█▄▄▄█ ", - }, - - buttons = { - { " Find File", "Spc f f", "Telescope find_files" }, - { "󰈚 Recent Files", "Spc f o", "Telescope oldfiles" }, - { "󰈭 Find Word", "Spc f w", "Telescope live_grep" }, - { " Bookmarks", "Spc m a", "Telescope marks" }, - { " Themes", "Spc t h", "Telescope themes" }, - { " Mappings", "Spc c h", "NvCheatsheet" }, - }, - }, - - cheatsheet = { theme = "grid" }, -- simple/grid - - lsp = { - signature = true, - semantic_tokens = false, - }, - - term = { - hl = "Normal:term,WinSeparator:WinSeparator", - sizes = { sp = 0.3, vsp = 0.2 }, - float = { - relative = "editor", - row = 0.3, - col = 0.25, - width = 0.5, - height = 0.4, - border = "single", - }, - behavior = { - auto_insert = true, - }, - }, -} - -M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file - -M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options - -M.mappings = require "core.mappings" - -M.base46 = { - integrations = { - "blankline", - "cmp", - "defaults", - "devicons", - "git", - "lsp", - "mason", - "nvchad_updater", - "nvcheatsheet", - "nvdash", - "nvimtree", - "statusline", - "syntax", - "treesitter", - "tbline", - "telescope", - "whichkey", - }, -} - -return M diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 228c2d5..d955e30 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -149,4 +149,4 @@ if vim.g.blankline_maps then end, { desc = "Jump to current context | blankline" }) end -require "custom.mappings" +pcall(require, "custom.mappings") diff --git a/lua/core/utils.lua b/lua/core/utils.lua deleted file mode 100644 index 34213a4..0000000 --- a/lua/core/utils.lua +++ /dev/null @@ -1,14 +0,0 @@ -local M = {} - -M.load_config = function() - local config = require "core.default_config" - local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] - - if chadrc_path then - config = vim.tbl_deep_extend("force", config, dofile(chadrc_path)) - end - - return config -end - -return M diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index df0d4a4..fe35faf 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -1,2 +1,127 @@ --- check default config at core/default_config.lua -return require("core.utils").load_config() +local M = {} + +M.options = { + nvchad_branch = "v3.0", +} + +M.ui = { + ------------------------------- base46 ------------------------------------- + -- hl = highlights + hl_add = {}, + hl_override = {}, + changed_themes = {}, + theme_toggle = { "onedark", "one_light" }, + theme = "onedark", -- default theme + transparency = false, + + -- cmp themeing + cmp = { + icons = true, + lspkind_text = true, + style = "default", -- default/flat_light/flat_dark/atom/atom_colored + }, + + telescope = { style = "borderless" }, -- borderless / bordered + + ------------------------------- nvchad_ui modules ----------------------------- + statusline = { + theme = "default", -- default/vscode/vscode_colored/minimal + -- default/round/block/arrow separators work only for default statusline theme + -- round and block will work for minimal theme only + separator_style = "default", + overriden_modules = nil, + }, + + -- lazyload it when there are 1+ buffers + tabufline = { + show_numbers = false, + enabled = true, + lazyload = true, + overriden_modules = nil, + }, + + -- nvdash (dashboard) + nvdash = { + load_on_startup = false, + + header = { + " ▄ ▄ ", + " ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ ", + " █ ▄ █▄█ ▄▄▄ █ █▄█ █ █ ", + " ▄▄ █▄█▄▄▄█ █▄█▄█▄▄█▄▄█ █ ", + " ▄ █▄▄█ ▄ ▄▄ ▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ", + " █▄▄▄▄ ▄▄▄ █ ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ █ ▄", + "▄ █ █▄█ █▄█ █ █ █▄█ █ █▄█ ▄▄▄ █ █", + "█▄█ ▄ █▄▄█▄▄█ █ ▄▄█ █ ▄ █ █▄█▄█ █", + " █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █▄█▄▄▄█ ", + }, + + buttons = { + { " Find File", "Spc f f", "Telescope find_files" }, + { "󰈚 Recent Files", "Spc f o", "Telescope oldfiles" }, + { "󰈭 Find Word", "Spc f w", "Telescope live_grep" }, + { " Bookmarks", "Spc m a", "Telescope marks" }, + { " Themes", "Spc t h", "Telescope themes" }, + { " Mappings", "Spc c h", "NvCheatsheet" }, + }, + }, + + cheatsheet = { theme = "grid" }, -- simple/grid + + lsp = { + signature = true, + semantic_tokens = false, + }, + + term = { + hl = "Normal:term,WinSeparator:WinSeparator", + sizes = { sp = 0.3, vsp = 0.2 }, + float = { + relative = "editor", + row = 0.3, + col = 0.25, + width = 0.5, + height = 0.4, + border = "single", + }, + behavior = { + auto_insert = true, + }, + }, +} + +M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file + +M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options + +M.mappings = require "core.mappings" + +M.base46 = { + integrations = { + "blankline", + "cmp", + "defaults", + "devicons", + "git", + "lsp", + "mason", + "nvchad_updater", + "nvcheatsheet", + "nvdash", + "nvimtree", + "statusline", + "syntax", + "treesitter", + "tbline", + "telescope", + "whichkey", + }, +} + +local chadrc_exists, chadrc = pcall(require, "custom.chadrc") + +if chadrc_exists then + M = vim.tbl_deep_extend("force", M, chadrc) +end + +return M -- 2.40.1 From a5fc21b4f182775dbcaca42d80f2ed8eadb22912 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 26 Feb 2024 05:35:22 +0530 Subject: [PATCH 37/68] add some vim* tsparsers in treesitter config --- lua/plugins/configs/treesitter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua index b21b55d..897c4e3 100644 --- a/lua/plugins/configs/treesitter.lua +++ b/lua/plugins/configs/treesitter.lua @@ -1,5 +1,5 @@ local options = { - ensure_installed = { "lua" }, + ensure_installed = { "lua", "vim", "vimdoc" }, highlight = { enable = true, -- 2.40.1 From afd88703588df9e18d102ef9ff4001334d64f861 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 27 Feb 2024 12:31:36 +0530 Subject: [PATCH 38/68] misc clean --- lua/core/init.lua | 9 -- lua/core/mappings.lua | 192 +++++++++++++----------------- lua/plugins/configs/cmp.lua | 13 +- lua/plugins/configs/lspconfig.lua | 6 +- lua/plugins/init.lua | 2 +- 5 files changed, 93 insertions(+), 129 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 8087d6a..59eaf75 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -136,12 +136,3 @@ local new_cmd = vim.api.nvim_create_user_command new_cmd("NvChadUpdate", function() require "nvchad.updater"() end, {}) - ---------------------------------------- globals ------------------------------------------- -vim.g.whichkey_maps = true -vim.g.blankline_maps = true -vim.g.terminal_maps = true -vim.g.telescope_maps = true -vim.g.nvimtree_maps = true -vim.g.comment_maps = true -vim.g.tabufline_maps = true diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index d955e30..74ba012 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -6,7 +6,6 @@ map("i", "", "", { desc = "Move left | general" }) map("i", "", "", { desc = "Move right | general" }) map("i", "", "", { desc = "Move down | general" }) map("i", "", "", { desc = "Move up | general" }) - map("n", "", "noh", { desc = "Clear highlights | general" }) map("n", "", "h", { desc = "Window left | general" }) map("n", "", "l", { desc = "Window right | general" }) @@ -19,134 +18,107 @@ map("n", "rn", "set rnu!", { desc = "Toggle relative number | g map("n", "b", "enew", { desc = "New buffer | general" }) map("n", "ch", "NvCheatsheet", { desc = "Mapping cheatsheet | general" }) +-- global lsp mappings map("n", "fm", function() vim.lsp.buf.format { async = true } end, { desc = "LSP formatting | lsp" }) -vim.keymap.set("n", "lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) -vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) -vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) -vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) +map("n", "lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) +map("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) +map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) +map("n", "q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) + +-- tabufline +map("n", "", function() + require("nvchad.tabufline").tabuflineNext() +end, { desc = "Goto next buffer | tabufline" }) + +map("n", "", function() + require("nvchad.tabufline").tabuflinePrev() +end, { desc = "Goto prev buffer | tabufline" }) + +map("n", "x", function() + require("nvchad.tabufline").close_buffer() +end, { desc = "Close buffer | tabufline" }) + +map("n", "/", function() + require("Comment.api").toggle.linewise.current() +end, { desc = "Toggle comment | comment" }) --- Mappings for terminal mode map( - "t", - "", - vim.api.nvim_replace_termcodes("", true, true, true), - { desc = "Escape terminal mode | general" } + "v", + "/", + ":lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + { desc = "Toggle comment | comment" } ) --- Mappings for M.tabufline -if vim.g.tabufline_maps then - map("n", "", function() - require("nvchad.tabufline").tabuflineNext() - end, { desc = "Goto next buffer | tabufline" }) +map("n", "", "NvimTreeToggle", { desc = "Toggle nvimtree | nvimtree" }) +map("n", "e", "NvimTreeFocus", { desc = "Focus nvimtree | nvimtree" }) - map("n", "", function() - require("nvchad.tabufline").tabuflinePrev() - end, { desc = "Goto prev buffer | tabufline" }) +map("n", "fw", "Telescope live_grep", { desc = "Live grep | telescope" }) +map("n", "fb", "Telescope buffers", { desc = "Find buffers | telescope" }) +map("n", "fh", "Telescope help_tags", { desc = "Help page | telescope" }) +map("n", "fo", "Telescope oldfiles", { desc = "Find oldfiles | telescope" }) +map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "Find in current buffer | telescope" }) +map("n", "cm", "Telescope git_commits", { desc = "Git commits | telescope" }) +map("n", "gt", "Telescope git_status", { desc = "Git status | telescope" }) +map("n", "pt", "Telescope terms", { desc = "Pick hidden term | telescope" }) +map("n", "th", "Telescope themes", { desc = "Nvchad themes | telescope" }) +map("n", "ff", "Telescope find_files", { desc = "Find files | telescope" }) - map("n", "x", function() - require("nvchad.tabufline").close_buffer() - end, { desc = "Close buffer | tabufline" }) -end +map( + "n", + "fa", + "Telescope find_files follow=true no_ignore=true hidden=true", + { desc = "Find all | telescope" } +) -if vim.g.comment_maps then - map("n", "/", function() - require("Comment.api").toggle.linewise.current() - end, { desc = "Toggle comment | comment" }) +-- terminal +map("t", "", "", { desc = "Escape terminal mode | terminal" }) +map("n", "h", function() + require("nvchad.term").new { pos = "sp", size = 0.3 } +end, { desc = "New horizontal term | terminal" }) - map( - "v", - "/", - "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", - { desc = "Toggle comment | comment" } - ) -end +map("n", "v", function() + require("nvchad.term").new { pos = "vsp", size = 0.3 } +end, { desc = "New vertical term | terminal" }) -if vim.g.nvimtree_maps then - map("n", "", "NvimTreeToggle", { desc = "Toggle nvimtree | nvimtree" }) - map("n", "e", "NvimTreeFocus", { desc = "Focus nvimtree | nvimtree" }) -end +map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } +end, { desc = "Toggleable vertical term | terminal" }) -if vim.g.telescope_maps then - map("n", "fw", "Telescope live_grep", { desc = "Live grep | telescope" }) - map("n", "fb", "Telescope buffers", { desc = "Find buffers | telescope" }) - map("n", "fh", "Telescope help_tags", { desc = "Help page | telescope" }) - map("n", "fo", "Telescope oldfiles", { desc = "Find oldfiles | telescope" }) +map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } +end, { desc = "New horizontal term | terminal" }) - map( - "n", - "fz", - "Telescope current_buffer_fuzzy_find", - { desc = "Find in current buffer | telescope" } - ) +map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "float", id = "floatTerm" } +end, { desc = "Toggleable Floating term | terminal" }) - map("n", "cm", "Telescope git_commits", { desc = "Git commits | telescope" }) - map("n", "gt", "Telescope git_status", { desc = "Git status | telescope" }) - map("n", "pt", "Telescope terms", { desc = "Pick hidden term | telescope" }) - map("n", "th", "Telescope themes", { desc = "Nvchad themes | telescope" }) +map("t", "", function() + local win = vim.api.nvim_get_current_win() + vim.api.nvim_win_close(win, true) +end, { desc = "Close term in terminal mode | terminal" }) - map("n", "ff", "Telescope find_files", { desc = "Find files | telescope" }) - map( - "n", - "fa", - "Telescope find_files follow=true no_ignore=true hidden=true", - { desc = "Find all | telescope" } - ) -end +-- whichkey +map("n", "wK", "WhichKey ", { desc = "Which-key all keymaps | whichkey" }) +map("n", "wk", function() + vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") +end, { desc = "Which-key query lookup | whichkey" }) --- Mappings for M.terminal -if vim.g.terminal_maps then - map("n", "h", function() - require("nvchad.term").new { pos = "sp", size = 0.3 } - end, { desc = "New horizontal term | terminal" }) +map("n", "cc", function() + local config = { scope = {} } + config.scope.exclude = { language = {}, node_type = {} } + config.scope.include = { node_type = {} } + local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) - map("n", "v", function() - require("nvchad.term").new { pos = "vsp", size = 0.3 } - end, { desc = "New vertical term | terminal" }) - - map({ "n", "t" }, "", function() - require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } - end, { desc = "Toggleable vertical term | terminal" }) - - map({ "n", "t" }, "", function() - require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } - end, { desc = "New horizontal term | terminal" }) - - map({ "n", "t" }, "", function() - require("nvchad.term").toggle { pos = "float", id = "floatTerm" } - end, { desc = "Toggleable Floating term | terminal" }) - - map("t", "", function() - local win = vim.api.nvim_get_current_win() - vim.api.nvim_win_close(win, true) - end, { desc = "Close term in terminal mode | terminal" }) -end - -if vim.g.whichkey_maps then - map("n", "wK", ":WhichKey ", { desc = "Which-key all keymaps | whichkey" }) - - map("n", "wk", function() - vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") - end, { desc = "Which-key query lookup | whichkey" }) -end - -if vim.g.blankline_maps then - map("n", "cc", function() - local config = { scope = {} } - config.scope.exclude = { language = {}, node_type = {} } - config.scope.include = { node_type = {} } - local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) - - if node then - local start_row, _, end_row, _ = node:range() - if start_row ~= end_row then - vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) - vim.api.nvim_feedkeys("_", "n", true) - end + if node then + local start_row, _, end_row, _ = node:range() + if start_row ~= end_row then + vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) + vim.api.nvim_feedkeys("_", "n", true) end - end, { desc = "Jump to current context | blankline" }) -end + end +end, { desc = "Jump to current context | blankline" }) pcall(require, "custom.mappings") diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index 9b669a8..46f8864 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -75,10 +75,12 @@ local options = { [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Insert, select = true, }, + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -87,10 +89,8 @@ local options = { else fallback() end - end, { - "i", - "s", - }), + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() @@ -99,10 +99,7 @@ local options = { else fallback() end - end, { - "i", - "s", - }), + end, { "i", "s" }), }, sources = { { name = "nvim_lsp" }, diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 5a7d5bd..d260572 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -31,7 +31,11 @@ M.on_attach = function(client, bufnr) end, opts "List workspace folders | lsp") map("n", "D", vim.lsp.buf.type_definition, opts "Go to type definition | lsp") - map("n", "rn", vim.lsp.buf.rename, opts "Rename symbol | lsp") + + map("n", "ra", function() + require "nvchad.renamer"() + end, opts "NvRename symbol | lsp") + map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Code action | lsp") map("n", "gr", vim.lsp.buf.references, opts "Show references | lsp") end diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 21f9578..c1ba077 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -81,7 +81,7 @@ local default_plugins = { "lewis6991/gitsigns.nvim", event = "User FilePost", opts = function() - return require("plugins.configs.gitsigns") + return require "plugins.configs.gitsigns" end, config = function(_, opts) dofile(vim.g.base46_cache .. "git") -- 2.40.1 From 21753150d4ccac61e6a16e3f8062f79b89f89df8 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 27 Feb 2024 19:37:57 +0530 Subject: [PATCH 39/68] misc clean 2 --- lua/core/mappings.lua | 111 ++++++++++++++++-------------- lua/plugins/configs/lspconfig.lua | 24 +++---- 2 files changed, 73 insertions(+), 62 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 74ba012..cb1a279 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,111 +1,122 @@ local map = vim.keymap.set -map("i", "", "^i", { desc = "Beginning of line | general" }) -map("i", "", "", { desc = "End of line | general" }) -map("i", "", "", { desc = "Move left | general" }) -map("i", "", "", { desc = "Move right | general" }) -map("i", "", "", { desc = "Move down | general" }) -map("i", "", "", { desc = "Move up | general" }) -map("n", "", "noh", { desc = "Clear highlights | general" }) -map("n", "", "h", { desc = "Window left | general" }) -map("n", "", "l", { desc = "Window right | general" }) -map("n", "", "j", { desc = "Window down | general" }) -map("n", "", "k", { desc = "Window up | general" }) -map("n", "", "w", { desc = "Save file | general" }) -map("n", "", "%y+", { desc = "Copy whole file | general" }) -map("n", "n", "set nu!", { desc = "Toggle line number | general" }) -map("n", "rn", "set rnu!", { desc = "Toggle relative number | general" }) -map("n", "b", "enew", { desc = "New buffer | general" }) -map("n", "ch", "NvCheatsheet", { desc = "Mapping cheatsheet | general" }) +map("i", "", "^i", { desc = "Move Beginning of line" }) +map("i", "", "", { desc = "Move End of line" }) +map("i", "", "", { desc = "Move Left" }) +map("i", "", "", { desc = "Move Right" }) +map("i", "", "", { desc = "Move Down" }) +map("i", "", "", { desc = "Move Up" }) + +map("n", "", "noh", { desc = "General Clear highlights" }) + +map("n", "", "h", { desc = "Switch Window left" }) +map("n", "", "l", { desc = "Switch Window right" }) +map("n", "", "j", { desc = "Switch Window down" }) +map("n", "", "k", { desc = "Switch Window up" }) + +map("n", "", "w", { desc = "File Save" }) +map("n", "", "%y+", { desc = "File Copy whole" }) + +map("n", "n", "set nu!", { desc = "Toggle Line number" }) +map("n", "rn", "set rnu!", { desc = "Toggle Relative number" }) +map("n", "ch", "NvCheatsheet", { desc = "Toggle NvCheatsheet" }) -- global lsp mappings map("n", "fm", function() vim.lsp.buf.format { async = true } -end, { desc = "LSP formatting | lsp" }) +end, { desc = "Lsp formatting" }) -map("n", "lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) -map("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) -map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) -map("n", "q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) +map("n", "lf", vim.diagnostic.open_float, { desc = "Lsp floating diagnostics" }) +map("n", "[d", vim.diagnostic.goto_prev, { desc = "Lsp prev diagnostic" }) +map("n", "]d", vim.diagnostic.goto_next, { desc = "Lsp next diagnostic" }) +map("n", "q", vim.diagnostic.setloclist, { desc = "Lsp diagnostic loclist" }) -- tabufline +map("n", "b", "enew", { desc = "Buffer New" }) + map("n", "", function() require("nvchad.tabufline").tabuflineNext() -end, { desc = "Goto next buffer | tabufline" }) +end, { desc = "Buffer Goto next" }) map("n", "", function() require("nvchad.tabufline").tabuflinePrev() -end, { desc = "Goto prev buffer | tabufline" }) +end, { desc = "Buffer Goto prev" }) map("n", "x", function() require("nvchad.tabufline").close_buffer() -end, { desc = "Close buffer | tabufline" }) +end, { desc = "Buffer Close" }) +-- Comment map("n", "/", function() require("Comment.api").toggle.linewise.current() -end, { desc = "Toggle comment | comment" }) +end, { desc = "Comment Toggle" }) map( "v", "/", ":lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", - { desc = "Toggle comment | comment" } + { desc = "Comment Toggle" } ) -map("n", "", "NvimTreeToggle", { desc = "Toggle nvimtree | nvimtree" }) -map("n", "e", "NvimTreeFocus", { desc = "Focus nvimtree | nvimtree" }) +-- nvimtree +map("n", "", "NvimTreeToggle", { desc = "Nvimtree Toggle window" }) +map("n", "e", "NvimTreeFocus", { desc = "Nvimtree Focus window" }) -map("n", "fw", "Telescope live_grep", { desc = "Live grep | telescope" }) -map("n", "fb", "Telescope buffers", { desc = "Find buffers | telescope" }) -map("n", "fh", "Telescope help_tags", { desc = "Help page | telescope" }) -map("n", "fo", "Telescope oldfiles", { desc = "Find oldfiles | telescope" }) -map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "Find in current buffer | telescope" }) -map("n", "cm", "Telescope git_commits", { desc = "Git commits | telescope" }) -map("n", "gt", "Telescope git_status", { desc = "Git status | telescope" }) -map("n", "pt", "Telescope terms", { desc = "Pick hidden term | telescope" }) -map("n", "th", "Telescope themes", { desc = "Nvchad themes | telescope" }) -map("n", "ff", "Telescope find_files", { desc = "Find files | telescope" }) +-- telescope +map("n", "fw", "Telescope live_grep", { desc = "Telescope Live grep" }) +map("n", "fb", "Telescope buffers", { desc = "Telescope Find buffers" }) +map("n", "fh", "Telescope help_tags", { desc = "Telescope Help page" }) +map("n", "fo", "Telescope oldfiles", { desc = "Telescope Find oldfiles" }) +map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "Telescope Find in current buffer" }) +map("n", "cm", "Telescope git_commits", { desc = "Telescope Git commits" }) +map("n", "gt", "Telescope git_status", { desc = "Telescope Git status" }) +map("n", "pt", "Telescope terms", { desc = "Telescope Pick hidden term" }) +map("n", "th", "Telescope themes", { desc = "Telescope Nvchad themes" }) +map("n", "ff", "Telescope find_files", { desc = "Telescope Find files" }) map( "n", "fa", "Telescope find_files follow=true no_ignore=true hidden=true", - { desc = "Find all | telescope" } + { desc = "Telescope Find all files" } ) -- terminal -map("t", "", "", { desc = "Escape terminal mode | terminal" }) +map("t", "", "", { desc = "Terminal Escape terminal mode" }) + map("n", "h", function() require("nvchad.term").new { pos = "sp", size = 0.3 } -end, { desc = "New horizontal term | terminal" }) +end, { desc = "Terminal New horizontal term" }) map("n", "v", function() require("nvchad.term").new { pos = "vsp", size = 0.3 } -end, { desc = "New vertical term | terminal" }) +end, { desc = "Terminal New vertical term" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } -end, { desc = "Toggleable vertical term | terminal" }) +end, { desc = "Terminal Toggleable vertical term" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } -end, { desc = "New horizontal term | terminal" }) +end, { desc = "Terminal New horizontal term" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "float", id = "floatTerm" } -end, { desc = "Toggleable Floating term | terminal" }) +end, { desc = "Terminal Toggle Floating term" }) map("t", "", function() local win = vim.api.nvim_get_current_win() vim.api.nvim_win_close(win, true) -end, { desc = "Close term in terminal mode | terminal" }) +end, { desc = "Terminal Close term in terminal mode" }) -- whichkey -map("n", "wK", "WhichKey ", { desc = "Which-key all keymaps | whichkey" }) +map("n", "wK", "WhichKey ", { desc = "Whichkey all keymaps" }) + map("n", "wk", function() vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") -end, { desc = "Which-key query lookup | whichkey" }) +end, { desc = "Whichkey query lookup" }) +-- blankline map("n", "cc", function() local config = { scope = {} } config.scope.exclude = { language = {}, node_type = {} } @@ -119,6 +130,6 @@ map("n", "cc", function() vim.api.nvim_feedkeys("_", "n", true) end end -end, { desc = "Jump to current context | blankline" }) +end, { desc = "Blankline Jump to current context" }) pcall(require, "custom.mappings") diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index d260572..3eb71a1 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -18,26 +18,26 @@ M.on_attach = function(client, bufnr) return { buffer = bufnr, desc = desc } end - map("n", "gD", vim.lsp.buf.declaration, opts "Go to declaration | lsp") - map("n", "gd", vim.lsp.buf.definition, opts "Go to definition | lsp") - map("n", "K", vim.lsp.buf.hover, opts "Show hover information | lsp") - map("n", "gi", vim.lsp.buf.implementation, opts "Go to implementation | lsp") - map("n", "", vim.lsp.buf.signature_help, opts "Show signature help | lsp") - map("n", "wa", vim.lsp.buf.add_workspace_folder, opts "Add workspace folder | lsp") - map("n", "wr", vim.lsp.buf.remove_workspace_folder, opts "Remove workspace folder | lsp") + map("n", "gD", vim.lsp.buf.declaration, opts "Lsp Go to declaration") + map("n", "gd", vim.lsp.buf.definition, opts "Lsp Go to definition") + map("n", "K", vim.lsp.buf.hover, opts "Lsp hover information") + map("n", "gi", vim.lsp.buf.implementation, opts "Lsp Go to implementation") + map("n", "", vim.lsp.buf.signature_help, opts "Lsp Show signature help") + map("n", "wa", vim.lsp.buf.add_workspace_folder, opts "Lsp Add workspace folder") + map("n", "wr", vim.lsp.buf.remove_workspace_folder, opts "Lsp Remove workspace folder") map("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, opts "List workspace folders | lsp") + end, opts "Lsp List workspace folders") - map("n", "D", vim.lsp.buf.type_definition, opts "Go to type definition | lsp") + map("n", "D", vim.lsp.buf.type_definition, opts "Lsp Go to type definition") map("n", "ra", function() require "nvchad.renamer"() - end, opts "NvRename symbol | lsp") + end, opts "Lsp NvRenamer") - map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Code action | lsp") - map("n", "gr", vim.lsp.buf.references, opts "Show references | lsp") + map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Lsp Code action") + map("n", "gr", vim.lsp.buf.references, opts "Lsp Show references") end M.capabilities = vim.lsp.protocol.make_client_capabilities() -- 2.40.1 From cd10647dd6260d138ace4337ffcc2dec8fe8db05 Mon Sep 17 00:00:00 2001 From: siduck Date: Wed, 28 Feb 2024 20:13:34 +0530 Subject: [PATCH 40/68] add mason bootstrap in main bootstrap file only --- lua/core/bootstrap.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index 50a8484..ee3f37d 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -33,7 +33,15 @@ M.lazy = function(install_path) require "plugins" -- mason packages & show post_bootstrap screen - require "nvchad.post_install"() + vim.cmd "MasonInstallAll" + local lastpkg = vim.g.mason_binaries_list[#vim.g.mason_binaries_list] + + -- Keep track of which mason pkgs get installed + require("mason-registry"):on("package:install:success", function(pkg) + if tostring(pkg) == "Package(name=" .. lastpkg .. ")" then + print "All done! Now read nvchad.com " + end + end) end M.gen_chadrc_template = function() -- 2.40.1 From adf67560cebeb9501a97c580cebc3759b92ab61c Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 29 Feb 2024 08:00:50 +0530 Subject: [PATCH 41/68] misc --- lua/nvconfig.lua | 2 -- lua/plugins/init.lua | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index fe35faf..bfaebc7 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -94,8 +94,6 @@ M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options -M.mappings = require "core.mappings" - M.base46 = { integrations = { "blankline", diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index c1ba077..645c09b 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -14,7 +14,7 @@ local default_plugins = { { "NvChad/ui", - branch = "v3.0", + branch = "clean", lazy = false, config = function() require "nvchad" -- 2.40.1 From 5d69a0d0f9f9e0b811a734d0adf1c751d3f2ce00 Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 29 Feb 2024 21:50:47 +0530 Subject: [PATCH 42/68] rm un-needed dofile call --- init.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 44b5eab..9e53d71 100644 --- a/init.lua +++ b/init.lua @@ -1,10 +1,6 @@ require "core" -local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1] - -if custom_init_path then - dofile(custom_init_path) -end +pcall(require, 'custom') local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" -- 2.40.1 From 7dc8c6d0b2a4b1bfde745050a3045c91b15f2def Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 29 Feb 2024 22:03:20 +0530 Subject: [PATCH 43/68] initial starter dir structure; --- init.lua | 35 ++- lua/{plugins => }/configs/cmp.lua | 0 .../lazy_nvim.lua => configs/lazy.lua} | 0 lua/{plugins => }/configs/lspconfig.lua | 0 lua/core/{init.lua => autocmds.lua} | 61 ----- lua/core/bootstrap.lua | 23 -- lua/core/options.lua | 60 +++++ lua/nvconfig.lua | 6 - lua/plugins/cmp.lua | 64 +++++ lua/plugins/configs/luasnip.lua | 23 -- lua/plugins/configs/mason.lua | 28 -- lua/plugins/configs/telescope.lua | 63 ----- lua/plugins/configs/treesitter.lua | 12 - lua/plugins/{configs => }/gitsigns.lua | 10 +- lua/plugins/init.lua | 239 ------------------ lua/plugins/lsp.lua | 7 + lua/plugins/mason.lua | 45 ++++ lua/plugins/{configs => }/nvimtree.lua | 10 +- lua/plugins/telescope.lua | 80 ++++++ lua/plugins/treesitter.lua | 23 ++ lua/plugins/ui.lua | 89 +++++++ 21 files changed, 403 insertions(+), 475 deletions(-) rename lua/{plugins => }/configs/cmp.lua (100%) rename lua/{plugins/configs/lazy_nvim.lua => configs/lazy.lua} (100%) rename lua/{plugins => }/configs/lspconfig.lua (100%) rename lua/core/{init.lua => autocmds.lua} (62%) create mode 100644 lua/core/options.lua create mode 100644 lua/plugins/cmp.lua delete mode 100644 lua/plugins/configs/luasnip.lua delete mode 100644 lua/plugins/configs/mason.lua delete mode 100644 lua/plugins/configs/telescope.lua delete mode 100644 lua/plugins/configs/treesitter.lua rename lua/plugins/{configs => }/gitsigns.lua (75%) delete mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/mason.lua rename lua/plugins/{configs => }/nvimtree.lua (87%) create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/ui.lua diff --git a/init.lua b/init.lua index 9e53d71..2e98038 100644 --- a/init.lua +++ b/init.lua @@ -1,19 +1,18 @@ -require "core" +require "core.options" +require "core.autocmds" +-- +-- local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +-- +-- -- bootstrap lazy.nvim! +-- if not vim.loop.fs_stat(lazypath) then +-- require("core.bootstrap").gen_chadrc_template() +-- require("core.bootstrap").lazy(lazypath) +-- end +-- +-- dofile(vim.g.base46_cache .. "defaults") +-- vim.opt.rtp:prepend(lazypath) -pcall(require, 'custom') - -local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" - --- bootstrap lazy.nvim! -if not vim.loop.fs_stat(lazypath) then - require("core.bootstrap").gen_chadrc_template() - require("core.bootstrap").lazy(lazypath) -end - -dofile(vim.g.base46_cache .. "defaults") -vim.opt.rtp:prepend(lazypath) -require "plugins" - -vim.schedule(function() - require "core.mappings" -end, 0) +-- require("lazy").setup({ +-- { import = "plugins" }, +-- { import = "custom.plugins" }, +-- }, require "configs.lazy") diff --git a/lua/plugins/configs/cmp.lua b/lua/configs/cmp.lua similarity index 100% rename from lua/plugins/configs/cmp.lua rename to lua/configs/cmp.lua diff --git a/lua/plugins/configs/lazy_nvim.lua b/lua/configs/lazy.lua similarity index 100% rename from lua/plugins/configs/lazy_nvim.lua rename to lua/configs/lazy.lua diff --git a/lua/plugins/configs/lspconfig.lua b/lua/configs/lspconfig.lua similarity index 100% rename from lua/plugins/configs/lspconfig.lua rename to lua/configs/lspconfig.lua diff --git a/lua/core/init.lua b/lua/core/autocmds.lua similarity index 62% rename from lua/core/init.lua rename to lua/core/autocmds.lua index 59eaf75..fbc0f36 100644 --- a/lua/core/init.lua +++ b/lua/core/autocmds.lua @@ -1,64 +1,3 @@ -local opt = vim.opt -local g = vim.g - --------------------------------------- globals ----------------------------------------- -g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" -g.toggle_theme_icon = "  " - --------------------------------------- options ------------------------------------------ -opt.laststatus = 3 -- global statusline -opt.showmode = false - -opt.clipboard = "unnamedplus" -opt.cursorline = true -opt.cursorlineopt = "number" - --- Indenting -opt.expandtab = true -opt.shiftwidth = 2 -opt.smartindent = true -opt.tabstop = 2 -opt.softtabstop = 2 - -opt.fillchars = { eob = " " } -opt.ignorecase = true -opt.smartcase = true -opt.mouse = "a" - --- Numbers -opt.number = true -opt.numberwidth = 2 -opt.ruler = false - --- disable nvim intro -opt.shortmess:append "sI" - -opt.signcolumn = "yes" -opt.splitbelow = true -opt.splitright = true -opt.termguicolors = true -opt.timeoutlen = 400 -opt.undofile = true - --- interval for writing swap file to disk, also used by gitsigns -opt.updatetime = 250 - --- go to previous/next line with h,l,left arrow and right arrow --- when cursor reaches end/beginning of line -opt.whichwrap:append "<>[]hl" - -g.mapleader = " " - --- disable some default providers -for _, provider in ipairs { "node", "perl", "python3", "ruby" } do - vim.g["loaded_" .. provider .. "_provider"] = 0 -end - --- add binaries installed by mason.nvim to path -local is_windows = vim.loop.os_uname().sysname == "Windows_NT" -vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH - --------------------------------------- autocmds ------------------------------------------ local autocmd = vim.api.nvim_create_autocmd -- dont list quickfix buffers diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index ee3f37d..2871609 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -44,27 +44,4 @@ M.lazy = function(install_path) end) end -M.gen_chadrc_template = function() - local path = fn.stdpath "config" .. "/lua/custom" - - if fn.isdirectory(path) ~= 1 then - local input = vim.env.NVCHAD_EXAMPLE_CONFIG or fn.input "Do you want to install example custom config? (y/N): " - - if input:lower() == "y" then - M.echo "Cloning example custom config repo..." - shell_call { "git", "clone", "--depth", "1", "https://github.com/NvChad/example_config", path } - fn.delete(path .. "/.git", "rf") - else - -- use very minimal chadrc - fn.mkdir(path, "p") - - local file = io.open(path .. "/chadrc.lua", "w") - if file then - file:write "---@type ChadrcConfig\nlocal M = {}\n\nM.ui = { theme = 'onedark' }\n\nreturn M" - file:close() - end - end - end -end - return M diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..bd7f2be --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,60 @@ +local opt = vim.opt +local g = vim.g + +-------------------------------------- globals ----------------------------------------- +g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" +g.toggle_theme_icon = "  " + +-------------------------------------- options ------------------------------------------ +opt.laststatus = 3 -- global statusline +opt.showmode = false + +opt.clipboard = "unnamedplus" +opt.cursorline = true +opt.cursorlineopt = "number" + +-- Indenting +opt.expandtab = true +opt.shiftwidth = 2 +opt.smartindent = true +opt.tabstop = 2 +opt.softtabstop = 2 + +opt.fillchars = { eob = " " } +opt.ignorecase = true +opt.smartcase = true +opt.mouse = "a" + +-- Numbers +opt.number = true +opt.numberwidth = 2 +opt.ruler = false + +-- disable nvim intro +opt.shortmess:append "sI" + +opt.signcolumn = "yes" +opt.splitbelow = true +opt.splitright = true +opt.termguicolors = true +opt.timeoutlen = 400 +opt.undofile = true + +-- interval for writing swap file to disk, also used by gitsigns +opt.updatetime = 250 + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +opt.whichwrap:append "<>[]hl" + +g.mapleader = " " + +-- disable some default providers +vim.g["loaded_node_provider"] = 0 +vim.g["loaded_python3_provider"] = 0 +vim.g["loaded_perl_provider"] = 0 +vim.g["loaded_ruby_provider"] = 0 + +-- add binaries installed by mason.nvim to path +local is_windows = vim.loop.os_uname().sysname == "Windows_NT" +vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index bfaebc7..5066ed2 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -1,9 +1,5 @@ local M = {} -M.options = { - nvchad_branch = "v3.0", -} - M.ui = { ------------------------------- base46 ------------------------------------- -- hl = highlights @@ -92,8 +88,6 @@ M.ui = { M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file -M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options - M.base46 = { integrations = { "blankline", diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..978d7e7 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,64 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + + opts = function() + return require "configs.cmp" + end, + + config = function(_, opts) + require("cmp").setup(opts) + end, + + dependencies = { + { + -- snippet plugin + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", + opts = { history = true, updateevents = "TextChanged,TextChangedI" }, + config = function(_, opts) + require("luasnip").config.set_config(opts) + + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_snipmate").load() + require("luasnip.loaders.from_lua").load() + + vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, + }) + end, + }, + + -- autopairing of (){}[] etc + { + "windwp/nvim-autopairs", + opts = { + fast_wrap = {}, + disable_filetype = { "TelescopePrompt", "vim" }, + }, + config = function(_, opts) + require("nvim-autopairs").setup(opts) + + -- setup cmp for autopairs + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, + }, + + -- cmp sources plugins + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + }, +} diff --git a/lua/plugins/configs/luasnip.lua b/lua/plugins/configs/luasnip.lua deleted file mode 100644 index f40672d..0000000 --- a/lua/plugins/configs/luasnip.lua +++ /dev/null @@ -1,23 +0,0 @@ --- vscode format -require("luasnip.loaders.from_vscode").lazy_load() -require("luasnip.loaders.from_vscode").lazy_load { paths = "your path!" } -require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } - --- snipmate format -require("luasnip.loaders.from_snipmate").load() -require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } - --- lua format -require("luasnip.loaders.from_lua").load() -require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } - -vim.api.nvim_create_autocmd("InsertLeave", { - callback = function() - if - require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] - and not require("luasnip").session.jump_active - then - require("luasnip").unlink_current() - end - end, -}) diff --git a/lua/plugins/configs/mason.lua b/lua/plugins/configs/mason.lua deleted file mode 100644 index 3692a15..0000000 --- a/lua/plugins/configs/mason.lua +++ /dev/null @@ -1,28 +0,0 @@ -local options = { - ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim - - PATH = "skip", - - ui = { - icons = { - package_pending = " ", - package_installed = "󰄳 ", - package_uninstalled = " 󰚌", - }, - - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - cancel_installation = "", - }, - }, - - max_concurrent_installers = 10, -} - -return options diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua deleted file mode 100644 index 0df500e..0000000 --- a/lua/plugins/configs/telescope.lua +++ /dev/null @@ -1,63 +0,0 @@ -local options = { - defaults = { - vimgrep_arguments = { - "rg", - "-L", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { - mirror = false, - }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, - }, - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = { "node_modules" }, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "truncate" }, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - color_devicons = true, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - mappings = { - n = { ["q"] = require("telescope.actions").close }, - }, - }, - - extensions_list = { "themes", "terms" }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "smart_case", - }, - }, -} - -return options diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua deleted file mode 100644 index 897c4e3..0000000 --- a/lua/plugins/configs/treesitter.lua +++ /dev/null @@ -1,12 +0,0 @@ -local options = { - ensure_installed = { "lua", "vim", "vimdoc" }, - - highlight = { - enable = true, - use_languagetree = true, - }, - - indent = { enable = true }, -} - -return options diff --git a/lua/plugins/configs/gitsigns.lua b/lua/plugins/gitsigns.lua similarity index 75% rename from lua/plugins/configs/gitsigns.lua rename to lua/plugins/gitsigns.lua index 27f3105..8f9fb6c 100644 --- a/lua/plugins/configs/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -23,4 +23,12 @@ local options = { end, } -return options +return { + "lewis6991/gitsigns.nvim", + event = "User FilePost", + opts = options, + config = function(_, opts) + dofile(vim.g.base46_cache .. "git") + require("gitsigns").setup(opts) + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua deleted file mode 100644 index 645c09b..0000000 --- a/lua/plugins/init.lua +++ /dev/null @@ -1,239 +0,0 @@ --- All plugins have lazy=true by default,to load a plugin on startup just lazy=false --- List of all default plugins & their definitions -local default_plugins = { - - "nvim-lua/plenary.nvim", - - { - "NvChad/base46", - branch = "v3.0", - build = function() - require("base46").load_all_highlights() - end, - }, - - { - "NvChad/ui", - branch = "clean", - lazy = false, - config = function() - require "nvchad" - end, - }, - - { - "NvChad/nvim-colorizer.lua", - event = "User FilePost", - config = function(_, opts) - require("colorizer").setup(opts) - - -- execute colorizer as soon as possible - vim.defer_fn(function() - require("colorizer").attach_to_buffer(0) - end, 0) - end, - }, - - { - "nvim-tree/nvim-web-devicons", - opts = function() - return { override = require "nvchad.icons.devicons" } - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "devicons") - require("nvim-web-devicons").setup(opts) - end, - }, - - { - "lukas-reineke/indent-blankline.nvim", - event = "User FilePost", - opts = { - indent = { char = "│", highlight = "IblChar" }, - scope = { char = "│", highlight = "IblScopeChar" }, - }, - config = function(_, opts) - dofile(vim.g.base46_cache .. "blankline") - - local hooks = require "ibl.hooks" - hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) - require("ibl").setup(opts) - end, - }, - - { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPost", "BufNewFile" }, - cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, - build = ":TSUpdate", - opts = function() - return require "plugins.configs.treesitter" - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "syntax") - dofile(vim.g.base46_cache .. "treesitter") - require("nvim-treesitter.configs").setup(opts) - end, - }, - - -- git stuff - { - "lewis6991/gitsigns.nvim", - event = "User FilePost", - opts = function() - return require "plugins.configs.gitsigns" - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "git") - require("gitsigns").setup(opts) - end, - }, - - -- lsp stuff - { - "williamboman/mason.nvim", - cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" }, - opts = function() - return require "plugins.configs.mason" - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "mason") - require("mason").setup(opts) - - -- custom nvchad cmd to install all mason binaries listed - vim.api.nvim_create_user_command("MasonInstallAll", function() - if opts.ensure_installed and #opts.ensure_installed > 0 then - vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) - end - end, {}) - - vim.g.mason_binaries_list = opts.ensure_installed - end, - }, - - { - "neovim/nvim-lspconfig", - event = "User FilePost", - config = function() - require("plugins.configs.lspconfig").defaults() - end, - }, - - -- load luasnips + cmp related in insert mode only - { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - { - -- snippet plugin - "L3MON4D3/LuaSnip", - dependencies = "rafamadriz/friendly-snippets", - opts = { history = true, updateevents = "TextChanged,TextChangedI" }, - config = function(_, opts) - require("luasnip").config.set_config(opts) - require "plugins.configs.luasnip" - end, - }, - - -- autopairing of (){}[] etc - { - "windwp/nvim-autopairs", - opts = { - fast_wrap = {}, - disable_filetype = { "TelescopePrompt", "vim" }, - }, - config = function(_, opts) - require("nvim-autopairs").setup(opts) - - -- setup cmp for autopairs - local cmp_autopairs = require "nvim-autopairs.completion.cmp" - require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end, - }, - - -- cmp sources plugins - { - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - }, - }, - opts = function() - return require "plugins.configs.cmp" - end, - config = function(_, opts) - require("cmp").setup(opts) - end, - }, - - { - "numToStr/Comment.nvim", - keys = { - { "gcc", mode = "n", desc = "Comment toggle current line" }, - { "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, - { "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, - { "gbc", mode = "n", desc = "Comment toggle current block" }, - { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, - { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, - }, - init = function() - vim.g.comment_maps = true - end, - config = function(_, opts) - require("Comment").setup(opts) - end, - }, - - -- file managing , picker etc - { - "nvim-tree/nvim-tree.lua", - cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - opts = function() - return require "plugins.configs.nvimtree" - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "nvimtree") - require("nvim-tree").setup(opts) - end, - }, - - { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - cmd = "Telescope", - opts = function() - return require "plugins.configs.telescope" - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "telescope") - local telescope = require "telescope" - telescope.setup(opts) - - -- load extensions - for _, ext in ipairs(opts.extensions_list) do - telescope.load_extension(ext) - end - end, - }, - - -- Only load whichkey after all the gui - { - "folke/which-key.nvim", - keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, - cmd = "WhichKey", - config = function(_, opts) - dofile(vim.g.base46_cache .. "whichkey") - require("which-key").setup(opts) - end, - }, -} - -local config = require "nvconfig" - -if #config.plugins > 0 then - table.insert(default_plugins, { import = config.plugins }) -end - -require("lazy").setup(default_plugins, config.lazy_nvim) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..b55658f --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,7 @@ +return { + "neovim/nvim-lspconfig", + event = "User FilePost", + config = function() + require("configs.lspconfig").defaults() + end, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..9f8248f --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,45 @@ +local options = { + ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + + PATH = "skip", + + ui = { + icons = { + package_pending = " ", + package_installed = "󰄳 ", + package_uninstalled = " 󰚌", + }, + + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + + max_concurrent_installers = 10, +} + +return { + "williamboman/mason.nvim", + cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" }, + opts = options, + config = function(_, opts) + dofile(vim.g.base46_cache .. "mason") + require("mason").setup(opts) + + -- custom nvchad cmd to install all mason binaries listed + vim.api.nvim_create_user_command("MasonInstallAll", function() + if opts.ensure_installed and #opts.ensure_installed > 0 then + vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) + end + end, {}) + + vim.g.mason_binaries_list = opts.ensure_installed + end, +} diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/nvimtree.lua similarity index 87% rename from lua/plugins/configs/nvimtree.lua rename to lua/plugins/nvimtree.lua index c54248e..cf8bdb0 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/nvimtree.lua @@ -74,4 +74,12 @@ local options = { }, } -return options +return { + "nvim-tree/nvim-tree.lua", + cmd = { "NvimTreeToggle", "NvimTreeFocus" }, + opts = options, + config = function(_, opts) + dofile(vim.g.base46_cache .. "nvimtree") + require("nvim-tree").setup(opts) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..c441438 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,80 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + cmd = "Telescope", + opts = function() + local options = { + defaults = { + vimgrep_arguments = { + "rg", + "-L", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = false, + }, + width = 0.87, + height = 0.80, + preview_cutoff = 120, + }, + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = { "node_modules" }, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + mappings = { + n = { ["q"] = require("telescope.actions").close }, + }, + }, + + extensions_list = { "themes", "terms" }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + }, + } + + return options + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "telescope") + local telescope = require "telescope" + telescope.setup(opts) + + -- load extensions + for _, ext in ipairs(opts.extensions_list) do + telescope.load_extension(ext) + end + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..d940c95 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,23 @@ +local config = { + ensure_installed = { "lua", "vim", "vimdoc" }, + + highlight = { + enable = true, + use_languagetree = true, + }, + + indent = { enable = true }, +} + +return { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPost", "BufNewFile" }, + cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, + build = ":TSUpdate", + opts = config, + config = function(_, opts) + dofile(vim.g.base46_cache .. "syntax") + dofile(vim.g.base46_cache .. "treesitter") + require("nvim-treesitter.configs").setup(opts) + end, +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..6366f45 --- /dev/null +++ b/lua/plugins/ui.lua @@ -0,0 +1,89 @@ +return { + "nvim-lua/plenary.nvim", + + { + "NvChad/base46", + -- branch = "v3.0", + dir = "~/projects/base46/", + build = function() + require("base46").load_all_highlights() + end, + }, + + { + "NvChad/ui", + -- branch = "v3.0", + dir = "~/projects/ui/", + lazy = false, + config = function() + require "nvchad" + end, + }, + + { + "NvChad/nvim-colorizer.lua", + event = "User FilePost", + config = function(_, opts) + require("colorizer").setup(opts) + + -- execute colorizer as soon as possible + vim.defer_fn(function() + require("colorizer").attach_to_buffer(0) + end, 0) + end, + }, + + { + "nvim-tree/nvim-web-devicons", + opts = function() + return { override = require "nvchad.icons.devicons" } + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "devicons") + require("nvim-web-devicons").setup(opts) + end, + }, + + { + "folke/which-key.nvim", + keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, + cmd = "WhichKey", + config = function(_, opts) + dofile(vim.g.base46_cache .. "whichkey") + require("which-key").setup(opts) + end, + }, + + { + "numToStr/Comment.nvim", + keys = { + { "gcc", mode = "n", desc = "Comment toggle current line" }, + { "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, + { "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, + { "gbc", mode = "n", desc = "Comment toggle current block" }, + { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, + { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, + }, + config = function(_, opts) + require("Comment").setup(opts) + end, + }, + + { + "lukas-reineke/indent-blankline.nvim", + event = "User FilePost", + + opts = { + indent = { char = "│", highlight = "IblChar" }, + scope = { char = "│", highlight = "IblScopeChar" }, + }, + + config = function(_, opts) + dofile(vim.g.base46_cache .. "blankline") + + local hooks = require "ibl.hooks" + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) + require("ibl").setup(opts) + end, + }, +} -- 2.40.1 From 73bf6c437f1c73c85daab5c76ee016f3bbd1ddd7 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 4 Mar 2024 08:07:10 +0530 Subject: [PATCH 44/68] misc --- init.lua | 19 +--------- lua/core/bootstrap.lua | 47 ------------------------- lua/{core => nvchad}/autocmds.lua | 7 ++-- lua/{ => nvchad}/configs/cmp.lua | 0 lua/{ => nvchad}/configs/lazy.lua | 0 lua/{ => nvchad}/configs/lspconfig.lua | 0 lua/{core => nvchad}/mappings.lua | 4 +-- lua/{ => nvchad}/nvconfig.lua | 0 lua/{core => nvchad}/options.lua | 4 +-- lua/{ => nvchad}/plugins/cmp.lua | 2 +- lua/{ => nvchad}/plugins/gitsigns.lua | 1 + lua/{ => nvchad}/plugins/lsp.lua | 2 +- lua/{ => nvchad}/plugins/mason.lua | 0 lua/{ => nvchad}/plugins/nvimtree.lua | 0 lua/{ => nvchad}/plugins/telescope.lua | 0 lua/{ => nvchad}/plugins/treesitter.lua | 0 lua/{ => nvchad}/plugins/ui.lua | 6 ++-- 17 files changed, 14 insertions(+), 78 deletions(-) delete mode 100644 lua/core/bootstrap.lua rename lua/{core => nvchad}/autocmds.lua (90%) rename lua/{ => nvchad}/configs/cmp.lua (100%) rename lua/{ => nvchad}/configs/lazy.lua (100%) rename lua/{ => nvchad}/configs/lspconfig.lua (100%) rename lua/{core => nvchad}/mappings.lua (98%) rename lua/{ => nvchad}/nvconfig.lua (100%) rename lua/{core => nvchad}/options.lua (94%) rename lua/{ => nvchad}/plugins/cmp.lua (97%) rename lua/{ => nvchad}/plugins/gitsigns.lua (99%) rename lua/{ => nvchad}/plugins/lsp.lua (64%) rename lua/{ => nvchad}/plugins/mason.lua (100%) rename lua/{ => nvchad}/plugins/nvimtree.lua (100%) rename lua/{ => nvchad}/plugins/telescope.lua (100%) rename lua/{ => nvchad}/plugins/treesitter.lua (100%) rename lua/{ => nvchad}/plugins/ui.lua (95%) diff --git a/init.lua b/init.lua index 2e98038..3d8a6e5 100644 --- a/init.lua +++ b/init.lua @@ -1,18 +1 @@ -require "core.options" -require "core.autocmds" --- --- local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" --- --- -- bootstrap lazy.nvim! --- if not vim.loop.fs_stat(lazypath) then --- require("core.bootstrap").gen_chadrc_template() --- require("core.bootstrap").lazy(lazypath) --- end --- --- dofile(vim.g.base46_cache .. "defaults") --- vim.opt.rtp:prepend(lazypath) - --- require("lazy").setup({ --- { import = "plugins" }, --- { import = "custom.plugins" }, --- }, require "configs.lazy") +print('use this along starter!!!') diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua deleted file mode 100644 index 2871609..0000000 --- a/lua/core/bootstrap.lua +++ /dev/null @@ -1,47 +0,0 @@ -local M = {} -local fn = vim.fn - -M.echo = function(str) - vim.cmd "redraw" - vim.api.nvim_echo({ { str, "Bold" } }, true, {}) -end - -local function shell_call(args) - local output = fn.system(args) - assert(vim.v.shell_error == 0, "External call failed with error code: " .. vim.v.shell_error .. "\n" .. output) -end - -M.lazy = function(install_path) - ------------- base46 --------------- - local lazy_path = fn.stdpath "data" .. "/lazy/base46" - - M.echo " Compiling base46 theme to bytecode ..." - - local base46_repo = "https://github.com/NvChad/base46" - shell_call { "git", "clone", "--depth", "1", "-b", "v3.0", base46_repo, lazy_path } - vim.opt.rtp:prepend(lazy_path) - - require("base46").compile() - - --------- lazy.nvim --------------- - M.echo " Installing lazy.nvim & plugins ..." - local repo = "https://github.com/folke/lazy.nvim.git" - shell_call { "git", "clone", "--filter=blob:none", "--branch=stable", repo, install_path } - vim.opt.rtp:prepend(install_path) - - -- install plugins - require "plugins" - - -- mason packages & show post_bootstrap screen - vim.cmd "MasonInstallAll" - local lastpkg = vim.g.mason_binaries_list[#vim.g.mason_binaries_list] - - -- Keep track of which mason pkgs get installed - require("mason-registry"):on("package:install:success", function(pkg) - if tostring(pkg) == "Package(name=" .. lastpkg .. ")" then - print "All done! Now read nvchad.com " - end - end) -end - -return M diff --git a/lua/core/autocmds.lua b/lua/nvchad/autocmds.lua similarity index 90% rename from lua/core/autocmds.lua rename to lua/nvchad/autocmds.lua index fbc0f36..42c964a 100644 --- a/lua/core/autocmds.lua +++ b/lua/nvchad/autocmds.lua @@ -28,14 +28,15 @@ autocmd("BufWritePost", { -- statusline if config.ui.statusline.theme ~= "custom" then - require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme) - vim.opt.statusline = "%!v:lua.require('nvchad.statusline." .. config.ui.statusline.theme .. "').run()" + require("plenary.reload").reload_module("nvchad.stl.utils") + require("plenary.reload").reload_module("nvchad.stl." .. config.ui.statusline.theme) + vim.opt.statusline = "%!v:lua.require('nvchad.stl." .. config.ui.statusline.theme .. "')()" end -- tabufline if config.ui.tabufline.enabled then require("plenary.reload").reload_module "nvchad.tabufline.modules" - vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules').run()" + vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules')()" end require("base46").load_all_highlights() diff --git a/lua/configs/cmp.lua b/lua/nvchad/configs/cmp.lua similarity index 100% rename from lua/configs/cmp.lua rename to lua/nvchad/configs/cmp.lua diff --git a/lua/configs/lazy.lua b/lua/nvchad/configs/lazy.lua similarity index 100% rename from lua/configs/lazy.lua rename to lua/nvchad/configs/lazy.lua diff --git a/lua/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua similarity index 100% rename from lua/configs/lspconfig.lua rename to lua/nvchad/configs/lspconfig.lua diff --git a/lua/core/mappings.lua b/lua/nvchad/mappings.lua similarity index 98% rename from lua/core/mappings.lua rename to lua/nvchad/mappings.lua index cb1a279..ba80b4f 100644 --- a/lua/core/mappings.lua +++ b/lua/nvchad/mappings.lua @@ -35,11 +35,11 @@ map("n", "q", vim.diagnostic.setloclist, { desc = "Lsp diagnostic loclis map("n", "b", "enew", { desc = "Buffer New" }) map("n", "", function() - require("nvchad.tabufline").tabuflineNext() + require("nvchad.tabufline").next() end, { desc = "Buffer Goto next" }) map("n", "", function() - require("nvchad.tabufline").tabuflinePrev() + require("nvchad.tabufline").prev() end, { desc = "Buffer Goto prev" }) map("n", "x", function() diff --git a/lua/nvconfig.lua b/lua/nvchad/nvconfig.lua similarity index 100% rename from lua/nvconfig.lua rename to lua/nvchad/nvconfig.lua diff --git a/lua/core/options.lua b/lua/nvchad/options.lua similarity index 94% rename from lua/core/options.lua rename to lua/nvchad/options.lua index bd7f2be..b7e5ad0 100644 --- a/lua/core/options.lua +++ b/lua/nvchad/options.lua @@ -2,7 +2,7 @@ local opt = vim.opt local g = vim.g -------------------------------------- globals ----------------------------------------- -g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" +-- g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" g.toggle_theme_icon = "  " -------------------------------------- options ------------------------------------------ @@ -47,7 +47,7 @@ opt.updatetime = 250 -- when cursor reaches end/beginning of line opt.whichwrap:append "<>[]hl" -g.mapleader = " " +-- g.mapleader = " " -- disable some default providers vim.g["loaded_node_provider"] = 0 diff --git a/lua/plugins/cmp.lua b/lua/nvchad/plugins/cmp.lua similarity index 97% rename from lua/plugins/cmp.lua rename to lua/nvchad/plugins/cmp.lua index 978d7e7..44fb8be 100644 --- a/lua/plugins/cmp.lua +++ b/lua/nvchad/plugins/cmp.lua @@ -3,7 +3,7 @@ return { event = "InsertEnter", opts = function() - return require "configs.cmp" + return require "nvchad.configs.cmp" end, config = function(_, opts) diff --git a/lua/plugins/gitsigns.lua b/lua/nvchad/plugins/gitsigns.lua similarity index 99% rename from lua/plugins/gitsigns.lua rename to lua/nvchad/plugins/gitsigns.lua index 8f9fb6c..ca7c70b 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/nvchad/plugins/gitsigns.lua @@ -27,6 +27,7 @@ return { "lewis6991/gitsigns.nvim", event = "User FilePost", opts = options, + config = function(_, opts) dofile(vim.g.base46_cache .. "git") require("gitsigns").setup(opts) diff --git a/lua/plugins/lsp.lua b/lua/nvchad/plugins/lsp.lua similarity index 64% rename from lua/plugins/lsp.lua rename to lua/nvchad/plugins/lsp.lua index b55658f..e42fa1a 100644 --- a/lua/plugins/lsp.lua +++ b/lua/nvchad/plugins/lsp.lua @@ -2,6 +2,6 @@ return { "neovim/nvim-lspconfig", event = "User FilePost", config = function() - require("configs.lspconfig").defaults() + require("nvchad.configs.lspconfig").defaults() end, } diff --git a/lua/plugins/mason.lua b/lua/nvchad/plugins/mason.lua similarity index 100% rename from lua/plugins/mason.lua rename to lua/nvchad/plugins/mason.lua diff --git a/lua/plugins/nvimtree.lua b/lua/nvchad/plugins/nvimtree.lua similarity index 100% rename from lua/plugins/nvimtree.lua rename to lua/nvchad/plugins/nvimtree.lua diff --git a/lua/plugins/telescope.lua b/lua/nvchad/plugins/telescope.lua similarity index 100% rename from lua/plugins/telescope.lua rename to lua/nvchad/plugins/telescope.lua diff --git a/lua/plugins/treesitter.lua b/lua/nvchad/plugins/treesitter.lua similarity index 100% rename from lua/plugins/treesitter.lua rename to lua/nvchad/plugins/treesitter.lua diff --git a/lua/plugins/ui.lua b/lua/nvchad/plugins/ui.lua similarity index 95% rename from lua/plugins/ui.lua rename to lua/nvchad/plugins/ui.lua index 6366f45..0c5fad3 100644 --- a/lua/plugins/ui.lua +++ b/lua/nvchad/plugins/ui.lua @@ -3,8 +3,7 @@ return { { "NvChad/base46", - -- branch = "v3.0", - dir = "~/projects/base46/", + branch = "v3.0", build = function() require("base46").load_all_highlights() end, @@ -12,8 +11,7 @@ return { { "NvChad/ui", - -- branch = "v3.0", - dir = "~/projects/ui/", + branch = "v3.0", lazy = false, config = function() require "nvchad" -- 2.40.1 From e307a4eacffcccbec8f8f292558967210a752a52 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 4 Mar 2024 08:18:44 +0530 Subject: [PATCH 45/68] better plugin structure --- .gitignore | 10 -- .ignore | 1 - lua/nvchad/{plugins => configs}/gitsigns.lua | 11 +- .../configs/{lazy.lua => lazy_nvim.lua} | 0 lua/nvchad/configs/lspconfig.lua | 2 +- lua/nvchad/configs/luasnip.lua | 23 +++ lua/nvchad/configs/mason.lua | 28 ++++ lua/nvchad/{plugins => configs}/nvimtree.lua | 10 +- lua/nvchad/configs/telescope.lua | 63 ++++++++ lua/nvchad/configs/treesitter.lua | 12 ++ lua/nvchad/plugins/cmp.lua | 64 -------- lua/nvchad/plugins/init.lua | 148 ++++++++++++++++++ lua/nvchad/plugins/lsp.lua | 7 - lua/nvchad/plugins/mason.lua | 45 ------ lua/nvchad/plugins/telescope.lua | 80 ---------- lua/nvchad/plugins/treesitter.lua | 23 --- lua/nvchad/plugins/ui.lua | 51 +++--- 17 files changed, 300 insertions(+), 278 deletions(-) delete mode 100644 .gitignore delete mode 100644 .ignore rename lua/nvchad/{plugins => configs}/gitsigns.lua (75%) rename lua/nvchad/configs/{lazy.lua => lazy_nvim.lua} (100%) create mode 100644 lua/nvchad/configs/luasnip.lua create mode 100644 lua/nvchad/configs/mason.lua rename lua/nvchad/{plugins => configs}/nvimtree.lua (87%) create mode 100644 lua/nvchad/configs/telescope.lua create mode 100644 lua/nvchad/configs/treesitter.lua delete mode 100644 lua/nvchad/plugins/cmp.lua create mode 100644 lua/nvchad/plugins/init.lua delete mode 100644 lua/nvchad/plugins/lsp.lua delete mode 100644 lua/nvchad/plugins/mason.lua delete mode 100644 lua/nvchad/plugins/telescope.lua delete mode 100644 lua/nvchad/plugins/treesitter.lua diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d8a93d9..0000000 --- a/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -plugin -custom -spell -ftplugin -syntax -coc-settings.json -.luarc.json -lazy-lock.json -after -**/.DS_Store diff --git a/.ignore b/.ignore deleted file mode 100644 index 42677fb..0000000 --- a/.ignore +++ /dev/null @@ -1 +0,0 @@ -!/lua/custom/ diff --git a/lua/nvchad/plugins/gitsigns.lua b/lua/nvchad/configs/gitsigns.lua similarity index 75% rename from lua/nvchad/plugins/gitsigns.lua rename to lua/nvchad/configs/gitsigns.lua index ca7c70b..27f3105 100644 --- a/lua/nvchad/plugins/gitsigns.lua +++ b/lua/nvchad/configs/gitsigns.lua @@ -23,13 +23,4 @@ local options = { end, } -return { - "lewis6991/gitsigns.nvim", - event = "User FilePost", - opts = options, - - config = function(_, opts) - dofile(vim.g.base46_cache .. "git") - require("gitsigns").setup(opts) - end, -} +return options diff --git a/lua/nvchad/configs/lazy.lua b/lua/nvchad/configs/lazy_nvim.lua similarity index 100% rename from lua/nvchad/configs/lazy.lua rename to lua/nvchad/configs/lazy_nvim.lua diff --git a/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index 3eb71a1..1b5adc9 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -22,7 +22,7 @@ M.on_attach = function(client, bufnr) map("n", "gd", vim.lsp.buf.definition, opts "Lsp Go to definition") map("n", "K", vim.lsp.buf.hover, opts "Lsp hover information") map("n", "gi", vim.lsp.buf.implementation, opts "Lsp Go to implementation") - map("n", "", vim.lsp.buf.signature_help, opts "Lsp Show signature help") + map("n", "sh", vim.lsp.buf.signature_help, opts "Lsp Show signature help") map("n", "wa", vim.lsp.buf.add_workspace_folder, opts "Lsp Add workspace folder") map("n", "wr", vim.lsp.buf.remove_workspace_folder, opts "Lsp Remove workspace folder") diff --git a/lua/nvchad/configs/luasnip.lua b/lua/nvchad/configs/luasnip.lua new file mode 100644 index 0000000..f40672d --- /dev/null +++ b/lua/nvchad/configs/luasnip.lua @@ -0,0 +1,23 @@ +-- vscode format +require("luasnip.loaders.from_vscode").lazy_load() +require("luasnip.loaders.from_vscode").lazy_load { paths = "your path!" } +require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } + +-- snipmate format +require("luasnip.loaders.from_snipmate").load() +require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } + +-- lua format +require("luasnip.loaders.from_lua").load() +require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } + +vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, +}) diff --git a/lua/nvchad/configs/mason.lua b/lua/nvchad/configs/mason.lua new file mode 100644 index 0000000..3692a15 --- /dev/null +++ b/lua/nvchad/configs/mason.lua @@ -0,0 +1,28 @@ +local options = { + ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + + PATH = "skip", + + ui = { + icons = { + package_pending = " ", + package_installed = "󰄳 ", + package_uninstalled = " 󰚌", + }, + + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + + max_concurrent_installers = 10, +} + +return options diff --git a/lua/nvchad/plugins/nvimtree.lua b/lua/nvchad/configs/nvimtree.lua similarity index 87% rename from lua/nvchad/plugins/nvimtree.lua rename to lua/nvchad/configs/nvimtree.lua index cf8bdb0..c54248e 100644 --- a/lua/nvchad/plugins/nvimtree.lua +++ b/lua/nvchad/configs/nvimtree.lua @@ -74,12 +74,4 @@ local options = { }, } -return { - "nvim-tree/nvim-tree.lua", - cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - opts = options, - config = function(_, opts) - dofile(vim.g.base46_cache .. "nvimtree") - require("nvim-tree").setup(opts) - end, -} +return options diff --git a/lua/nvchad/configs/telescope.lua b/lua/nvchad/configs/telescope.lua new file mode 100644 index 0000000..0df500e --- /dev/null +++ b/lua/nvchad/configs/telescope.lua @@ -0,0 +1,63 @@ +local options = { + defaults = { + vimgrep_arguments = { + "rg", + "-L", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = false, + }, + width = 0.87, + height = 0.80, + preview_cutoff = 120, + }, + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = { "node_modules" }, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + mappings = { + n = { ["q"] = require("telescope.actions").close }, + }, + }, + + extensions_list = { "themes", "terms" }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + }, +} + +return options diff --git a/lua/nvchad/configs/treesitter.lua b/lua/nvchad/configs/treesitter.lua new file mode 100644 index 0000000..897c4e3 --- /dev/null +++ b/lua/nvchad/configs/treesitter.lua @@ -0,0 +1,12 @@ +local options = { + ensure_installed = { "lua", "vim", "vimdoc" }, + + highlight = { + enable = true, + use_languagetree = true, + }, + + indent = { enable = true }, +} + +return options diff --git a/lua/nvchad/plugins/cmp.lua b/lua/nvchad/plugins/cmp.lua deleted file mode 100644 index 44fb8be..0000000 --- a/lua/nvchad/plugins/cmp.lua +++ /dev/null @@ -1,64 +0,0 @@ -return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - - opts = function() - return require "nvchad.configs.cmp" - end, - - config = function(_, opts) - require("cmp").setup(opts) - end, - - dependencies = { - { - -- snippet plugin - "L3MON4D3/LuaSnip", - dependencies = "rafamadriz/friendly-snippets", - opts = { history = true, updateevents = "TextChanged,TextChangedI" }, - config = function(_, opts) - require("luasnip").config.set_config(opts) - - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_snipmate").load() - require("luasnip.loaders.from_lua").load() - - vim.api.nvim_create_autocmd("InsertLeave", { - callback = function() - if - require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] - and not require("luasnip").session.jump_active - then - require("luasnip").unlink_current() - end - end, - }) - end, - }, - - -- autopairing of (){}[] etc - { - "windwp/nvim-autopairs", - opts = { - fast_wrap = {}, - disable_filetype = { "TelescopePrompt", "vim" }, - }, - config = function(_, opts) - require("nvim-autopairs").setup(opts) - - -- setup cmp for autopairs - local cmp_autopairs = require "nvim-autopairs.completion.cmp" - require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end, - }, - - -- cmp sources plugins - { - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - }, - }, -} diff --git a/lua/nvchad/plugins/init.lua b/lua/nvchad/plugins/init.lua new file mode 100644 index 0000000..7785c48 --- /dev/null +++ b/lua/nvchad/plugins/init.lua @@ -0,0 +1,148 @@ +return { + + "nvim-lua/plenary.nvim", + + { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPost", "BufNewFile" }, + cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, + build = ":TSUpdate", + opts = function() + return require "nvchad.configs.treesitter" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "syntax") + dofile(vim.g.base46_cache .. "treesitter") + require("nvim-treesitter.configs").setup(opts) + end, + }, + + -- git stuff + { + "lewis6991/gitsigns.nvim", + event = "User FilePost", + opts = function() + return require "nvchad.configs.gitsigns" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "git") + require("gitsigns").setup(opts) + end, + }, + + -- lsp stuff + { + "williamboman/mason.nvim", + cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" }, + opts = function() + return require "nvchad.configs.mason" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "mason") + require("mason").setup(opts) + + -- custom nvchad cmd to install all mason binaries listed + vim.api.nvim_create_user_command("MasonInstallAll", function() + if opts.ensure_installed and #opts.ensure_installed > 0 then + vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) + end + end, {}) + + vim.g.mason_binaries_list = opts.ensure_installed + end, + }, + + { + "neovim/nvim-lspconfig", + event = "User FilePost", + config = function() + require("nvchad.configs.lspconfig").defaults() + end, + }, + + -- load luasnips + cmp related in insert mode only + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { + -- snippet plugin + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", + opts = { history = true, updateevents = "TextChanged,TextChangedI" }, + config = function(_, opts) + require("luasnip").config.set_config(opts) + require "nvchad.configs.luasnip" + end, + }, + + -- autopairing of (){}[] etc + { + "windwp/nvim-autopairs", + opts = { + fast_wrap = {}, + disable_filetype = { "TelescopePrompt", "vim" }, + }, + config = function(_, opts) + require("nvim-autopairs").setup(opts) + + -- setup cmp for autopairs + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, + }, + + -- cmp sources plugins + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + }, + opts = function() + return require "nvchad.configs.cmp" + end, + config = function(_, opts) + require("cmp").setup(opts) + end, + }, + + { + "numToStr/Comment.nvim", + keys = { + { "gcc", mode = "n", desc = "Comment toggle current line" }, + { "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, + { "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, + { "gbc", mode = "n", desc = "Comment toggle current block" }, + { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, + { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, + }, + init = function() + vim.g.comment_maps = true + end, + config = function(_, opts) + require("Comment").setup(opts) + end, + }, + + { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + cmd = "Telescope", + opts = function() + return require "nvchad.configs.telescope" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "telescope") + local telescope = require "telescope" + telescope.setup(opts) + + -- load extensions + for _, ext in ipairs(opts.extensions_list) do + telescope.load_extension(ext) + end + end, + }, +} diff --git a/lua/nvchad/plugins/lsp.lua b/lua/nvchad/plugins/lsp.lua deleted file mode 100644 index e42fa1a..0000000 --- a/lua/nvchad/plugins/lsp.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "neovim/nvim-lspconfig", - event = "User FilePost", - config = function() - require("nvchad.configs.lspconfig").defaults() - end, -} diff --git a/lua/nvchad/plugins/mason.lua b/lua/nvchad/plugins/mason.lua deleted file mode 100644 index 9f8248f..0000000 --- a/lua/nvchad/plugins/mason.lua +++ /dev/null @@ -1,45 +0,0 @@ -local options = { - ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim - - PATH = "skip", - - ui = { - icons = { - package_pending = " ", - package_installed = "󰄳 ", - package_uninstalled = " 󰚌", - }, - - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - cancel_installation = "", - }, - }, - - max_concurrent_installers = 10, -} - -return { - "williamboman/mason.nvim", - cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUpdate" }, - opts = options, - config = function(_, opts) - dofile(vim.g.base46_cache .. "mason") - require("mason").setup(opts) - - -- custom nvchad cmd to install all mason binaries listed - vim.api.nvim_create_user_command("MasonInstallAll", function() - if opts.ensure_installed and #opts.ensure_installed > 0 then - vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " ")) - end - end, {}) - - vim.g.mason_binaries_list = opts.ensure_installed - end, -} diff --git a/lua/nvchad/plugins/telescope.lua b/lua/nvchad/plugins/telescope.lua deleted file mode 100644 index c441438..0000000 --- a/lua/nvchad/plugins/telescope.lua +++ /dev/null @@ -1,80 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - cmd = "Telescope", - opts = function() - local options = { - defaults = { - vimgrep_arguments = { - "rg", - "-L", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { - mirror = false, - }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, - }, - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = { "node_modules" }, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "truncate" }, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - color_devicons = true, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - mappings = { - n = { ["q"] = require("telescope.actions").close }, - }, - }, - - extensions_list = { "themes", "terms" }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "smart_case", - }, - }, - } - - return options - end, - config = function(_, opts) - dofile(vim.g.base46_cache .. "telescope") - local telescope = require "telescope" - telescope.setup(opts) - - -- load extensions - for _, ext in ipairs(opts.extensions_list) do - telescope.load_extension(ext) - end - end, -} diff --git a/lua/nvchad/plugins/treesitter.lua b/lua/nvchad/plugins/treesitter.lua deleted file mode 100644 index d940c95..0000000 --- a/lua/nvchad/plugins/treesitter.lua +++ /dev/null @@ -1,23 +0,0 @@ -local config = { - ensure_installed = { "lua", "vim", "vimdoc" }, - - highlight = { - enable = true, - use_languagetree = true, - }, - - indent = { enable = true }, -} - -return { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPost", "BufNewFile" }, - cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, - build = ":TSUpdate", - opts = config, - config = function(_, opts) - dofile(vim.g.base46_cache .. "syntax") - dofile(vim.g.base46_cache .. "treesitter") - require("nvim-treesitter.configs").setup(opts) - end, -} diff --git a/lua/nvchad/plugins/ui.lua b/lua/nvchad/plugins/ui.lua index 0c5fad3..34a6a97 100644 --- a/lua/nvchad/plugins/ui.lua +++ b/lua/nvchad/plugins/ui.lua @@ -1,5 +1,4 @@ return { - "nvim-lua/plenary.nvim", { "NvChad/base46", @@ -42,40 +41,13 @@ return { end, }, - { - "folke/which-key.nvim", - keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, - cmd = "WhichKey", - config = function(_, opts) - dofile(vim.g.base46_cache .. "whichkey") - require("which-key").setup(opts) - end, - }, - - { - "numToStr/Comment.nvim", - keys = { - { "gcc", mode = "n", desc = "Comment toggle current line" }, - { "gc", mode = { "n", "o" }, desc = "Comment toggle linewise" }, - { "gc", mode = "x", desc = "Comment toggle linewise (visual)" }, - { "gbc", mode = "n", desc = "Comment toggle current block" }, - { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, - { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, - }, - config = function(_, opts) - require("Comment").setup(opts) - end, - }, - { "lukas-reineke/indent-blankline.nvim", event = "User FilePost", - opts = { indent = { char = "│", highlight = "IblChar" }, scope = { char = "│", highlight = "IblScopeChar" }, }, - config = function(_, opts) dofile(vim.g.base46_cache .. "blankline") @@ -84,4 +56,27 @@ return { require("ibl").setup(opts) end, }, + + -- file managing , picker etc + { + "nvim-tree/nvim-tree.lua", + cmd = { "NvimTreeToggle", "NvimTreeFocus" }, + opts = function() + return require "nvchad.configs.nvimtree" + end, + config = function(_, opts) + dofile(vim.g.base46_cache .. "nvimtree") + require("nvim-tree").setup(opts) + end, + }, + + { + "folke/which-key.nvim", + keys = { "", "", "", '"', "'", "`", "c", "v", "g" }, + cmd = "WhichKey", + config = function(_, opts) + dofile(vim.g.base46_cache .. "whichkey") + require("which-key").setup(opts) + end, + }, } -- 2.40.1 From b17c4d9e86bceba7ddfcb9ee3f0b4f7db3989b3b Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 4 Mar 2024 11:56:40 +0530 Subject: [PATCH 46/68] mv nvconfig to lua/ --- lua/nvchad/autocmds.lua | 2 +- lua/nvchad/configs/mason.lua | 2 +- lua/nvchad/plugins/ui.lua | 2 +- lua/{nvchad => }/nvconfig.lua | 14 ++++---------- 4 files changed, 7 insertions(+), 13 deletions(-) rename lua/{nvchad => }/nvconfig.lua (90%) diff --git a/lua/nvchad/autocmds.lua b/lua/nvchad/autocmds.lua index 42c964a..0e6260a 100644 --- a/lua/nvchad/autocmds.lua +++ b/lua/nvchad/autocmds.lua @@ -12,7 +12,7 @@ autocmd("FileType", { autocmd("BufWritePost", { pattern = vim.tbl_map(function(path) return vim.fs.normalize(vim.loop.fs_realpath(path)) - end, vim.fn.glob(vim.fn.stdpath "config" .. "/lua/custom/**/*.lua", true, true, true)), + end, vim.fn.glob(vim.fn.stdpath "config" .. "/lua/**/*.lua", true, true, true)), group = vim.api.nvim_create_augroup("ReloadNvChad", {}), callback = function(opts) diff --git a/lua/nvchad/configs/mason.lua b/lua/nvchad/configs/mason.lua index 3692a15..a87f593 100644 --- a/lua/nvchad/configs/mason.lua +++ b/lua/nvchad/configs/mason.lua @@ -1,5 +1,5 @@ local options = { - ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim + ensure_installed = { "lua-language-server", 'stylua' }, -- not an option from mason.nvim PATH = "skip", diff --git a/lua/nvchad/plugins/ui.lua b/lua/nvchad/plugins/ui.lua index 34a6a97..29a6081 100644 --- a/lua/nvchad/plugins/ui.lua +++ b/lua/nvchad/plugins/ui.lua @@ -10,7 +10,7 @@ return { { "NvChad/ui", - branch = "v3.0", + branch = "starter", lazy = false, config = function() require "nvchad" diff --git a/lua/nvchad/nvconfig.lua b/lua/nvconfig.lua similarity index 90% rename from lua/nvchad/nvconfig.lua rename to lua/nvconfig.lua index 5066ed2..dc4e72c 100644 --- a/lua/nvchad/nvconfig.lua +++ b/lua/nvconfig.lua @@ -25,15 +25,15 @@ M.ui = { -- default/round/block/arrow separators work only for default statusline theme -- round and block will work for minimal theme only separator_style = "default", - overriden_modules = nil, + order=nil, }, -- lazyload it when there are 1+ buffers tabufline = { - show_numbers = false, enabled = true, lazyload = true, - overriden_modules = nil, + order= {'treeOffset', 'buffers' , 'tabs', 'btns'}, + modules = nil, }, -- nvdash (dashboard) @@ -86,8 +86,6 @@ M.ui = { }, } -M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file - M.base46 = { integrations = { "blankline", @@ -110,10 +108,6 @@ M.base46 = { }, } -local chadrc_exists, chadrc = pcall(require, "custom.chadrc") - -if chadrc_exists then - M = vim.tbl_deep_extend("force", M, chadrc) -end +M = vim.tbl_deep_extend("force", M, require('chadrc')) return M -- 2.40.1 From 168274038c61083833e11cb8ac6bf325a4756de3 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 4 Mar 2024 22:44:44 +0530 Subject: [PATCH 47/68] add nvchad colorscheme in colors/ --- colors/nvchad.lua | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 colors/nvchad.lua diff --git a/colors/nvchad.lua b/colors/nvchad.lua new file mode 100644 index 0000000..d2d98a1 --- /dev/null +++ b/colors/nvchad.lua @@ -0,0 +1,3 @@ +vim.opt.termguicolors = true +dofile(vim.g.base46_cache .. "defaults") +dofile(vim.g.base46_cache .. "statusline") -- 2.40.1 From 6608363bd96e3d495001087a7796dbc7273ab76c Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 5 Mar 2024 08:01:37 +0530 Subject: [PATCH 48/68] disable semantic tokens in on_init, in lspconfig.lua --- lua/nvchad/configs/lspconfig.lua | 25 ++++++++++++++----------- lua/nvchad/mappings.lua | 4 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index 1b5adc9..ca2bb87 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -1,19 +1,9 @@ local M = {} local map = vim.keymap.set +local conf = require("nvconfig").ui.lsp -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) - local conf = require("nvconfig").ui.lsp - - -- semanticTokens - if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then - client.server_capabilities.semanticTokensProvider = nil - end - - if conf.signature and client.server_capabilities.signatureHelpProvider then - require("nvchad.signature").setup(client, bufnr) - end - local function opts(desc) return { buffer = bufnr, desc = desc } end @@ -38,6 +28,18 @@ M.on_attach = function(client, bufnr) map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Lsp Code action") map("n", "gr", vim.lsp.buf.references, opts "Lsp Show references") + + -- setup signature popup + if conf.signature and client.server_capabilities.signatureHelpProvider then + require("nvchad.signature").setup(client, bufnr) + end +end + +-- disable semanticTokens +M.on_init = function(client, _) + if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then + client.server_capabilities.semanticTokensProvider = nil + end end M.capabilities = vim.lsp.protocol.make_client_capabilities() @@ -67,6 +69,7 @@ M.defaults = function() require("lspconfig").lua_ls.setup { on_attach = M.on_attach, capabilities = M.capabilities, + on_init = M.on_init, settings = { Lua = { diff --git a/lua/nvchad/mappings.lua b/lua/nvchad/mappings.lua index ba80b4f..2c06e88 100644 --- a/lua/nvchad/mappings.lua +++ b/lua/nvchad/mappings.lua @@ -54,7 +54,7 @@ end, { desc = "Comment Toggle" }) map( "v", "/", - ":lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", { desc = "Comment Toggle" } ) @@ -132,4 +132,4 @@ map("n", "cc", function() end end, { desc = "Blankline Jump to current context" }) -pcall(require, "custom.mappings") +require "custom.mappings" -- 2.40.1 From f6af7e8a29c967af37239f0ac572d8384a8bcb13 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 5 Mar 2024 08:04:07 +0530 Subject: [PATCH 49/68] rm un-needed require --- lua/nvchad/mappings.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/nvchad/mappings.lua b/lua/nvchad/mappings.lua index 2c06e88..ee2e0a5 100644 --- a/lua/nvchad/mappings.lua +++ b/lua/nvchad/mappings.lua @@ -131,5 +131,3 @@ map("n", "cc", function() end end end, { desc = "Blankline Jump to current context" }) - -require "custom.mappings" -- 2.40.1 From c4db8736ce62afa9adff9810d4b41a9597021eb3 Mon Sep 17 00:00:00 2001 From: Sidhanth Rathod Date: Tue, 5 Mar 2024 08:10:54 +0530 Subject: [PATCH 50/68] rm useless command --- lua/nvchad/autocmds.lua | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lua/nvchad/autocmds.lua b/lua/nvchad/autocmds.lua index 0e6260a..3fadcac 100644 --- a/lua/nvchad/autocmds.lua +++ b/lua/nvchad/autocmds.lua @@ -69,10 +69,3 @@ vim.api.nvim_create_autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, { end end, }) - --------------------------------------- commands ------------------------------------------ -local new_cmd = vim.api.nvim_create_user_command - -new_cmd("NvChadUpdate", function() - require "nvchad.updater"() -end, {}) -- 2.40.1 From 2282f9d338c74a3b545b533219a0fcc185b20113 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 5 Mar 2024 21:36:34 +0530 Subject: [PATCH 51/68] rm termguicolors opt as its loaded in base46 --- colors/nvchad.lua | 1 - lua/nvchad/options.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/colors/nvchad.lua b/colors/nvchad.lua index d2d98a1..f35cc9b 100644 --- a/colors/nvchad.lua +++ b/colors/nvchad.lua @@ -1,3 +1,2 @@ -vim.opt.termguicolors = true dofile(vim.g.base46_cache .. "defaults") dofile(vim.g.base46_cache .. "statusline") diff --git a/lua/nvchad/options.lua b/lua/nvchad/options.lua index b7e5ad0..e623668 100644 --- a/lua/nvchad/options.lua +++ b/lua/nvchad/options.lua @@ -36,7 +36,6 @@ opt.shortmess:append "sI" opt.signcolumn = "yes" opt.splitbelow = true opt.splitright = true -opt.termguicolors = true opt.timeoutlen = 400 opt.undofile = true -- 2.40.1 From 634f6d55dee15ccd44a7a3c7f706a0c8151584ed Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 7 Mar 2024 06:50:13 +0530 Subject: [PATCH 52/68] update some module paths --- lua/nvchad/configs/lspconfig.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index ca2bb87..321a8f3 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -23,7 +23,7 @@ M.on_attach = function(client, bufnr) map("n", "D", vim.lsp.buf.type_definition, opts "Lsp Go to type definition") map("n", "ra", function() - require "nvchad.renamer"() + require "nvchad.lsp.renamer"() end, opts "Lsp NvRenamer") map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Lsp Code action") @@ -31,7 +31,7 @@ M.on_attach = function(client, bufnr) -- setup signature popup if conf.signature and client.server_capabilities.signatureHelpProvider then - require("nvchad.signature").setup(client, bufnr) + require("nvchad.lsp.signature").setup(client, bufnr) end end -- 2.40.1 From 2cf989cf3183872530ccbe1916a3a0efd3c83d02 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 8 Mar 2024 19:46:31 +0530 Subject: [PATCH 53/68] rm useless term option --- lua/nvchad/mappings.lua | 6 ++++-- lua/nvconfig.lua | 11 +++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lua/nvchad/mappings.lua b/lua/nvchad/mappings.lua index ee2e0a5..3bd56cf 100644 --- a/lua/nvchad/mappings.lua +++ b/lua/nvchad/mappings.lua @@ -84,20 +84,22 @@ map( -- terminal map("t", "", "", { desc = "Terminal Escape terminal mode" }) +-- new terminals map("n", "h", function() require("nvchad.term").new { pos = "sp", size = 0.3 } end, { desc = "Terminal New horizontal term" }) map("n", "v", function() require("nvchad.term").new { pos = "vsp", size = 0.3 } -end, { desc = "Terminal New vertical term" }) +end, { desc = "Terminal New vertical window" }) +-- toggleable map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } end, { desc = "Terminal Toggleable vertical term" }) map({ "n", "t" }, "", function() - require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } + require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.3 } end, { desc = "Terminal New horizontal term" }) map({ "n", "t" }, "", function() diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index dc4e72c..2f5b8c1 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -25,14 +25,14 @@ M.ui = { -- default/round/block/arrow separators work only for default statusline theme -- round and block will work for minimal theme only separator_style = "default", - order=nil, + order = nil, }, -- lazyload it when there are 1+ buffers tabufline = { enabled = true, lazyload = true, - order= {'treeOffset', 'buffers' , 'tabs', 'btns'}, + order = { "treeOffset", "buffers", "tabs", "btns" }, modules = nil, }, @@ -80,9 +80,6 @@ M.ui = { height = 0.4, border = "single", }, - behavior = { - auto_insert = true, - }, }, } @@ -108,6 +105,4 @@ M.base46 = { }, } -M = vim.tbl_deep_extend("force", M, require('chadrc')) - -return M +return vim.tbl_deep_extend("force", M, require('chadrc')) -- 2.40.1 From 166bb9bebaa5e1fc555c886bdf7a72e83e8b00bf Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 9 Mar 2024 13:00:51 +0530 Subject: [PATCH 54/68] rm some useless comments --- lua/nvconfig.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index 2f5b8c1..02b9440 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -10,7 +10,6 @@ M.ui = { theme = "onedark", -- default theme transparency = false, - -- cmp themeing cmp = { icons = true, lspkind_text = true, @@ -26,6 +25,7 @@ M.ui = { -- round and block will work for minimal theme only separator_style = "default", order = nil, + modules = nil, }, -- lazyload it when there are 1+ buffers @@ -36,7 +36,6 @@ M.ui = { modules = nil, }, - -- nvdash (dashboard) nvdash = { load_on_startup = false, @@ -70,7 +69,7 @@ M.ui = { }, term = { - hl = "Normal:term,WinSeparator:WinSeparator", + -- hl = "Normal:term,WinSeparator:WinSeparator", sizes = { sp = 0.3, vsp = 0.2 }, float = { relative = "editor", @@ -105,4 +104,4 @@ M.base46 = { }, } -return vim.tbl_deep_extend("force", M, require('chadrc')) +return vim.tbl_deep_extend("force", M, require "chadrc") -- 2.40.1 From bbc2cbaae65881f6d505fd8a6ef0e2453f7a3f73 Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 9 Mar 2024 15:41:16 +0530 Subject: [PATCH 55/68] rm including types in default lspconfig lua_lsp setup --- lua/nvchad/configs/lspconfig.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index 321a8f3..3c06d5f 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -80,8 +80,6 @@ M.defaults = function() library = { [vim.fn.expand "$VIMRUNTIME/lua"] = true, [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, - [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true, - [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, }, maxPreload = 100000, preloadFileSize = 10000, -- 2.40.1 From 6b40fb590f9750e209fb8fb78d59d2e89d0748a6 Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 9 Mar 2024 18:13:19 +0530 Subject: [PATCH 56/68] use vim.o instead of vim.opt for non tb opts --- lua/nvchad/options.lua | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lua/nvchad/options.lua b/lua/nvchad/options.lua index e623668..181987b 100644 --- a/lua/nvchad/options.lua +++ b/lua/nvchad/options.lua @@ -1,46 +1,46 @@ local opt = vim.opt +local o = vim.o local g = vim.g -------------------------------------- globals ----------------------------------------- --- g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" g.toggle_theme_icon = "  " -------------------------------------- options ------------------------------------------ -opt.laststatus = 3 -- global statusline -opt.showmode = false +o.laststatus = 3 +o.showmode = false -opt.clipboard = "unnamedplus" -opt.cursorline = true -opt.cursorlineopt = "number" +o.clipboard = "unnamedplus" +o.cursorline = true +o.cursorlineopt = "number" -- Indenting -opt.expandtab = true -opt.shiftwidth = 2 -opt.smartindent = true -opt.tabstop = 2 -opt.softtabstop = 2 +o.expandtab = true +o.shiftwidth = 2 +o.smartindent = true +o.tabstop = 2 +o.softtabstop = 2 opt.fillchars = { eob = " " } -opt.ignorecase = true -opt.smartcase = true -opt.mouse = "a" +o.ignorecase = true +o.smartcase = true +o.mouse = "a" -- Numbers -opt.number = true -opt.numberwidth = 2 -opt.ruler = false +o.number = true +o.numberwidth = 2 +o.ruler = false -- disable nvim intro opt.shortmess:append "sI" -opt.signcolumn = "yes" -opt.splitbelow = true -opt.splitright = true -opt.timeoutlen = 400 -opt.undofile = true +o.signcolumn = "yes" +o.splitbelow = true +o.splitright = true +o.timeoutlen = 400 +o.undofile = true -- interval for writing swap file to disk, also used by gitsigns -opt.updatetime = 250 +o.updatetime = 250 -- go to previous/next line with h,l,left arrow and right arrow -- when cursor reaches end/beginning of line -- 2.40.1 From 6fb5c313edc966f187c7483a16affaec0518b641 Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 9 Mar 2024 21:37:34 +0530 Subject: [PATCH 57/68] update branch for base46/ui plugin --- lua/nvchad/plugins/ui.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/nvchad/plugins/ui.lua b/lua/nvchad/plugins/ui.lua index 29a6081..ae4ed21 100644 --- a/lua/nvchad/plugins/ui.lua +++ b/lua/nvchad/plugins/ui.lua @@ -2,7 +2,7 @@ return { { "NvChad/base46", - branch = "v3.0", + branch = "v2.5", build = function() require("base46").load_all_highlights() end, @@ -10,7 +10,7 @@ return { { "NvChad/ui", - branch = "starter", + branch = "v2.5", lazy = false, config = function() require "nvchad" -- 2.40.1 From 96ba9ceb0c31c5e595a2b184586805fadaeec864 Mon Sep 17 00:00:00 2001 From: William Sedlacek Date: Sat, 9 Mar 2024 17:31:07 -0800 Subject: [PATCH 58/68] add vim.g.vscode_snippets_exclude option (#2715) The `exclude` option for luasnip is useful for disabling snippets which a user may not want on by default. For example the `all` option includes a snippet for `timeHMS` which always gets caught by `cmp` when typing `ts` for me which means all my typescript files end up as `file.16:07:21` --- lua/nvchad/configs/luasnip.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvchad/configs/luasnip.lua b/lua/nvchad/configs/luasnip.lua index f40672d..f164d11 100644 --- a/lua/nvchad/configs/luasnip.lua +++ b/lua/nvchad/configs/luasnip.lua @@ -1,5 +1,5 @@ -- vscode format -require("luasnip.loaders.from_vscode").lazy_load() +require("luasnip.loaders.from_vscode").lazy_load { exclude = vim.g.vscode_snippets_exclude or {} } require("luasnip.loaders.from_vscode").lazy_load { paths = "your path!" } require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } -- 2.40.1 From 259274a624d83e3624f5fb2bfaf5632ad5c449b3 Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 10 Mar 2024 19:18:10 +0530 Subject: [PATCH 59/68] rm dead base46 integration from nvconfig --- lua/nvconfig.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index 02b9440..cfa8d56 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -91,7 +91,6 @@ M.base46 = { "git", "lsp", "mason", - "nvchad_updater", "nvcheatsheet", "nvdash", "nvimtree", -- 2.40.1 From cf1db9821a9bfe4e03eaa036fd791e55eae53117 Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 10 Mar 2024 20:00:40 +0530 Subject: [PATCH 60/68] use has(win32) func to detect windows #2690 --- lua/nvchad/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvchad/options.lua b/lua/nvchad/options.lua index 181987b..26350b7 100644 --- a/lua/nvchad/options.lua +++ b/lua/nvchad/options.lua @@ -55,5 +55,5 @@ vim.g["loaded_perl_provider"] = 0 vim.g["loaded_ruby_provider"] = 0 -- add binaries installed by mason.nvim to path -local is_windows = vim.loop.os_uname().sysname == "Windows_NT" +local is_windows = vim.fn.has("win32") ~= 0 vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH -- 2.40.1 From 80c2e01c752cad5490dcb2aea56163a1b27196bc Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 14 Mar 2024 11:15:37 +0530 Subject: [PATCH 61/68] load blankline highlights after its setup() too https://github.com/lukas-reineke/indent-blankline.nvim/issues/754 --- lua/nvchad/plugins/ui.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/nvchad/plugins/ui.lua b/lua/nvchad/plugins/ui.lua index ae4ed21..677e3c0 100644 --- a/lua/nvchad/plugins/ui.lua +++ b/lua/nvchad/plugins/ui.lua @@ -54,6 +54,8 @@ return { local hooks = require "ibl.hooks" hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) require("ibl").setup(opts) + + dofile(vim.g.base46_cache .. "blankline") end, }, -- 2.40.1 From b94c57954f115ebd5b4a6c9f35b729ee8e51e117 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 15 Mar 2024 06:37:04 +0530 Subject: [PATCH 62/68] enable git by default for nvimtree --- lua/nvchad/autocmds.lua | 8 +++----- lua/nvchad/configs/lspconfig.lua | 2 +- lua/nvchad/configs/nvimtree.lua | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lua/nvchad/autocmds.lua b/lua/nvchad/autocmds.lua index 3fadcac..229237e 100644 --- a/lua/nvchad/autocmds.lua +++ b/lua/nvchad/autocmds.lua @@ -27,11 +27,9 @@ autocmd("BufWritePost", { local config = require "nvconfig" -- statusline - if config.ui.statusline.theme ~= "custom" then - require("plenary.reload").reload_module("nvchad.stl.utils") - require("plenary.reload").reload_module("nvchad.stl." .. config.ui.statusline.theme) - vim.opt.statusline = "%!v:lua.require('nvchad.stl." .. config.ui.statusline.theme .. "')()" - end + require("plenary.reload").reload_module "nvchad.stl.utils" + require("plenary.reload").reload_module("nvchad.stl." .. config.ui.statusline.theme) + vim.opt.statusline = "%!v:lua.require('nvchad.stl." .. config.ui.statusline.theme .. "')()" -- tabufline if config.ui.tabufline.enabled then diff --git a/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index 3c06d5f..96e6ba2 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -2,7 +2,7 @@ local M = {} local map = vim.keymap.set local conf = require("nvconfig").ui.lsp --- export on_attach & capabilities for custom lspconfigs +-- export on_attach & capabilities M.on_attach = function(client, bufnr) local function opts(desc) return { buffer = bufnr, desc = desc } diff --git a/lua/nvchad/configs/nvimtree.lua b/lua/nvchad/configs/nvimtree.lua index c54248e..da68148 100644 --- a/lua/nvchad/configs/nvimtree.lua +++ b/lua/nvchad/configs/nvimtree.lua @@ -1,7 +1,6 @@ local options = { filters = { dotfiles = false, - exclude = { vim.fn.stdpath "config" .. "/lua/custom" }, }, disable_netrw = true, hijack_netrw = true, @@ -19,7 +18,7 @@ local options = { preserve_window_proportions = true, }, git = { - enable = false, + enable = true, ignore = true, }, filesystem_watchers = { @@ -32,7 +31,7 @@ local options = { }, renderer = { root_folder_label = false, - highlight_git = false, + highlight_git = true, highlight_opened_files = "none", indent_markers = { @@ -44,7 +43,7 @@ local options = { file = true, folder = true, folder_arrow = true, - git = false, + git = true, }, glyphs = { -- 2.40.1 From 8df62c803de3cc21ecba41b4945af7091c96832f Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 15 Mar 2024 09:05:43 +0530 Subject: [PATCH 63/68] rm useless code --- lua/nvchad/plugins/init.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/nvchad/plugins/init.lua b/lua/nvchad/plugins/init.lua index 7785c48..021bba3 100644 --- a/lua/nvchad/plugins/init.lua +++ b/lua/nvchad/plugins/init.lua @@ -119,9 +119,6 @@ return { { "gb", mode = { "n", "o" }, desc = "Comment toggle blockwise" }, { "gb", mode = "x", desc = "Comment toggle blockwise (visual)" }, }, - init = function() - vim.g.comment_maps = true - end, config = function(_, opts) require("Comment").setup(opts) end, -- 2.40.1 From 178bf21fdef6679ea70af3f6e45b1c1e6ed8e8a6 Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 16 Mar 2024 07:48:33 +0530 Subject: [PATCH 64/68] rm outdated info --- .github/README.md | 9 ++++----- init.lua | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 init.lua diff --git a/.github/README.md b/.github/README.md index 8f3ec47..640c26e 100644 --- a/.github/README.md +++ b/.github/README.md @@ -15,7 +15,7 @@
-[![Neovim Minimum Version](https://img.shields.io/badge/Neovim-0.9.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.9.5-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) @@ -33,11 +33,11 @@ ## What is it? -- NvChad is a neovim config written in lua aiming to provide a base configuration with very beautiful UI and blazing fast startuptime (around 0.02 secs ~ 0.07 secs). We tweak UI plugins such as telescope, nvim-tree, bufferline etc well to provide an aesthetic UI experience. +- NvChad is a neovim config written in lua aiming to provide a base configuration with very beautiful UI and blazing fast startuptime (around 0.02 secs ~ 0.07 secs). We tweak UI plugins such as telescope, nvim-tree etc well to provide an aesthetic UI experience. - Lazy loading is done 93% of the time meaning that plugins will not be loaded by default, they will be loaded only when required also at specific commands, events etc. This lowers the startuptime and it was like 0.07~ secs tested on an old pentium machine 1.4ghz + 4gb ram & HDD. -- NvChad isn't a framework! It's supposed to be used as a "base" config, so users can tweak the defaults well, and also remove the things they don't like in the default config and build their config on top of it. Users can tweak the entire default config while staying in their custom config (lua/custom dir). This is the control center of the user's config and gitignored so the users can stay up-to-date with NvChad's latest config (main branch) while still controlling it with their chadrc (file that controls entire custom dir). +- NvChad is supposed to be used with its [starter config](https://github.com/nvchad/starter), so nvchad main repo ( this repo ) can be imported as a plugin via lazy's import feature and then you can easily use this repo's modules like autocmds etc. ## Theme Showcase @@ -87,7 +87,6 @@ A fuzzy file finder, picker, sorter, previewer and much more: ## Plugins list - Many beautiful themes, theme toggler by our [base46 plugin](https://github.com/NvChad/base46) -- Inbuilt terminal toggling & management with [Nvterm](https://github.com/NvChad/nvterm) - Lightweight & performant ui plugin with [NvChad UI](https://github.com/NvChad/ui) It provides statusline modules, tabufline ( tabs + buffer manager) , beautiful cheatsheets, NvChad updater, hide & unhide terminal buffers, theme switcher and much more! - File navigation with [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua) - Beautiful and configurable icons with [nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) @@ -118,5 +117,5 @@ If you like NvChad and would like to support & appreciate it via donation then I ## Credits -- [Elianiva](https://github.com/elianiva) helped me with NeoVim Lua related issues many times, NvChad wouldn't exist without his help at all as he helped me in my initial neovim journey! +- [Elianiva](https://github.com/elianiva) helped me with NeoVim Lua related issues many times, helped me in my initial neovim journey! - @lorvethe for making the beautiful NvChad logo. diff --git a/init.lua b/init.lua deleted file mode 100644 index 3d8a6e5..0000000 --- a/init.lua +++ /dev/null @@ -1 +0,0 @@ -print('use this along starter!!!') -- 2.40.1 From 2e54fce0281cee808c30ba309610abfcb69ee28a Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 18 Mar 2024 06:29:28 +0530 Subject: [PATCH 65/68] add nvchad_types back & conform plugin --- lua/nvchad/configs/lspconfig.lua | 2 ++ lua/nvchad/mappings.lua | 6 +++--- lua/nvchad/plugins/init.lua | 13 +++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lua/nvchad/configs/lspconfig.lua b/lua/nvchad/configs/lspconfig.lua index 96e6ba2..e80b190 100644 --- a/lua/nvchad/configs/lspconfig.lua +++ b/lua/nvchad/configs/lspconfig.lua @@ -80,6 +80,8 @@ M.defaults = function() library = { [vim.fn.expand "$VIMRUNTIME/lua"] = true, [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true, + [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, }, maxPreload = 100000, preloadFileSize = 10000, diff --git a/lua/nvchad/mappings.lua b/lua/nvchad/mappings.lua index 3bd56cf..3342751 100644 --- a/lua/nvchad/mappings.lua +++ b/lua/nvchad/mappings.lua @@ -21,11 +21,11 @@ map("n", "n", "set nu!", { desc = "Toggle Line number" }) map("n", "rn", "set rnu!", { desc = "Toggle Relative number" }) map("n", "ch", "NvCheatsheet", { desc = "Toggle NvCheatsheet" }) --- global lsp mappings map("n", "fm", function() - vim.lsp.buf.format { async = true } -end, { desc = "Lsp formatting" }) + require("conform").format { lsp_fallback = true } +end, { desc = "Format Files" }) +-- global lsp mappings map("n", "lf", vim.diagnostic.open_float, { desc = "Lsp floating diagnostics" }) map("n", "[d", vim.diagnostic.goto_prev, { desc = "Lsp prev diagnostic" }) map("n", "]d", vim.diagnostic.goto_next, { desc = "Lsp next diagnostic" }) diff --git a/lua/nvchad/plugins/init.lua b/lua/nvchad/plugins/init.lua index 021bba3..4669a3d 100644 --- a/lua/nvchad/plugins/init.lua +++ b/lua/nvchad/plugins/init.lua @@ -2,6 +2,19 @@ return { "nvim-lua/plenary.nvim", + -- formatting! + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stylua" }, + }, + }, + config = function(_, opts) + require("conform").setup(opts) + end, + }, + { "nvim-treesitter/nvim-treesitter", event = { "BufReadPost", "BufNewFile" }, -- 2.40.1 From e5f8a38ae3d6b3bedf68f29b0e96dad7a4ca2da5 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 19 Mar 2024 09:32:01 +0530 Subject: [PATCH 66/68] reload chadrc in autocmd --- lua/nvchad/autocmds.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/nvchad/autocmds.lua b/lua/nvchad/autocmds.lua index 229237e..4583e42 100644 --- a/lua/nvchad/autocmds.lua +++ b/lua/nvchad/autocmds.lua @@ -21,6 +21,7 @@ autocmd("BufWritePost", { local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".") require("plenary.reload").reload_module "nvconfig" + require("plenary.reload").reload_module "chadrc" require("plenary.reload").reload_module "base46" require("plenary.reload").reload_module(module) -- 2.40.1 From 16b3eeb1fa7fceaa99b5c76e84e34c28ecb7ceab Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 22 Mar 2024 10:48:37 +0100 Subject: [PATCH 67/68] update to upstream --- lua/custom/chadrc.lua | 7 ++++++- lua/custom/configs/lspsettings.lua | 4 ++-- spell/en.utf-8.add | 7 +++++++ spell/en.utf-8.add.spl | Bin 4058 -> 4095 bytes 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index ba6b286..9480811 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -8,6 +8,12 @@ M.ui = { theme = "oceanic-next", theme_toggle = { "oceanic-next", "ayu_light" }, + cmp = { + icons = true, + lspkind_text = true, + style = "atom", -- default/flat_light/flat_dark/atom/atom_colored + }, + hl_override = highlights.override, hl_add = highlights.add, lsp_semantic_tokens = true, @@ -16,7 +22,6 @@ M.ui = { -- default/round/block/arrow separators work only for default statusline theme -- round and block will work for minimal theme only separator_style = "default", - overriden_modules = nil, }, -- lazyload it when there are 1+ buffers tabufline = { diff --git a/lua/custom/configs/lspsettings.lua b/lua/custom/configs/lspsettings.lua index e8da2c4..2ca78ef 100644 --- a/lua/custom/configs/lspsettings.lua +++ b/lua/custom/configs/lspsettings.lua @@ -55,9 +55,9 @@ M.ltex = { languageToolOrg = { apiKey = require "custom.secret.languagetool_token", username = "accounts@cscherr.de", - languageToolHttpServerUrl = "https://api.languagetoolplus.com/v2/", + languageToolHttpServerUri = "https://api.languagetoolplus.com", }, - languageToolHttpServerUrl = "https://api.languagetoolplus.com/v2/", + languageToolHttpServerUri = "https://api.languagetoolplus.com", }, }, } diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index 2586189..53e9273 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -309,3 +309,10 @@ Notfallmaßnahmen Eligswalde Usecases OpenAPI +#atz/! +satz/! +Satz +#orlde +Worlde/! +Wordle +GameBuilder diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index 0b2cb082701923cde15f2a1758294694e4968fb6..b20d5827f2e141df667e24261720e27ff785a150 100644 GIT binary patch delta 767 zcmY*XOK1~O6rKCtvNG)HwRlT8KO$uJ%$UYFT)+k(-d1(@ix1((82?C@_nN?V@>%tJ(5 zd_Hh8@uy5VU^sBgCRYNtuC>eL!d3tPY|{=kI>-&%1jLWIe9@tK@&uj(@Z_n956mxZ z9q;nrz=UZ~i==}Jr0 zsiHB0bu^WyWmK+NQ09~HV;beX@QbV{X`qS^6j=2%)#S3Dlo#{LZ(c6)yGVwn_wwL~RfMgwZmLJsf5hUgc^;=PAkgJ`7FxK7a3%7=V8-b2rL zCVt^qTY(sfZ5Ma$*f=e`Ox0x0?T9S5xhFAz0gooqG|hJs6ZDPWB<^*KTp99O pbmRY3?Nhv)7{O8*Q+z$SNe$jjUZVRvk{Y9r+(>0;mRC~a{{T$6vLgTh delta 746 zcmY+C&ubG=5Xax_+a%lk#3#h@ZZv9z>mOQ}U_MS>I$LZwoyn`D!0lV;P+CdD5o zDdNGCQ&b2Zi}YZjcq!Y8M^P^xyy#z`|AAht-?ur*W0&{d%zWlM^X4%3BbQvr&$pUZ zy*_p*MBnS(3Hkd z(S{2SEW=EZQJUeg$VjH!0L?@0^?)jt?n_aG&lW$3Jf$v6qfBpj#mGYN6XOw0vFv*` zLls1<1`(l6PqD*At?C9P$a^j%HUU*KHM1a#YbxqP)KO=d90s`d_4Bzi0^5_(u4z}YO(g4Kg3SN zyG0HA@e+whm4C%X=qqR9+0pJ02)z7Mm{D^Aj6Tzw5lRmsO$jCU8baw75;d`uy@t0A z8uPa$O{a}6Le3|?lsJ_!Y&yU^D6a}Wo61;ffOsvDC!hBdiyGNHoV=KJY4-oQ8RT+u Z58cV7rsyHxNnN40+)d@^7VoF#{s9lQsWkuq -- 2.40.1 From 4aca543656b0a0019f10a61b5d9812d3864d5074 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 22 Mar 2024 10:57:21 +0100 Subject: [PATCH 68/68] add core back --- lua/core/default_config.lua | 92 ++++++++++++++++++++++++++++ lua/core/init.lua | 115 +++++++++++++++++++++++++++++++++++ lua/core/utils.lua | 118 ++++++++++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 lua/core/default_config.lua create mode 100644 lua/core/init.lua create mode 100644 lua/core/utils.lua diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua new file mode 100644 index 0000000..639916a --- /dev/null +++ b/lua/core/default_config.lua @@ -0,0 +1,92 @@ +local M = {} + +M.options = { + nvchad_branch = "v2.0", +} + +M.ui = { + ------------------------------- base46 ------------------------------------- + -- hl = highlights + hl_add = {}, + hl_override = {}, + changed_themes = {}, + theme_toggle = { "onedark", "one_light" }, + theme = "onedark", -- default theme + transparency = false, + lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens + + -- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations + extended_integrations = {}, -- these aren't compiled by default, ex: "alpha", "notify" + + -- cmp themeing + cmp = { + icons = true, + lspkind_text = true, + style = "default", -- default/flat_light/flat_dark/atom/atom_colored + border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables + selected_item_bg = "colored", -- colored / simple + }, + + telescope = { style = "borderless" }, -- borderless / bordered + + ------------------------------- nvchad_ui modules ----------------------------- + statusline = { + theme = "default", -- default/vscode/vscode_colored/minimal + -- default/round/block/arrow separators work only for default statusline theme + -- round and block will work for minimal theme only + separator_style = "default", + overriden_modules = nil, + }, + + -- lazyload it when there are 1+ buffers + tabufline = { + show_numbers = false, + enabled = true, + lazyload = true, + overriden_modules = nil, + }, + + -- nvdash (dashboard) + nvdash = { + load_on_startup = false, + + header = { + " ▄ ▄ ", + " ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ ", + " █ ▄ █▄█ ▄▄▄ █ █▄█ █ █ ", + " ▄▄ █▄█▄▄▄█ █▄█▄█▄▄█▄▄█ █ ", + " ▄ █▄▄█ ▄ ▄▄ ▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ", + " █▄▄▄▄ ▄▄▄ █ ▄ ▄▄▄ ▄ ▄▄▄ ▄ ▄ █ ▄", + "▄ █ █▄█ █▄█ █ █ █▄█ █ █▄█ ▄▄▄ █ █", + "█▄█ ▄ █▄▄█▄▄█ █ ▄▄█ █ ▄ █ █▄█▄█ █", + " █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █▄█▄▄▄█ ", + }, + + buttons = { + { " Find File", "Spc f f", "Telescope find_files" }, + { "󰈚 Recent Files", "Spc f o", "Telescope oldfiles" }, + { "󰈭 Find Word", "Spc f w", "Telescope live_grep" }, + { " Bookmarks", "Spc m a", "Telescope marks" }, + { " Themes", "Spc t h", "Telescope themes" }, + { " Mappings", "Spc c h", "NvCheatsheet" }, + }, + }, + + cheatsheet = { theme = "grid" }, -- simple/grid + + lsp = { + -- show function signatures i.e args as you type + signature = { + disabled = false, + silent = true, -- silences 'no signature help available' message from appearing + }, + }, +} + +M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file + +M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options + +M.mappings = require "core.mappings" + +return M diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..19804e1 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,115 @@ +local opt = vim.opt +local g = vim.g +local config = require("core.utils").load_config() + +-------------------------------------- globals ----------------------------------------- +g.nvchad_theme = config.ui.theme +g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" +g.toggle_theme_icon = "  " +g.transparency = config.ui.transparency + +-------------------------------------- options ------------------------------------------ +opt.laststatus = 3 -- global statusline +opt.showmode = false + +opt.clipboard = "unnamedplus" +opt.cursorline = true + +-- Indenting +opt.expandtab = true +opt.shiftwidth = 2 +opt.smartindent = true +opt.tabstop = 2 +opt.softtabstop = 2 + +opt.fillchars = { eob = " " } +opt.ignorecase = true +opt.smartcase = true +opt.mouse = "a" + +-- Numbers +opt.number = true +opt.numberwidth = 2 +opt.ruler = false + +-- disable nvim intro +opt.shortmess:append "sI" + +opt.signcolumn = "yes" +opt.splitbelow = true +opt.splitright = true +opt.termguicolors = true +opt.timeoutlen = 400 +opt.undofile = true + +-- interval for writing swap file to disk, also used by gitsigns +opt.updatetime = 250 + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +opt.whichwrap:append "<>[]hl" + +g.mapleader = " " + +-- disable some default providers +for _, provider in ipairs { "node", "perl", "python3", "ruby" } do + vim.g["loaded_" .. provider .. "_provider"] = 0 +end + +-- add binaries installed by mason.nvim to path +local is_windows = vim.loop.os_uname().sysname == "Windows_NT" +vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH + +-------------------------------------- autocmds ------------------------------------------ +local autocmd = vim.api.nvim_create_autocmd + +-- dont list quickfix buffers +autocmd("FileType", { + pattern = "qf", + callback = function() + vim.opt_local.buflisted = false + end, +}) + +-- reload some chadrc options on-save +autocmd("BufWritePost", { + pattern = vim.tbl_map(function(path) + return vim.fs.normalize(vim.loop.fs_realpath(path)) + end, vim.fn.glob(vim.fn.stdpath "config" .. "/lua/custom/**/*.lua", true, true, true)), + group = vim.api.nvim_create_augroup("ReloadNvChad", {}), + + callback = function(opts) + local fp = vim.fn.fnamemodify(vim.fs.normalize(vim.api.nvim_buf_get_name(opts.buf)), ":r") --[[@as string]] + local app_name = vim.env.NVIM_APPNAME and vim.env.NVIM_APPNAME or "nvim" + local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".") + + require("plenary.reload").reload_module "base46" + require("plenary.reload").reload_module(module) + require("plenary.reload").reload_module "custom.chadrc" + + config = require("core.utils").load_config() + + vim.g.nvchad_theme = config.ui.theme + vim.g.transparency = config.ui.transparency + + -- statusline + require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme) + vim.opt.statusline = "%!v:lua.require('nvchad.statusline." .. config.ui.statusline.theme .. "').run()" + + -- tabufline + if config.ui.tabufline.enabled then + require("plenary.reload").reload_module "nvchad.tabufline.modules" + vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules').run()" + end + + require("base46").load_all_highlights() + -- vim.cmd("redraw!") + end, +}) + +-------------------------------------- commands ------------------------------------------ +local new_cmd = vim.api.nvim_create_user_command + +new_cmd("NvChadUpdate", function() + require "nvchad.updater"() +end, {}) diff --git a/lua/core/utils.lua b/lua/core/utils.lua new file mode 100644 index 0000000..8b2a03d --- /dev/null +++ b/lua/core/utils.lua @@ -0,0 +1,118 @@ +local M = {} +local merge_tb = vim.tbl_deep_extend + +M.load_config = function() + local config = require "core.default_config" + local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] + + if chadrc_path then + local chadrc = dofile(chadrc_path) + + config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) + config = merge_tb("force", config, chadrc) + config.mappings.disabled = nil + end + + return config +end + +M.remove_disabled_keys = function(chadrc_mappings, default_mappings) + if not chadrc_mappings then + return default_mappings + end + + -- store keys in a array with true value to compare + local keys_to_disable = {} + for _, mappings in pairs(chadrc_mappings) do + for mode, section_keys in pairs(mappings) do + if not keys_to_disable[mode] then + keys_to_disable[mode] = {} + end + section_keys = (type(section_keys) == "table" and section_keys) or {} + for k, _ in pairs(section_keys) do + keys_to_disable[mode][k] = true + end + end + end + + -- make a copy as we need to modify default_mappings + for section_name, section_mappings in pairs(default_mappings) do + for mode, mode_mappings in pairs(section_mappings) do + mode_mappings = (type(mode_mappings) == "table" and mode_mappings) or {} + for k, _ in pairs(mode_mappings) do + -- if key if found then remove from default_mappings + if keys_to_disable[mode] and keys_to_disable[mode][k] then + default_mappings[section_name][mode][k] = nil + end + end + end + end + + return default_mappings +end + +M.load_mappings = function(section, mapping_opt) + vim.schedule(function() + local function set_section_map(section_values) + if section_values.plugin then + return + end + + section_values.plugin = nil + + for mode, mode_values in pairs(section_values) do + local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {}) + for keybind, mapping_info in pairs(mode_values) do + -- merge default + user opts + local opts = merge_tb("force", default_opts, mapping_info.opts or {}) + + mapping_info.opts, opts.mode = nil, nil + opts.desc = mapping_info[2] + + vim.keymap.set(mode, keybind, mapping_info[1], opts) + end + end + end + + local mappings = require("core.utils").load_config().mappings + + if type(section) == "string" then + mappings[section]["plugin"] = nil + mappings = { mappings[section] } + end + + for _, sect in pairs(mappings) do + set_section_map(sect) + end + end) +end + +M.lazy_load = function(plugin) + vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, { + group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}), + callback = function() + local file = vim.fn.expand "%" + local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= "" + + if condition then + vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin) + + -- dont defer for treesitter as it will show slow highlighting + -- This deferring only happens only when we do "nvim filename" + if plugin ~= "nvim-treesitter" then + vim.schedule(function() + require("lazy").load { plugins = plugin } + + if plugin == "nvim-lspconfig" then + vim.cmd "silent! do FileType" + end + end, 0) + else + require("lazy").load { plugins = plugin } + end + end + end, + }) +end + +return M -- 2.40.1