-3

I want to create a new vim syntax checker for a new programming language that is not used widely, first i tried to read the code of the follwing plugins neomake, syntastic , and Ale in order to understand how i can build my own syntax checker plugin but i could not really get it so i just want know what is the best and easy way to create syntax checker plugin for vim

8
  • You do not want to implement a plugin such as Syntastic. These plugins typically have no knowledge of programming languages: they only provide infrastructure for plugging a language-specific “checker” into a Vim buffer, in function of the detected file type. A checker is what you want to implement: it is an external program which parses your file and emits error messages, much like a compiler. You should look at the documentation of e.g. Syntastic (:h syntastic.txt) rather than at its implementation. For inspiration from existing checkers, look at e.g. lacheck (LaTeX), pylint (Python)… Commented Oct 7, 2021 at 19:07
  • so this language has its own compiler , can i use this compiler to builld the plugin ?? Commented Oct 7, 2021 at 19:13
  • Possibly. Beware though that the checker would be called very frequently, e.g. each time you save your buffer, so you’d rather avoid actually compiling (too heavy). I don’t know the specific language and compiler you are interested in, perhaps it has an option to stop compiling after some parsing/typing phase? Commented Oct 7, 2021 at 19:20
  • You are putting the cart before the horse. 1. Make your compiler or whatever do the syntax checking on its own. 2. Make it output something reasonable, like filename:line:column: message. 3. Read :help write-compiler-plugin. In short: deal with the syntax checking first and then worry about Vim integration. Commented Oct 7, 2021 at 19:21
  • @romainl my language already has a compiler , so i need to kknow how to integrate this with a vim plugin , some developers told me that if my language has a linter it is going to be easier to integrate with vim as you see here link Commented Oct 7, 2021 at 20:40

1 Answer 1

1

I am not sure what you are asking for, here.

At a very high level, linting works like this:

  • you pass a file to some program or some code via stdin,
  • the program analyses the code in the file,
  • the program outputs nothing if the code is correct or a list of errors if the code is incorrect.

For example, assuming our linter is called mylinter:

$ mylinter file_with_correct_code.foo
<nothing>

$ mylinter file_with_erroneous_code.foo
/path/to/file_with_erroneous_code.foo:12:23: missing semicolon

No one knows anything about your language or compiler so you are the only one who can tell if and how your compiler can be used as described above, which is a prerequisite for Vim integration.

How to integrate it in Vim is the next step, and it is entirely dependent on those informations, which you failed to provide.

So…

  1. Figure out if/how your compiler can be used that way.

    We can't do that for you.

  2. Read the help section I already pointed to in the comments: :help write-compiler-plugin to know how to integrate your linter in Vim the vanilla way or the relevant sections of the plugins you want to integrate with.

    We may be able to help with specific issues.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.