From a4ee3624d0c96db0ac424b1eeadfd6fda2c9f768 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Sat, 28 Oct 2023 20:05:40 +0530 Subject: [PATCH] - Backed up (for later retrieval) a custom set of nvim lazy configurations --- common/.config/nvim/custom.nvim/init.lua | 2 + .../.config/nvim/custom.nvim/lazy-lock.json | 40 ++++++ .../nvim/custom.nvim/lua/pratik/core/init.lua | 2 + .../custom.nvim/lua/pratik/core/keymaps.lua | 48 +++++++ .../custom.nvim/lua/pratik/core/options.lua | 51 +++++++ .../nvim/custom.nvim/lua/pratik/lazy.lua | 15 ++ .../lua/pratik/plugins/dressing.lua | 4 + .../lua/pratik/plugins/ide/auto-pairs.lua | 24 ++++ .../lua/pratik/plugins/ide/gitsigns.lua | 5 + .../lua/pratik/plugins/ide/lspconfig.lua | 134 ++++++++++++++++++ .../lua/pratik/plugins/ide/mason.lua | 53 +++++++ .../lua/pratik/plugins/ide/nvim-cmp.lua | 67 +++++++++ .../lua/pratik/plugins/ide/rust-tools.lua | 3 + .../pratik/plugins/ide/symbols-outline.lua | 8 ++ .../custom.nvim/lua/pratik/plugins/init.lua | 11 ++ .../lua/pratik/plugins/looks/colorizer.lua | 5 + .../lua/pratik/plugins/looks/lualine.lua | 71 ++++++++++ .../plugins/looks/nightfly-colorscheme.lua | 8 ++ .../lua/pratik/plugins/looks/web-devicons.lua | 3 + .../lua/pratik/plugins/maximizer.lua | 3 + .../lua/pratik/plugins/nvim-tree.lua | 53 +++++++ .../lua/pratik/plugins/telescope.lua | 31 ++++ .../plugins/treesitter-text-objects.lua | 110 ++++++++++++++ .../lua/pratik/plugins/treesitter.lua | 64 +++++++++ .../lua/pratik/plugins/which-key.lua | 36 +++++ 25 files changed, 851 insertions(+) create mode 100644 common/.config/nvim/custom.nvim/init.lua create mode 100644 common/.config/nvim/custom.nvim/lazy-lock.json create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/core/init.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/core/keymaps.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/core/options.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/lazy.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/dressing.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/auto-pairs.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/gitsigns.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/lspconfig.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/mason.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/nvim-cmp.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/rust-tools.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/symbols-outline.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/init.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/colorizer.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/lualine.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/nightfly-colorscheme.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/web-devicons.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/maximizer.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/nvim-tree.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/telescope.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter-text-objects.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter.lua create mode 100644 common/.config/nvim/custom.nvim/lua/pratik/plugins/which-key.lua diff --git a/common/.config/nvim/custom.nvim/init.lua b/common/.config/nvim/custom.nvim/init.lua new file mode 100644 index 0000000..8a37d10 --- /dev/null +++ b/common/.config/nvim/custom.nvim/init.lua @@ -0,0 +1,2 @@ +require("pratik.core") +require("pratik.lazy") diff --git a/common/.config/nvim/custom.nvim/lazy-lock.json b/common/.config/nvim/custom.nvim/lazy-lock.json new file mode 100644 index 0000000..ef9f320 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lazy-lock.json @@ -0,0 +1,40 @@ +{ + "LuaSnip": { "branch": "master", "commit": "80a8528f084a97b624ae443a6f50ff8074ba486b" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "dressing.nvim": { "branch": "master", "commit": "1f2d1206a03bd3add8aedf6251e4534611de577f" }, + "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, + "gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" }, + "lazy.nvim": { "branch": "main", "commit": "16603c6917435d8446f7357cb61095138a417085" }, + "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "e4f34741daa9cf95de68a603d3e7a6844a69fdf0" }, + "mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" }, + "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, + "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "0ae13ac58136c6175638b6e1ba04cb487dd22272" }, + "nvim-lspconfig": { "branch": "master", "commit": "cb49a4cd622d7ed775c31561bb8aa6a50712d6b9" }, + "nvim-tree.lua": { "branch": "master", "commit": "78a9ca5ed6557f29cd0ce203df44213e54bfabb9" }, + "nvim-treesitter": { "branch": "master", "commit": "bf0a96568a54618138ac42c84758945cdafef86b" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "e69a504baf2951d52e1f1fbb05145d43f236cbf1" }, + "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, + "nvim-web-devicons": { "branch": "master", "commit": "5de460ca7595806044eced31e3c36c159a493857" }, + "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, + "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, + "vim-fugitive": { "branch": "master", "commit": "cbe9dfa162c178946afa689dd3f42d4ea8bf89c1" }, + "vim-gitgutter": { "branch": "main", "commit": "f7b97666ae36c7b3f262f3190dbcd7033845d985" }, + "vim-highlightedyank": { "branch": "master", "commit": "fa3f57b097e9521ce41a66b6c7cf5d9adea70ea3" }, + "vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" }, + "vim-nightfly-guicolors": { "branch": "master", "commit": "9053e99131731f268258ab4d35d4841c3126ff9a" }, + "vim-paragraph-motion": { "branch": "master", "commit": "2f6b36670327952b0bcc6915f4947feb85977af3" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-trailing-whitespace": { "branch": "master", "commit": "5540b3faa2288b226a8d9a4e8244558b12c598aa" } +} \ No newline at end of file diff --git a/common/.config/nvim/custom.nvim/lua/pratik/core/init.lua b/common/.config/nvim/custom.nvim/lua/pratik/core/init.lua new file mode 100644 index 0000000..1e45909 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/core/init.lua @@ -0,0 +1,2 @@ +require("pratik.core.keymaps") +require("pratik.core.options") diff --git a/common/.config/nvim/custom.nvim/lua/pratik/core/keymaps.lua b/common/.config/nvim/custom.nvim/lua/pratik/core/keymaps.lua new file mode 100644 index 0000000..defc95c --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/core/keymaps.lua @@ -0,0 +1,48 @@ +-- set leader key to space +vim.g.mapleader = " " + +local keymap = vim.keymap + +-- General Keymaps ------------------- + +-- clear search highlights +keymap.set("n", "hx", ":nohl", { desc = "Clear search highlights" }) + +-- delete single character without copying into register +keymap.set("n", "x", '"_x') + +-- increment/decrement numbers +keymap.set("n", "+", "", { desc = "Increment number" }) +keymap.set("n", "-", "", { desc = "Decrement number" }) + +-- window management +keymap.set("n", "sv", "v", { desc = "Split window vertically" }) +keymap.set("n", "sh", "s", { desc = "Split window horizontally" }) +keymap.set("n", "se", "=", { desc = "Make splits equal size" }) +keymap.set("n", "sx", "close", { desc = "Close current split" }) + +keymap.set("n", "ta", "tabnew", { desc = "Open new tab" }) +keymap.set("n", "tx", "tabclose", { desc = "Close current tab" }) +keymap.set("n", "tn", "tabn", { desc = "Go to next tab" }) +keymap.set("n", "tp", "tabp", { desc = "Go to previous tab" }) +-- keymap.set("n", "tf", "tabnew %", { desc = "Open current buffer in new tab" }) + +-- Center cursor after scrolling +keymap.set("n", "", "zz") +keymap.set("n", "", "zz") + +-- Plugin Keymaps ------------------- + +-- vim-maximizer +keymap.set("n", "sm", ":MaximizerToggle", { desc = "Maximize Split" }) + +-- nvim-tree +keymap.set("n", "ee", ":NvimTreeToggle", { desc = "Open/Close file explorer" }) +keymap.set("n", "ef", ":NvimTreeFocus", { desc = "Bring focus back to file explorer" }) +keymap.set("n", "er", "NvimTreeRefresh", { desc = "Refresh file explorer" }) + +-- telescope +keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd" }) +keymap.set("n", "fr", "Telescope oldfiles", { desc = "Fuzzy find recent files" }) +keymap.set("n", "fs", "Telescope live_grep", { desc = "Find string in cwd" }) +keymap.set("n", "fc", "Telescope grep_string", { desc = "Find string under cursor in cwd" }) diff --git a/common/.config/nvim/custom.nvim/lua/pratik/core/options.lua b/common/.config/nvim/custom.nvim/lua/pratik/core/options.lua new file mode 100644 index 0000000..84d7e30 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/core/options.lua @@ -0,0 +1,51 @@ +local opt = vim.opt -- for conciseness + +-- line numbers +opt.relativenumber = true -- show relative line numbers +opt.number = true -- shows absolute line number on cursor line (when relative number is on) + +-- tabs & indentation +opt.tabstop = 2 -- 2 spaces for tabs (prettier default) +opt.shiftwidth = 2 -- 2 spaces for indent width +opt.expandtab = true -- expand tab to spaces +opt.autoindent = true -- copy indent from current line when starting new one + +-- line wrapping +opt.wrap = true -- disable line wrapping + +opt.encoding = "utf-8" + +opt.syntax = "on" +opt.showmatch = true +opt.shortmess:append("I") +opt.mouse:append("a") + +-- search settings +opt.ignorecase = true -- ignore case when searching +opt.smartcase = true -- if you include mixed case in your search, assumes you want case-sensitive +opt.incsearch = true + +-- cursor line +opt.cursorline = true -- highlight the current cursor line + +-- appearance + +-- turn on termguicolors for nightfly colorscheme to work +-- (have to use iterm2 or any other true color terminal) +opt.termguicolors = true +opt.background = "dark" -- colorschemes that can be light or dark will be made dark +opt.signcolumn = "yes" -- show sign column so that text doesn't shift + +-- backspace +opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position + +-- clipboard +opt.clipboard:append("unnamedplus") -- use system clipboard as default register +opt.clipboard:append("unnamed") + +-- split windows +opt.splitright = true -- split vertical window to the right +opt.splitbelow = true -- split horizontal window to the bottom + +-- turn off swapfile +opt.swapfile = false diff --git a/common/.config/nvim/custom.nvim/lua/pratik/lazy.lua b/common/.config/nvim/custom.nvim/lua/pratik/lazy.lua new file mode 100644 index 0000000..ea3f0d8 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/lazy.lua @@ -0,0 +1,15 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + { import = "pratik.plugins" }, + { import = "pratik.plugins.ide" }, + { import = "pratik.plugins.looks" }, +}, { + change_detection = { + notify = false, + } +}) diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/dressing.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/dressing.lua new file mode 100644 index 0000000..105f7e5 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/dressing.lua @@ -0,0 +1,4 @@ +return { + "stevearc/dressing.nvim", + event = "VeryLazy", +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/auto-pairs.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/auto-pairs.lua new file mode 100644 index 0000000..5661655 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/auto-pairs.lua @@ -0,0 +1,24 @@ +return { + "windwp/nvim-autopairs", + event = { "InsertEnter" }, + dependencies = { + "hrsh7th/nvim-cmp", + }, + config = function() + -- configure autopairs + require("nvim-autopairs").setup({ + check_ts = true, -- enable treesitter + ts_config = { + lua = { "string" }, -- don't add pairs in lua string treesitter nodes + javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, + }) + + -- import nvim-autopairs completion functionality + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + + -- make autopairs and completion work together + require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/gitsigns.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/gitsigns.lua new file mode 100644 index 0000000..eaf7ae7 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/gitsigns.lua @@ -0,0 +1,5 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = true, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/lspconfig.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/lspconfig.lua new file mode 100644 index 0000000..a6828e2 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/lspconfig.lua @@ -0,0 +1,134 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + }, + config = function() + -- Change the Diagnostic symbols in the sign column (gutter) + local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + -- import lspconfig plugin + local lspconfig = require("lspconfig") + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + -- configure html server + lspconfig["html"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure typescript server with plugin + lspconfig["tsserver"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure css server + lspconfig["cssls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure tailwindcss server + lspconfig["tailwindcss"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure graphql language server + lspconfig["graphql"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" }, + }) + + -- configure emmet language server + lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + }) + + -- configure python server + lspconfig["pyright"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, + }) + + -- Setup keymaps + local keymap = vim.keymap -- for conciseness + local opts = { noremap = true, silent = true } + local on_attach = function(client, bufnr) + opts.buffer = bufnr + + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) -- show definition, references + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) -- mapping to restart lsp if necessary + end + + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/mason.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/mason.lua new file mode 100644 index 0000000..2d32587 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/mason.lua @@ -0,0 +1,53 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + config = function() + -- enable mason and configure icons + require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + require("mason-lspconfig").setup({ + -- list of servers for mason to install + ensure_installed = { + "tsserver", + "html", + "cssls", + "lua_ls", + "graphql", + "emmet_ls", + "pyright", + "rust_analyzer", + "dockerls", + "bashls", + "yamlls", + "jsonls" + }, + -- auto-install configured servers (with lspconfig) + automatic_installation = true, -- not the same as ensure_installed + }) + + require("mason-tool-installer").setup({ + ensure_installed = { + "prettier", -- prettier formatter + "stylua", -- lua formatter + "isort", -- python formatter + "black", -- python formatter + "pylint", -- python linter + "eslint_d", -- js linter + "jsonlint", + "markdownlint", + "shellcheck", + }, + }) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/nvim-cmp.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/nvim-cmp.lua new file mode 100644 index 0000000..8cabb54 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/nvim-cmp.lua @@ -0,0 +1,67 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + "L3MON4D3/LuaSnip", -- snippet engine + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + -- Rust Cargo + dependencies = { + { + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + src = { + cmp = { enabled = true }, + }, + }, + }, + }, + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "crates" }, -- Rust crates + { name = "nvim_lsp" }, + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/rust-tools.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/rust-tools.lua new file mode 100644 index 0000000..48d1d9e --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/rust-tools.lua @@ -0,0 +1,3 @@ +return { + "neovim/nvim-lspconfig", +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/symbols-outline.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/symbols-outline.lua new file mode 100644 index 0000000..dbc4605 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/ide/symbols-outline.lua @@ -0,0 +1,8 @@ +return { + { + "simrat39/symbols-outline.nvim", + cmd = "SymbolsOutline", + keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, + config = true, + }, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/init.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/init.lua new file mode 100644 index 0000000..0d8eacd --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/init.lua @@ -0,0 +1,11 @@ +return{ + -- My Favorite vanilla Vim plugins + 'tpope/vim-fugitive', + 'tpope/vim-surround', + 'tpope/vim-repeat', + 'machakann/vim-highlightedyank', + 'dbakker/vim-paragraph-motion', + 'airblade/vim-gitgutter', + 'bronson/vim-trailing-whitespace', + 'tpope/vim-commentary', +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/colorizer.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/colorizer.lua new file mode 100644 index 0000000..a65b5cc --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/colorizer.lua @@ -0,0 +1,5 @@ +return { + "NvChad/nvim-colorizer.lua", + event = { "BufReadPre", "BufNewFile" }, + config = true, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/lualine.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/lualine.lua new file mode 100644 index 0000000..3698644 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/lualine.lua @@ -0,0 +1,71 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local lualine = require("lualine") + local lazy_status = require("lazy.status") -- to configure lazy pending updates count + + local colors = { + blue = "#65D1FF", + green = "#3EFFDC", + violet = "#FF61EF", + yellow = "#FFDA7B", + red = "#FF4A4A", + fg = "#c3ccdc", + bg = "#112638", + inactive_bg = "#2c3043", + } + + local my_lualine_theme = { + normal = { + a = { bg = colors.blue, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + insert = { + a = { bg = colors.green, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + visual = { + a = { bg = colors.violet, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + command = { + a = { bg = colors.yellow, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + replace = { + a = { bg = colors.red, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + inactive = { + a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = "bold" }, + b = { bg = colors.inactive_bg, fg = colors.semilightgray }, + c = { bg = colors.inactive_bg, fg = colors.semilightgray }, + }, + } + + -- configure lualine with modified theme + lualine.setup({ + options = { + theme = my_lualine_theme, + }, + sections = { + lualine_x = { + { + lazy_status.updates, + cond = lazy_status.has_updates, + color = { fg = "#ff9e64" }, + }, + { "encoding" }, + { "fileformat" }, + { "filetype" }, + }, + }, + }) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/nightfly-colorscheme.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/nightfly-colorscheme.lua new file mode 100644 index 0000000..661885b --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/nightfly-colorscheme.lua @@ -0,0 +1,8 @@ +return { + 'bluz71/vim-nightfly-guicolors', + priority = 1000, -- Makes sure this loads before all other plugins + config = function() + -- load the colorscheme here + vim.cmd([[colorscheme nightfly]]) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/web-devicons.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/web-devicons.lua new file mode 100644 index 0000000..89aa773 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/looks/web-devicons.lua @@ -0,0 +1,3 @@ +return{ + 'nvim-tree/nvim-web-devicons', +} \ No newline at end of file diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/maximizer.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/maximizer.lua new file mode 100644 index 0000000..b93cffb --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/maximizer.lua @@ -0,0 +1,3 @@ +return{ + 'szw/vim-maximizer', +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/nvim-tree.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/nvim-tree.lua new file mode 100644 index 0000000..9aab4b9 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/nvim-tree.lua @@ -0,0 +1,53 @@ +return { + "nvim-tree/nvim-tree.lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local nvimtree = require("nvim-tree") + + -- recommended settings from nvim-tree documentation + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + + -- change color for arrows in tree to light blue + vim.cmd([[ highlight NvimTreeFolderArrowClosed guifg=#3FC5FF ]]) + vim.cmd([[ highlight NvimTreeFolderArrowOpen guifg=#3FC5FF ]]) + + -- configure nvim-tree + nvimtree.setup({ + view = { + width = 28, + relativenumber = true, + }, + -- change folder arrow icons + renderer = { + indent_markers = { + enable = true, + }, + icons = { + glyphs = { + folder = { + arrow_closed = "", -- arrow when folder is closed + arrow_open = "", -- arrow when folder is open + }, + }, + }, + }, + -- disable window_picker for + -- explorer to work well with + -- window splits + actions = { + open_file = { + window_picker = { + enable = false, + }, + }, + }, + filters = { + custom = { ".DS_Store" }, + }, + git = { + ignore = false, + }, + }) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/telescope.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/telescope.lua new file mode 100644 index 0000000..03bdfc2 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/telescope.lua @@ -0,0 +1,31 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-tree/nvim-web-devicons", + }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.setup({ + defaults = { + path_display = { "truncate " }, + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, + }, + }) + + telescope.load_extension("fzf") + + -- set keymaps + local keymap = vim.keymap -- for conciseness + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter-text-objects.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter-text-objects.lua new file mode 100644 index 0000000..68d5164 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter-text-objects.lua @@ -0,0 +1,110 @@ +return { + "nvim-treesitter/nvim-treesitter-textobjects", + lazy = true, + config = function() + require("nvim-treesitter.configs").setup({ + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, + ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, + ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, + ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, + + -- works for javascript/typescript files (custom capture I created in after/queries/ecma/textobjects.scm) + ["a:"] = { query = "@property.outer", desc = "Select outer part of an object property" }, + ["i:"] = { query = "@property.inner", desc = "Select inner part of an object property" }, + ["l:"] = { query = "@property.lhs", desc = "Select left part of an object property" }, + ["r:"] = { query = "@property.rhs", desc = "Select right part of an object property" }, + + ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" }, + ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" }, + + ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, + ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, + + ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, + ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, + + ["af"] = { query = "@call.outer", desc = "Select outer part of a function call" }, + ["if"] = { query = "@call.inner", desc = "Select inner part of a function call" }, + + ["am"] = { query = "@function.outer", desc = "Select outer part of a method/function definition" }, + ["im"] = { query = "@function.inner", desc = "Select inner part of a method/function definition" }, + + ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, + }, + }, + swap = { + enable = true, + swap_next = { + ["na"] = "@parameter.inner", -- swap parameters/argument with next + ["n:"] = "@property.outer", -- swap object property with next + ["nm"] = "@function.outer", -- swap function with next + }, + swap_previous = { + ["pa"] = "@parameter.inner", -- swap parameters/argument with prev + ["p:"] = "@property.outer", -- swap object property with prev + ["pm"] = "@function.outer", -- swap function with previous + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]f"] = { query = "@call.outer", desc = "Next function call start" }, + ["]m"] = { query = "@function.outer", desc = "Next method/function def start" }, + ["]c"] = { query = "@class.outer", desc = "Next class start" }, + ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, + ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, + + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_next_end = { + ["]F"] = { query = "@call.outer", desc = "Next function call end" }, + ["]M"] = { query = "@function.outer", desc = "Next method/function def end" }, + ["]C"] = { query = "@class.outer", desc = "Next class end" }, + ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, + ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, + }, + goto_previous_start = { + ["[f"] = { query = "@call.outer", desc = "Prev function call start" }, + ["[m"] = { query = "@function.outer", desc = "Prev method/function def start" }, + ["[c"] = { query = "@class.outer", desc = "Prev class start" }, + ["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" }, + ["[l"] = { query = "@loop.outer", desc = "Prev loop start" }, + }, + goto_previous_end = { + ["[F"] = { query = "@call.outer", desc = "Prev function call end" }, + ["[M"] = { query = "@function.outer", desc = "Prev method/function def end" }, + ["[C"] = { query = "@class.outer", desc = "Prev class end" }, + ["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" }, + ["[L"] = { query = "@loop.outer", desc = "Prev loop end" }, + }, + }, + }, + }) + + local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move") + + -- vim way: ; goes to the direction you were moving. + vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) + vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) + + -- Optionally, make builtin f, F, t, T also repeatable with ; and , + vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f) + vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F) + vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t) + vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T) + end, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter.lua new file mode 100644 index 0000000..bbd9922 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/treesitter.lua @@ -0,0 +1,64 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + "windwp/nvim-ts-autotag", + }, + config = function() + -- import nvim-treesitter plugin + local treesitter = require("nvim-treesitter.configs") + + -- configure treesitter + treesitter.setup({ -- enable syntax highlighting + highlight = { + enable = true, + }, + -- enable indentation + indent = { enable = true }, + -- enable autotagging (w/ nvim-ts-autotag plugin) + autotag = { + enable = true, + }, + -- ensure these language parsers are installed + ensure_installed = { + "json", + "javascript", + "typescript", + "tsx", + "yaml", + "html", + "css", + "markdown", + "markdown_inline", + "graphql", + "bash", + "lua", + "vim", + "dockerfile", + "gitignore", + "query", + "rust", + "toml", + "ron", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + -- enable nvim-ts-context-commentstring plugin for commenting tsx and jsx + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + }) + end, + }, +} diff --git a/common/.config/nvim/custom.nvim/lua/pratik/plugins/which-key.lua b/common/.config/nvim/custom.nvim/lua/pratik/plugins/which-key.lua new file mode 100644 index 0000000..c96b272 --- /dev/null +++ b/common/.config/nvim/custom.nvim/lua/pratik/plugins/which-key.lua @@ -0,0 +1,36 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-tree/nvim-web-devicons", + }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.setup({ + defaults = { + path_display = { "truncate " }, + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, + }, + }) + + telescope.load_extension("fzf") + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd" }) + keymap.set("n", "fr", "Telescope oldfiles", { desc = "Fuzzy find recent files" }) + keymap.set("n", "fs", "Telescope live_grep", { desc = "Find string in cwd" }) + keymap.set("n", "fc", "Telescope grep_string", { desc = "Find string under cursor in cwd" }) + end, +}