Code Monkey home page Code Monkey logo

chezmoi.nvim's Introduction

Description

chezmoi integration with Neovim. Edit files, as normal, with Neovim and have changes automatically placed in the Chezmoi source state. Also add and remove files from Chezmoi source state from within Neovim.

This shows editing of a file that is Chezmoi managed (notice the [CM] in the status bar) followed by editing a file that is not Chezmoi managed (notice no [CM] in the status bar).

This shows the commands that add and forget the current file.

Compatibility

Neovim >= 0.5.0

Installation

Install using your favorite plugin manager. Make certain you have chezmoi installed.

If you use vim-plug:

Plug 'WhoIsSethDaniel/chezmoi.nvim'

Or if you use Vim 8 style packages:

cd <plugin dir>
git clone https://github.com/WhoIsSethDaniel/chezmoi.nvim

Configuration

Somewhere in your configuration you will need:

require"chezmoi".setup()

You can pass configuration to setup().

require"chezmoi".setup({
  exec = "chezmoi.new",
  auto_add = true,  -- the default is true
  add_options = '--empty'
})

If you are using Vimscript for configuration:

lua <<EOF
require"chezmoi".setup()
EOF

Options:

  • exec: default 'chezmoi'. Only set 'exec' if you have installed chezmoi under a name other than 'chezmoi'. The given name must be in your path and executable.
  • auto_add: default 'true'. Set to 'false' if you do not want changes to chezmoi managed files to be auto-added to the source state.
  • add_options: default '--empty'. A string of options for 'chezmoi add'. By default this is '--empty' which means empty files will be added. If you set this option and wish for empty files to be added you will need to add '--empty' since setting this option removes the default. This is also the default if you use :ChezmoiAdd.

Usage

Whenever you save a file that is managed by chezmoi it will be 'add'ed to the chezmoi source state. This allows you to edit files as you normally would without thinking about using 'chezmoi edit'.

Commands

There are two commands that are defined:

  • :ChezmoiAdd: this will add the current file to the chezmoi source state. Pass options the same way you would pass them to chezmoi. This will add the current file and will pass the --exact and --empty options to chezmoi. Default options may be set using the add_options configuration variable. e.g.:
:ChezmoiAdd --empty --exact
  • :ChezmoiForget: this will remove the current file from the chezmoi source state (e.g. chezmoi forget ...)

Status Line

There is very basic statusline integration. I use lualine and I do the following in my lualine config:

function chezmoi() return require 'chezmoi'.status() end
...
require('lualine').setup{
    ...
    sections = {
        ...
        lualine_c = { ... {chezmoi} ... }
        ...
    }
}

When you edit a file you will see a [CM] displayed when you are editing a file managed by chezmoi.

chezmoi.nvim's People

Contributors

whoissethdaniel avatar

Stargazers

Andy Shevchenko avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.