Skip to content

Neovim Configuration

Zhang Pu edited this page Feb 10, 2022 · 3 revisions

Architecture of Configurations

This configuration was written by pure Lua.

Directories

You could find all configurations in directory nvim/lua. And the followings are what stored in sub-directories:

  • core/: the options of Nvim(options.lua), the groups of Vim auto-commands(event.lua), the configuration of packer.nvim(plugins.lua), and the mapping of keys(keymap.lua),

  • modules/: all plugins are categorized in this directory, which including in it:

    • the enhancement of nvim itself(editor/),
    • the LSP and completion configuration(lsp/),
    • the optimization of TUI(ui/)
    • other tools of nvim(tools/),
  • utility/: a library of tools:

    • logger/: a simple implementation of logger, disabled in default,

    • keybinding/: encapsulation of nvim APIs for key binding,

    • packer_analyzer/: a lazy-loader configuration checker, not finished(might be cancelled).

Git Branches and Tags

The branch master only support nvim now. you could find the common configuration for nvim and vim both on branch common_config_for_n_vim, which is under maintenance but no new features in planning.

And this configuration would be evolved with nvim development. You could find tags look like nvim-0.5.x, it means that this commit is the final one support nvim 0.5.x. Now this configuration only support nvim 0.6.0 and later version.

Keymaps and Plugins

Most used keymaps are shown in this table(use <space> as <leader>):

Mode Key Function Dependency
NORMAL <leader>j switch to next tab -
NORMAL <leader>k switch to previous tab -
NORMAL <leader>1~<leader>5 switch to the 1st to 5th tab -
NORMAL <C-h> equal to <C-w>h -
NORMAL <C-j> equal to <C-w>j -
NORMAL <C-k> equal to <C-w>k -
NORMAL <C-l> equal to <C-w>l -
NORMAL <A-[> vertical window resize -5 -
NORMAL <A-]> vertical window resize +5 -
NORMAL <A-;> windows resize -2 -
NORMAL <A-'> windows resize +2 -
NORMAL <C-q> quit nvim and save current buffer/tab and abandon other modifications -
NORMAL Y yank this line from cursor -
NORMAL D delete this line from cursor -
NORMAL n jump to next search result with auto-highlight -
NORMAL N jump to previous search result with auto-highlight -
COMMAND <C-b> equal to <left> -
COMMAND <C-f> equal to <right> -
COMMAND <C-e> equal to <Home> -
COMMAND <C-d> equal to <End> -
COMMAND <C-h> equal to <Del> -
COMMAND <C-t> equal to <BS> -
VISUAL J move whole line down -
VISUAL K move whole line up -
VISUAL < tab -
VISUAL > shift tab -
NORMAL <leader>ps :PackerSync packer.nvim
NORMAL <leader>pu :PackerUpdate packer.nvim
NORMAL <leader>pi :PackerInstall packer.nvim
NORMAL <leader>pc :PackerClean packer.nvim
NORMAL <leader>li :LspInfo, show LSP info attached current buffer nvim-lspconfig
NORMAL <leader>lr :LspRestart nvim-lspconfig
NORMAL g[ jump to previous diagnostics lspsaga.nvim
NORMAL g] jump to next diagnostics lspsaga.nvim
NORMAL gs show signature info lspsaga.nvim
NORMAL <leader>rn rename symbol under cursor lspsaga.nvim
NORMAL K show hover information lspsaga.nvim
NORMAL <C-Up> select previous code action lspsaga.nvim
NORMAL <C-Down> select next code action lspsaga.nvim
NORMAL <leader>ca code action lspsaga.nvim
VISUAL <leader>ca code action based range lspsaga.nvim
NORMAL gd go to definition -
NORMAL gp preview the definition in popup lspsaga.nvim
NORMAL <leader>o Toggle the outline view symbols-outline.nvim
NORMAL gt Toggle the trouble view of diagnostics trouble.nvim
NORMAL gr Toggle the reference view, powered by trouble.nvim trouble.nvim
NORMAL <A-/> comment toggle nvim-comment
NORMAL <leader>w map all words into specific keys to jump to hop.nvim
NORMAL <leader>l map all lines into specific keys to jump to hop.nvim
NORMAL <A-j> switch to next buffer bufferline.nvim
NORMAL <A-k> switch to previous buffer bufferline.nvim
NORMAL <A-1>~<A-9> jump to the 1st to 9th buffer bufferline.nvim
NORMAL <leader>e Nvim file explorer Toggle nvim-tree

Customization

You could customize this configuration as your wish.

Clone this wiki locally