Skip to content
forked from Allaman/nvim

Straight forward and pure Lua based Neovim configuration for my work as DevOps/Cloud Engineer with batteries included for Python and Golang

License

Notifications You must be signed in to change notification settings

AndrewWinterman/nvim

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

My Neovim Configuration

πŸ’» This configuration is working on my Manjaro Linux as well as on my macOS and requires Neovim dev build (0.8)!

Have a look at my rice how my Linux machine is configured and at my mac-setup how my MBP is configured. My dotfiles are also on GitHub.

More Screenshots

Terminal: alacritty

Font: Jetbrains Mono

Leader Key Clusters via which-key

See ./lua/config/which.lua for details.

Go development

Debugging via DAP

Hydra modes for better shortcut handling

Motivation

There are many great Neovim configurations online (see Inspiration) that give you a pleasant experience right out of the box. However, I am a long time (Neo)Vim user with a specific workflow and needs. Additionally, I do not have any Lua background and was not willing to spent too much time into that. Therefore, it was quite hard for me to customize and strip down the existing configs to my needs especially because the code is quite sophisticated.

I decided to move to my own fresh Lua based Neovim from my good old vimrc trying to accomplish the following principles.

Principles

  1. Migrate to Lua based alternative plugins respectively use only Lua based plugins (if possible).
  2. Keep the config as maintainable as possible knowing that this would possibly impact the code quality.
  3. Modular and meaningful directory structure and file naming.
  4. Just make it work and not make it beautiful πŸ˜ƒ. Of course, Neovim itself must look beautiful, but my focus is not on beautiful code or on utilizing all Lua features.

Features

General βš™οΈ

Navigation 🧭

Coding πŸ–₯️

Try out

If you have Docker on your system you can try out this config via the provided Dockerfile

πŸ’‘ All dependencies of my config are installed except texlab, tectonic, and vim-grammarous which makes it at 1.9GB a rather large image

Build the image

There are some issues with building a multi architecture Docker image via GitHub Action. Until I sorted that out, you can build the Docker image locally on your own

docker build -t nvim .

Just start nvim

docker run --name nvim --rm -it nvim

Mount a local directory (to ~/mount) and start nvim

docker run --name nvim --rm -it -v ${HOME}/tmp:/home/nvim/mount nvim

Start container in bash instead of nvim

docker run --name nvim --rm -it --entrypoint=/bin/bash nvim

Installation

I created an installation script that sets up all required tools on a fresh machine to work with my Neovim config.

For now, it works on Debian/Ubuntu and Arch. MacOS will be added soon.

πŸ’‘If you are a Tmux user have a look at vim-tpipelins's requirements for your tmux.conf and enable it in ./lua/user-conf.lua.

USE AT YOUR OWN RISK!!

Requirements

There are some tools that are required in order to use some features/plugins:

Tools

LSPs, Formatting, Linters, DAP

The following programs should be installed on your system so that the appropriate tools can be installed:

  • Go
  • Python
  • NodeJs > 12
  • Cargo

Go

Go related dependencies are managed by go.nvim and are installed by running :GoInstallBinaries (when a Go file is loaded). They are installed in your $GOPATH.

All other

All other dependencies are managed by Mason and Mason tool installer. Tools are installed by running :MasonToolsInstall (in vim.fn.stdpath("data") .. "mason"). Mason requirements must be available on your system.

For advanced spell checks via vim-grammarous Java 8+ is required

Bindings

Mode key binding
n spaceΒ  Leader key
n <c-h | j | k | l> Change window focus (including Tmux panes)
n <leader>Tab Switch to previously opened buffer
n <Tab> Switch to next buffer (bnext)
n <S-Tab> Switch to previous buffer (bprev)
n st Visual selection with Treesitter hint textobject
v sa Add surrounding
n sd Delete surrounding
n sr Replace surrounding
n <c-Tab> Start auto completion (without typing anything)
n gcc ToggleΒ line comment
n/v gc ToggleΒ line comment (works with movements like gcip)
n ss Search 2 char (mini.jump2d)
i/s <c-j> Luasnip expand/forward
i/s <c-k> Luasnip backward
i <c-h> Luasnip select choice
n <c-n> Toggleterm (opens/hides a full terminal in Neovim)
i <c-l> Move out of closing bracket
n <CR> Start incremental selection
v <Tab> Increment selection
v <S-Tab> Decrement selection

Structure

Each plugin to be installed is defined in plugins.lua and each plugin has its own configuration file (if necessary) in lua/config/ which is loaded by packer.

.
β”œβ”€β”€ after
β”‚Β Β  └── ftplugin      # file specific settings
β”œβ”€β”€ init.lua          # main entry point
β”œβ”€β”€ lua
β”‚Β Β  β”œβ”€β”€ config/       # each plugin configuration is in its own file
β”‚Β Β  β”œβ”€β”€ autocmd.lua   # autocommands
β”‚Β Β  β”œβ”€β”€ functions.lua # lua functions to extend functionality
β”‚Β Β  β”œβ”€β”€ mappings.lua  # Vim keymaps definitions -> config/which.lua for more
β”‚Β Β  β”œβ”€β”€ options.lua   # non plugin related (vim) options
β”‚Β Β  β”œβ”€β”€ plugins.lua   # define plugins to be managed via Packer
β”‚Β Β  └── user-conf.lua # parameters to configure some settings
β”œβ”€β”€ plugin            # packer_compiled
β”œβ”€β”€ snippets          # snippets directory (luasnip style)
└── spell             # my spell files linked from another repo

User configuration

The intention of my Neovim configuration was never to be a fully customizable "distribution" like LunarVim, SpaceVim, etc but from time to time I like to change my color scheme and the idea of making this configurable came to my mind. Based upon this idea I implemented some further lightweight configuration options that might be useful.

All options can be found in ./lua/user-conf.lua.

Remove plugins

Basically, you can remove unwanted plugins by just removing the appropriate line in ./lua/plugins.lua and, if applicable, delete its configuration file in ./lua/config/.

ℹ️ Keep in mind that some plugins are configured to work in conjunction with other plugins. For instance, autopairs is configured in ./lua/config/treesitter.lua. For now there is no logic implemented that cross-checks such dependencies.

Add plugins

If you want to follow my method adding a plugin is straight forward:

In lua/plugins.lua add the plugin to Packer. You are free to use a name for the configuration file (should be a valid filename).

use {"<Address-of-the-plugin>", config = get_config("<name-of-the-plugin>")}

Create lua/config/<name-of-the-plugin>.lua where you put the plugins settings. If your plugin does not require additional configuration or loading you can omit the config part.

Open another instance of Neovim (I always try to keep one running instance of Neovim open in case I messed up my config) and run PackerSync.

Inspiration

About

Straight forward and pure Lua based Neovim configuration for my work as DevOps/Cloud Engineer with batteries included for Python and Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 93.3%
  • Shell 3.5%
  • Dockerfile 3.1%
  • Ruby 0.1%