My NeoVim configuration with built-in packer, written in Lua.
- Built-in packer
- Useful plugins with detailed configuration
- Written in Lua
- nvim ≥ 0.7
- Other softwares: ripgrep, git
- language servers you need, you can add related configs here.
- Move
~/.config/nvimto another place - Clone this repo to
~/.config/nvim:git clone https://github.com/alohaia/nvimcfg ~/.config/nvim - Enter
nvimand do some preparation work:lua require('aloha.prepare')
PackInstallPackInstall: install all plugins(disable != true)PackInstall <plugin>: install specific plugins(disable != true)
PackUpdatePackUpdate: update all installed plugins(disable != true) and install plugins which are not installed(disable != true)PackUpdate <plugin>: update specific plugins(disable != true), install it if it's not installed
PackUninstall <plugin>: uninstall specific plugins(disable != true)PackCleanPackClean: uninstall disabled plugins(disable == true)PackClean <plugin>: same asPackUninstall
PackSync: equivalent toPackClean+PackUpdatePackAdd <plugin>: load an opt plugin and its configs manually, use this command instead ofpackaddas far as possible
-- Default config
require 'aloha' {
packer = {
plugins = require('aloha.plugins'),
plugin_configs = require('aloha.plugin_configs'),
config = {
pack_root = vim.fn.stdpath('data') .. '/site/pack',
pack_name = 'packer',
git = {
cmd = 'git',
clone_depth = 1,
clone_submodules = true,
shallow_submodules = true,
base_url = 'https://github.com',
},
rm = 'rm -rf',
strict_deps = true,
},
},
transparency = true,
mapleader = ' ',
}packerplugins: plugin list with basic configuration, see~/.config/nvim/lua/aloha/plugins.luafor exampleplugin_configs: configuration for plugins, see~/.config/nvim/lua/aloha/plugin_configs/init.luafor exampleconfig: settings for built-in packerpack_root,pack_name: plugins will be installed underpack_root/pack_name/{opt,start}gitcmd: base git command, can be replaced withproxychains -q gitfor example.clone_depth:--depthoption forcloneshallow_submodules: whether to add--shallow-submodulesinclonecommand and add--depth=1insubmodule updatecommandbase_url: base URL of GitHub, you can replace this to use a mirror site
strict_deps: when set totrue, a plugin's config won't be executed if any dependencies of this plugin is not successfully loaded
transparency: transparent background and related configmapleader:<Leader>key
Tips You can set
packer.rmtogio trashon GNOME. You can also setpacker.gittoproxychains -q gitto use proxy, but using~/.gitconfigis better. For example:[http] proxy = socks5://127.0.0.1:1089 [https] proxy = socks5://127.0.0.1:1089
Example
~/.config/nvim/lua/aloha/plugins.luareturn { ['alohaia/hugowiki.nvim'] = { ft = 'markdown,rmd,text' }, ['dhruvasagar/vim-table-mode'] = { ft = {'rmd', 'markdown', 'text'} }, ['godlygeek/tabular'] = { config = function() vim.cmd[[cnorea Tab Tabularize]] end }, ['jalvesaq/Nvim-R'] = {disable = true, ft = 'r', branch = 'master'}, ['kyazdani42/nvim-tree.lua'] = { cmd = 'NvimTreeToggle', map = { {mode = 'n', lhs = '<leader>nt'}, } }, ['lewis6991/gitsigns.nvim'] = { dependencies = 'nvim-lua/plenary.nvim' }, ['nvim-telescope/telescope.nvim'] = { cmd = 'Telescope', map = { {mode = 'n', lhs = ',f'}, {mode = 'n', lhs = ',b'}, {mode = 'n', lhs = ',F'}, {mode = 'n', lhs = ',g'}, }, dependencies = { 'nvim-lua/plenary.nvim', 'nvim-lua/popup.nvim', 'nvim-telescope/telescope-fzy-native.nvim' } }, -- dependencies ['nvim-lua/plenary.nvim'] = {opt=true}, ['nvim-lua/popup.nvim'] = {opt=true}, ['nvim-telescope/telescope-fzy-native.nvim'] = {opt=true}, ['nvim-treesitter/nvim-treesitter-textobjects'] = {opt=true}, }
A key-value table of plugins. The key is a plugin's name like alohaia/vim-hexowiki, and the value is another dictionary of basic settings:
opt(bool): Whether the plugin is installed as an opt pack. Plugins withft,cmdorenableoptions are also opt plugins.ft(string,list): For which filetype(s) should the plugin be loaded, such as'markdown,text'and{'markdown', 'text'}.cmd(string,list): On which vim command(s) should the plugin be loaded.map(table): On which mapping(s) should the plugin be loaded.enable(bool,function): Whether to load this plugin.branch(string): Branch of the plugin. This is effective only at initial installation.dependencies(string,table): Plugin's dependencies. Adependenciesshould be in the plugin list additionally.disabled(bool): Whether the plugin is disabled. Disabled plugins won't be installed or updated and will be removed while cleaning. The difference between disabled plugins and plugins that are not in the plugin list is that the former appears in completion list of packer commands.config(function,string): Configuration for the plugin, Can be a function:- Function: well be directly called in due course.
- String:
- Begin with
:: Regarded as a vim command - Begin with
!: Regarded as a commandline command - Other cases: Regarded as a piece of Lua code
- Begin with
I recommend you write only simple configuration in
configand useplugin_configswhich I'll introduce later to config plugins.
A table of configuration for plugins. The key is a plugin's name, and the value is a function.
Example
~/.config/nvim/lua/aloha/plugin_configs.lualocal configs = {} configs['glepnir/galaxyline.nvim'] = function() require('aloha.plugin_configs.galaxyline') end configs['alohaia/hugowiki.nvim'] = function() vim.g.hugowiki_home = '~/blog.hugo/content/' vim.g.hugowiki_try_init_file = 1 vim.g.hugowiki_follow_after_create = 0 vim.g.hugowiki_use_imaps = 1 vim.g.hugowiki_disable_fold = 0 vim.g.markdown_fenced_languages = { 'lua', 'c', 'cpp', 'r', 'javascript', 'python', 'sh', 'bash', 'zsh', 'yaml', 'tex' } -- ... end -- ... return configsAnd then you can use
require('aloha.plugin_configs')in~/.config/nvim/init.luato get plugin configs.

