Per project flake8 configuration - vim

I'm using flake8 through syntastic in vim and I want a configuration file per project.
On the syntastic documentation it states that:
Depending on the checker, the filename of the corresponding
configuration file can be specified by setting either
g:syntastic_<filetype>_checker_file or
g:syntastic_<checker>_config_file. See the checker's documentation in
the wiki for the exact name.
The flake8 documentation says that .flake8 is a valid configuration file name. So I tried to place a valid flake8-configuration file called .flake8 in the root folder of my project. No luck.
I've also tried setting g:syntastic_flake8_config_file and g:syntastic_python_checker_file to .flake8 in my ~/.vimrc, still nothing.
What am I missing?

Just adding a .flake8 file to my working directory didn't work for me either.
But you can pass commandline options to syntastic checkers by setting the following option in your .vimrc:
let g:syntastic_LANGUAGE_CHECKER_args = 'ARGUMENT'
Flake8 accepts a --config=PATH flag to specify a config file, so in your case this would be:
let g:syntastic_python_flake8_args = '--config=PATH_TO_FLAKE8_CONFIG_FILE'

Related

vim + ESLint: override the default .eslint file with a project-specific one

My Settings
I am using ESLint with vim. ESLint executable and options files (.eslintrc.js) are configured within ~/.vimrc:
let g:ale_javascript_eslint_executable="/usr/local/bin/eslint"
let g:ale_javascript_eslint_options="-c /Users/adam/team-standard/.eslintrc.js"
...
let g:ale_linters = {
\ 'javascript': ['eslint'],
\}
The team-default/.eslintrc.js is our team's standard coding style, based on a eslint-config-airbnb. It is kept in a shared github repository.
My Problem
Many GitHub projects have their own .eslintrc.js files. When I open a project with an .eslintrc.js file, I want the files within that project to be checked with the project's file, not with the default file.
In another words, I want vim to look for an .eslintrc.js file in the current file's directory hierarchy, take the one closest to the file, and revert to the default if none is found.
What Have I Tried
STFW
Looked at public .vimrc files with .eslintrc.js at github (example)
My Question
How can I configure vim, ale and ESLint to look for an .eslintrc.js file up the current js file directory hierarchy, and revert to a predefined file if none is found?
Following "Is there a way to specify a default eslint configuration file when using ALE plugin of Vim?"
The easy solution is placing the default configuration file at ~, either directly or by sym-linking, and removing the g:ale_javascript_eslint_options line from the configuration.
This way, ESLint will use the first .eslintrc.js file it finds down the directory hierarchy.

:vsplit autocomplete not working with /django/ directory in VIM

Normally if I type :vsplit /path/to/some/directoryTab, the available directories will autocomplete.
After doing a reinstall of VIM, there is one directory that now will not allow autocomplete, and I can't figure out why. The directory is ~/Sites/django/. Once I type ~/Sites/, Tab will show me drupal and apps directories, but will not show django. If my working directory is inside this django directory, :vsplit won't let me autocomplete either.
I did a ls -haltr on the directory and it looks the same as the others inside the ~/Sites/ directory.
Also, when I use the CtrlP plugin inside this directory, I get the error "==NO ENTRIES==". In other places, CtrlP works fine.
Why might this be happening and how can I fix it?
The directory is getting ignored because it has /django/ in it's path...which was set by my Python linter. The linter causes Vim to ignore /*django*/. To see this, use set wildignore to see what directories are getting ignored.
I just changed the directory to /dj/ and it works fine.
I could have also changed the wildignore directories by using set wig-=my_directory command.

How to make vim javacomplete to work?

I confess that I am a beginner in using vim and this question might be as dumb as it sounds. These are what I've done so far :
I downloaded the latest zip file format of the script from here.
I unzipped it to the .vim directory that placed the files javacomplete.vim, java_parser.vim and Reflection.java inside the ~/.vim/autoload directory by default.
The following option is set (much better, I've added it to my .vimrc file):
:setlocal omnifunc=javacomplete#Complete
java and javac are set properly in the system path variable (they work from the command line).
Assuming that that's all I need to do, pressing <C-x><C-o> (in the insert mode) doesn't do any auto-completion inside a .java file.
What am I doing wrong here?
If you're using Vim 7.2, there's a few issues related to how the plugin locates the java-based Reflection helper.
If you have .class listed in your wildignore or suffixes, then it can't actually locate the class file to execute.
I have a clone that I modified to get around that on github : https://github.com/cilquirm/javacomplete
Give that a go and see if it works for you

How to resolve these Vimball problems when I install plugins?

I don't like Vimball files in Vim but more and more plugins use Vimball to install themselves.
A month ago I installed a 64 bits OS and moved my vimfiles directory to c:\users\"my-name"
No problem. Everything works fine.
Today I wanted update a plugin (which is now in Vimball).
After sourcing the plugin (:so %)
I received a lot of errors:
Error detected while processing function vimball#Vimvall..vimball#VimballHome:
E739: Cannot create directory C:/Progra~1/Vim/vimfiles
Error detected while processing function vimball# Vimball..<SNR>119_ChgDir:
E344: Can't find directory "C:\Progra~1\Vim\vimfiles in cdpath
E472: Command failed
...and so a whole page more of these kind of errors.
What's happening and how can I resolve it?
Vimballs are extracted into the first existing directory on 'runtimepath'; based on your output, is looks like Vim doesn't recognize the location where you moved your vimfiles to, and instead defaults to the system-wide C:/Progra~1/Vim/vimfiles location, which probably is protected by Windows permissions, thereby causing the errors.
Check the output of :set runtimepath?; the first component should be your C:\Users\my-name\vimfiles; if it isn't, you need to make Vim include it, either via external means (e.g. setting the HOME environment variable), or directly in your ~/.vimrc with :set runtimepath=.... See :help runtimepath for details.
Also, check for g:vimball_home; this Vimball configuration overrides the default logic.
As a workaround (not a solution), you can pass a custom install directory to the :UseVimball command.

Pathogen (Vim) non-default bundle directory location

I like the idea of keeping all my Vim plugins and my vimrc in Dropbox. I also love pathogen. Looking at the pathogen.vim file, it seems I can provide the pathogen#infect() function with an alternative location for my bundle folder. But this just doesn't work. I've searched high and low for a solution, but nothing I do will allow me to change the 'working directory', as it were, for pathogen to '~/Dropbox/Vim/GlobalRuntimePath/bundle'. I've tried sourcing pathogen.vim directly in my vimrc, to no avail. Pathogen doesn't complain, just my vimrc when it tries to call upon functions from plugins that no longer exists when I remove their local copies.
Am I asking the wrong questions?
There is a way for adding custom bundle directories provided in
Pathogen. First, one should append paths to the directories containing
additional bundles to the runtimepath option:
:set runtimepath+=~/Dropbox/Vim/GlobalRuntimePath
Then, when loading Pathogen in .vimrc file, one should specify the
name of all bundle directories (they must have the same one) as the
argument to the runtime_append_all_bundles call:
:call pathogen#runtime_append_all_bundles('bundle')
If bundle directories are named by default, bundle, the argument can
be omitted.

Resources