From 4026d6af1ca43beadb49e4035796e7191c343200 Mon Sep 17 00:00:00 2001 From: Kulvir Singh Date: Sun, 7 Jan 2024 23:06:57 +0530 Subject: [PATCH] Quality of life features added --- nvim_packer/after/plugin/blame.lua | 1 + nvim_packer/after/plugin/bufferline.lua | 1 + nvim_packer/after/plugin/catppuccin.lua | 5 + nvim_packer/after/plugin/fugitive.lua | 2 + nvim_packer/after/plugin/indentblankline.lua | 26 +++ nvim_packer/after/plugin/lsp.lua | 45 ++++ nvim_packer/after/plugin/lualine.lua | 14 ++ nvim_packer/after/plugin/telescope.lua | 13 ++ nvim_packer/after/plugin/tmuxnavigator.lua | 9 + nvim_packer/after/plugin/treesitter.lua | 13 ++ nvim_packer/init.lua | 1 + nvim_packer/lua/core/init.lua | 2 + nvim_packer/lua/core/packer.lua | 63 +++++ nvim_packer/lua/core/remap.lua | 34 +++ nvim_packer/lua/core/set.lua | 29 +++ nvim_packer/plugin/packer_compiled.lua | 229 +++++++++++++++++++ 16 files changed, 487 insertions(+) create mode 100644 nvim_packer/after/plugin/blame.lua create mode 100644 nvim_packer/after/plugin/bufferline.lua create mode 100644 nvim_packer/after/plugin/catppuccin.lua create mode 100644 nvim_packer/after/plugin/fugitive.lua create mode 100644 nvim_packer/after/plugin/indentblankline.lua create mode 100644 nvim_packer/after/plugin/lsp.lua create mode 100644 nvim_packer/after/plugin/lualine.lua create mode 100644 nvim_packer/after/plugin/telescope.lua create mode 100644 nvim_packer/after/plugin/tmuxnavigator.lua create mode 100644 nvim_packer/after/plugin/treesitter.lua create mode 100644 nvim_packer/init.lua create mode 100644 nvim_packer/lua/core/init.lua create mode 100644 nvim_packer/lua/core/packer.lua create mode 100644 nvim_packer/lua/core/remap.lua create mode 100644 nvim_packer/lua/core/set.lua create mode 100644 nvim_packer/plugin/packer_compiled.lua diff --git a/nvim_packer/after/plugin/blame.lua b/nvim_packer/after/plugin/blame.lua new file mode 100644 index 0000000..4d4343b --- /dev/null +++ b/nvim_packer/after/plugin/blame.lua @@ -0,0 +1 @@ +require('blame').setup{} diff --git a/nvim_packer/after/plugin/bufferline.lua b/nvim_packer/after/plugin/bufferline.lua new file mode 100644 index 0000000..1c295dc --- /dev/null +++ b/nvim_packer/after/plugin/bufferline.lua @@ -0,0 +1 @@ +require("bufferline").setup{} diff --git a/nvim_packer/after/plugin/catppuccin.lua b/nvim_packer/after/plugin/catppuccin.lua new file mode 100644 index 0000000..4c6816d --- /dev/null +++ b/nvim_packer/after/plugin/catppuccin.lua @@ -0,0 +1,5 @@ +require("catppuccin").setup({ + flavour = "mocha", +}) + +vim.cmd.colorscheme("catppuccin") diff --git a/nvim_packer/after/plugin/fugitive.lua b/nvim_packer/after/plugin/fugitive.lua new file mode 100644 index 0000000..dd4fcc3 --- /dev/null +++ b/nvim_packer/after/plugin/fugitive.lua @@ -0,0 +1,2 @@ +vim.keymap.set("n", "gs", vim.cmd.Git); + diff --git a/nvim_packer/after/plugin/indentblankline.lua b/nvim_packer/after/plugin/indentblankline.lua new file mode 100644 index 0000000..63f40bf --- /dev/null +++ b/nvim_packer/after/plugin/indentblankline.lua @@ -0,0 +1,26 @@ +local highlight = { + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", +} +local hooks = require "ibl.hooks" +-- create the highlight groups in the highlight setup hook, so they are reset +-- every time the colorscheme changes +hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) + vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) + vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) + vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) + vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) + vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) + vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) +end) + +vim.g.rainbow_delimiters = { highlight = highlight } +require("ibl").setup { scope = { highlight = highlight } } + +hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) diff --git a/nvim_packer/after/plugin/lsp.lua b/nvim_packer/after/plugin/lsp.lua new file mode 100644 index 0000000..20d34f7 --- /dev/null +++ b/nvim_packer/after/plugin/lsp.lua @@ -0,0 +1,45 @@ +local lsp_zero = require('lsp-zero') + +lsp_zero.on_attach(function(client, bufnr) + local opts = {buffer = bufnr, remap = false} + + vim.keymap.set("n", "ca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "rn", function() vim.lsp.buf.rename() end, opts) + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "ws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) +end) + +require('mason').setup({}) +require('mason-lspconfig').setup({ + ensure_installed = {'tsserver', 'tailwindcss', 'cssls', 'clangd', 'pyright' }, + handlers = { + lsp_zero.default_setup, + lua_ls = function() + local lua_opts = lsp_zero.nvim_lua_ls() + require('lspconfig').lua_ls.setup(lua_opts) + end, + } +}) + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} + +cmp.setup({ + sources = { + {name = 'path'}, + {name = 'nvim_lsp'}, + {name = 'nvim_lua'}, + }, + formatting = lsp_zero.cmp_format(), + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + }), +}) diff --git a/nvim_packer/after/plugin/lualine.lua b/nvim_packer/after/plugin/lualine.lua new file mode 100644 index 0000000..c48603d --- /dev/null +++ b/nvim_packer/after/plugin/lualine.lua @@ -0,0 +1,14 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'onedark', + }, + sections = { + lualine_a = { + { + 'filename', + path = 1, + } + } + } +} diff --git a/nvim_packer/after/plugin/telescope.lua b/nvim_packer/after/plugin/telescope.lua new file mode 100644 index 0000000..28bf51d --- /dev/null +++ b/nvim_packer/after/plugin/telescope.lua @@ -0,0 +1,13 @@ +local builtin = require('telescope.builtin') + +require('telescope').setup({ + defaults = { + file_ignore_patterns = { ".git/", "node_modules" }, + layout_strategy = 'horizontal', + prompt_prefix = '🔭 ', + selection_caret = ' ', + initial_mode = 'insert', + }, +}) +vim.keymap.set('n', 'f', builtin.find_files, {}) +vim.keymap.set('n', '', builtin.git_files, {}) diff --git a/nvim_packer/after/plugin/tmuxnavigator.lua b/nvim_packer/after/plugin/tmuxnavigator.lua new file mode 100644 index 0000000..d6a94f9 --- /dev/null +++ b/nvim_packer/after/plugin/tmuxnavigator.lua @@ -0,0 +1,9 @@ +require('nvim-tmux-navigation').setup { + keybindings = { + left = "", + down = "", + up = "", + right = "", + next = "", + } +} diff --git a/nvim_packer/after/plugin/treesitter.lua b/nvim_packer/after/plugin/treesitter.lua new file mode 100644 index 0000000..9c85d1d --- /dev/null +++ b/nvim_packer/after/plugin/treesitter.lua @@ -0,0 +1,13 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = { "cpp", "typescript", "c", "python" }, + + sync_install = false, + + auto_install = true, + + highlight = { + enable = true, + + additional_vim_regex_highlighting = false, + }, +} diff --git a/nvim_packer/init.lua b/nvim_packer/init.lua new file mode 100644 index 0000000..d9a3b72 --- /dev/null +++ b/nvim_packer/init.lua @@ -0,0 +1 @@ +require("core") diff --git a/nvim_packer/lua/core/init.lua b/nvim_packer/lua/core/init.lua new file mode 100644 index 0000000..923f41c --- /dev/null +++ b/nvim_packer/lua/core/init.lua @@ -0,0 +1,2 @@ +require("core.remap") +require("core.set") diff --git a/nvim_packer/lua/core/packer.lua b/nvim_packer/lua/core/packer.lua new file mode 100644 index 0000000..bea8eef --- /dev/null +++ b/nvim_packer/lua/core/packer.lua @@ -0,0 +1,63 @@ +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + + -- Telescope (Fuzzy Finder) + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.5', + requires = { {'nvim-lua/plenary.nvim'} } + } + + -- One Dark Theme + -- use 'navarasu/onedark.nvim' + use { "catppuccin/nvim", as = "catppuccin" } + + -- Treesitter (better Syntax Highlighting) + use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) + use('nvim-treesitter/playground') + + -- Command Line view at the bottom + use('nvim-lualine/lualine.nvim') + + use('tpope/vim-fugitive') + use('github/copilot.vim') + + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + requires = { + -- LSP support + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + {'neovim/nvim-lspconfig'}, + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'hrsh7th/cmp-nvim-lua'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'L3MON4D3/LuaSnip'}, + {'honza/vim-snippets'} + } + } + + -- Better comments + use { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup() + end + } + + use 'alexghergh/nvim-tmux-navigation' + use 'FabijanZulj/blame.nvim' + + use "lukas-reineke/indent-blankline.nvim" + + use "nvim-tree/nvim-web-devicons" + + use {'akinsho/bufferline.nvim', tag = "*", requires = 'nvim-tree/nvim-web-devicons'} + +end) diff --git a/nvim_packer/lua/core/remap.lua b/nvim_packer/lua/core/remap.lua new file mode 100644 index 0000000..7585d4b --- /dev/null +++ b/nvim_packer/lua/core/remap.lua @@ -0,0 +1,34 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "n", vim.cmd.Ex) + +-- Prime said this is greated remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- some next greatest remaps +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({"n", "v"}, "d", [["_d]]) + +-- move lines smooth butter smooth +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- Pasting from clipboard hurts in vim +vim.keymap.set('n', 'P', '"+p') + +-- Copying to Clipboard +--vim.keymap.set('v', 'y', '"+y') + +vim.keymap.set('n', 'h', vim.cmd.split) +vim.keymap.set('n', 'v', vim.cmd.vsplit) + +-- Keep ya head straight +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') + +vim.keymap.set("n", "", vim.cmd.bnext) +vim.keymap.set("n", "", vim.cmd.bprev) +vim.keymap.set('n', 'q', vim.cmd.bdelete) + diff --git a/nvim_packer/lua/core/set.lua b/nvim_packer/lua/core/set.lua new file mode 100644 index 0000000..9acbe80 --- /dev/null +++ b/nvim_packer/lua/core/set.lua @@ -0,0 +1,29 @@ +vim.opt.nu = true +vim.opt.rnu = true + +vim.opt.autoread = true + +-- Prevent continue comment on new line +vim.api.nvim_create_autocmd( + "FileType", + { pattern = "*", command = [[setlocal formatoptions-=c formatoptions-=r formatoptions-=o]] } +) + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.shiftround = true +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = 'yes' + +vim.cmd.termguicolors = true + +vim.g.netrw_banner = 0 +vim.g.netrw_browse_split = 0 +vim.g.netrw_winsize = 25 diff --git a/nvim_packer/plugin/packer_compiled.lua b/nvim_packer/plugin/packer_compiled.lua new file mode 100644 index 0000000..da3c7d5 --- /dev/null +++ b/nvim_packer/plugin/packer_compiled.lua @@ -0,0 +1,229 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end +else + time = function(chunk, start) end +end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/Users/kulvir/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?.lua;/Users/kulvir/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?/init.lua;/Users/kulvir/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?.lua;/Users/kulvir/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/Users/kulvir/.cache/nvim/packer_hererocks/2.1.1700008891/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["Comment.nvim"] = { + config = { "\27LJ\2\n5\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\fComment\frequire\0" }, + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + LuaSnip = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["blame.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/blame.nvim", + url = "https://github.com/FabijanZulj/blame.nvim" + }, + ["bufferline.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/bufferline.nvim", + url = "https://github.com/akinsho/bufferline.nvim" + }, + catppuccin = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/catppuccin", + url = "https://github.com/catppuccin/nvim" + }, + ["cmp-buffer"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + ["copilot.vim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/copilot.vim", + url = "https://github.com/github/copilot.vim" + }, + ["indent-blankline.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + ["lsp-zero.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim", + url = "https://github.com/VonHeikemen/lsp-zero.nvim" + }, + ["lualine.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/lualine.nvim", + url = "https://github.com/nvim-lualine/lualine.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-tmux-navigation"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/nvim-tmux-navigation", + url = "https://github.com/alexghergh/nvim-tmux-navigation" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/nvim-tree/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + playground = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/playground", + url = "https://github.com/nvim-treesitter/playground" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["vim-fugitive"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/vim-fugitive", + url = "https://github.com/tpope/vim-fugitive" + }, + ["vim-snippets"] = { + loaded = true, + path = "/Users/kulvir/.local/share/nvim/site/pack/packer/start/vim-snippets", + url = "https://github.com/honza/vim-snippets" + } +} + +time([[Defining packer_plugins]], false) +-- Config for: Comment.nvim +time([[Config for Comment.nvim]], true) +try_loadstring("\27LJ\2\n5\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\fComment\frequire\0", "config", "Comment.nvim") +time([[Config for Comment.nvim]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end