Comments (9)
It took me a bit to get back to this -- thanks for your patience! I tried this out in cweagans/dotfiles@d672172 and it worked really really well! This is exactly what I had in mind and it's flexible enough for other people to define their own workflows too.
I think my only feedback would be to maybe have something in the plugin that runs chezmoi source-path
in the background to get the Chezmoi source. That way, the autocommand could look something like this instead:
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = { require("chezmoi").source_path },
callback = function()
-- invoke with vim.schedule() for better startup time
vim.schedule(require("chezmoi.commands.__edit").watch)
end,
})
from chezmoi.nvim.
Ah, yeah i've also thought about it, but i think we should just provide the callback function so that users can set it properly with nvim_create_autocmd. What do you think about this?
from chezmoi.nvim.
That'd work. I suppose I don't care how automatic it is - just that there is a way to automatically sync whenever I edit stuff in my chezmoi dir.
from chezmoi.nvim.
Can i do this for you then? I have been doing some refactoring and i think i can add this feature too.
from chezmoi.nvim.
Sure! Thank you! Glad to test whenever!! :)
from chezmoi.nvim.
I think it is almost done. Currently testing on refactor
branch, and my configuration is now like below
require("chezmoi").setup({
edit = {
watch = true,
force = true,
},
notification = {
on_open = false,
on_save = true,
on_watch = true,
},
})
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" },
callback = function()
-- invoke with vim.schedule() for better startup time
vim.schedule(require("chezmoi.commands.__edit").watch)
end,
})
Please test the feature on the refactor
branch if you ever get a chance.
from chezmoi.nvim.
Good point. I've actually also tried it, but i thought assigning the result of chezmoi.source_path
to the autocmd pattern
required more lines of code. Furthermore, it will make our neovim take slightly more time during the startup since chezmoi.source_path
returns a list of exact filenames(absolute paths) rather than a pattern strings. It's true that we have to at least check if the file is really a chezmoi managed file, in that case we can do some additional check in watch()
function like below; In this commit, i've used chezmoi.status
.
chezmoi.nvim/lua/chezmoi/commands/__edit.lua
Lines 44 to 58 in 4fbd33d
Please let me know if you got any suggestion or better idea!
from chezmoi.nvim.
@cweagans Do you mind if i close this issue if you don't have any opinion?
from chezmoi.nvim.
Not at all!
from chezmoi.nvim.
Related Issues (9)
- question about netrw HOT 3
- using telescope HOT 2
- apply on save doesn't work HOT 1
- find_files picker is incompatible with select_tab_drop HOT 10
- [FEATURE REQUEST] recently edited by chezmoi HOT 5
- Error when running list on new setup. HOT 6
- Chezmoi vim and chezmoi nvim conflict together HOT 5
- Chezmoi script support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chezmoi.nvim.