π» 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.
There is a number of 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.
- Migrate to Lua based alternative plugins respectively use only Lua based plugins (if possible).
- Keep the config as maintainable as possible knowing that this would possibly impact the code quality.
- Modular and meaningful directory structure and file naming.
- 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.
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
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 .
docker run --name nvim --rm -it nvim
docker run --name nvim --rm -it -v ${HOME}/tmp:/home/nvim/mount nvim
docker run --name nvim --rm -it --entrypoint=/bin/bash nvim
- Package management and plugin configuration via Packer
- Mnemonic keyboard mappings inspired by Spacemacs via which-key.nvim; no more than three keystrokes for each keybinding
- Submodes powered by Hydra.nvim
- Fully featured status line via Lualine
- Terminal integration via nvim-toggleterm.lua
- Fancy notifications via nvim-notify
- Better writing with vale integration via null-ls
- Fast startup π
- Telescope.nvim for all your search needs
- Project management with Project.nvim
- File tree navigation/manipulation via nvim-tree
- Convenient Tmux navigation with your home row via Navigator.nvim
- LF integration via lf.vim for a full featured file manager in Neovim
- Convenient jumping through windows with nvim-window
- Auto completion powered by nvim-cmp
- Built-in LSP configured via nvim-lspconfig
- Treesitter and Tresitter-textobjects for your syntax needs
- Auto formatting via null-ls.nvim
- Excellent Go support via LSP and go.nvim including sensible keybindings
- Git integration via Neogit, gitsigns, git-blame, and gitui
- Schema integration via LSPs for Kubernetes, package.json, github workflows, gitlab-ci.yml, kustomization.yaml, and more
- Always know where you are in your code via nvim-navic
- Outlining symbols with symbols-outline.nvim
- Snippets provided by Luasnip and friendly snippets with autocompletion
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
Mode | key | binding |
---|---|---|
n | spaceΒ | Leader key |
n | β¬ β¬ β¬ β‘ | Resize panes |
n | <c-h | j | k | l> | Change pane 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 |
v | ga | Easyalign |
n | gcc | ToggleΒ line comment |
n/v | gc | ToggleΒ line comment (works with movements like gcip ) |
n | ss | Search 2 char forward (lightspeed) |
n | S | Search 2 char backward (lightspeed) |
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 |
Mappings are clustered according to their topic/tool.
See ./lua/config/which.lua
for details.
key | cluster |
---|---|
b | Buffer management |
c | Language specific actions (only in Go, e.g. run tests) |
f | File management |
g | Git actionsΒ |
l | LSP integration (only when a LSP is attached) |
m | Misc stuff |
q | Quickfix |
s | Searching |
w | Window management |
x | Languagetool integration |
z | Spell bindings |
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
.
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.
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
.
There are some tools that are required in order to use some features/plugins:
- prettier
go install mvdan.cc/gofumpt@latest
- terraform fmt
- stylua
- black
For the builtin LSP (see lspconfig for more info about LSP configuration)
sudo npm i -g bash-language-server dockerfile-language-server-nodejs yaml-language-server typescript typescript-language-server vscode-langservers-extracted
:GoInstallBinaries
will install all go dependencies for go.nvim and the go LSP- pyright as Python LSP
- terraform-ls
- lua-language-server
- texlab and tectonic
- For advanced spell checks via vim-grammarous Java 8+ is required
- For better writing vale is required