Closed xfzv closed 1 year ago
I partially solved my issue by using:
vim.cmd ([[ let g:chezmoi#source_dir_path = "~/dotfiles" ]])
in my plugins.lua
file before loading the plug-in. Partially because while it works for dot_zshenv
or dot_zshrc
, many of my chezmoi
files that have some go templates in it such as:
.chezmoiignore
(like #43).chezmoiexternal.yml
.chezmoi.yml.tmpl
are still not having proper syntax highlighting. It works fine for two .ini.tmpl
and .js.tmpl
files I have for some reasons. Seems quite erratic.
I re-read Packer documentation and thought I could use setup =
instead of config =
to run this command before the plugin is load with my current method, but it doesn't seem to work.
Hi. Thank you for your catching.
Missing highlighting in .chezmoi*.yml should be fixed by #47 (it has processed yaml but not yml before).
For highlighting *.service.tmpl
correctly, it seems to need special adjustment for merging syntax systemd
and go-template
. I'll split it out as a new issue.
For user-override.js.tmpl
, more details needed. Please tell the file path from your chezmoi's source directory if you don't mind.
For the core problem this issue that integration with neovim
, lua
and packer
, I don't know how do combination and configuration of these affect ordering around file type detection yet. I don't use neovim
and need to make time for making similar environment and reproduction. Please give me a few months to start once being free.
Is this normal? Not sure if it means
0
because#
is treated as a comment or if it's actually1
aka plug-in disabled.
A prefix #
means the value is number type (not string).
So calling :let foo = 0
, :let bar = '0'
and :let
should show:
foo #0
bar 0
Missing highlighting in .chezmoi*.yml should be fixed by https://github.com/alker0/chezmoi.vim/pull/47 (it has processed yaml but not yml before).
Doesn't seem to work after updating:
After manually running :set ft=yml.chezmoitmpl
:
For highlighting *.service.tmpl correctly, it seems to need special adjustment for merging syntax systemd and go-template. I'll split it out as a new issue.
Thanks, will try when it's merged.
For user-override.js.tmpl, more details needed. Please tell the file path from your chezmoi's source directory if you don't mind.
~/dotfiles/dot_mozilla/firefox/default-release/user-overrides.js.tmpl
Please update it and check if it enables highlighting automatically for below files.
.chezmoiignore
.chezmoiexternal.yml
.chezmoi.yml.tmpl
user-overrides.js.tmpl
For passing options to this plugin in managed by packer, you need to define manually because both setup =
and config =
don't run before file type detection.
In packer settings, the config =
option runs a script after loaded the plugin, and setup =
does before but after file type detection, does it start to watch the plugin be going to load. setup =
seems to focus to help you run scripts lazily rather than early for good at combining the plugin and a plugin-specific script and make it wait custom trigger together.
Please ask anything if you still get (excepting about .service.tmpl
you can track in #48) , or close it.
Please update it and check if it enables highlighting automatically for below files.
* `.chezmoiignore` * `.chezmoiexternal.yml` * `.chezmoi.yml.tmpl` * `user-overrides.js.tmpl`
Nothing changed after updating to recent commits unfortunately.
Only .chezmoiignore
has proper syntax highlighting but it worked fine prior to updating.
.chezmoiexternal.yml
, .chezmoi.yml.tmpl
and user-overrides.js.tmpl
still have incorrect syntax highlighting (see screenshots from previous posts)
For passing options to this plugin in managed by packer, you need to define manually because both
setup =
andconfig =
don't run before file type detection. In packer settings, theconfig =
option runs a script after loaded the plugin, andsetup =
does before but after file type detection, does it start to watch the plugin be going to load.setup =
seems to focus to help you run scripts lazily rather than early for good at combining the plugin and a plugin-specific script and make it wait custom trigger together.
I'm just using:
vim.cmd([[ let g:chezmoi#source_dir_path = "/home/{{ .chezmoi.username }}/dotfiles" ]])
in my plugins.lua.tmpl
file before the use
function where my plugins are loaded. I load alker0/chezmoi.vim
without any additional packer
option.
I don't think I need anything else?
let chezmoi#_loaded
chezmoi#_loaded #1
let chezmoi#source_dir_path
chezmoi#source_dir_path /home/xfzv/dotfiles
hmm...
What does running this show? This shows updated time and where packer installed it into, if using packer, it needs to be in start/
, or opt/
doesn't work.
# With bracket keeps your current directory
(cd ~/.local/share/nvim/site/pack/packer && stat -c "%n,%y" ./*/chezmoi.vim{,/*} | column -t -s,)
If it's in opt/
, you need to reinstall this plugin manually via:
use { 'alker0/chezmoi.vim' }
PackerSync
use { 'alker0/chezmoi.vim' }
PackerSync
By the way, for getting ordering of startup phases verbosely, you can run this.
echo > /tmp/foo.txt && nvim --startuptime /tmp/foo.txt ~/dotfiles/.chezmoi.yml.tmpl '+quit' && nvim /tmp/foo.txt
And it should show like (if succeeded):
/tmp/foo.txt
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.005 000.005: --- NVIM STARTING ---
000.077 000.072: event init
000.169 000.092: ...MANY...
000.169 000.092: ...LINES...
003.479 000.059 000.059: sourcing /usr/share/nvim/runtime/ftplugin.vim
003.545 000.032 000.032: sourcing /usr/share/nvim/runtime/indent.vim
005.048 000.148 000.148: require('packer.XXX')
005.048 000.148 000.148: ...MANY...
005.048 000.148 000.148: ...LINES...
006.362 002.781 000.147: sourcing /home/alker/.config/nvim/init.lua
006.367 000.589: sourcing vimrc file(s)
=================================== Ordering of some lines below is the most important. =========================
006.627 000.230 000.230: sourcing /home/alker/.local/share/nvim/site/pack/packer/start/chezmoi.vim/filetype.vim
006.857 000.187 000.187: sourcing /usr/share/nvim/runtime/filetype.lua
007.048 000.097 000.097: sourcing /usr/share/nvim/runtime/syntax/synload.vim
007.207 000.305 000.208: sourcing /usr/share/nvim/runtime/syntax/syntax.vim
007.867 000.282 000.282: ...MANY...
007.867 000.282 000.282: ...LINES...
009.954 000.238 000.238: require('setup/impatient')
009.956 000.423 000.185: sourcing /home/alker/.config/nvim/plugin/packer_compiled.lua
010.097 000.040 000.040: sourcing /usr/share/nvim/runtime/plugin/man.lua
010.105 000.779: ...SOME...
010.105 000.779: ...LINES...
011.044 000.807: reading ShaDa
011.406 000.119 000.119: sourcing /home/alker/.local/share/nvim/site/pack/packer/start/chezmoi.vim/autoload/chezmoi/filetype.vim
012.259 000.709 000.709: require('vim.filetype')
012.797 000.040 000.040: sourcing /usr/share/nvim/runtime/ftplugin/yaml.vim
013.283 000.114 000.114: sourcing /usr/share/nvim/runtime/indent/yaml.vim
014.052 000.669 000.669: sourcing /usr/share/nvim/runtime/syntax/yaml.vim
014.305 000.033 000.033: sourcing /usr/share/nvim/runtime/ftplugin/yaml.vim
015.026 000.017 000.017: sourcing /usr/share/nvim/runtime/indent/yaml.vim
015.749 000.581 000.581: sourcing /usr/share/nvim/runtime/syntax/yaml.vim
016.053 000.148 000.148: sourcing /home/alker/.local/share/nvim/site/pack/packer/start/chezmoi.vim/vendor/vim-go/syntax/gotmpl.vim
016.055 000.162 000.014: sourcing /home/alker/.local/share/nvim/site/pack/packer/start/chezmoi.vim/syntax/gotmpl.vim
016.099 000.239 000.077: sourcing /home/alker/.local/share/nvim/site/pack/packer/start/chezmoi.vim/syntax/chezmoitmpl.vim
016.511 002.947: opening buffers
016.525 000.015: BufEnter autocommands
016.527 000.002: editing files in windows
hmm... What does running this show? This shows updated time and where packer installed it into, if using packer, it needs to be in
start/
, oropt/
doesn't work.# With bracket keeps your current directory (cd ~/.local/share/nvim/site/pack/packer && stat -c "%n,%y" ./*/chezmoi.vim{,/*} | column -t -s,)
./start/chezmoi.vim 2022-11-10 11:17:37.527066452 +0100
./start/chezmoi.vim/after 2022-10-29 15:34:56.633189244 +0200
./start/chezmoi.vim/autoload 2022-10-29 15:34:56.633189244 +0200
./start/chezmoi.vim/filetype.vim 2022-11-10 11:17:37.527066452 +0100
./start/chezmoi.vim/.git 2022-11-12 10:53:34.550462466 +0100
./start/chezmoi.vim/LICENSE 2022-10-29 15:34:56.633189244 +0200
./start/chezmoi.vim/README.md 2022-10-29 15:34:56.633189244 +0200
./start/chezmoi.vim/syntax 2022-10-29 15:34:56.633189244 +0200
./start/chezmoi.vim/vendor 2022-10-29 15:34:56.633189244 +0200
By the way, for getting ordering of startup phases verbosely, you can run this.
echo > /tmp/foo.txt && nvim --startuptime /tmp/foo.txt ~/dotfiles/.chezmoi.yml.tmpl '+quit' && nvim /tmp/foo.txt
And it should show like (if succeeded):
/tmp/foo.txt
Please try the latest and re-check if it works.
But it might not do for .chezmoiignore
, and if so, please run these and tell the output.
:set filetype
:echo substitute(execute('let'), '\n\%(b:chezmoi_\|b:current_syntax\)\@![^\n]*', '', 'g')
Please try the latest and re-check if it works. But it might not do for
.chezmoiignore
, and if so, please run these and tell the output.* `:set filetype` * `:echo substitute(execute('let'), '\n\%(b:chezmoi_\|b:current_syntax\)\@![^\n]*', '', 'g')`
After updating, .chezmoiignore
still has proper syntax highlighting, the other problematic files still don't.
Some files have correct syntax highligthing and some other don't as far as I'm concerned.
~/dotfiles/dot_mozilla/firefox/profiles.ini.tmpl
:
~/dotfiles/test.sh.tmpl
: (not sure but the {{ -}}
signs are different)
Does this work fine on your end for example? it doesn't here.
The correct filetype is set automatically (yaml.chezmoitmpl
) but there is no syntax highlighting at all:
For this file, running :echo substitute(execute('let'), '\n\%(b:chezmoi_\|b:current_syntax\)\@![^\n]*', '', 'g')
gives me:
b:chezmoi_default_detect_target /home/xfzv/dotfiles/test.yaml
b:chezmoi_source_path /home/xfzv/dotfiles/test.yaml
b:chezmoi_original_filetype yaml
My neovim environment still doesn't reproduce the issue so I don't sure this comes from.
nvim --version
shows:
NVIM v0.8.0-1210-gd367ed9b2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az505-656
Features: +acl +iconv +tui
In ~/.config/nvim/lua/plugins.lua
:
In ~/dotfiles/test-sh.toml
and ~/dotfiles/test-yaml.toml
:
This may come from integration with others.
Please try toggling On/Off each plugins (e.g. with disabled
of packer option) and tell whether any works correctly.
Please try toggling On/Off each plugins (e.g. with disabled of packer option) and tell whether any works correctly.
Will do and report back. Thanks for your time. :bow:
I finally found the culprit :tada: - it's nvim-treesitter. Everything is fine without it:
and the highlighting issues come back as soon as I enable it again.
Closing because it's definitely not an issue with chezmoi.vim
. I don't know how to keep tree-sitter
enabled while using chezmoi.vim
though. The disabled
option is only for actual parsers, not file types.
Edit: Maybe with a function as documented here?
Feel free to let me know if you have any idea about this.
Thank you again for your time and your help!
Using additional_vim_regex_highlighting = true
seems to works just fine.
Edit: My bad, it doesn't make any difference. I forgot to run :PackerCompile
after re-enabling tree-sitter. :man_facepalming:
Yes! :tada: I'm glad I could help you and also fix and improve it. Thank you for a lot of time and response for my many questions.
I'm using wbthomason/packer.nvim to manage my plug-ins, including this one (loaded early, as suggested in the README:
https://github.com/alker0/chezmoi.vim/blob/7fd839d7fa275e7ffc4b11e2f1d99527c9024681/README.md?plain=1#L56
Relevant part of my
plugins.lua
:I'm using a custom source dir path for chezmoi, so I use:
This seems to work as expected:
However, I'm not getting any syntax highlighting at all. Here are various screenshots:
Screenshots
- regular `~/.zshenv` (top) and `dot_zshenv` (bottom) ![image](https://user-images.githubusercontent.com/78810647/197205249-f8990d7a-7226-4e78-8773-70576c1ca13a.png) - `.chezmoiignore` in source dir: ![image](https://user-images.githubusercontent.com/78810647/197206223-eadc65a9-b357-4082-9849-3ae7aaf7a2b5.png) - After running `:set ft=chezmoitmpl` manually: ![image](https://user-images.githubusercontent.com/78810647/197206406-60b11a13-f456-4a32-adef-eca713d41787.png)Not sure what I'm doing wrong, any advice is appreciated. Thanks!
Edit:
Is this normal? Not sure if it means
0
because#
is treated as a comment or if it's actually1
aka plug-in disabled.