Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Checker for vim scripts #725

Closed
lpenz opened this issue Jul 15, 2013 · 15 comments
Closed

Checker for vim scripts #725

lpenz opened this issue Jul 15, 2013 · 15 comments

Comments

@lpenz
Copy link

lpenz commented Jul 15, 2013

Syntastic ironically has no verification for vim scripts/vim syntax.
It's beautiful when a tool is able to self-apply.

I was able to see if a plugin is valid by issuing:
vim -e --noplugin -u /dev/null -c 'source plugin/myplugin.vim | quit'
Unfortunatelly, that only produces an error code, no output indicating the problem.

@lcd047
Copy link
Collaborator

lcd047 commented Jul 15, 2013

Oh yes, many people would like to have some kind of syntax checker / formatter / pretty printer for VimL, even without syntastic. Sadly, and to the best of my knowledge, nobody has written such a tool yet. Looking at Vim sources, I'd say writing such a tool would be highly nontrivial.

@dbakker
Copy link

dbakker commented Jul 21, 2013

I just finished writing a Vim Linting utility if you're interested. :)

@lcd047
Copy link
Collaborator

lcd047 commented Jul 21, 2013

Excellent! But, why not make it a standalone distribution? Syntastic internals may change, so why keep your vimlint tied to it.

@dbakker
Copy link

dbakker commented Jul 21, 2013

@lcd047 My reasoning is that having to install vimlint using an external utility such as pip is harder than just adding another bundle for most people. But I suppose it would make sense to move the content of the syntax_checkers/ directory to syntastic itself before its internals change.

@lcd047
Copy link
Collaborator

lcd047 commented Jul 21, 2013

@dbakker Well, vimlint has two unrelated components: a python script, and a syntax checker for syntastic. The syntax checker belongs in syntastic, but the python script is just a normal, autonomous script, it doesn't need syntastic, vundle, or Vim to run. Making it a first-class, standalone script would also simplify the corresponding syntastic checker. :)

@bukzor
Copy link
Contributor

bukzor commented Jan 23, 2014

There is a vim syntax checker here, in case anyone has the motivation to try it out:
https://github.com/syngan/vim-vimlint/

@lcd047
Copy link
Collaborator

lcd047 commented Jan 24, 2014

@bukzor Added in 87e237a. It's actually a frontend to Yukihiro Nakadaira's vimlparser, which does most of the heavy lifting (you need to have both installed). Vimlparser also has Python and JavaScript components, but they are not used by syntastic. You don't need to have Python installed to run the checker, which is nice.

On a side note: there is a naming conflict with the checker mentioned above written by @dbakker. Sorry about that, the name vimlint is more appropriate for the new checker, since the project by @dbakker is actually called vim-lint. A possible solution would be to rename the checker by @dbakker as vim_lint.

@bukzor
Copy link
Contributor

bukzor commented Jan 24, 2014

@lcd047 Nice! Kudos!

For maximum meta-ness I used syntastic+vimlint to lint the syntastic vimlint file.

syntax_checkers/vim/vimlint.vim|63 col 27 warning| [EVL103] unused argument `a:filename`                      

I've no clue exactly how spurious that warning is, but it does seem correct.

Is this issue closed then?

@lcd047
Copy link
Collaborator

lcd047 commented Jan 24, 2014

Well, I don't think it was ever meant as a bug report. :) VimL is a pain in the rear of a language, and it's good to have a high quality checker for it. And vimlparser is an excellent one, it actually produces ASTs, and there are utilities that can compile the code to Python, and to JavaScript. Now if we could also have a style checker, to look for things like indentation and consistent spelling of keywords, it would be even nicer. :)

@lcd047 lcd047 closed this as completed Apr 8, 2014
@dbarnett
Copy link
Contributor

I was excited to see there's a linter for vimscript, but I can't for the life of me figure out how to use it.

https://github.com/scrooloose/syntastic/blob/ce89396808/syntax_checkers/vim/vimlint.vim contains no relevant comments. Clearly it depends on a plugin that defines autoload/vimlparser.vim and autoload/vimlint.vim, but there are no hints about where to find said plugin, and there are quite a few projects on github called "vimlint".

@myint
Copy link
Contributor

myint commented Nov 21, 2014

@dbarnett, is this what you were looking for?

@dbarnett
Copy link
Contributor

Yeah, eventually found that. Still think the file should have at least a brief comment and maybe a link or two, considering most checkers have something, it's a rare checker that requires two separate plugins, and one of them has a "TODO: write something" instead of a README.

@lcd047
Copy link
Collaborator

lcd047 commented Nov 21, 2014

@dbarnett: Is there any particular reason why you expect to find user-level docs in the source files rather than where the docs are normally supposed to be? For syntastic, the docs are the manual, and the wiki.

@dbarnett
Copy link
Contributor

Yeah, a few reasons:

  • Some checkers do. E.g., the cpplint checker has "For details about cpplint, see https://code.google.com/p/google-styleguide/".
  • I didn't know about the wiki. I knew about the manual and comments in some checkers.
  • It's quicker. There's a complex directory structure of checkers that's easy to browse (and guaranteed not to be out-of-date with itself), and cross-referencing with a wiki just to figure out "what is this thing?" is an extra step.

Now I've bootstrapped myself, so whatever. But the angle I came at it from I ended up trying one after another "vimlint" plugin from github that claimed to integrate with syntastic, and not being able to get any of them to work.

@lcd047
Copy link
Collaborator

lcd047 commented Nov 21, 2014

Some checkers do. E.g., the cpplint checker has "For details about cpplint, see https://code.google.com/p/google-styleguide/".

Ok, they no longer do. The relevant comments have been moved to the wiki more than an year ago; this patch just removes them from the sources. Commit 650c736.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants