├── chadrc.lua ├── mappings.lua ├── configs ├── lspconfig.lua └── null-ls.lua ├── plugins.lua ├── README.md └── install.sh /chadrc.lua: -------------------------------------------------------------------------------- 1 | ---@type ChadrcConfig 2 | local M = {} 3 | M.ui = { theme = 'catppuccin' } 4 | M.plugins = "custom.plugins" 5 | M.mappings = require("custom.mappings") 6 | return M 7 | -------------------------------------------------------------------------------- /mappings.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | M.dap = { 4 | plugin = true, 5 | n = { 6 | ["db"] = { 7 | " DapToggleBreakpoint ", 8 | "Add breakpoint at line", 9 | }, 10 | ["dr"] = { 11 | " DapContinue ", 12 | "Start or continue the debugger", 13 | } 14 | } 15 | } 16 | 17 | return M 18 | -------------------------------------------------------------------------------- /configs/lspconfig.lua: -------------------------------------------------------------------------------- 1 | local base = require("plugins.configs.lspconfig") 2 | local on_attach = base.on_attach 3 | local capabilities = base.capabilities 4 | 5 | local lspconfig = require("lspconfig") 6 | 7 | lspconfig.clangd.setup { 8 | on_attach = function(client, bufnr) 9 | client.server_capabilities.signatureHelpProvider = false 10 | on_attach(client, bufnr) 11 | end, 12 | capabilities = capabilities, 13 | } 14 | -------------------------------------------------------------------------------- /configs/null-ls.lua: -------------------------------------------------------------------------------- 1 | local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) 2 | local null_ls = require("null-ls") 3 | 4 | local opts = { 5 | sources = { 6 | null_ls.builtins.formatting.clang_format, 7 | }, 8 | on_attach = function(client, bufnr) 9 | if client.supports_method("textDocument/formatting") then 10 | vim.api.nvim_clear_autocmds({ 11 | group = augroup, 12 | buffer = bufnr, 13 | }) 14 | vim.api.nvim_create_autocmd("BufWritePre", { 15 | group = augroup, 16 | buffer = bufnr, 17 | callback = function() 18 | vim.lsp.buf.format({ bufnr = bufnr }) 19 | end, 20 | }) 21 | end 22 | end, 23 | } 24 | 25 | return opts 26 | -------------------------------------------------------------------------------- /plugins.lua: -------------------------------------------------------------------------------- 1 | local plugins = { 2 | { 3 | "rcarriga/nvim-dap-ui", 4 | event = "VeryLazy", 5 | dependencies = "mfussenegger/nvim-dap", 6 | config = function() 7 | local dap = require("dap") 8 | local dapui = require("dapui") 9 | dapui.setup() 10 | dap.listeners.after.event_initialized["dapui_config"] = function() 11 | dapui.open() 12 | end 13 | dap.listeners.before.event_terminated["dapui_config"] = function() 14 | dapui.close() 15 | end 16 | dap.listeners.before.event_exited["dapui_config"] = function() 17 | dapui.close() 18 | end 19 | end 20 | }, 21 | { 22 | "jay-babu/mason-nvim-dap.nvim", 23 | event = "VeryLazy", 24 | dependencies = { 25 | "williamboman/mason.nvim", 26 | "mfussenegger/nvim-dap", 27 | }, 28 | opts = { 29 | handlers = {} 30 | }, 31 | }, 32 | { 33 | "mfussenegger/nvim-dap", 34 | config = function(_, _) 35 | require("core.utils").load_mappings("dap") 36 | end 37 | }, 38 | { 39 | "jose-elias-alvarez/null-ls.nvim", 40 | event = "VeryLazy", 41 | opts = function() 42 | return require "custom.configs.null-ls" 43 | end, 44 | }, 45 | { 46 | "neovim/nvim-lspconfig", 47 | config = function() 48 | require "plugins.configs.lspconfig" 49 | require "custom.configs.lspconfig" 50 | end, 51 | }, 52 | { 53 | "williamboman/mason.nvim", 54 | opts = { 55 | ensure_installed = { 56 | "clangd", 57 | "clang-format", 58 | "codelldb", 59 | } 60 | } 61 | } 62 | } 63 | return plugins 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Neovim CPP 2 | 3 | [![GitHub license](https://img.shields.io/github/license/dreamsofcode-io/neovim-cpp)](https://github.com/dreamsofcode-io/neovim-cpp/blob/main/LICENSE) 4 | 5 | this repository is a personal collection of dotfiles I've curated to optimize the experience of using Neovim with C++. It includes a selection of plugins and configurations that are specifically designed to enhance C++ development. 6 | 7 | ## Table of Contents 8 | 9 | - [Installation](#installation) 10 | - [Usage](#usage) 11 | - [Shell Script](#Shell-Script) 12 | - [Credits](#credits) 13 | 14 | ## Installation 15 | 16 | To install Neovim CPP, follow these steps: 17 | 18 | 1. Clone the repository: 19 | ```bash 20 | git clone https://github.com/dreamsofcode-io/neovim-cpp.git --depth 1 21 | ``` 22 | 2. Change to the project directory: 23 | ```bash 24 | cd neovim-cpp 25 | ``` 26 | 3. Run the shell script to install the dependencies: 27 | ```bash 28 | sh install.sh 29 | ``` 30 | 31 | ## Usage 32 | 33 | After installation, you can start using Neovim. The plugins and configurations included in this project will provide you with a comfortable and efficient environment for C++ development. 34 | 35 | ## Shell-Script 36 | 37 | The `install.sh` shell script is responsible for installing the necessary dependencies for this repository. this script will open nvim with MasonInstallAll command to install all necessary plugins by adding it into init.lua file. so if the script didn't remove MasonInstallAll command from init.lua, you can remove it manually by running this in your terminal: 38 | ```bash 39 | sed -i '/^vim.cmd("MasonInstallAll")$/d' ~/.config/nvim/init.lua 40 | ``` 41 | 42 | ## Credits 43 | 44 | This project was developed by [dreamsofcode-io](https://github.com/dreamsofcode-io). 45 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Define colors 4 | RED='\033[0;31m' 5 | WHITE='\033[0;37m' 6 | GREEN='\033[0;32m' 7 | NC='\033[0m' # No Color 8 | 9 | clear 10 | 11 | # Check if Git is installed 12 | if ! command -v git &> /dev/null 13 | then 14 | echo -e "${RED}[ERROR]${NC} => Git could not be found. Install git before this." 15 | exit 16 | fi 17 | 18 | . /etc/os-release 19 | 20 | if [ "$ID" = "arch" ]; then 21 | read -p "looks like you are on arch linux. would you like to install jetbrains nerd font? (yes/no) " response 22 | case "$response" in 23 | [yY][eE][sS]|[yY]) 24 | sudo pacman -S ttf-jetbrains-mono-nerd 25 | ;; 26 | *) 27 | echo -e "${RED}Skipping nerd font installation...${NC}" 28 | clear 29 | ;; 30 | esac 31 | fi 32 | 33 | # Backup Operation 34 | echo -e "${GREEN}-==Backup Operation==-${NC}" 35 | # Ask user if they want to create a backup 36 | read -p "Do you want to create a backup of your current .config/nvim directory? (yes/no) " response 37 | case "$response" in 38 | [yY][eE][sS]|[yY]) 39 | # Check if the backup directory exists 40 | if [ ! -d ~/.config/nvim-backup ]; then 41 | mkdir ~/.config/nvim-backup 42 | fi 43 | # Create a timestamped backup of the .config/nvim directory 44 | timestamp=$(date +%Y%m%d-%H%M%S) 45 | cp -r ~/.config/nvim ~/.config/nvim-backup/$timestamp 46 | ;; 47 | *) 48 | echo -e "${WHITE}Skipping backup...${NC}" 49 | ;; 50 | esac 51 | 52 | # Install NvChad 53 | echo -e "${GREEN}-==Installing NvChad ...==-${NC}" 54 | git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1 > /dev/null 2>&1 55 | 56 | # Cloning Repository 57 | echo -e "${GREEN}-==Cloning Repository ...==-${NC}" 58 | git clone https://github.com/dreamsofcode-io/neovim-cpp.git > /dev/null 2>&1 59 | # Navigate to the cloned directory 60 | cd neovim-cpp 61 | 62 | # Copying Files 63 | echo -e "${GREEN}-==Copying Files==-${NC}" 64 | rsync -av --exclude='README.md' --exclude='.git/' --exclude='install.sh' . ~/.config/nvim/lua/custom 65 | 66 | # Adding Command 67 | # Display a warning message (for MasonInstallAll) 68 | echo -e "${WHITE}Neovim is about to open to install needed packages, after it downloaded the packages, quit neovim with quit command! and wait for script to do the rest.${NC}" 69 | 70 | # Ask user for confirmation 71 | read -p "Do you understand the instructions? (yes/no) " response 72 | case "$response" in 73 | [yY][eE][sS]|[yY]) 74 | echo -e "${GREEN}-==Adding MasonInstallAll Command==-${NC}" 75 | # Append the MasonInstallAll command to the init.lua file 76 | echo 'vim.cmd("MasonInstallAll")' >> ~/.config/nvim/init.lua 77 | # Open Neovim 78 | nvim 79 | ;; 80 | *) 81 | echo -e "${RED}Exiting...${NC}" 82 | exit 1 83 | ;; 84 | esac 85 | 86 | # Removing Command 87 | echo -e "${GREEN}-==Removing MasonInstallAll Command==-${NC}" 88 | # Remove the command from init.lua 89 | sed -i '/^vim.cmd("MasonInstallAll")$/d' ~/.config/nvim/init.lua 90 | 91 | # Removing Directory 92 | echo -e "${GREEN}-==Removing necessary files==-${NC}" 93 | # Remove the cloned directory 94 | rm -rf ../neovim-cpp 95 | --------------------------------------------------------------------------------