Making a beautiful Neovim Config from scratch (BONUS: Godot Support)

3 min read 4 hours ago
Published on Oct 13, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

In this tutorial, we will create a beautiful Neovim configuration from scratch, tailored for game development with Godot 3 and Godot 4. This guide will cover auto-formatting and auto-completion features that enhance your coding efficiency while ensuring an aesthetically pleasing setup.

Step 1: Install Neovim

  1. Download Neovim

    • Visit the Neovim releases page and download the latest version suitable for your operating system.
  2. Install Neovim

    • Follow the installation instructions specific to your OS:
      • Windows: Use the installer or unzip the archive into a folder and add it to your PATH.
      • macOS: Use Homebrew with the command:
        brew install neovim
        
      • Linux: Use your package manager, for example:
        sudo apt install neovim
        

Step 2: Set Up Your Configuration Directory

  1. Create the Configuration Folder

    • Open your terminal and run:
      mkdir -p ~/.config/nvim
      
  2. Create the Init File

    • Create a new file named init.vim:
      touch ~/.config/nvim/init.vim
      

Step 3: Install a Plugin Manager

  1. Choose a Plugin Manager

    • Use a popular plugin manager like vim-plug. To install:
      curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
        https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
      
  2. Configure init.vim for Plugins

    • Open init.vim and add the following lines to set up vim-plug:
      call plug#begin('~/.local/share/nvim/plugged')
      
      " Add plugins here
      
      call plug#end()
      

Step 4: Add Essential Plugins

  1. Add Plugins for Godot Support

    • Within the call plug#begin and call plug#end() block, add:
      Plug 'neovim/nvim-lspconfig'         " LSP configurations
      Plug 'hrsh7th/nvim-cmp'              " Autocompletion
      Plug 'hrsh7th/cmp-nvim-lsp'          " LSP source for nvim-cmp
      Plug 'hrsh7th/cmp-buffer'            " Buffer completions
      Plug 'hrsh7th/cmp-path'              " File path completions
      Plug 'nvim-treesitter/nvim-treesitter', { 'do': ':TSUpdate' } " Syntax highlighting
      
  2. Install the Plugins

    • Open Neovim and run the command:
      :PlugInstall
      

Step 5: Configure LSP for Godot

  1. Set Up LSP for Godot

    • Add the following configuration to your init.vim:
      lua << EOF
      require'lspconfig'.gdscript.setup{}
      EOF
      
  2. Ensure GDScript Language Server is Installed

Step 6: Enable Auto-Formatting

  1. Install a Formatting Plugin

    • Add the following plugin for formatting:
      Plug 'sbdchd/neoformat'
      
  2. Configure Auto-Formatting in init.vim

    • Add the following lines:
      autocmd BufWritePre *.gd Neoformat
      

Step 7: Customize Appearance

  1. Choose a Color Scheme

    • Add a color scheme plugin like:
      Plug 'gruvbox-community/gruvbox'
      
  2. Set the Color Scheme in init.vim

    • After the call plug#end(), add:
      colorscheme gruvbox
      set background=dark
      

Conclusion

You have successfully created a Neovim configuration that supports Godot development with auto-formatting and auto-completion. To enhance your setup further, consider exploring additional plugins and personalizing your preferences. Keep your configuration updated and enjoy coding in Neovim!