Git Product home page Git Product logo

validator.vim's Introduction

Validator

Build Status

Syntax check framework for vim which checks syntax on the fly asynchronously.

Requirements

You should have a relatively new version of vim which supports such features: job, timers and lambda.

Your vim should be compiled with python or python3.

Validator relies on external syntax checkers, so you need to install the checkers fit for the files you are editting.

Builtin Checkers

  • c/c++, clang-tidy
  • python, flake8
  • cython, cython
  • css, csslint
  • javascript, jshint, eslint, jscs
  • ruby, mri, rubocop
  • json, jsonlint
  • lua, luac, luacheck
  • sh, sh, shellcheck
  • rst, rst2pseudoxml
  • vim, vint, vimlparser
  • go, gofmt, golint, gometalinter
  • rust, cargo check (not instant)

Configuration

Select checkers for a file type:

let g:validator_{filetype}_checkers = ['<checker_name>']

" for example, choose eslint to check javascript:
let g:validator_javascript_checkers = ['eslint']

To customize error message:

let g:validator_error_msg_format = "[ ● %d/%d issues ]"

To auto open quickfix window:

let g:validator_auto_open_quickfix = 1

To handle file type alias:

let g:validator_filetype_map = {'<alias>': '<filetype_supported>'}

" for example
let g:validator_filetype_map = {"python.django": "python"}

Ignore file types:

let g:validator_ignore = ['<filetype>']

To customize the signs colors, you can use the following groups:

" For syntax errors & warnings
ValidatorErrorSign
ValidatorWarningSign

" For style errors & warnings
" (By default, use the same colors as the 2 groups above)
ValidatorStyleErrorSign
ValidatorStyleWarningSign

To show permanently the sign column and prevent annonying behavior when the sign column appear and then it disappears.

sign

let g:validator_permament_sign = 1

To specify the checker executable path or pass checker arguments manually:

" If not specified `<args_name>` is `<filetype>_<checker>`.
let g:validator_<args_name>_args = '<args>'
" If not specified `<binary_name>` is `<filetype>_<checker>`.
let g:validator_<binary_name>_binary = '/path/to/executable'

" For c/c++
let g:validator_clang_tidy_binary = '/path/to/executable'

" For flake8
let g:validator_python_flake8_args = '--max-line-length=120'
let g:validator_python_flake8_binary = '/Users/maralla/.dotfiles/virtualenvs/py27/bin/flake8'

" For rubocop
let g:validator_ruby_rubocop_args = '-f s -c .rubocop.yml'
let g:validator_ruby_rubocop_binary = '/Users/maralla/.rvm/gems/ruby-2.3.0/bin/rubocop'

Install

$ pack install maralla/validator.vim
Plug 'maralla/validator.vim'

Usage

Validator.vim automatically checks syntax in the background when file content changes, so no need to do any trigger manually. If you do want to do a check manually use this command ValidatorCheck. This command is especially useful when you set the file type manually.

Debugging

Enable the debugging with:

let g:validator_debug = 1

The output is logged in plugin installation directory:

e.g. /path/to/validator.vim/pythonx/validator.log

validator.vim's People

Contributors

francescarpi avatar junkblocker avatar kabbamine avatar laino avatar lukkor avatar maralla avatar mcclunatic avatar victormours avatar warbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

validator.vim's Issues

Help to install rust checker

I'm trying to learn Rust but have no idea how to install its checkers.
From validator's readme rst, rst2pseudoxml but cargo search rst2pseudoxml gave me no result

Can someone help me on this?

Can't use validator.vim even with python3 vim support

I have python3 support in my vim instance yet your plugin says it doesn't see below

~ vim --version | grep -i python
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3       +wildignore
Linking: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm      
➜  ~ vim                           
Validator requires vim compiled with python
Press ENTER or type command to continue

Any ideas

validator_filetype_map not work for me

Hi again,

I have this setting:

let g:validator_filetype_map = {"python.django": "python", "javascript.jsx": "javascript"}
let g:validator_javascript_checkers = ['eslint']
let g:validator_python_checkers = ['flake8']
let g:validator_error_msg_format = "[ ● %d/%d issues ]"

But aliases not work and I not know why.

I'm using python.django filetype. This is an example:

#!/usr/bin/env python
# encoding: utf-8
# vim:ft=python.django:
# --------------------------------------------------------------------------

class Example(object):
    pass

Can you reproduce it?
Thx

Lessons Learned from Syntastic

Hey there, @maralla thanks for your work on this.
I just read this thread: vim-syntastic/syntastic#699 and it is VERY INFORMATIVE on the limitations vim has and how far can Syntastic go. He mentions the flaws that they only found out later and etc and still many plugin developers commit the same errors.

So I thought you would like to know those (in case you don't already)...

Cheers

Add support for go / gometalinter

I'm not sure if you intend this project to be strictly a "linter" or a full blown syntax checker, but implementing alecthomas/gometalinter would be ideal for Golang. I see you have implemented Go in completor.vim so maybe it's in the roadmap?

Always reserve place for a sign

Am I getting right that let g:validator_permament_sign = 1 should always reserve place for the error sign at the left? In my case, it appears when there is any issue and then it disappears changing the main window width. Is there any way to prevent this behavior?

The quickfix window does not close with the window that it was opened for

The quickfix window that I get with let g:validator_auto_open_quickfix = 1 when opening a file does not close when I close that file, resulting in me having to close that, too. Seems unnecessary. Never had to do that with syntastic.

Is this project still alive?
Or is w0rp/ale the one to use now?

Validator cover ctrlp's search text input

First. thank you for your contribute. this plugin is awesome. it make me migrate vim8 from neovim easelly :)

I found weird action for using ctrlp plugin's search features. as you seen.

validator

I can send you my .vimrc file if you want.

Checkers Arguments Support

Syntastic supports customization of checkers by passing extra args to them. For example I used to have this setting:

let g:syntastic_python_flake8_args="--max-line-length=120"

This disables pep8 warnings about exceeding the default max line length (80) and trigger on 120 instead.

I imagine this would be useful in other scenarios as well.

g:validator_option overridden

I have the following setting in my .vimrc

let g:validator_option = {
    \   'args': {
    \       'python': {'flake8': '--max-line-length=120'}
    \   }
    \ }

But when I open a python file, the value of g:validator_option is {'args': {'python': {}}, 'exe': {'python': {}}}.

I had to change the setting to:

autocmd BufRead,BufNewFile *.py let g:validator_option = {
    \   'args': {
    \       'python': {'flake8': '--max-line-length=120'}
    \   }
    \ }

For it to take effect in python files.

This either needs to be cleared up in the documentation or a more friendly setting implemented, maybe something like:

let g:validator_option = {
    \   'python': {
    \       'exec': {
    \           'flake8': '/path/to/flake8'
    \       },
    \       'args': {
    \           'flake8': '--max-line-length=120'
    \       },
    \   }
    \ }

Attempt to support pylint

Hi, I made a quick attempt to add support for pylint as an additional python linter and found an issue with how validator.vim works and how pylint expects to be executed.

The problem boils down to the use of the temporary file which is passed to the linter, pylint expects to be executed with the path to a python package, or a module within a package hierarchy. This makes pylint fall flat on on its face.

I understand it is necessary to use a temporary file for on-the-fly checking, so my first thought was to send the file content to pylint on stdin but this sadly is not a supported mechanism.

My second thought was to tell pylint the working directory it should use when linting the python module, yet again my hopes were dashed.

The leaves one possible option that I can see, other than abandoning supporting pylint, which is to use a temporary file in the same directory as the file being edited instead of in /var. This doesn't seem like a nice solution to me but I've become quite reliant on the diagnostics of pylint despite its annoyances but have grown tired of syntastic's lack of support for vim jobs.

Since the temporary file is created based on the name returned from tempname() it seems like this approach might be a bogus.

A penny for your thoughts.

Doesn't work for me, I don't know how to debug it

Hi!

I'm using Vim8 on Windows, the plugin installed fine (using Vundle) and :scriptnames shows the autoload script for it, I added this to my .vimrc:

let g:validator_python_checkers = ['flake8']

(flake8 is in the path and working).

But it doesnt do anything, calling:

:call validator#enable()

No error, no output, no checking.

:call validator#get_status_string()

No error, no string.

There is a validator.log file in the plugin directory, but it is empty.

Make location of validator.log depend on a variable from vimrc

Hey,

I'm running into this issue that the location of validator.log is more or less hardcoded

It would be kind of nice if that path could be defined by a variable in vimrc.

In my case I have plugins installed and managed globally. Users can't write into this directory, only read it. Therefore, when validator starts, the users get a permission error. To avoid that I could instead set this path in the global vimrc to a place in the respective user's home, for instance ~/.vim/validator.log

Significant VimEnter loadtime

I have noticed loadtime of this plugin about 100ms, from 30 to 115->120. Is that normal?
030.000: VimEnter autocommands
117.000: VimEnter autocommands

slow vim leave

with a large js file this autocmd will take a while.thanks

Prevent the "Press ENTER" prompt with quickfix window disabled on long messages

It appears that when I have the quickfix window disabled, going over a line with a warning/error shows the "Press ENTER or type command to continue" whenever I am on this line. This makes interacting with that line in normal/visual modes very difficult, as any action that would put me on that line would result in the "Press ENTER" prompt appearing, which is pretty annoying.

Confusing mark for 'eol' options

Hi

In default vim configuration, binary option is off.

Is that mean, append newline character automatically at end of file when saving current buffer.

So i ran eslint -c .eslintrc myfile.js there is no 'eol-last' errors.

But, validator plugin in vim warning no end of new line at file because no 'eol' character while editing file.

So i switch vim editing mode to not prepend newline when saving current buffer. (:set binary) but this seems to weird.

I think that is not problem.. but need some way to avoid this situation.

Only work with flake8 on python file

Somehow it only works with fake8 even I installed other checkers via pip (python file).
let g:validator_python_checkers = ['pylint', 'pyflakes', 'pycodestyle', 'pydocstyle']

Use local binary of ESLint instead of global?

Currently having issues with the plugin because it's trying to use the global eslint instead of the local project one:

2018-12-13 12:31:54,073 [INFO] parse input = [<lints.javascript.eslint.EsLint object at 0x7f1c9bf63908>, ["Error: Cannot find module 'vue-eslint-parser'", '    at ModuleResolver.resolve (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/util/module-resolver.js:72:19)', '    at loadFromDisk (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config/config-file.js:514:42)', '    at Object.load (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config/config-file.js:564:20)', '    at Config.getLocalConfigHierarchy (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:240:44)', '    at Config.getConfigHierarchy (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:192:43)', '    at Config.getConfigVector (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:299:21)', '    at Config.getConfig (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:342:29)', '    at processText (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/cli-engine.js:180:33)', '    at CLIEngine.executeOnText (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/cli-engine.js:686:40)', '    at Object.execute (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/cli.js:197:46)'], 1]
2018-12-13 12:31:54,073 [INFO] parse input = [<lints.javascript.eslint.EsLint object at 0x7f1c9bf63908>, ["Error: Cannot find module 'vue-eslint-parser'", '    at ModuleResolver.resolve (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/util/module-resolver.js:72:19)', '    at loadFromDisk (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config/config-file.js:514:42)', '    at Object.load (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config/config-file.js:564:20)', '    at Config.getLocalConfigHierarchy (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:240:44)', '    at Config.getConfigHierarchy (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:192:43)', '    at Config.getConfigVector (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:299:21)', '    at Config.getConfig (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/config.js:342:29)', '    at processText (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/cli-engine.js:180:33)', '    at CLIEngine.executeOnText (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/cli-engine.js:686:40)', '    at Object.execute (/home/luke/.nvm/versions/node/v9.11.2/lib/node_modules/eslint/lib/cli.js:197:46)'], 1]
2018-12-13 12:31:54,073 [INFO] parsed lists = []
2018-12-13 12:31:54,073 [INFO] parsed lists = []

How do I ensure the plugin uses the local ESLint binary and config if it exists?

Multiple quickfix buffers.

I have the option let g:validator_auto_open_quickfix = 1 set in my .vimrc. I also use CtrlP (not sure if it's relevant). If I open multiple buffers i get multiple quickfix windows. Sometimes when CtrlP does search or autocomplete - more quickfix buffers appear. Is there a way to aggregate the errors into a single quickfix buffer or at least switch quickfix results when I do :bufnext and :bufprev?

Validator.vim do not work

comes with my debug.log

2018-03-22 01:11:17,243 [WARNING] parse input = [<lints.python.pyflakes.PyFlakes object at 0x10e0dd780>, ['"pycodestyle" requested unknown parameters causing \'FileProcessor\' object has no attribute \'previous_unindented_logical_line\''], 4]
2018-03-22 01:11:17,245 [WARNING] parsed lists = []

puzzled me a lot : (

Seg fault when saving files using :wq

Using :wq to save a file that is being validated causes a segfault:

Vim: Caught deadly signal SEGV
Vim: Finished.

Segmentation fault (core dumped)

The file does appear to have been saved. It doesn't seem to make a difference if there are any changes to the buffer before the save or whether the file exists or not. Saving an empty buffer does not cause it.
Using :x or :w then :q doesn't cause the same problem.

I am using vim 8.0 (included patches: 1-46) (I can add the full vim --version if it'd help) on Redhat 6 with python 3.5.
I have removed everything from .vimrc except

call plug#start()
Plug 'maralla/validator.vim'
call plug#end()

It seems to only be a problem if the filetype is one that is being checked. :set ft= before saving prevents the segfault.

To reproduce

$: vi /tmp/foo.py
#type anything into buffer (valid python or not) 
:wq<CR>

I have had the same problem for python and sh files but not lua. I do not have any other checkers installed to test.

Cannot turn off clang-tidy

clang-tidy seems to be enabled by default. I tried turning it off by putting the following in my .vimrc:

let g:syntastic_c_checkers=[]
let g:syntastic_cpp_checkers=[]

Even after restarting vim, the clang-tidy checker seems to be active.

Invalid argument when used with rust

This could be a configuration issue rather than a bug but when I open or save a rust file I get an error message saying

Error detected while processing function <lambda>3[1]..<SNR>75_do_check[10]..<SNR>75_check:
line 45:
E475: Invalid argument: cwd

I don't know enough vimscript to start seeing where this is going wrong but let me know if you need any more information.

I have tried setting g:validator_debug = 1 but nothing is written to the log.

Removing this plugin prevents the error appearing so I'm fairly confident it's from this plugin although I'm happy to believe it's a different one interfering with it somehow.

Dependence Validator

Hello,

I try install Validator in NeoVim but I have this error:
Validator requires vim compiled with python or python3 and has features job, timers and lambda

I have Python and Python3 but What is it: job timers and lambda ? and how add this dependence ?

Thanks

Is it possible to run validations in a remote environment?

I've used Syntastic for a while and just stumbled across validator when browsing this issue vim-syntastic/syntastic#699

The conclusion there seemed to be that it's not feasible to allow syntastic to run the validations in a remote environment, at least partly because it sounds like syntastic checks can only run synchronously.

I noticed that validator mentions being an asynchronous validation checker, so I'm curious, is it possible to run validations in a remote environment? For example, ssh to a build server or docker exec into a running container

For some kinds of checkers (particularly ones that are more like compilers such as validating flow types in js) setting up the environment can be non-trivial. So it would be really useful to be able to run the checker in my already-configured app or build environment rather than having to separately configure a part of the build environment on OSX where vim is running.

No linting when setting manually the filetype

  • Create a new file
  • Set it to python
  • Put content

No linting.

There are many ways to improve this behavior, either by providing a command for manual invocation of Validator or by using the event FileType.

Filetype python.django

Hi,

I'm working with python.django filetype.

How can I configure the checker? Because I can not do this...

let g:validator_python.django_checkers = ['flake8']

Thanks!

How to use validator properly (python)

gvimvim 8.1 1-26/windows10

flake8 installed via: pip install flake8

vimrc:

let g:validator_highlight_message = 1
let g:validator_auto_open_quickfix = 1
let g:validator_error_msg_format = "[ ● %d/%d issues ]"
let g:validator_debug = 1

When I tried to issue :ValidatorCheck against python file buffer, vim echo this error message:
E119: Not enough arguments for function <SN>58_check

I tried to make some errors and use flake8 directly from cmd, this is what I got:

__init__.py:65:1: E305 expected 2 blank lines after class or function definition, found 1
__init__.py:65:1: F821 undefined name 'classd'
__init__.py:66:1: E302 expected 2 blank lines, found 0

some color changes:

  hi ValidatorErrorSign guifg=#F98365
  hi ValidatorWarningSign guifg=#546E7A

:copen gives empty output.
validator.log is empty

Rubocop support improvements

Hi,

Thanks for merging the PR on basic rubocop support.
Here is a list of improvements I'm working on:

  • Fix regex to take into account following case: E:496: 1: unexpected token kEND
  • Add option to rubocop's args to use .rubocop.yml file
  • Add support for rubocop error class

Feel free to add improvements or work on the list.
I have a last question about linters, is it planned to move linters into dedicated repos?

Thanks for your work, validator.vim is awesome!

Upon expanding UltiSnips snippet, selection lost

Steps to reproduce:

  1. Have UltiSnips and vaidator.vim installed
  2. vim _.py
  3. Start to type in class and expand the snippet
  4. Notice that the selection is lost, which is inconsistent with what UltiSnips normally does

How to set custom compile-commands.json for clang-tidy

Hi,

How do I set custom compile-commands.json for clang-tidy? I need this to use validator properly with a meson build.

I tried to put "-p ./build" into .clang-tidy-config to set the meson build directory, but it didn't seem to work. Any ideas what I might be doing wrong?

Validator is using wrong .eslintrc

Validator appears to be using the ~/.eslintrc instead of the .eslintrc in my project directory. The vim working directory is set to my project root directory.

Shellcheck versions compatibility

A lot of Linux distributions (Most of LTS) ships with an old version of shellcheck (< 0.4), Ubuntu 16 for example uses the 0.3.7 version where the flag -x does not exist.

It will be great to verify the shellcheck's version before adding the flags.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.