Closed benjaminbauer closed 11 months ago
Thank you for your reporting.
In my Neovim environment, trying kickstart.nvim
doesn't reproduce currently. I cloned kickstart.nvim
and inserted the following lines as the first plugin of lazy.nvim
. That's all I did and get highlighting for chezmoi template.
require('lazy').setup({
-- NOTE: First, some plugins that don't require any configuration
-- ==== Inserted lines ====
{
'alker0/chezmoi.vim',
lazy = false,
init = function(plugin)
vim.g['chezmoi#use_tmp_buffer'] = true
end,
},
-- ...other default
})
And nvim ~/.local/share/chezmoi/run_once_setup.sh.tmpl
showes:
It may come from failing to integrate between this plugin and other additional plugins by your custom.
Please try toggling On/Off each plugins with enabled = false
plugin option of lazy.nvim
, and tell whether any works correctly.
Your Also:
advice is exactly right. The README has to guide also lazy.nvim
users to making this plugin work. After resolving this issue, I will add a config sample with considering resolving steps of that.
Thanks @alker0! I reverted my init.lua
to the current HEAD of kickstart and added your lines. I still get the same result:
NVIM v0.9.2
Build type: RelWithDebInfo
LuaJIT 2.1.1692716794
Does the plugin rely on anything external for the filetype detection?
Thank you for trying to reset your config. This issue doesn't seem to come from a plugins combination.
Does the plugin rely on anything external for the filetype detection?
No, it doesn't depend any externals unless you enable the option g:chezmoi#use_external
. If your chezmoi-managed directory isn't the default path (e.g. ~/.local/share/chezmoi/
), you need to tell the plugin there with the g:chezmoi#source_dir_path
option like this:
{
'alker0/chezmoi.vim',
lazy = false,
init = function(plugin)
vim.g['chezmoi#use_tmp_buffer'] = true
-- Specify your chezmoi source dir path instead of this example path.
vim.g['g:chezmoi#source_dir_path'] = os.getenv('HOME') .. '/dotfiles'
end,
},
Please try it if you placed the source directory where isn't default. If not, call these commands in editing run_once_setup.sh.tmpl
and tell me each output.
:scriptnames
:echo isdirectory($HOME . '/.local/share/chezmoi')
:echo isdirectory(g:chezmoi#source_dir_path)
:echo join(filter(split(execute('let'), '\n'), 'v:val =~# "chezmoi[#_]"'), "\n")
If you care about privacy of your environment, you have to tell me only :echo isdirectory(...)
commands of above.
Thanks! It was the g:chezmoi#source_dir_path
. Two pointers wrt to your snippet:
init = function(plugin)
: plugin
is unused and can be ommitedvim.g['g:chezmoi#source_dir_path'] =
: it is supposed to be vim.g["chezmoi#source_dir_path"]
Can the plugin be adapted to pick up the sourceDir
from chezmoi instead of (I assume) a static list of paths? chezmoi data
can deliver the actual sourceDir
FWIW: For kickstart.nvim users that do want to minimize changes to init.lua
, the chezmoi plugin is also perfectly happy when one puts this in a file in the "standard" kickstart custom plugin path nvim/lua/custom/plugins/
return {
'alker0/chezmoi.vim',
lazy = false,
init = function()
vim.g['chezmoi#use_tmp_buffer'] = true
-- adapt to your actual source dir path IF not using the standard path
-- see `chezmoi data | grep sourceDir`
vim.g["chezmoi#source_dir_path"] = vim.fn.expand("$HOME/dotfiles")
end,
}
Great:tada:
Thank you for some pointers. Sure, the plugin
argument and the g:
prefix are unnecessary. Also vim.fn.expand(...)
is definitely better than os.getenv(...)
.
Can the plugin be adapted to pick up the sourceDir from chezmoi instead of (I assume) a static list of paths?
Please try to add vim.g['chezmoi#use_external'] = 1
like other plugin options. Setting g:chezmoi#use_external
at 1
should automatically tell the plugin your source dir path by calling chezmoi source-path
.
You can get more details from the Option
section of README.
the chezmoi plugin is also perfectly happy when one puts this in a file in the "standard" kickstart custom plugin path
nvim/lua/custom/plugins/
Oh, I didn't know that cool hack. We need to add only { import = 'custom.plugins' },
as if this is the last plugin of lazy.nvim
. If we use a plugin manager other than lazy.nvim
, we can also apply it by little change because it's builtin feature of lua language. However in README
, it shouldn't need to give that for getting work of the plugin.
Thank you a lot for your helping improvement of documentation.
Very welcome!
vim.g['chezmoi#use_external'] = 1
instead of setting chezmoi#source_dir_path
also works. The docs mention, that using chezmoi#use_external
is slower. So I guess setting chezmoi#source_dir_path
is the better option in the scenario
I am trying to get his plugin to work in Neovim 0.9 with the popular https://github.com/nvim-lua/kickstart.nvim
I am using the proposed fix in https://github.com/alker0/chezmoi.vim/issues/57#issuecomment-1425027170.
What does not work: the filetype detection:
template
gets detected. When I manually set the filetype in the buffer to e.g.sh.chezmoitmpl
on a file calledrun_once_setup.sh.tmpl
it works.I know this kind of support is out of scope for this plugin. Any pointers are still appreciated!
Also: Consider to include the config for lazy.nvim in the README