From 72b9fa501885b4480be0e57d2963c565a7880857 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sat, 17 Jul 2021 09:08:45 +0530 Subject: [PATCH 1/4] mappings: Use ESC to clear search highlighting and to get out of terminal insert mode --- lua/mappings.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/mappings.lua b/lua/mappings.lua index fb52afb..e04c137 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -133,3 +133,9 @@ map("n", "", ":bd!", opt) -- close tab -- move between tabs map("n", "", [[BufferLineCycleNext]], opt) map("n", "", [[BufferLineCyclePrev]], opt) + +-- use ESC to turn off search highlighting +map("n", "", ":noh", opts) + +-- get out of terminal with ESC +map("t", "", "", opts) From dbc4979ebd7497cb75ea5c37495c0b8da94fb4aa Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sat, 17 Jul 2021 14:34:36 +0530 Subject: [PATCH 2/4] Go to next/previous line with h,l,left and right --- lua/options.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/options.lua b/lua/options.lua index caed235..cd53fb9 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -31,6 +31,10 @@ opt.expandtab = true opt.shiftwidth = 2 opt.smartindent = true +-- 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 = " " g.auto_save = false From 1d7602e3e4e546d83636a114b5027ce0e3d3117b Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sat, 17 Jul 2021 16:48:41 +0530 Subject: [PATCH 3/4] mappings: Don't yank the text after pasting in visual mode --- lua/mappings.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/mappings.lua b/lua/mappings.lua index e04c137..f3bf180 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -20,6 +20,9 @@ map("v", "x", [=[ "_x ]=], opt) vim.api.nvim_set_keymap("i", "jk", "", {}) +-- Don't copy the replaced text after pasting in visual mode +map("v", "p", '"_dP', opt) + -- OPEN TERMINALS -- map("n", "", [[vnew term://bash ]], opt) -- term over right map("n", "", [[ split term://bash | resize 10 ]], opt) -- term bottom From 9c1a3ad2a2487c22cbc7fee02ef85aae24e438bd Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Sat, 17 Jul 2021 16:44:52 +0530 Subject: [PATCH 4/4] Use a different saner syntax for pcall takes less lines, looks much better remove neoscroll.lua, missed in 2952f4d5c74522c1ed0e22b1926335bde4c3ade0 --- lua/packerInit.lua | 21 +++++++-------------- lua/pluginList.lua | 11 +++-------- lua/plugins/autopairs.lua | 13 ++++--------- lua/plugins/autosave.lua | 10 ++-------- lua/plugins/bufferline.lua | 10 ++-------- lua/plugins/compe.lua | 10 ++-------- lua/plugins/gitsigns.lua | 10 ++-------- lua/plugins/icons.lua | 10 ++-------- lua/plugins/lspconfig.lua | 12 +++--------- lua/plugins/neoscroll.lua | 5 ----- lua/plugins/nvimtree.lua | 11 +++-------- lua/plugins/others.lua | 34 ++++++++++++---------------------- lua/plugins/statusline.lua | 12 +++--------- lua/plugins/telescope.lua | 10 ++-------- lua/plugins/treesitter.lua | 10 ++-------- lua/plugins/zenmode.lua | 10 ++-------- lua/theme.lua | 15 +++++---------- 17 files changed, 56 insertions(+), 158 deletions(-) delete mode 100644 lua/plugins/neoscroll.lua diff --git a/lua/packerInit.lua b/lua/packerInit.lua index d6b6c93..c23706a 100644 --- a/lua/packerInit.lua +++ b/lua/packerInit.lua @@ -1,11 +1,6 @@ -local packer -if - not pcall( - function() - packer = require "packer" - end - ) - then +local present, packer = pcall(require, "packer") + +if not present then local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" print("Cloning packer..") @@ -21,12 +16,10 @@ if packer_path } ) - if pcall( - function() - packer = require "packer" - end - ) - then + + present, packer = pcall(require, "packer") + + if present then print("Packer cloned successfully.") else error("Couldn't clone packer !\nPacker path: " .. packer_path) diff --git a/lua/pluginList.lua b/lua/pluginList.lua index 34650f3..6577d40 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -1,11 +1,6 @@ -local packer -if - pcall( - function() - require "packerInit" - end - ) - then +local present, _ = pcall(require, "packerInit") + +if present then packer = require "packer" else return false diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua index 9399571..4d035e6 100644 --- a/lua/plugins/autopairs.lua +++ b/lua/plugins/autopairs.lua @@ -1,12 +1,7 @@ -local autopairs, autopairs_completion -if - not pcall( - function() - autopairs = require "nvim-autopairs" - autopairs_completion = require "nvim-autopairs.completion.compe" - end - ) - then +local present1, autopairs = pcall(require, "nvim-autopairs") +local present2, autopairs_completion = pcall(require, "nvim-autopairs.completion.compe") + +if not (present1 or present2) then return end diff --git a/lua/plugins/autosave.lua b/lua/plugins/autosave.lua index fda9f9a..559ce3f 100644 --- a/lua/plugins/autosave.lua +++ b/lua/plugins/autosave.lua @@ -1,12 +1,6 @@ -- autosave.nvim plugin disabled by default -local autosave -if - not pcall( - function() - autosave = require "autosave" - end - ) - then +local present, autosave = pcall(require, "autosave") +if not present then return end diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua index c34b771..ed01a76 100644 --- a/lua/plugins/bufferline.lua +++ b/lua/plugins/bufferline.lua @@ -1,14 +1,8 @@ local global_theme = "themes/" .. vim.g.nvchad_theme local colors = require(global_theme) -local bufferline -if - not pcall( - function() - bufferline = require "bufferline" - end - ) - then +local present, bufferline = pcall(require, "bufferline") +if not present then return end diff --git a/lua/plugins/compe.lua b/lua/plugins/compe.lua index c41139a..238ca7c 100644 --- a/lua/plugins/compe.lua +++ b/lua/plugins/compe.lua @@ -1,11 +1,5 @@ -local compe -if - not pcall( - function() - compe = require "compe" - end - ) - then +local present, compe = pcall(require, "compe") +if not present then return end diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index d42758a..e2309ec 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,11 +1,5 @@ -local gitsigns -if - not pcall( - function() - gitsigns = require "gitsigns" - end - ) - then +local present, gitsigns = pcall(require, "gitsigns") +if not present then return end diff --git a/lua/plugins/icons.lua b/lua/plugins/icons.lua index 03e5f59..3425fde 100644 --- a/lua/plugins/icons.lua +++ b/lua/plugins/icons.lua @@ -1,11 +1,5 @@ -local icons -if - not pcall( - function() - icons = require "nvim-web-devicons" - end - ) - then +local present, icons = pcall(require, "nvim-web-devicons") +if not present then return end diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 58681ee..ad6bbaa 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,12 +1,6 @@ -local lspconfig, lspinstall -if - not pcall( - function() - lspconfig = require "lspconfig" - lspinstall = require "lspinstall" - end - ) - then +local present1, lspconfig = pcall(require, "lspconfig") +local present2, lspinstall = pcall(require, "lspinstall") +if not (present1 or present2) then return end diff --git a/lua/plugins/neoscroll.lua b/lua/plugins/neoscroll.lua deleted file mode 100644 index bc95671..0000000 --- a/lua/plugins/neoscroll.lua +++ /dev/null @@ -1,5 +0,0 @@ -pcall( - function() - require("neoscroll").setup() - end -) diff --git a/lua/plugins/nvimtree.lua b/lua/plugins/nvimtree.lua index 8450b88..5e9c041 100644 --- a/lua/plugins/nvimtree.lua +++ b/lua/plugins/nvimtree.lua @@ -1,14 +1,9 @@ -local tree_cb -if - not pcall( - function() - tree_cb = require "nvim-tree.config".nvim_tree_callback - end - ) - then +local present, tree_c = pcall(require, "nvim-tree.config") +if not present then return end +local tree_cb = tree_c.nvim_tree_callback local g = vim.g vim.o.termguicolors = true diff --git a/lua/plugins/others.lua b/lua/plugins/others.lua index 6382701..2278d09 100644 --- a/lua/plugins/others.lua +++ b/lua/plugins/others.lua @@ -1,35 +1,25 @@ local M = {} M.colorizer = function() - local colorizer - if - not pcall( - function() - colorizer = require("colorizer") - end - ) - then - return + local present, colorizer = pcall(require, "colorizer") + if present then + colorizer.setup() + vim.cmd("ColorizerReloadAllBuffers") end - - colorizer.setup() - vim.cmd("ColorizerReloadAllBuffers") end M.comment = function() - pcall( - function() - require("nvim_comment").setup() - end - ) + local present, nvim_comment = pcall(require, "nvim_comment") + if present then + nvim_comment.setup() + end end M.lspkind = function() - pcall( - function() - require("lspkind").init() - end - ) + local present, lspkind = pcall(require, "lspkind") + if present then + lspkind.init() + end end M.neoscroll = function() diff --git a/lua/plugins/statusline.lua b/lua/plugins/statusline.lua index b49cdaf..8f543c8 100644 --- a/lua/plugins/statusline.lua +++ b/lua/plugins/statusline.lua @@ -1,12 +1,6 @@ -local gl, condition -if - not pcall( - function() - gl = require "galaxyline" - condition = require "galaxyline.condition" - end - ) - then +local present1, gl = pcall(require, "galaxyline") +local present2, condition = pcall(require, "galaxyline.condition") +if not (present1 or present2) then return end diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index f9f3819..c3799eb 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,11 +1,5 @@ -local telescope -if - not pcall( - function() - telescope = require("telescope") - end - ) - then +local present, telescope = pcall(require, "telescope") +if not present then return end diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index bf574eb..c1ca2ef 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,11 +1,5 @@ -local ts_config -if - not pcall( - function() - ts_config = require "nvim-treesitter.configs" - end - ) - then +local present, ts_config = pcall(require, "nvim-treesitter.configs") +if not present then return end diff --git a/lua/plugins/zenmode.lua b/lua/plugins/zenmode.lua index 4a49f5d..40d01c0 100644 --- a/lua/plugins/zenmode.lua +++ b/lua/plugins/zenmode.lua @@ -1,11 +1,5 @@ -local true_zen -if - not pcall( - function() - true_zen = require "true-zen" - end - ) - then +local present, true_zen = pcall(require, "true-zen") +if not present then return end diff --git a/lua/theme.lua b/lua/theme.lua index 83a7449..c87aa51 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,15 +1,10 @@ vim.g.nvchad_theme = "onedark" -local base16 -if - not pcall( - function() - base16 = require "base16" - end - ) - then - return false -else +local present, base16 = pcall(require, "base16") + +if present then base16(base16.themes["onedark"], true) return true +else + return false end