A clean, organized pre-configured neovim configuration guide in a single init.lua
.
For documentation check init.lua
.
If you want to start from scratch but with some helper functions you can try out blank.lua
file.
Check lazy branch on using lazy.nvim instead of packer.nvim as package manager.
This init.lua
comes with the following plugins pre-configured to work, for a more detailed list check the init.lua
and search for /PLUG
:
- nvim-lspconfig - configure LSP servers to run on your files/projects.
- null-ls - provides an LSP protocol to run your tools such as eslint, prettier, stylua, etc.
- mason.nvim - automatically install LSP servers and tools (like eslint,
prettier, etc) for
lspconfig
andnull-ls
to use. - telescope.nvim - fuzzy find things like files, grep code, buffers, etc.
- neo-tree.nvim - a simple file explorer.
- nvim-cmp - autocompletion framework to provide suggestion within buffers, code, attached LSP servers, etc.
- vim-vsnip - snippets engine plugin and provider via friendly-snippets.
- nvim-treesitter - mainly used to highlight code using the treesitter parser, a must have for cleaner looking syntax highlighting and many more features like code folding, smart indenting, etc.
- lualine.nvim - a better looking statusline.
- bufferline.nvim - a better looking tabline for buffers.
- which-key.nvim - show a tooltip to display keybinds when pressing those keybinds
- Comment.nvim - add comments based on file type.
- gitsigns.nvim - provide git changes on the buffer.
This is just my take on creating just one single config file to handle all configurations for nvim. Where having multiple files brings an overhead of maintenance of logic in different files, I wanted to take a more straight forward approach of keeping it all in one file.
The aim is to take away the mental model of multiple files and trying to avoid jumping between files to add/update your configurations and just use one file with a couple simple methods to manage and organize your code within it in order to have a better nvim experience.
One such method is to navigate through different sections with search tags, that comes in the form of words attached
to different sections in within comments. Using /
and searching for the tag will jump you to that section.
For example, if you want to navigate to the packer section to add additional plugins you would then search for /PLUG
and it will take you to that section. The same for when you want to configure some part of your LSP configuration, you
would search for /LSP
and you will be directed to the relevant LSP section of the code.
LSP configuration comes out-of-box and not tightly bound with packer.nvim, since packer compiles plugins to make them faster to load, this does not work well with LSP and its configuration.
So LSP configurations are setup outside of packer and loaded by default. The advantage to this is that LSP is loaded and ready to work and not just lazy-loaded in order to save time.
Which brings me to another point, at the end of the day this single configuration file is created for your guidance on writing your own configuration without much of a hassle, it's by no means a way to write the most optimized nvim configuration possible (although it loads quite fast within ~200ms on my machine 😅).
However, you are free to take this and optimize it any way you would like, in fact, I would highly encourage you do so because in the end this is just a guide for your convenience!
NOTE: If you have an existing config, you should make a backup of it.
git clone https://github.com/creativenull/nvim-one.git ~/.config/nvim
In a powershell terminal:
git clone https://github.com/creativenull/nvim-one.git ~\AppData\Local\nvim
You can ignore those and restart nvim, the problem is usually the plugin setup being called before the plugin is even installed.
Try to run :TSUpdate
to get the latest parser for lua.
Make sure you follow the installation method above for it to work properly, if you ran with ln -s ...
to link the
directory to ~/.config/nvim
then it won't work for now.
Alternatively, you can try <Leader>vs
to reload config manually.