jbmorice / chezmoi.nvim

Chezmoi plugin for neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chezmoi.nvim


Edit your chezmoi-managed files and automatically apply.

chezmoi.nvim demo

What Is chezmoi.nvim?

chezmoi.nvim is a plugin designed to assist in editing and applying chezmoi-managed files within neovim. A notable distinction from the command line tool chezmoi is that chezmoi.nvim utilizes built-in neovim functions for file editing, allowing us to edit and watch multiple files simultaneously.

Getting Started

Requirements

Installation

-- Lazy.nvim
{
  'xvzc/chezmoi.nvim',
  dependencies = { 'nvim-lua/plenary.nvim' },
  config = function()
    require("chezmoi").setup {
      -- your configurations
    }
  end
},

Configuration

-- default values
{
  edit = {
    watch = false, -- Set true to automatically apply on save.
    force = false, -- Set true to force apply. Works only when watch = true.
  },
  notification = {
    on_open = true, -- vim.notify when start editing chezmoi-managed file.
    on_apply = true, -- vim.notify on apply.
  },
}

Telescope Integration

-- telscope-config.lua
local telescope = require("telescope")

telescope.setup {
  -- ... your telescope config
}

telescope.load_extension('chezmoi')
vim.keymap.set('n', '<leader>cz', telescope.extensions.chezmoi.find_files, {})

User Command

:ChezmoiEdit <target> <args>
" This will open '~/.local/chezmoi/dot_zshrc' and apply the changes on save
" :ChezmoiEdit ~/.zshrc --watch
" Arguments
" --watch Automatically apply changes on save
" --force force apply.

:ChezmoiList <args>
" :ChezmoiList --include=files
" You can put any of command line arguments of 'chezmoi' here

API

See Commands for more information

List

local managed_files = require("chezmoi.commands").list()
print(vim.inspect(managed_files))

Edit

-- Note: chezmoi.nvim utilizes builtin neovim functions for file editing instead of `chzmoi edit`
require("chezmoi.commands").edit("~/.zshrc", { "--watch" })

About

Chezmoi plugin for neovim

License:MIT License


Languages

Language:Lua 99.2%Language:Makefile 0.8%