Skip to content

slarwise/nvim-but-yaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim but yaml

Configure neovim using yaml.

Installation

Clone this repo to somewhere under :help packpath or install using a package manager. Then install yq.

Usage

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.

Supported configuration

  • 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

Schema

Use schema.yaml to validate your configuration.

Validate using CLI

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

Validate in editor

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

Releases

No releases published

Packages

No packages published