This repository contains my personal Vim (.vimrc) and CoC (coc-settings.json) configurations for Fedora. This setup aims to provide a modern, IDE-like experience in Vim, primarily powered by coc.nvim for Language Server Protocol (LSP) features, completion, and diagnostics.
This configuration provides:
- Hybrid Line Numbers: (
set nu rnu) - Modern Autocompletion & Diagnostics: Powered by
coc.nvim(Language Server Protocol client) for various languages. - File Tree Navigation: NERDTree for project Browse.
- Git Integration:
vim-fugitivefor Git commands within Vim. - Status Line:
lightline.vimfor a sleek and informative status bar. - Folding & Commenting: Convenient keybindings and plugins for code manipulation.
- Language-Specific Features: Enhanced support for Python, Go, Terraform, Dockerfile, Rego, JSON, and YAML.
- Testing Integration:
vim-testfor running tests from Vim. - Code Formatting: Auto-formatting and custom format commands (XML, JSON).
- Customizable Color Scheme: Currently using 'gotham' with true color support.
Before starting, ensure you have the following installed on your system:
- Vim 9.0+: This configuration is tested with Vim 9.1.
- To check your Vim version, open Vim and run
:version.
- To check your Vim version, open Vim and run
- Node.js (LTS version recommended):
coc.nvimrelies on Node.js for its backend.- Download from nodejs.org.
- Verify installation:
node -vandnpm -v.
- Python 3: For
coc-pythonand general Python utilities.- Verify installation:
python3 --version.
- Verify installation:
- Go (optional, but recommended for Go development):
- Download from go.dev.
- Verify installation:
go version.
git: For cloning repositories and Vim-Plug.curlorwget: For downloadingvim-plug.ctags: For Tagbar plugin.- On Debian/Ubuntu:
sudo apt install ctags - On macOS (Homebrew):
brew install ctags
- On Debian/Ubuntu:
jq: For JSON formatting command.- On Debian/Ubuntu:
sudo apt install jq - On macOS (Homebrew):
brew install jq
- On Debian/Ubuntu:
Follow these steps to get your Vim environment up and running:
First, clone this repository to your home directory:
git clone https://github.com/thenom/vimrc.git ~/.vim_configVim-Plug is the plugin manager used in this configuration. Run the following command in your terminal:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vimCreate symbolic links from your home directory's Vim configuration files to the ones in your cloned repository. This ensures Vim uses the version-controlled files.
ln -sfn ~/.vim_config/vimrc ~/.vimrc
mkdir -p ~/.vim/
ln -sfn ~/.vim_config/coc-settings.json ~/.vim/coc-settings.jsonOpen Vim and run the PlugInstall command. This will download and install all the plugins listed in your vimrc.
:PlugInstallYou should see a status window showing the progress. Once complete, close the status window by pressing q.
coc.nvim requires specific extensions for language support. After :PlugInstall is done, stay in Vim and run these commands:
:CocInstall coc-pyright coc-go coc-json coc-yaml coc-snippetsThis will install the extensions providing LSP features for Python, Go, JSON, YAML, and general snippet functionality.
Some language servers and tools need to be installed separately on your system.
-
Python Language Server (
python-lsp-server[all]), Black (formatter), Flake8 (linter): These should be installed in your Python environment. It's recommended to install them into your global Python 3 environment or within any virtual environments you use.pip install "python-lsp-server[all]" black flake8 -
Go Language Server (
gopls):coc-goshould managegoplsautomatically. If you encounter issues, ensure it's installed:go install golang.org/x/tools/gopls@latest
-
Terraform Language Server (
terraform-ls): Ensure the officialhashicorp/terraform-lsis installed and in your system'sPATH.Use your distribution's package manager if
terraform-lsis available. (Example for Fedora/RHEL):wget -O- https://rpm.releases.hashicorp.com/fedora/hashicorp.repo | sudo tee /etc/yum.repos.d/hashicorp.repo sudo dnf install terraform-ls