Neovim is a modern and powerful text editor that is fully compatible with Vim and supports Lua plugins, LSP client, and remote plugins. It is a project that seeks to aggressively refactor Vim in order to simplify maintenance, enable advanced UIs, and maximize extensibility. You can learn more about Neovim from its official website, its GitHub repository, or its releases page.
βββ init.lua
βββ π lua
β βββ π core heart of elievim which provides api
β β βββ init.lua
β β βββ keymap.lua keymap api
β β βββ options.lua vim options
β β
β βββ π keymap
β β βββ config.lua
β β βββ init.lua
β β βββ plugins.lua
β β
β βββ π commands
β β β
β β βββ init.lua
β β βββ go.lua
β β βββ ansible.lua
β β
β βββ π modules
β β
β βββ π completion
β β βββ config.lua
β β βββ plugins.lua
β βββ π lang
β β βββ config.lua
β β βββ plugins.lua
β βββ π tools
β β βββ config.lua
β β βββ plugins.lua
β βββ π ui
β βββ config.lua
β βββ plugins.lua
βββ π snippets snippets
βββ lua.json
βββ package.json
Ellie is a pet form of Elahe coming from Elahe Dastan.
You need to remove your old configuration and then install elievim
using:
rm -Rf ~/.config/nvim
rm -Rf ~/.local/share/nvim
rm -Rf ~/.cache/nvim
git clone https://github.com/1995parham/elievim
When you have a new module in the modules
folder, you can register plugins as follows in the plugins.lua
:
local conf = require('modules.ui.config')
return {
{'1995parham/naz.vim', config = conf.naz},
{'plugin github repo name'},
}
This is a keyword of lazy.nvim,
and you need to check its document.
If a plugin has many configs you can create other file in
modules/your-folder-name/config.lua
and avoid making the plugins.lua
file too long.
return {
-- modules/completion/plugins.lua
{
'neovim/nvim-lspconfig',
-- used filetype to lazy load lsp
-- config your language filetype in here
ft = { 'lua','rust','c','cpp'},
config = conf.nvim_lsp,
},
-- modules/tools/plugins.lua
{
'nvim-telescope/telescope.nvim',
-- use command to lazy load.
cmd = 'Telescope',
config = conf.telescope,
dependencies = {
{ 'nvim-lua/popup.nvim' },
{ 'nvim-lua/plenary.nvim' },
{ 'nvim-telescope/telescope-fzy-native.nvim' },
}
},
}
In elievim there are some APIs that make it easy to set key mapping.
All APIs are defined in core/keymap.lua
.
-- functions to generate keymap by vim.keymap.set
keymap.nmap()
keymap.imap()
keymap.cmap()
keymap.vmap()
keymap.xmap()
keymap.tmap()
-- generate opts into vim.keymap.set
keymap.new_opts()
-- function type that work with keymap.new_opts
keymap.silent()
keymap.noremap()
keymap.expr()
keymap.nowait()
keymap.remap()
-- just return string with <Cmd> and <CR>
keymap.cmd()
-- work like cmd but for visual map
keymap.cu()
Use these APIs to config your key mapping in keymap
folder. In this folder
keymap/init.lua
is necessary but if you have many VIM modes' remap you can config them in keymap/other-file.lua
Then config plugins key mapping in keymap/init.lua
. The example of API usage is as follows:
-- genreate keymap in normal mode
nmap {
-- packer which is replaced by lazy.nvim
{'<Leader>pu',cmd('PackerUpdate'),opts(noremap,silent,'Packer update')},
{'<Leader>pi',cmd('PackerInstall'),opts(noremap,silent)},
{'<Leader>pc',cmd('PackerCompile'),opts(noremap,silent)},
}
map
for each table, generate a new table that can pass to vim.keymap.set
as follows:
cmd('PackerUpdate')
just return a string<cmd>PackerUpdate<CR>
as RHS. LHS is<leader>pu
andopts(noremap, silent, 'Packer update')
generate options table as follows:
{noremap = true,silent = true, desc = 'Packer Update' }
For some vim mode remap and Do not need use cmd
function because
you want to have another key mapping not a command as RHS.
-- window jump
{"<C-h>",'<C-w>h',opts(noremap)}
Also, you can pass a table not include sub table to map
like
nmap {'key','rhs',opts(noremap,silent)}
Use :h vim.keymap.set
to know more about.
To utilize Language Servers, you'll typically need the following commands:
- luarocks
- npm / node
- pip / python
Language servers are configured in lua/modules/completion/config.lua
based on
nvim-lspconfig
.
- Install Language Servers: Use
mason.nvim
to install the language servers you need. - Automatic Configuration (Recommended): Most language servers will be automatically configured
by
mason-lspconfig.nvim
. - Manual Configuration (Optional): If a server isn't automatically configured, or you prefer manual setup,
add configurations to
lua/modules/completion/config.lua
.
['taplo'] = function()
require('lspconfig').taplo.setup({})
end,
If you use this approach, make sure you don't also manually set up servers
directly via lspconfig
as this will cause servers to be set up more than
once.
# macOS (needs a restart)
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
# Linux (X11)
xset r rate 210 40
- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
- https://github.com/neovim/nvim-lspconfig/wiki
- https://github.com/williamboman/mason.nvim/tree/main/lua/mason-registry
- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/MAIN.md
- https://neovim.io/doc/user/
- https://github.com/ray-x/go.nvim
This document outlines useful features of my development configuration specifically designed for Python and Go projects.
-
Need to comment out a section of code while in virtual mode? This configuration offers a handy shortcut! Simply use the key combination
gc
while your selection is active. This will efficiently comment out all the lines within your chosen block. -
I am using
oversser.nvim
to run commands in the background, these commands includesnpm run dev
,npm start
,just start
, etc. -
This configuration leverages the power of
oversser.nvim
to seamlessly run background commands directly within Neovim. This eliminates the need to switch windows or terminals, keeping you focused on your coding flow. Overseer allows you to execute common development commands likenpm run dev
,npm start
, andjust start
in the background. This means you can initiate development servers, linters, or other long-running processes without interrupting your work in Neovim. Activate Overseer with a simple keyboard shortcut:spc + r + r
. This brings up the Overseer interface where you can choose the command you want to run in the background. Overseer takes care of the execution, freeing you to focus on your code.
-
I love the
FillStruct
feature included in this configuration! Here's how it works:- Place your cursor inside a struct definition.
- Trigger the code actions menu using
spc + c + a
(or your preferred shortcut). - Look for the Fill Struct action and select it.
VoilΓ ! Your struct will be populated with empty fields, ready for you to customize. The implementation details for this feature can be found in the
reftool.lua
file of the go.nvim plugin: https://github.com/ray-x/go.nvim/blob/master/lua/go/reftool.lua.