I want to set up python linting in Vim using the ALE Vim-package. So far it works well in Atom using the Atom-Plugin, but in Vim it somehow is not working. I installed
pylint using pip3,
Vim 8.1 and
ALE using the Vundle Plugin-Manager.
In my .vimrc I set the
let g:ale_linters={
'python': ['pylint'],
.....+other languages....
}
option. Additionally I read the ALE docs and also tried setting the following:
let g:ale_python_executable='python3'
let g:ale_python_pylint_use_global=1
ALE gets installed correctly and works for Javascript, but for Python, there is just nothing happening.
In case of incorrect code (missing ")") like:
print("Hi"
nothing is marked as error.
It would be great if someone knows how to set this up and can provide some help! Thanks.
I was able to get this working, with the following steps:
install pylint
python3 -m pip install pylint
At least for my setup there was a warning:
Installing collected packages: pylint
WARNING: The scripts epylint, pylint, pyreverse and symilar are
installed in '/home/vagrant/.local/bin' which is not on PATH.
so then:
Add pylint to $PATH
export PATH="$HOME/.local/bin:$PATH"
(this can be added to ~/.profile to be configured persistently)
At you should be able to run pylint manually:
$ cat syntaxerr.py
print("hi
$ pylint syntaxerr.py
************* Module syntaxerr
syntaxerr.py:1:10: E0001: EOL while scanning string literal (, line 1) (syntax-error)
Install ALE
git clone https://github.com/dense-analysis/ale.git ~/.vim/pack/git-plugins/start/ale
At this point the syntax check is working as long as syntax is enabled:
$ cat .vimrc
syntax on
If you'd like to configure g:ale_linters, note that you must escape the newline to create a multi-line dictionary:
let g:ale_linters={
\ 'python': ['pylint'],
\}
Finally, to see how ALE is currently configured, you can always run the following command:
:ALEInfo
Related
I'm trying to use Anaconda python3.7 + vim 8.1 + jedi-vim on Rocks 7.0 (Manzanita) but I get an error saying that libpython3.7m.a cannot be loaded and I can't find a solution.
First things first. I have to compile vim by myself because the vim installed by default has only +python and I have to use python3.
I cloned the git and, following several other suggestions found online I configure vim with
./configure --enable-cscope --enable-multibyte --enable-python3interp=dynamic --with-features=huge --with-python-config-dir=/home/mazzi/miniconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu --with-tlib=ncurses --enable-fail-if-missing --prefix=/home/mazzi/.local
The prefix is due to the fact that I don't have root access and its output of can be found here. Please note that during the whole procedure I had to stay inside a conda environment, otherwise the configuration would fail saying that no python3 was found.
I then make, with this output, and make install with this other output.
I check vim version and everything seems ok.
Finally, I start vim normally (/home/mazzi/.local/bin is on the PATH, before the system paths, and the vim command points to ~/.local/bin/vim) and type :py3 pass but I get the following error:
E370: Could not load library libpython3.7m.a
E263: Sorry, this command is disabled, the Python library could not be loaded.
What can I do?
Additional info
Some of my sources:
https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source (without sudo and just to be clear I did not try YouCompleteMe due to some issues in the past that forced me to go to jedi-vim)
https://gist.github.com/hxhc/778d7c3a3ad491dedf3675a47275a979
Compiling vim 8.0 with Python 3 support resulting in SIGABRT
https://github.com/Valloric/YouCompleteMe/issues/2855#issuecomment-352181535
I'm brand new to Vim and just trying to get setup with vim-airline. I'm using Pathogen to install and have followed the instructions provided. vim-airline is successfully cloned in ~/.vim/bundle/vim-airline.
When I try to add the required let g:airline_powerline_fonts = 1 instruction to my ~/.vimrc file I get the following error from the console when trying to source it:
bad math expression: ':' without '?'
I'm running vim 8.0.134 on macOS Sierra with zsh and oh-my-zsh.
Any ideas why this error is being thrown and how I can get around it?
It looks like you tried to run $ source ~/.vimrc in the shell?
I think you want to reload your vimrc file from within vim:
:source ~/.vimrc
Maybe you confused this with running $ source ~/.zshrc from the shell.
In MacVim, I save following code as test.py
print "Hello world! python2"
, which is apparently wrong with python3, but
after I run :w to save the file, there is no error message for it,
Following is a part of ~/.vimrc, which is all about Syntastic:
" Syntastic
"" Recommended settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
"" Display checker-name for that error-message
let g:syntastic_aggregate_errors = 1
"" I use the brew to install flake8
let g:syntastic_python_checkers=['flake8', 'python3']
How to make Syntastic detect this type of error as I run test.py in Terminal:
NingGW:Desktop ninggw$ python3 test.py
File "test.py", line 1
print "Hello world! python2"
^
SyntaxError: Missing parentheses in call to 'print'
Following is what :SyntasticInfo said:
Syntastic version: 3.8.0-10 (Vim 800, Darwin, GUI)
Info for filetype: python
Global mode: active
Filetype python is active
The current file will be checked automatically
Available checkers: flake8 python
Currently enabled checker: flake8
Press ENTER or type command to continue
flake8 is a Python package. It uses Python's built-in facilities to parse code, so it accepts syntax for the Python version that it belongs to.
How to install it for your python3 installation depends on how that installation itself was installed - unless you're fine with using pip.
From the FAQ:
4.11. Q. How can I check scripts written for different versions of Python?
A. Install a Python version manager such as virtualenv or pyenv, activate the environment for the relevant version of Python, and install in it the checkers you want to use. Set g:syntastic_python_checkers accordingly in your vimrc, and run Vim from the virtual environment.
If you're starting Vim from a desktop manager rather than from a terminal you might need to write wrapper scripts around your checkers, to activate the virtual environment before running the actual checks. Then you'll need to point the relevant g:syntastic_python_<checker>_exec variables to the wrapper scripts.
orror in compile prses. how to solve it?
According to this blog post, you just have to compile the YouCompleteMe modules by running the install.sh script in the YCM install.
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
Once this completes you should be able to install the plugin (here's how to do it with Vundle). Once in Vim
:source ~/.vimrc
:PluginInstall
Apparently, when you run ./.install.sh --clang-completer it says that it is "out of date."
I ran python2 install.py and it worked for me. (I believe it was python2.)
Also, I had was using vim and neovim, and I decided to do ./install.sh --clang-completer inside my ~/.vim/bundle/Vundle.vim/ and at the same tim decided to do python2 install.py inside my ~/.configs/nvim/bundle/Vundle.vim/ and the python install installed faster and did the same thing.
The difference might be that you need to "compile vim with pdython support," but the simple fix for that is installing python-nvim (if using neovim), or - I think - vim just comes with python support. (? maybe.)
I encountered the same error message when trying out new neovim installation. In my case, it was because I was using vim-plugin and the plugins are installed in the ~/.vim/plugged instead of ~/.vim/bundle (this is the plugin folder for Vundle before I switched to vim-plug).
Thus, after scratching my head for few hours, turns out I have to run install.sh in the ~/.vim/plugged (not ~/.vim/bundle). I hope this will save someone's time.
For some reason macvim installed with brew doesn't have the python3 support. Here is how I installed it:
brew install macvim --with-cscope --with-python3
Whenever I run
:echo has('python3')
The result is 0, meaning there is no python3 support. Does anybody know what is the problem? Any help is appreciated.
Python 3 is deliberately disabled in the macvim recipe in homebrew.
You can, however, run "brew edit macvim" and fix up the recipe so it works.
I recommend the following actions (which have worked for me):
Use the current MacVim 7.4 snapshot 72 (update the url and sha1). brew still has older snapshot 71.
sha1 '3fb5b09d7496c8031a40e7a73374424ef6c81166'
Delete all the patches from the end of the recipe. The last line should be __END__. None of the patches are necessary anymore - ruby support was fixed upstream in snapshot 72.
depends_on :python3 => :recommended
in the install function, when its messing with the args, fixup the python section like so:
args << "--enable-python3interp=yes" if build.with? 'python3'
ENV.prepend 'LDFLAGS', "-L#{python3.libdir} -F#{python3.framework} -framework Ruby" if python3 && python3.brewed?
Ensure you use a homebrew python3 and if you have upgraded to Mavericks, re-brew absolutely everything - the stdc++ library has changed and you cannot mix old and new when linking.
brew it with:
$ brew install --HEAD macvim
$ mvim --version # to ensure it has all the right things linked
I've run through ultisnips and vinarise, both of which work and neither of which caused the window to mysteriously disappear as previously lamented in the recipe for macvim & python3. I've also done other basic testing with :py3 command. No issues seen (yet)