Discussion:
In vim, how to tell which version of a syntax file is being used?
(too old to reply)
Kenny McCormack
2025-02-15 16:27:05 UTC
Permalink
Overall problem: I'm trying to debug a problem in the syntax highlighting
of a particular shell script.

I want to know if there is some variable that is set by the syntax
apparatus that tells me either or both of:

1) What version of sh.vim was used?
2) The full path of the used sh.vim file?
--
I don't do things wrong.
I do things right.

I'm a legitimate person.
Janis Papanagnou
2025-02-15 22:29:23 UTC
Permalink
Post by Kenny McCormack
Overall problem: I'm trying to debug a problem in the syntax highlighting
of a particular shell script.
I want to know if there is some variable that is set by the syntax
1) What version of sh.vim was used?
2) The full path of the used sh.vim file?
If in doubt I'm inspecting (according to :help) what Vim shows me
when I'm typing ':set rtp'. There's a couple directories and mine
shows (for and on a Unix system) '/usr/share/vim/vim73' so my 'sh'
default syntax file would be '/usr/share/vim/vim73/syntax/sh.vim'.

But there's more directories shown in that path list that appear
before the '/usr/share' path, and I have also a local directory
'~/.vim/after/syntax/sh/...' where some changes to the default
behavior for 'sh' are defined.

Janis
Kenny McCormack
2025-02-16 01:25:40 UTC
Permalink
Post by Janis Papanagnou
Post by Kenny McCormack
Overall problem: I'm trying to debug a problem in the syntax highlighting
of a particular shell script.
I want to know if there is some variable that is set by the syntax
1) What version of sh.vim was used?
2) The full path of the used sh.vim file?
If in doubt I'm inspecting (according to :help) what Vim shows me
when I'm typing ':set rtp'. There's a couple directories and mine
shows (for and on a Unix system) '/usr/share/vim/vim73' so my 'sh'
default syntax file would be '/usr/share/vim/vim73/syntax/sh.vim'.
But there's more directories shown in that path list that appear
before the '/usr/share' path, and I have also a local directory
'~/.vim/after/syntax/sh/...' where some changes to the default
behavior for 'sh' are defined.
Right. I am familiar with all that.

But (IMNSHO, of course) those all fit in the "kludgey workarounds" category.
I mean, they are indirect ways of coming to an approximation of the truth.

What I really want (and my reason for posting this thread) is to know if
there is a direct (not directory) way to actually get the information, not
an approximation.

Isn't there some kind of "verbose mode" that makes VIM tell you every file
it sources (as it is sourcing it)? That would be closer to the truth, but
still not ideal.

Incidentally, I did put a sh.vim in my locatel syntax directory, and was
able to conclude, using inotifywait, that it was being sourced when a shell
script as loaded in vim. But that also is in the "approximation" category.
--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/GodDelusion
Janis Papanagnou
2025-02-16 04:20:17 UTC
Permalink
Post by Kenny McCormack
Post by Janis Papanagnou
Post by Kenny McCormack
Overall problem: I'm trying to debug a problem in the syntax highlighting
of a particular shell script.
I want to know if there is some variable that is set by the syntax
1) What version of sh.vim was used?
2) The full path of the used sh.vim file?
If in doubt I'm inspecting (according to :help) what Vim shows me
when I'm typing ':set rtp'. There's a couple directories and mine
shows (for and on a Unix system) '/usr/share/vim/vim73' so my 'sh'
default syntax file would be '/usr/share/vim/vim73/syntax/sh.vim'.
But there's more directories shown in that path list that appear
before the '/usr/share' path, and I have also a local directory
'~/.vim/after/syntax/sh/...' where some changes to the default
behavior for 'sh' are defined.
Right. I am familiar with all that.
But (IMNSHO, of course) those all fit in the "kludgey workarounds" category.
I mean, they are indirect ways of coming to an approximation of the truth.
What I really want (and my reason for posting this thread) is to know if
there is a direct (not directory) way to actually get the information, not
an approximation.
Isn't there some kind of "verbose mode" that makes VIM tell you every file
it sources (as it is sourcing it)? That would be closer to the truth, but
still not ideal.
Incidentally, I did put a sh.vim in my locatel syntax directory, and was
able to conclude, using inotifywait, that it was being sourced when a shell
script as loaded in vim. But that also is in the "approximation" category.
Hmm.., you were speaking about "an approximation of the truth".

Well, in physics generally, and specifically in software, everything is
sort of indirect (and even affected by user interaction). Even if Vim
would provide a "verbose debug" option that would not be a guaranteed.
So I'm not sure how much "direct" you intend, what level you dismiss,
and what you'd accept. - For me the built-in paths would be reliable
enough. Since no more certainty seems to be natively supported by Vim
you'd either have to resort to such "workarounds"; since you mentioned
'inotifywait' I'd add 'strace' to that and look for the 'open()' calls.
But maybe you prefer to inspect the Vim source code - but that appears
complicated -, or add a diagnostic message in a self-compiled version?
You see, it can be simple or arbitrary complex. - It depends on your
demands - can you be more specific here? - and your grade of interest
or paranoia. :-)

Janis
Eric Pozharski
2025-02-16 15:29:42 UTC
Permalink
*SKIP* [ 2 lines 3 levels deep]
Post by Kenny McCormack
Post by Kenny McCormack
I want to know if there is some variable that is set by the syntax
1) What version of sh.vim was used?
2) The full path of the used sh.vim file?
As I understand it -- no way. From what I see: vim can unload
*specific* functions, hooks, maps, or somethingidefinetelymissing. vim
doesn't[1] _unsource_ files, that's why it doesn't keep an index. That
being said...

*SKIP* [ 9 lines 2 levels deep]
Post by Kenny McCormack
But (IMNSHO, of course) those all fit in the "kludgey workarounds"
category. I mean, they are indirect ways of coming to an
approximation of the truth.
What I really want (and my reason for posting this thread) is to know
if there is a direct (not directory) way to actually get the
information, not an approximation.
May I suggest:

:h sourcep

This is as close to trace as you can get. Otherwise, per
janis_papanagnou+ng@, strace(1) is at your service. I can't comment on
autocmd though (never needed them).

*CUT* [ 7 lines 1 level deep]

[1] It's "doesn't" and not "can't" because ":h breaka" suggests there're
strings attached to (compiled?) code and lines of (sourced) files.
Say, <syntax/vim.vim>, <indent/vim.vim>, (sic)
<after/ftplugin/vim.vim>, and whatnot are all sourced files of
VimBasic (sorry for tangent). Which file would be picked for
":breaka vim 42 vim.vim" is a mistery. (I'm not sure this is
correct, examples are contradictory. See? VimBasic!)
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
DrunkenThon
2025-02-16 18:44:01 UTC
Permalink
Post by Kenny McCormack
Isn't there some kind of "verbose mode" that makes VIM tell you every file
it sources (as it is sourcing it)? That would be closer to the truth, but
still not ideal.
Hello, Kenny.
You can use --startuptime option to log vim startup process to a file.
For example:
$ vi --startuptime startup.log

The log file will contain lines like these:
...
19 004.001 001.654 001.654: sourcing /usr/share/vim/vim91/colors/lists/default.vim
20 004.276 002.182 000.528: sourcing /usr/share/vim/vim91/syntax/syncolor.vim
...


:help --startuptime
--startuptime {fname} *--startuptime*
During startup write timing messages to the file {fname}.
This can be used to find out where time is spent while loading
your .vimrc, plugins and opening the first file.
When {fname} already exists new messages are appended.
{only available when compiled with the |+startuptime|
feature}

There is also :scriptnames command.
:help :scriptnames

:scr[iptnames] List all sourced script names, in the order they were
first encountered. The number is used for the script
ID |<SID>|.
For a script that was used with `import autoload` but
was not actually sourced yet an "A" is shown after the
script ID.
For a script that was referred to by one name but
after resolving symbolic links got sourced with
another name the other script is after "->". E.g.
"20->22" means script 20 was sourced as script 22.
Also see `getscriptinfo()`.
{not available when compiled without the |+eval|
feature}

This is not exactly what you wanted, but at least you can see which files
were opened/processed at startup and in what order.
--
Best regards,
DrunkenThon.
Jens Schweikhardt
2025-02-16 22:27:34 UTC
Permalink
Kenny McCormack <***@shell.xmission.com> wrote
in <voreqk$akck$***@news.xmission.com>:
...
# Isn't there some kind of "verbose mode" that makes VIM tell you every file
# it sources (as it is sourcing it)? That would be closer to the truth, but
# still not ideal.

Does :scriptnames work for you?

Regards,

Jens
--
Jens Schweikhardt https://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
Kenny McCormack
2025-02-17 01:03:17 UTC
Permalink
Post by Jens Schweikhardt
...
# Isn't there some kind of "verbose mode" that makes VIM tell you every file
# it sources (as it is sourcing it)? That would be closer to the truth, but
# still not ideal.
Does :scriptnames work for you?
It does. But it still looks to me like an approximation.
I.e., still not ideal, but could be a possible workaround.

Note that my VIM sessions tend to be very long-lived and I end up with
dozens of files (i.e., buffers) loaded, so the output of :scriptnames is
quite long and lists the syntax files for lots of different languages.
--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/God
Loading...