Skip to content
generated from nvimdev/dope

neovim configuration based on cosyvim πŸ™ˆπŸŽˆπŸ’Œ

License

Notifications You must be signed in to change notification settings

1995parham/elievim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

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

Repository files navigation

The Way of Life

Your editor, your rules

Elahe
GitHub Workflow Status GitHub

Introduction

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.

Structure

β”œβ”€β”€ 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

Nomenclature

Ellie is a pet form of Elahe coming from Elahe Dastan.

How to Install?

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

How to register plugins?

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'},
}

What is config?

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' },
      }
    },
}

How to config key mapping?

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 and opts(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.

LSP Tools Requirements

To utilize Language Servers, you'll typically need the following commands:

- luarocks
- npm / node
- pip / python

Configuration

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.

Tips

Improve key repeat

# macOS (needs a restart)
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10

# Linux (X11)
xset r rate 210 40

Links

Languages

This document outlines useful features of my development configuration specifically designed for Python and Go projects.

General

  • 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 includes npm 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 like npm run dev, npm start, and just 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.

Golang

  • I love the FillStruct feature included in this configuration! Here's how it works:

    1. Place your cursor inside a struct definition.
    2. Trigger the code actions menu using spc + c + a (or your preferred shortcut).
    3. 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.

About

neovim configuration based on cosyvim πŸ™ˆπŸŽˆπŸ’Œ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages