liuchengxu / space-vim

:four_leaf_clover: Lean & mean spacemacs-ish Vim distribution
https://liuchengxu.github.io/space-vim/
MIT License
2.85k stars 255 forks source link

Python linters are not working? #197

Closed koustuvsinha closed 7 years ago

koustuvsinha commented 7 years ago

Environment

Problem Description

I am looking into how to use ALE linting in python but it appears not to lint anything as yet. After installing ALE through .spacevim running :ALEInfo I get this:

 Current Filetype: python
Available Linters: ['flake8', 'mypy', 'pylint']
  Enabled Linters: ['flake8']
 Linter Variables:
let g:ale_python_flake8_executable = 'flake8'
let g:ale_python_flake8_options = ''
let g:ale_python_flake8_use_global = 0
 Global Variables:
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = '✹ Error'
let g:ale_echo_msg_format = '[#%linter%#] %s [%severity%]'
let g:ale_echo_msg_warning_str = '⚠ Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'markdown': ['mdl'], 'sh': ['shellcheck'], 'html': ['tidy'], 'javascript': ['eslint'], 'python': ['flake8']}
let g:ale_open_list = 0
let g:ale_set_highlights = 0
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '•'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '•'
let g:ale_statusline_format = ['E•%d', 'W•%d', 'OK']
let g:ale_warn_about_trailing_whitespace = 1

Thanks!

liuchengxu commented 7 years ago

ALE is disabled as default in space-vim. You can invoke ALE via SPC t s (toggle syntax-checking).

If you want to enable it automatically, please add this to UserConfig() in .spacevim:

  let g:ale_enabled = 1
koustuvsinha commented 7 years ago

When I try to manually invoke via SPC t s I get this error:

E492: Not an editor command: SyntasticToggleMode

I guess syntastic is conflicting with ALE? How can I remove it altogether?

liuchengxu commented 7 years ago

That does not make sense. Since you're using Vim8, only ALE should be used for syntax checking, instead of syntastic. See here, if Vim8 or neovim, install ALE.

Check the plugins' status via :PlugStatus, see if ALE or syntastic has been installed. What's more, what does :verbose nmap <leader>ts say?

koustuvsinha commented 7 years ago

In :PlugStatus, there is no ALE, only Syntastic (OK: not loaded). :verbose nmap <leader>ts output:

screen shot 2017-08-11 at 11 59 41 pm

I think I have to update space-vim, these changes you mentioned might be new. I will again let you know after I update it.

koustuvsinha commented 7 years ago

After updating space-vim, :PlugStatus :

screen shot 2017-08-12 at 12 03 47 am

liuchengxu commented 7 years ago

Then how about :version and can you post your .spacevim?

koustuvsinha commented 7 years ago

:version : VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 25 2016 20:58:13)

.spacevim :

" You can enable the existing layers in space-vim and
" exclude the partial plugins in a certain layer.
" The command Layer is vaild in the function Layers().
" Use exclude option if you don't want the full Layer,
" e.g., Layer 'better-defaults', { 'exclude': 'itchyny/vim-cursorword' }
function! Layers()

    " Default layers, recommended!
    Layer 'fzf'
    Layer 'unite'
    Layer 'better-defaults'
    Layer 'syntax-checking'

endfunction

" Put your private plugins here.
function! UserInit()

    " Space has been set as the default leader key,
    " if you want to change it, uncomment and set it here.
    " let g:spacevim_leader = "<\Space>"
    " let g:spacevim_localleader = ','

    " Install private plugins
    " Plug 'extr0py/oni'
    " Plug 'w0rp/ale'

endfunction

" Put your costom configurations here, e.g., change the colorscheme.
function! UserConfig()

    " If you enable airline layer and have installed the powerline fonts, set it here.
    " let g:airline_powerline_fonts=1
    " color desert
    nnoremap <space> za
    vnoremap <space> zf
    let g:ale_enabled = 1
    let g:airline#extensions#ale#enabled = 1

endfunction
liuchengxu commented 7 years ago

That's wired. Can you try reinstalling syntax-checking layer with :PlugClean syntastic, :source $VIMRC and :PlugInstall?

Furthermore, check out the plugins used in space-vim via :for p in g:spacevim_plugins | echo p | endfor.

koustuvsinha commented 7 years ago

plugins used :

junegunn/fzf
junegunn/fzf.vim
tweekmonster/fzf-filemru
Shougo/unite.vim
tpope/vim-rsi
t9md/vim-choosewin
mhinz/vim-startify
dominikduda/vim_current_word
ntpeters/vim-better-whitespace
haya14busa/incsearch.vim
haya14busa/incsearch-fuzzy.vim
scrooloose/syntastic
liuchengxu/space-vim-dark
liuchengxu/vim-better-default
liuchengxu/eleline.vim

I could not reinstall the syntax checking later via the :PlugClean syntastic command, it says E488: Trailing characters

liuchengxu commented 7 years ago

Oops, can you comment the line Layer 'syntax-checking', then reopen Vim and run :PlugClean! to remove the plugins in syntax-checking layer(in this case, it should be the unexpected syntastic). Alternatively, you can remove syntastic manually, cd ~/.vim/plugged && rm -rf syntastic. After the cleaning, please try to reinstall syntax-checking layer. Last one, see if :echo g:spacevim_vim8 returns 1.

koustuvsinha commented 7 years ago

Ok surprisingly :echo g:spacevim_vim8 returns 0, while I have vim 8 installed :

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 25 2016 20:58:13)
Included patches: 1-13
Compiled by ksinha@somehost
liuchengxu commented 7 years ago

Please update space-vim to the latest and run :PlugInstall to install ALE.

I have just pushed a commit to remove the check on patches include in Vim8, which should be handled by the plugins really utilize the related functionalities. Thanks for your patient response.

koustuvsinha commented 7 years ago

updated and installed ALE. still the problem persists. To force ALE to work I even added let g:ale_sign_column_always = 1, let g:ale_sign_error = '>>' and let g:ale_sign_warning = '--' to my .spacevim file, and I can see vim has reserved a gutter space but still no output is shown, even when I manually do :ALEToggle. Does ALE need to be started up by some process? Also nothing happens when I manually run :ALELint

koustuvsinha commented 7 years ago

I think this could be a reason due to my compilation of vim? These are the packages that I had enabled when compiling vim, can you check whether any one of these needs to be enabled and re-built?

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 25 2016 20:58:13)
Included patches: 1-13
Compiled by ksinha@somehost
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
+balloon_eval    +folding         +mouse_xterm     +termguicolors
+browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
+clientserver    +insert_expand   +packages        +toolbar
+clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        -perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       +python          +vreplace
+cscope          +lispindent      -python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con_gui  -lua             +rightleft       +writebackup
+diff            +menu            -ruby            +X11
+digraphs        +mksession       +scrollbind      -xfontset
+dnd             +modify_fname    +signs           +xim
-ebcdic          +mouse           +smartindent     -xpm
+emacs_tags      +mouseshape      +startuptime     +xsmp_interact
+eval            +mouse_dec       +statusline      +xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax
+farsi           +mouse_netterm   +tag_binary
liuchengxu commented 7 years ago

Can you make sure that ALE has been installed successfully? Check it via :PlugStatus. Then see what :ALEInfo says.

You configurations added later are not essential. ALE will get to work automatically if you put let g:ale_enabled = 1 in UserConfig().

koustuvsinha commented 7 years ago

:PlugStatus : ale: OK

:ALEInfo ->

 Current Filetype: python
Available Linters: ['flake8', 'mypy', 'pylint']
  Enabled Linters: ['flake8']
 Linter Variables:
let g:ale_python_flake8_executable = 'flake8'
let g:ale_python_flake8_options = ''
let g:ale_python_flake8_use_global = 0
 Global Variables:
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = '✹ Error'
let g:ale_echo_msg_format = '[#%linter%#] %s [%severity%]'
let g:ale_echo_msg_warning_str = '⚠ Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'markdown': ['mdl'], 'sh': ['shellcheck'], 'html': ['tidy'], 'javascript': ['eslint'], 'python': ['flake8']}
let g:ale_open_list = 0
let g:ale_set_highlights = 0
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['E•%d', 'W•%d', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:
liuchengxu commented 7 years ago

your Command History is empty? That's problematic.

Enable all the avaiable linters by adding the following configuration to UserConfig(). See if it helps.

let g:ale_linters.python = ['flake8', 'mypy', 'pylint']
koustuvsinha commented 7 years ago

Enabled all linters, still no change. And command history is empty. Do these linters have to be installed separately?

liuchengxu commented 7 years ago

So, can you ensure that these tools(flake8, mypy or pylint) have been installed? These linters have to be installed first.

koustuvsinha commented 7 years ago

Installed all of them, and now the linting is working. Sometimes its so easy to miss the obvious!!!

Thank you for your superb patience and help! Really appreciate it :)