alker0 / chezmoi.vim

Highlight dotfiles you manage with chezmoi.
Other
128 stars 4 forks source link

Use 'chezmoi source-path' for the source dir detection #33

Closed j-xella closed 2 years ago

j-xella commented 2 years ago

This should hopefully fix #32

alker0 commented 2 years ago

Probably it is better to be an option that using chezmoi source-path, because system(...) function takes hundreds ms. You can compare startup time via running this:

$ cd path/to/chezmoi.vim
$ git switch main # and call `chezmoi apply` if needed
$ vim --startuptime /tmp/vim-before.log filetype.vim # and exit with `:q`
$ git switch issue-32 # and call `chezmoi apply` if needed
$ vim --startuptime /tmp/vim-after.log filetype.vim # and exit with `:q`
$ tail -n 1 /tmp/vim-before.log /tmp/vim-after.log

In my WSL2 Ubuntu, this shows:

==> /tmp/vim-before.log <==
029.960  000.002: --- VIM STARTED ---

==> /tmp/vim-after.log <==
284.624  000.001: --- VIM STARTED ---
j-xella commented 2 years ago

Probably it is better to be an option that using chezmoi source-path, because system(...) function takes hundreds ms. You can compare startup time via running this:

I agree that calling system may make vim start-up longer. However, there is already a way to disable it - if g:chezmoi#source_dir_path is set before chezmoi.vim is sourced, no system call will be executed. So, for initial users, it would be better if chezmoi.vim was more "clever", IMO, even if it takes some addiitonal milliseconds of vim start-up. And if users are really concerned about vim start-up times, they can always set g:chezmoi#source_dir_path explicitly in their vimrc

alker0 commented 2 years ago

I see, making g:chezmoi#executable_path trigger of system() sounds good.

If use executabe() instead of exists() for checking and calling g:chezmoi#executable_path, it allows to set only binary name like chezmoi so would be easier ? If so, the name g:chezmoi#executable_path may need to adjustment.

alker0 commented 2 years ago

Great. Thank you for the improvement and adding clear description.