Repository navigation
Conversation
h-east
commented
Sep 9, 2026
c211226 to
e47b269
Compare
37608c2 to
1c38d53
Compare
|
thanks, but is this really useful? |
|
I'm currently building a Vim(9) script language server in Vim9 script, but I don't think it makes sense to parse everything from scratch in a overly rigid way. Since it runs inside Vim anyway, I think it's better to just query Vim directly. |
While being a nice achievement from a technical point of view, is Vim9 really the best languages to parse vimscript and to implement an LSP in? |
Problem: There is no way to have Vim read a script and compile its
:def functions without running it, so that a script can be
checked for errors without its side effects.
Solution: Add "++dryrun" to ":source": only the definitions in the
script are executed, a declared variable gets its type but
not its value, everything else is skipped, then the functions
are compiled and the errors reported. An error in a
definition does not stop the reading. The condition of an
":if", ":elseif", ":while" or ":for" and an import name with
a function call are not evaluated, and no SourceCmd,
SourcePre or SourcePost autocommand is triggered.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Problem: With ":source ++dryrun" compiling a :def function stops at
the first error, the errors in the rest of the function are
only reported after that one is fixed.
Solution: Go on with the next line after an error, the function is
still not compiled. A condition that fails to compile is
replaced by a placeholder and a variable with an invalid type
is declared as "any", so that no further errors follow from
the first one.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Problem: A class or enum in an autoload script cannot be defined again,
objects made from it would refer to the old definition. A
dry run makes no object, but reading the script a second time
with ":source ++dryrun" fails with E1041 all the same, and
what follows in the class is read as if outside of it.
Solution: In a dry run, and for a class a dry run defined, delete the
class with the other exported variables when the script is
read again.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
1c38d53 to
dcc0022
Compare
|
@jvoisin The language server is a separate project, and the language it For example, clangd does not parse C or C++ on its own, it uses the @chrisbra That is what makes it useful beyond my language server. |
|
I haven't looked at the details of this PR yet but it seems like a good idea to me. Creating tooling for Vim script is very difficult without this capability. I'm working on a builtin to properly detect Vim9 source files, leveraging skip mode, and similarly concluded that doing this with an external parser is impractical at best. @h-east on a related note, I have a patch somewhere to fix skipping of text-input commands (:append etc). I'll dig it up in the next couple of days and post a PR. |
|
@dkearns Thanks. Your patch for the text-input commands matters here |
|
Okay then, find. Thanks all |