Code Monkey home page Code Monkey logo

chezmoi.nvim's Introduction

xvzc's GitHub stats

chezmoi.nvim's People

Contributors

jbmorice avatar xvzc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

jbmorice

chezmoi.nvim's Issues

apply on save doesn't work

when i save a dot file it doesn't apply the change via chezmoi. I've set it in config file.

return {
	"xvzc/chezmoi.nvim",
	dependencies = { "nvim-lua/plenary.nvim" },
	config = function()
		require("chezmoi").setup({
			-- your configurations
			{
				edit = {
					watch = true, -- Set true to automatically apply on save.
					force = true, -- 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.
				},
			},
		})
	end,
}

Chezmoi vim and chezmoi nvim conflict together

Hi, I just recently fall in love with chezmoi and dotfiles)
To manage chezmoi files I use:

  1. chezmoi.vim. It provides highlighting for .tmpl and name-specific files like .zshrc
  2. chezmoi.nvim for editing chezmoi files and automatically applying them

But I stumbled over that chezmoi.vim conflicts with chezmoi.nvim when chezmoi.vim creates a temp buffer for supporting files like .tmpl. I don't understand why, but it just copies empty strings into the clipboard when I open a NEW chezmoi buffer.

CleanShot.2024-03-28.at.11.43.24.mp4

The issue only appears when autocmd from docs is set:

vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
  pattern = { os.getenv('HOME') .. '/.local/share/chezmoi/*' },
  callback = function()
    vim.schedule(require('chezmoi.commands.__edit').execute())
  end,
})

Do you think it is possible to find a workaround around it?

Treat all files in `chezmoi source-path` as Chezmoi files

Thanks for putting this together! I'm probably gonna start using this pretty regularly.

Would you be interested in a pull request to automatically treat anything in chezmoi source-path as a Chezmoi file? That way, I can chezmoi cd, then nvim ., start editing, and have stuff applied automatically. Right now, it only applies changes if I :ChezmoiEdit ~/path/to/my/file.

Error when running list on new setup.

I'm getting the following errors when I attempt to run :Telescope chezmoi list-files. For context, here are the relevant dotfiles. Any ideas on what I may be doing wrong would be much appreciated!!

   Error  17:01:37 msg_show.lua_error Error executing luv callback:
cannot resume dead coroutine
stack traceback:
	[builtin#36]: at 0x56306f0f6f70
	[C]: in function 'wait'
	.../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:486: in function 'wait'
	.../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:453: in function 'sync'
	...e/nvim/lazy/chezmoi.nvim/lua/chezmoi/commands/__base.lua:44: in function 'list'
	...zy/chezmoi.nvim/lua/telescope/_extensions/find_files.lua:41: in function <...zy/chezmoi.nvim/lua/telescope/_extensions/find_files.lua:38>
	...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:183: in function 'run_command'
	...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:259: in function 'load_command'
	...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:108: in function <...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:107>
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function 'cmd'
	.../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:429: in function 'run_replace_or_original'
	...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'run_replace_or_original'
	...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
	...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:269: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:268>
   Error  17:01:37 msg_show.lua_error Error executing luv callback:
...e/nvim/lazy/chezmoi.nvim/lua/chezmoi/commands/__base.lua:34: 'chezmoi list'command returned non 0 exit code:
chezmoi: unknown command "list" for "chezmoi"
stack traceback:
	[builtin#36]: at 0x56306f0f6f70
	[C]: in function 'wait'
	.../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:486: in function 'wait'
	.../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:453: in function 'sync'
	...e/nvim/lazy/chezmoi.nvim/lua/chezmoi/commands/__base.lua:44: in function 'list'
	...zy/chezmoi.nvim/lua/telescope/_extensions/find_files.lua:41: in function <...zy/chezmoi.nvim/lua/telescope/_extensions/find_files.lua:38>
	...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:183: in function 'run_command'
	...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:259: in function 'load_command'
	...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:108: in function <...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:107>
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function 'cmd'
	.../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:429: in function 'run_replace_or_original'
	...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'run_replace_or_original'
	...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
	...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:269: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:268>

using telescope

i've added the telescope integration part but running it still shows the original dotfiles not the chezmio dotfiles. What am i missing?

image

find_files picker is incompatible with select_tab_drop

It seems like find_files only calls chezmoi edit if the telescope select action is the default (open in current window). If select_tab_drop is set as the default, select_tab_drop will still be called correctly, but chezmoi edit will not.

Minimal config

vim.fn.system({ "rm", "-rf", "/tmp/nvim/site" })
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
	require("packer").startup({
		{
			"wbthomason/packer.nvim",
			"nvim-telescope/telescope.nvim",
			{
				"xvzc/chezmoi.nvim",
				requires = { "nvim-lua/plenary.nvim" },
			},
		},

		config = {
			package_root = package_root,
			compile_path = install_path .. "/plugin/packer_compiled.lua",
			display = { non_interactive = true },
		},
	})
end
_G.load_config = function()
	local telescope_actions = require("telescope.actions")
	require("telescope").setup({
		defaults = {
			mappings = {
				-- enabling these will disable chezmoi edit
				i = { ["<cr>"] = telescope_actions.select_tab_drop },
				n = { ["<cr>"] = telescope_actions.select_tab_drop },
			},
		},
	})
	require("telescope").load_extension("chezmoi")

	vim.keymap.set("n", "<space>c", require("telescope").extensions.chezmoi.find_files)
end
if vim.fn.isdirectory(install_path) == 0 then
	print("Installing Telescope and dependencies.")
	vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()

vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]])

Chezmoi script support

I faced a case, where I was forced to use a chezmoi script. I had to duplicate a config file into multiple places because of the nature of the application. When I edited and saved its config file (using the recommended autocommand), I noticed that chezmoi.nvim did not run the config duplication script that chezmoi would run when chezmoi apply is called.

I do not know whether it is a bug or an intentional.

Sure that the problem can be solved via extending the autocommand to run the chezmoi scripts, but that can become quiclkly ugly, since chezmoi has rich scripting features. (I know my specific case can be solved relatively elegantly with a symlinking script as well.)

Would be it problematic to support chezmoi scripts?

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.