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/nvim
to another place - Clone this repo to
~/.config/nvim
:git clone https://github.com/alohaia/nvimcfg ~/.config/nvim
- Enter
nvim
and do some preparation work:lua require('aloha.prepare')
PackInstall
PackInstall
: install all plugins(disable != true
)PackInstall <plugin>
: install specific plugins(disable != true
)
PackUpdate
PackUpdate
: 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
)PackClean
PackClean
: uninstall disabled plugins(disable == true
)PackClean <plugin>
: same asPackUninstall
PackSync
: equivalent toPackClean
+PackUpdate
PackAdd <plugin>
: load an opt plugin and its configs manually, use this command instead ofpackadd
as 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 = ' ',
}
packer
plugins
: plugin list with basic configuration, see~/.config/nvim/lua/aloha/plugins.lua
for exampleplugin_configs
: configuration for plugins, see~/.config/nvim/lua/aloha/plugin_configs/init.lua
for exampleconfig
: settings for built-in packerpack_root
,pack_name
: plugins will be installed underpack_root/pack_name/{opt,start}
git
cmd
: base git command, can be replaced withproxychains -q git
for example.clone_depth
:--depth
option forclone
shallow_submodules
: whether to add--shallow-submodules
inclone
command and add--depth=1
insubmodule update
commandbase_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.rm
togio trash
on GNOME. You can also setpacker.git
toproxychains -q git
to use proxy, but using~/.gitconfig
is 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.lua
return { ['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
,cmd
orenable
options 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. Adependencies
should 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
config
and useplugin_configs
which 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.lua
local 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.lua
to get plugin configs.