xvzc / chezmoi.nvim Goto Github PK
View Code? Open in Web Editor NEWChezmoi plugin for neovim
License: MIT License
Chezmoi plugin for neovim
License: MIT License
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,
}
Hi, I just recently fall in love with chezmoi and dotfiles)
To manage chezmoi files I use:
.tmpl
and name-specific files like .zshrc
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.
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?
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
.
very interesting plugin!
In addition of using this plugin to manage my chezmoi in neovim i am wondering if you have any solution for my question here:
twpayne/chezmoi#3511
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>
is there any command that can list the files "recently" edited by chezmoi, similar to telescope.builtin.oldfiles()
in telescope?
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.
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()]])
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.