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

partounian/nvim

Β 
Β 

Repository files navigation

My Nvim Configuration

screenshot

πŸ’» This configuration works on my NixOS Linux as well as on my macOS. It requires and is tested with Neovim >= 0.10. It should run with Neovim 0.9.5 but I can't recommend it.

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

which-key

See ./lua/core/config/ui/which-key.lua for details.

Go development

go-dev

Debugging via DAP

dap

Motivation

There are many great Neovim configurations (see Inspiration), that give you a pleasant experience right out of the box, available. 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 configuration.

πŸ’‘ Due to installing required tools like LSPs, CLI apps, etc. the image is approximately 3 GB large

Dockerhub

There is a GitHub action in place that builds and pushes the Docker image to Dockerhub as allaman/nvim

Just start Neovim in container

docker run --name nvim --rm -it allaman/nvim

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

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

Start container in bash instead of Neovim

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

Build the image

You can also build the image on your own

docker build -t nvim .

Replace allaman/nvim in the former commands with just nvim.

Requirements

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

Run :checkhealth core to check the status.

Tools

For the neo-tree delete functionality:

For Latex functionality:

  • Tectonic (can be changed in config.lua)
  • Skim (can be changed in config.lua)

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

All other

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

Bindings

Some bindings can be overwritten in your user config file. See ./lua/core/config/defaults.lua for possible settings.

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 (bprevious)
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
n/v ga Start mini.align (align text)
n gcc ToggleΒ line comment
n/v gc ToggleΒ line comment (works with movements like gcip)
n ss Jump to character(s) (flash.nvim)
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 brackets
n <CR> Start incremental selection
v <Tab> Increment selection
v <S-Tab> Decrement selection
n <c-f> Search buffer
i/v/n/s <c-s> Save file
n <leader>Rr Toggle Search and Replace (via Spectre)
n <leader>Rw Search (and replace) current word (via Spectre)
n <leader>Rf Search (and replace) in current file (via Spectre)
n <leader>Rc Replace current selection (in Spectre)
n <leader>RR Replace all (in Spectre)
n :LtexLang <lang> Set a specific language like "de-DE" for ltex-ls
n <leader>mc Enable GitHub Copilot (if plugin is enabled in your user config)
n <leader>tr Toggle Overseer (if plugin is enabled in your user config)
n <leader>r OverseerRun (if plugin is enabled in your user config)
n <leader>lf yazi.nvim or lf.nvim (if enabled in your user config)
n <leader>tz Toggle distraction free mode (if plugin is enabled in your user config)
n <leader>tF Disable auto formatting (if conform.nvim is enabled in your user config)
n <leader>tL Disable linting (if nvim-lint is enabled in your user config)

Hit <leader> to start which-key which gives you more mappings grouped by topic.

Structure

❯ tree -L 1 .
.
β”œβ”€β”€ after              # file specific settings
β”œβ”€β”€ config-example.lua # user-config file
β”œβ”€β”€ init.lua           # main entry point
β”œβ”€β”€ lazy-lock.json     # Lockfile for Lazy.nvim
β”œβ”€β”€ lua                # lua configuration
β”œβ”€β”€ snippets           # snippets directory (luasnip style)
└── spell              # my spell files linked from another repo
❯ tree -L 1 lua
lua
β”œβ”€β”€ config # Neovim config and user-config handling
β”œβ”€β”€ core   # checkhealth and plugins
└── utils  # utilities
❯ tree -L 1 lua/config
lua/config
β”œβ”€β”€ autocmds.lua # autocmds
β”œβ”€β”€ defaults/    # default configuration
β”œβ”€β”€ init.lua     # entry point
β”œβ”€β”€ lazy.lua     # plugin management
└── mappings.lua # "global" key mappings
❯ tree -L 1 lua/core
lua/core
β”œβ”€β”€ health.lua # :checkhealth core
└── plugins # plugins and their config

Each plugin to be installed is defined in ./lua/core/plugins/ in a separate file.

User configuration

The intention of my Neovim configuration was never to be a fully customizable "distribution" like LunarVim, LazyVim, 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 configuration options that might be useful.

The default configuration can be found in ./lua/config/defaults.

You can overwrite any of this configuration by writing a .nvim_config.lua file that follows the same structure as the default table and pick only those keys that you want to modify. Have a look at my user configuration in my dots repo. The configuration file should be placed in $XDG_CONFIG_HOME, $HOME, or the windows equivalent path.

You can start with cp ./config-example.lua $HOME/.nvim_config.lua.

Remove plugins

You can remove unwanted plugins by just removing the appropriate file in ./lua/core/plugins/. Lazy will take care of removing the plugin. You should also clean up any default configurations in ./lua/config/defaults.

Keep in mind that some plugins are configured to work in conjunction with other plugins. For instance, autopairs is configured in ./lua/core/plugins/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:

Create a file in ./lua/core/plugins/ following the expected format of Lazy.

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 Lazy sync.

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 99.7%
  • Dockerfile 0.3%