Configure neovim using yaml.
Clone this repo to somewhere under :help packpath
or install using a package
manager. Then install yq.
First, create a yaml configuration file, which will look something like this. For a more detailed example, see ./examples/nvim.yaml.
# nvim.yaml
options:
shiftwidth: 4
mappings:
normal:
<C-J>: <Cmd>cnext<CR>
<C-K>: <Cmd>cprevious<CR>
autocmds:
TextYankPost:
command: silent! lua vim.highlight.on_yank()
language_server:
mappings:
normal:
gd: <Cmd>lua vim.lsp.buf.definition()<CR>
handlers:
textDocument/hover:
border: rounded
diagnostics:
signs: false
filetype_mappings:
extension:
tf: terraform
filetypes:
go:
options:
expandtab: false
tabstop: 4
language_server:
name: gopls
cmd:
- gopls
root_dir:
patterns:
- go.mod
- .git
settings:
single_file_support: true
Then, add the following to your init.lua
:
-- init.lua
require("nvim_but_yaml").apply("<absolute-path-to-nvim.yaml>")
Now your configuration in nvim.yaml
will be applied on startup.
- Global options
- Colorscheme
- Mappings
- Global variables
- Autocommands (Skip augroups for now)
- Commands
- Language server settings
- Mappings
- Filetype
- Options
- Mappings
- Language server
- Syntax
- Indent
- Plugins. I think we should skip this
Use schema.yaml to validate your configuration.
This example uses yajsv to validate the
configuration file nvim.yaml
.
curl https://raw.githubusercontent.com/slarwise/nvim-but-yaml/main/schema.yaml > schema.yaml
yajsv -s schema.yaml nvim.yaml
If you use the yaml-language-server, it is possible to provide the schema in your configuration file, like this:
# yaml-language-server: $schema=https://raw.githubusercontent.com/slarwise/nvim-but-yaml/main/schema.yaml
options:
background: dark