From ae8ba0a2273e7a2b21f1f61083dfa540d876d7a2 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Tue, 13 Mar 2018 11:32:04 -0400 Subject: [PATCH] Replace syntastic with ale --- .gitmodules | 9 +- README.md | 3 +- vim/bundle/ale | 1 + vim/bundle/lightline-ale | 1 + vim/bundle/syntastic | 1 - vim/colors/darkcloud.vim | 12 +-- vim/config/keyboard.vim | 48 +++++----- vim/config/plugins/ale.vim | 22 +++++ vim/config/plugins/lightline.vim | 137 ++++++++++++---------------- vim/config/plugins/syntastic.vim | 150 ------------------------------- 10 files changed, 120 insertions(+), 264 deletions(-) create mode 160000 vim/bundle/ale create mode 160000 vim/bundle/lightline-ale delete mode 160000 vim/bundle/syntastic create mode 100644 vim/config/plugins/ale.vim delete mode 100644 vim/config/plugins/syntastic.vim diff --git a/.gitmodules b/.gitmodules index 5a03ac5..a29d3b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,9 +31,6 @@ [submodule "vim/bundle/vimfiler.vim"] path = vim/bundle/vimfiler.vim url = https://github.com/Shougo/vimfiler.vim.git -[submodule "vim/bundle/syntastic"] - path = vim/bundle/syntastic - url = https://github.com/scrooloose/syntastic.git [submodule "vim/bundle/tcomment_vim"] path = vim/bundle/tcomment_vim url = https://github.com/tomtom/tcomment_vim.git @@ -121,3 +118,9 @@ [submodule "vim/bundle/splitjoin.vim"] path = vim/bundle/splitjoin.vim url = https://github.com/AndrewRadev/splitjoin.vim +[submodule "vim/bundle/ale"] + path = vim/bundle/ale + url = https://github.com/w0rp/ale +[submodule "vim/bundle/lightline-ale"] + path = vim/bundle/lightline-ale + url = https://github.com/maximbaz/lightline-ale diff --git a/README.md b/README.md index fe168d1..9cf19b7 100644 --- a/README.md +++ b/README.md @@ -129,13 +129,14 @@ As usual, to have your system use `vimpager` in place of `less`, you'll need to | ?N | N | Go to the next spelling mistake | | ?P | N | Go to the previous spelling mistake | -#### Formatting #### +#### Fixing and Formatting #### | Binding | Mode | Action | |----------|------|---------------------------------------------------------------| | Leader+J | N+V | Format line/selected lines to a max width of the _textwidth_ | | Leader+f | N+V | Format document/selection alignment using Vim syntax | | Leader+f | N+V | (Markdown) Format table cursor is currently on | +| Leader+F | N | Fix document with available ale fixers | | Leader+t | N | Convert all tabs into spaces and continue session with spaces | | Leader+T | N | Convert all spaces into tabs and continue session with tabs | | Leader+w | N | Remove all trailing whitespace | diff --git a/vim/bundle/ale b/vim/bundle/ale new file mode 160000 index 0000000..05d39bc --- /dev/null +++ b/vim/bundle/ale @@ -0,0 +1 @@ +Subproject commit 05d39bc1a9eb79ff6f36b190b4612ff052812e7e diff --git a/vim/bundle/lightline-ale b/vim/bundle/lightline-ale new file mode 160000 index 0000000..cb4610c --- /dev/null +++ b/vim/bundle/lightline-ale @@ -0,0 +1 @@ +Subproject commit cb4610cb2f6655f6fae12aaeffecadf083dc97e6 diff --git a/vim/bundle/syntastic b/vim/bundle/syntastic deleted file mode 160000 index b7b473b..0000000 --- a/vim/bundle/syntastic +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b7b473b2688827dcd7d8c801197b8bfc31b20dc4 diff --git a/vim/colors/darkcloud.vim b/vim/colors/darkcloud.vim index 627fb9e..6566a1d 100644 --- a/vim/colors/darkcloud.vim +++ b/vim/colors/darkcloud.vim @@ -531,15 +531,9 @@ hi SpellLocal guisp=NONE gui=NONE guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NON hi! link SignifyLineDelete DiffDelete hi! link SignifyLineChange DiffChange - "syntastic - call s:X("SyntasticError","#d75f5f","","standout,bold","Red","") - call s:X("SyntasticWarning","#ffd787","","standout,bold","Yellow","") - hi! link SyntasticErrorLine SyntasticError - hi! link SyntasticWarningLine SyntasticWarning - hi! link SyntasticErrorSign SyntasticError - hi! link SyntasticWarningSign SyntasticWarning - hi! link qfSeparator Delimiter - hi! link qfLineNr SyntasticError + "ale + call s:X("ALEErrorSign","#d75f5f","","standout,bold","Red","") + call s:X("ALEWarningSign","#ffd787","","standout,bold","Yellow","") "taglist hi! link TagListFileName Directory diff --git a/vim/config/keyboard.vim b/vim/config/keyboard.vim index 2236ec0..83e2084 100644 --- a/vim/config/keyboard.vim +++ b/vim/config/keyboard.vim @@ -177,11 +177,12 @@ " | (I) -> (neocomplete) close the popup and " | (I) -> (neocomplete) undo the most recent completion " -" (formatting) +" (fixing-and-formatting) " J | (N) -> split document into lines of tw or 80 " J | (V) -> split selection into lines of tw or 80 " f | (N) -> format document and return to cursor " f | (V) -> format the selection and return to cursor +" F | (N) -> run available ale fixers on the document " t | (N) -> convert tabs into spaces " T | (N) -> convert spaces into tabs " w | (N) -> remove whitespace @@ -522,16 +523,16 @@ nnoremap 0 'zX:echo "all folds have been reset"' "view commit history and diffs - nnoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - xnoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - inoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - nnoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - xnoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - inoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - nnoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - xnoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - inoremap ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' - nnoremap } ':SyntasticToggleOff:Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + nnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + xnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + inoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + nnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + xnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + inoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + nnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + xnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + inoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' + nnoremap } ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' "bindings to trigger the tagbar list of tags nnoremap ':TagbarToggle:echo "tagbar toggled"' @@ -595,15 +596,15 @@ set pastetoggle= "toggle syntax checking - nnoremap ':SyntasticToggleAll' - xnoremap ':SyntasticToggleAllgv' - inoremap ':SyntasticToggleAll' - nnoremap ':SyntasticToggleAll' - xnoremap ':SyntasticToggleAllgv' - inoremap ':SyntasticToggleAll' - nnoremap ':SyntasticToggleAll' - xnoremap ':SyntasticToggleAllgv' - inoremap ':SyntasticToggleAll' + nnoremap ':ALEToggle' + xnoremap ':ALETogglegv' + inoremap ':ALEToggle' + nnoremap ':ALEToggle' + xnoremap ':ALETogglegv' + inoremap ':ALEToggle' + nnoremap ':ALEToggle' + xnoremap ':ALETogglegv' + inoremap ':ALEToggle' "toggle goyo nnoremap ` ':Goyo' @@ -702,15 +703,18 @@ endif "} - "FORMATTING:{ + "FIXING AND FORMATTING:{ "format width to text width (or 80 chars if text width is 0) nnoremap J ':let b:tw=&textwidth:if (b:tw == 0)set tw=80endifgg0vG$gq:if (b:tw == 0)set tw=0let b:tw=80endif:echo "Document has been formatted to a width of ".b:tw." characters"' vnoremap J ':let b:tw=&textwidth:if (b:tw == 0)set tw=80endifgvgq:if (b:tw == 0)set tw=0let b:tw=80endif:echo "Selection has been formatted to a width of ".b:tw." characters"' - "format by Vim syntax + by Autoformat tool syntax + "format by Vim syntax nnoremap f mzgg=G`z:echo "The document has been formatted" vnoremap f mz=`z:echo "The selection has been formatted" + "fix with ale + nnoremap F ':ALEFix:echo "Available ale fixers have been run on the document"' + "convert tabs to spaces and spaces to tabs nnoremap t ':let b:et=&expandtab:set expandtab:retab!:let &expandtab=b:et:echo "Tabs have been converted to spaces"' nnoremap T ':let b:et=&expandtab:set noexpandtab:%retab!:let &expandtab=b:et:echo "Spaces have been converted to tabs"' diff --git a/vim/config/plugins/ale.vim b/vim/config/plugins/ale.vim new file mode 100644 index 0000000..5708ea5 --- /dev/null +++ b/vim/config/plugins/ale.vim @@ -0,0 +1,22 @@ +"autostart syntax checking when vim opens to a compatible filetype (default: 0) +if !exists("g:autostartchecker") || &diff + let g:autostartchecker = 0 +endif + +let g:ale_enabled = g:autostartchecker + +" open list of warnings and errors when they exist +let g:ale_open_list = 1 + +" don't fix on save +let g:ale_fix_on_save = 0 + +" list of ale fixers +let g:ale_fixers = { + \ 'javascript': [ 'eslint' ] + \ } + +" don't run ale on minified files +let g:ale_pattern_options = { + \ '\.min\.[^\.]*$': { 'ale_linters': [], 'ale_fixers': [] }, + \ } diff --git a/vim/config/plugins/lightline.vim b/vim/config/plugins/lightline.vim index 69a59ca..a5a1445 100644 --- a/vim/config/plugins/lightline.vim +++ b/vim/config/plugins/lightline.vim @@ -27,14 +27,13 @@ endfunction function! LLFugitive() try if expand('%:t') !~? 'Tagbar\|Gundo' && &ft !~? 'vimfiler' && exists('*fugitive#head') - let mark = '' " edit here for cool mark + let mark = '' " edit here for cool mark let _ = fugitive#head() return strlen(_) ? mark._ : '' endif catch + return '' endtry - - return '' endfunction function! LLFileformat() @@ -67,15 +66,45 @@ function! TagbarStatusFunc(current, sort, fname, ...) abort return lightline#statusline(0) endfunction -augroup AutoSyntastic - autocmd! - autocmd BufWritePost * call s:syntastic() -augroup END +let g:lightline = {} -function! s:syntastic() - SyntasticCheck - call lightline#update() -endfunction +let g:lightline.colorscheme = 'darkcloud' +let g:lightline#ale#indicator_checking = "" +let g:lightline#ale#indicator_warnings = "W:" +let g:lightline#ale#indicator_errors = "E:" +let g:lightline#ale#indicator_ok = "OK" + +let g:lightline.component_function = { + \ 'fugitive': 'LLFugitive', + \ 'filename': 'LLFilename', + \ 'fileformat': 'LLFileformat', + \ 'filetype': 'LLFiletype', + \ 'fileencoding': 'LLFileencoding', + \ 'mode': 'LLMode' + \ } + +let g:lightline.component_expand = { + \ 'linter_checking': 'lightline#ale#checking', + \ 'linter_warnings': 'lightline#ale#warnings', + \ 'linter_errors': 'lightline#ale#errors', + \ 'linter_ok': 'lightline#ale#ok' + \ } + +let g:lightline.component_type = { + \ 'linter_checking': 'left', + \ 'linter_warnings': 'warning', + \ 'linter_errors': 'error', + \ 'linter_ok': 'left' + \ } + +let g:lightline.component = { + \ 'tagbar': '%{tagbar#currenttag("[%s]", "", "f")}' + \ } + +let g:lightline.active = { + \ 'left': [[ 'mode', 'paste' ], [ 'fugitive', 'filename' ], [ 'tagbar' ]], + \ 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok' ], [ 'lineinfo', 'percent' ], [ 'fileformat', 'fileencoding', 'filetype' ]] + \ } "status bar config with and without powerline fonts (default: 0) if !exists("g:powerlinefonts") @@ -83,59 +112,11 @@ if !exists("g:powerlinefonts") endif if (g:powerlinefonts == 1) - let g:lightline = { - \ 'colorscheme': 'darkcloud', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], [ 'tagbar' ] ], - \ 'right': [ [ 'syntastic', 'lineinfo' ], [ 'percent' ], [ 'fileformat', 'fileencoding', 'filetype' ] ] - \ }, - \ 'component_function': { - \ 'fugitive': 'LLFugitive', - \ 'filename': 'LLFilename', - \ 'fileformat': 'LLFileformat', - \ 'filetype': 'LLFiletype', - \ 'fileencoding': 'LLFileencoding', - \ 'mode': 'LLMode', - \ }, - \ 'component_expand': { - \ 'syntastic': 'SyntasticStatuslineFlag', - \ }, - \ 'component_type': { - \ 'syntastic': 'error', - \ }, - \ 'separator': {'left': '', 'right': ''}, - \ 'subseparator': {'left': '', 'right': ''}, - \ 'component': { - \ 'tagbar': '%{tagbar#currenttag("[%s]", "", "f")}', - \ }, - \ } + let g:lightline.separator = { 'left': '', 'right': '' } + let g:lightline.subseparator = { 'left': '', 'right': '' } else - let g:lightline = { - \ 'colorscheme': 'darkcloud', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], [ 'tagbar' ] ], - \ 'right': [ [ 'syntastic', 'lineinfo' ], [ 'percent' ], [ 'fileformat', 'fileencoding', 'filetype' ] ] - \ }, - \ 'component_function': { - \ 'fugitive': 'LLFugitive', - \ 'filename': 'LLFilename', - \ 'fileformat': 'LLFileformat', - \ 'filetype': 'LLFiletype', - \ 'fileencoding': 'LLFileencoding', - \ 'mode': 'LLMode', - \ }, - \ 'component_expand': { - \ 'syntastic': 'SyntasticStatuslineFlag', - \ }, - \ 'component_type': { - \ 'syntastic': 'error', - \ }, - \ 'separator': {'left': '', 'right': ''}, - \ 'subseparator': {'left': '|', 'right': '|'}, - \ 'component': { - \ 'tagbar': '%{tagbar#currenttag("[%s]", "", "f")}', - \ } - \ } + let g:lightline.separator = { 'left': '', 'right': '' } + let g:lightline.subseparator = { 'left': '|', 'right': '|' } endif "ligtline theme {{{ @@ -151,24 +132,24 @@ endif let s:ycol = '#ffd787' let s:bcol = '#87d7ff' - let s:p = {'normal':{},'inactive':{},'insert':{},'replace':{},'visual':{},'tabline':{}} + let s:p = { 'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {} } - let s:p.normal.left = [[ s:bcol,s:base1 ],[ s:base6,s:base0 ]] - let s:p.normal.right = [[ s:base4,s:base1 ],[ s:base6,s:base0 ]] - let s:p.inactive.left = [[ s:base6,s:base0 ],[ s:base4,s:base1 ]] - let s:p.inactive.right = [[ s:base4,s:base1 ],[ s:base6,s:base0 ]] - let s:p.insert.left = [[ s:rcol,s:base1 ],[ s:base6,s:base0 ]] - let s:p.replace.left = [[ s:base1,s:rcol ],[ s:base6,s:base0 ]] - let s:p.visual.left = [[ s:ycol,s:base1 ],[ s:base6,s:base0 ]] + let s:p.normal.left = [[ s:bcol, s:base1 ], [ s:base6, s:base0 ]] + let s:p.normal.right = [[ s:base4, s:base1 ], [ s:base6, s:base0 ]] + let s:p.inactive.left = [[ s:base6, s:base0 ], [ s:base4, s:base1 ]] + let s:p.inactive.right = [[ s:base4, s:base1 ], [ s:base6, s:base0 ]] + let s:p.insert.left = [[ s:rcol, s:base1 ], [ s:base6, s:base0 ]] + let s:p.replace.left = [[ s:base1, s:rcol ], [ s:base6, s:base0 ]] + let s:p.visual.left = [[ s:ycol, s:base1 ], [ s:base6, s:base0 ]] - let s:p.normal.middle = [[ s:base4,s:base1 ]] - let s:p.inactive.abmiddle = [[ s:base3,s:base1 ]] - let s:p.tabline.left = [[ s:base5,s:base0 ]] - let s:p.tabline.tabsel = [[ s:base5,s:base1 ]] - let s:p.tabline.middle = [[ s:base0,s:base4 ]] + let s:p.normal.middle = [[ s:base4, s:base1 ]] + let s:p.inactive.abmiddle = [[ s:base3, s:base1 ]] + let s:p.tabline.left = [[ s:base5, s:base0 ]] + let s:p.tabline.tabsel = [[ s:base5, s:base1 ]] + let s:p.tabline.middle = [[ s:base0, s:base4 ]] let s:p.tabline.right = copy(s:p.normal.right) - let s:p.normal.error = [[ s:rcol,s:base1 ]] - let s:p.normal.warning = [[ s:ycol,s:base1 ]] + let s:p.normal.error = [[ s:rcol, s:base1 ]] + let s:p.normal.warning = [[ s:ycol, s:base1 ]] let g:lightline#colorscheme#darkcloud#palette = lightline#colorscheme#fill(s:p) "}}} diff --git a/vim/config/plugins/syntastic.vim b/vim/config/plugins/syntastic.vim deleted file mode 100644 index 888e668..0000000 --- a/vim/config/plugins/syntastic.vim +++ /dev/null @@ -1,150 +0,0 @@ -"autostart syntax checking when vim opens to a compatible filetype (default: 0) -if !exists("g:autostartchecker") - let g:autostartchecker = 0 -endif - -if &diff - let g:autostartchecker = 0 -else - if (g:autostartchecker == 1) - let g:syntastic_mode_map = { - \ 'mode':'active', - \ 'active_filetypes':[], - \ 'passive_filetypes':[] - \ } - - let g:syntastic_check_on_open = 1 - else - let g:syntastic_mode_map = { - \ 'mode':'passive', - \ 'active_filetypes':[], - \ 'passive_filetypes':[] - \ } - - let g:syntastic_check_on_open = 0 - endif - - "configure warnings/errors that should be silenced by module - let g:syntastic_less_lessc_quiet_messages = { - \ 'regex':[ - \ 'NameError:.* is undefined', - \ 'FileError:.*' - \ ]} - - let g:syntastic_scss_sass_quiet_messages = { - \ 'regex':[ - \ 'File to import not found or unreadable.*' - \ ]} - - let g:syntastic_java_javac_quiet_messages = { - \ 'regex':[ - \ 'cannot find symbol.*', - \ 'method does not override or implement a method from a supertype.*', - \ 'package [^\ ]* does not exist.*' - \ ]} - - let g:syntastic_javascript_eslint_quiet_messages = { - \ 'regex':[ - \ '.* is defined but never used', - \ "'[^']*' is not defined", - \ 'Missing "use strict" statement', - \ 'Unexpected [^ ]* statement.*' - \ ]} - - let g:syntastic_javascript_jshint_quiet_messages = { - \ 'regex':[ - \ 'Expected an assignment or function call and instead saw an expression.' - \ ]} - - let g:syntastic_javascript_standard_quiet_messages = { - \ 'regex':[ - \ '.* is defined but never used', - \ "'[^']*' is not defined" - \ ]} - - let g:syntastic_markdown_mdl_quiet_messages = { - \ 'regex':[ - \ '.*MD013.*', - \ '.*MD002.*', - \ '.*MD029.*' - \ ]} - - let g:syntastic_python_flake8_quiet_messages = { - \ 'regex':[ - \ '.*\[W293\]', - \ '.*\[E501\]' - \ ]} - - let g:syntastic_php_phpmd_quiet_messages = { - \ 'regex':[ - \ 'Avoid using short method names like.*', - \ 'Avoid variables with short names like.*', - \ 'The method.*has [0-9][0-9]* lines of code.*', - \ 'The method.*has a Cyclomatic Complexity.*', - \ 'The method.*has an NPath complexity.*', - \ 'The function.*has a Cyclomatic Complexity.*', - \ 'The function.*has an NPath complexity.*', - \ 'The function.*Avoid really long methods\.', - \ 'The class.*has an overall complexity.*', - \ 'The class.*has.*public methods.*', - \ 'The class.*lines of code' - \ ]} - - let g:syntastic_sh_bashate_quiet_messages = { - \ 'regex':[ - \ 'Indent not multiple of 4' - \ ]} - - let g:syntastic_sh_shellcheck_quiet_messages = { - \ 'regex':[ - \ '.*\[SC1001\]', - \ '.*\[SC2015\]', - \ '.*\[SC2016\]', - \ '.*\[SC2029\]', - \ '.*\[SC2034\]', - \ '.*\[SC2148\]', - \ '.*\[SC2181\]', - \ '.*follow non-constant source', - \ 'Not following:' - \ ]} - - autocmd BufNewFile,BufRead PKGBUILD,bash.bashrc,.bashrc let g:syntastic_quiet_messages = {"level":"warnings"} - - let g:syntastic_check_on_wq = 0 - let g:syntastic_always_populate_loc_list = 1 - let g:syntastic_auto_loc_list = 1 - let g:syntastic_loc_list_height = 5 -endif - -"function to enable syntastic and set check_on_open on -function s:SyntasticToggleOn() - let g:syntastic_check_on_open = 1 - - if (g:syntastic_mode_map.mode == "passive") - SyntasticToggleMode - endif -endfunction - -command! -buffer SyntasticToggleOn call s:SyntasticToggleOn() - -"function to disable syntastic and set check_on_open off -function s:SyntasticToggleOff() - let g:syntastic_check_on_open = 0 - - if (g:syntastic_mode_map.mode == "active") - SyntasticToggleMode - endif -endfunction - -command! -buffer SyntasticToggleOff call s:SyntasticToggleOff() - -"function to toggle syntastic and check_on_open on and off together -function s:SyntasticToggleAll() - if (g:syntastic_check_on_open == 1) - call s:SyntasticToggleOff() - else - call s:SyntasticToggleOn() - endif -endfunction - -command! -buffer SyntasticToggleAll call s:SyntasticToggleAll()