summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-09-04 16:51:18 +0100
committerw0rp <devw0rp@gmail.com>2018-09-04 16:51:18 +0100
commitd476578a402763f2c6e4e0ada2eb345d0ac938d7 (patch)
tree77f5a61c6eada15821391ecb4f78b87fa8e406db /autoload
parent8f2e1c393f74326979e1c74af8dc9b6ca8004778 (diff)
downloadale-d476578a402763f2c6e4e0ada2eb345d0ac938d7.zip
Improve ALE project style checking
* The project style linter now runs while you type. * Now the scripts for checking the project require blank lines. * Many style issues have been found and fixed.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale.vim2
-rw-r--r--autoload/ale/c.vim1
-rw-r--r--autoload/ale/completion.vim1
-rw-r--r--autoload/ale/engine.vim4
-rw-r--r--autoload/ale/fix.vim1
-rw-r--r--autoload/ale/fixers/fixjson.vim1
-rw-r--r--autoload/ale/fixers/importjs.vim1
-rw-r--r--autoload/ale/fixers/php_cs_fixer.vim1
-rw-r--r--autoload/ale/fixers/phpcbf.vim1
-rw-r--r--autoload/ale/fixers/puppetlint.vim1
-rw-r--r--autoload/ale/fixers/rubocop.vim1
-rw-r--r--autoload/ale/fixers/scalafmt.vim1
-rw-r--r--autoload/ale/fixers/shfmt.vim1
-rw-r--r--autoload/ale/fixers/xmllint.vim2
-rw-r--r--autoload/ale/handlers/gawk.vim2
-rw-r--r--autoload/ale/handlers/go.vim1
-rw-r--r--autoload/ale/handlers/ols.vim1
-rw-r--r--autoload/ale/handlers/pony.vim1
-rw-r--r--autoload/ale/handlers/redpen.vim11
-rw-r--r--autoload/ale/handlers/ruby.vim2
-rw-r--r--autoload/ale/handlers/sml.vim5
-rw-r--r--autoload/ale/handlers/vale.vim1
-rw-r--r--autoload/ale/job.vim2
-rw-r--r--autoload/ale/list.vim3
-rw-r--r--autoload/ale/lsp.vim1
-rw-r--r--autoload/ale/socket.vim1
-rw-r--r--autoload/ale/toggle.vim1
-rw-r--r--autoload/ale/util.vim1
28 files changed, 42 insertions, 10 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index 3747539b..41d78753 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -27,7 +27,7 @@ let s:getcmdwintype_exists = exists('*getcmdwintype')
function! ale#ShouldDoNothing(buffer) abort
" The checks are split into separate if statements to make it possible to
" profile each check individually with Vim's profiling tools.
-
+ "
" Do nothing if ALE is disabled.
if !getbufvar(a:buffer, 'ale_enabled', get(g:, 'ale_enabled', 0))
return 1
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index 5ec62011..e7b43d88 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -54,6 +54,7 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
call add(l:previous_options, l:option)
" Check if cflag contained a '-' and should not have been splitted
let l:option_list = split(l:option, '\zs')
+
if l:option_list[-1] isnot# ' '
continue
endif
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index abe0f56e..c1736678 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -75,6 +75,7 @@ endfunction
" Check if we should look for completions for a language.
function! ale#completion#GetPrefix(filetype, line, column) abort
let l:regex = s:GetFiletypeValue(s:should_complete_map, a:filetype)
+
" The column we're using completions for is where we are inserting text,
" like so:
" abc
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index fdf883f5..b6c2d3c9 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -231,6 +231,7 @@ function! s:HandleExit(job_id, exit_code) abort
if l:next_chain_index < len(get(l:linter, 'command_chain', []))
call s:InvokeChain(l:buffer, l:executable, l:linter, l:next_chain_index, l:output)
+
return
endif
@@ -595,9 +596,8 @@ function! ale#engine#ProcessChain(buffer, linter, chain_index, input) abort
\)
endif
+ " If we have a command to run, execute that.
if !empty(l:command)
- " We hit a command to run, so we'll execute that
-
" The chain item can override the output_stream option.
if has_key(l:chain_item, 'output_stream')
let l:output_stream = l:chain_item.output_stream
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 4d82b367..1ae1a4a1 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -71,6 +71,7 @@ function! ale#fix#ApplyFixes(buffer, output) abort
if l:data.lines_before != l:lines
call remove(g:ale_fix_buffer_data, a:buffer)
execute 'echoerr ''The file was changed before fixing finished'''
+
return
endif
endif
diff --git a/autoload/ale/fixers/fixjson.vim b/autoload/ale/fixers/fixjson.vim
index 64c6ba81..33ce0af3 100644
--- a/autoload/ale/fixers/fixjson.vim
+++ b/autoload/ale/fixers/fixjson.vim
@@ -17,6 +17,7 @@ function! ale#fixers#fixjson#Fix(buffer) abort
let l:command = l:executable . ' --stdin-filename ' . l:filename
let l:options = ale#Var(a:buffer, 'json_fixjson_options')
+
if l:options isnot# ''
let l:command .= ' ' . l:options
endif
diff --git a/autoload/ale/fixers/importjs.vim b/autoload/ale/fixers/importjs.vim
index 50d3d74e..b5487b2c 100644
--- a/autoload/ale/fixers/importjs.vim
+++ b/autoload/ale/fixers/importjs.vim
@@ -5,6 +5,7 @@ call ale#Set('javascript_importjs_executable', 'importjs')
function! ale#fixers#importjs#ProcessOutput(buffer, output) abort
let l:result = ale#util#FuzzyJSONDecode(a:output, [])
+
return split(get(l:result, 'fileContent', ''), "\n")
endfunction
diff --git a/autoload/ale/fixers/php_cs_fixer.vim b/autoload/ale/fixers/php_cs_fixer.vim
index 26b8e5de..5c59e262 100644
--- a/autoload/ale/fixers/php_cs_fixer.vim
+++ b/autoload/ale/fixers/php_cs_fixer.vim
@@ -14,6 +14,7 @@ endfunction
function! ale#fixers#php_cs_fixer#Fix(buffer) abort
let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer)
+
return {
\ 'command': ale#Escape(l:executable)
\ . ' ' . ale#Var(a:buffer, 'php_cs_fixer_options')
diff --git a/autoload/ale/fixers/phpcbf.vim b/autoload/ale/fixers/phpcbf.vim
index 487f369a..f14b8406 100644
--- a/autoload/ale/fixers/phpcbf.vim
+++ b/autoload/ale/fixers/phpcbf.vim
@@ -18,6 +18,7 @@ function! ale#fixers#phpcbf#Fix(buffer) abort
let l:standard_option = !empty(l:standard)
\ ? '--standard=' . l:standard
\ : ''
+
return {
\ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ' -'
\}
diff --git a/autoload/ale/fixers/puppetlint.vim b/autoload/ale/fixers/puppetlint.vim
index 81f34e89..bf36e486 100644
--- a/autoload/ale/fixers/puppetlint.vim
+++ b/autoload/ale/fixers/puppetlint.vim
@@ -4,6 +4,7 @@
if !exists('g:ale_puppet_puppetlint_executable')
let g:ale_puppet_puppetlint_executable = 'puppet-lint'
endif
+
if !exists('g:ale_puppet_puppetlint_options')
let g:ale_puppet_puppetlint_options = ''
endif
diff --git a/autoload/ale/fixers/rubocop.vim b/autoload/ale/fixers/rubocop.vim
index 35569b19..0a39ef62 100644
--- a/autoload/ale/fixers/rubocop.vim
+++ b/autoload/ale/fixers/rubocop.vim
@@ -10,7 +10,6 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --auto-correct %t'
-
endfunction
function! ale#fixers#rubocop#Fix(buffer) abort
diff --git a/autoload/ale/fixers/scalafmt.vim b/autoload/ale/fixers/scalafmt.vim
index 07d28275..dd0e7745 100644
--- a/autoload/ale/fixers/scalafmt.vim
+++ b/autoload/ale/fixers/scalafmt.vim
@@ -15,7 +15,6 @@ function! ale#fixers#scalafmt#GetCommand(buffer) abort
return ale#Escape(l:executable) . l:exec_args
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t'
-
endfunction
function! ale#fixers#scalafmt#Fix(buffer) abort
diff --git a/autoload/ale/fixers/shfmt.vim b/autoload/ale/fixers/shfmt.vim
index 882cf3a4..fc55f425 100644
--- a/autoload/ale/fixers/shfmt.vim
+++ b/autoload/ale/fixers/shfmt.vim
@@ -13,5 +13,4 @@ function! ale#fixers#shfmt#Fix(buffer) abort
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\}
-
endfunction
diff --git a/autoload/ale/fixers/xmllint.vim b/autoload/ale/fixers/xmllint.vim
index 9beaa48c..b14ffd36 100644
--- a/autoload/ale/fixers/xmllint.vim
+++ b/autoload/ale/fixers/xmllint.vim
@@ -11,12 +11,14 @@ function! ale#fixers#xmllint#Fix(buffer) abort
let l:command = l:executable . ' --format ' . l:filename
let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize')
+
if l:indent isnot# ''
let l:env = ale#Env('XMLLINT_INDENT', repeat(' ', l:indent))
let l:command = l:env . l:command
endif
let l:options = ale#Var(a:buffer, 'xml_xmllint_options')
+
if l:options isnot# ''
let l:command .= ' ' . l:options
endif
diff --git a/autoload/ale/handlers/gawk.vim b/autoload/ale/handlers/gawk.vim
index 942bc2b2..50bc4c45 100644
--- a/autoload/ale/handlers/gawk.vim
+++ b/autoload/ale/handlers/gawk.vim
@@ -9,9 +9,11 @@ function! ale#handlers#gawk#HandleGawkFormat(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:ecode = 'E'
+
if l:match[2] is? 'warning:'
let l:ecode = 'W'
endif
+
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': 0,
diff --git a/autoload/ale/handlers/go.vim b/autoload/ale/handlers/go.vim
index 224df664..f17cd862 100644
--- a/autoload/ale/handlers/go.vim
+++ b/autoload/ale/handlers/go.vim
@@ -21,5 +21,6 @@ function! ale#handlers#go#Handler(buffer, lines) abort
\ 'type': 'E',
\})
endfor
+
return l:output
endfunction
diff --git a/autoload/ale/handlers/ols.vim b/autoload/ale/handlers/ols.vim
index 1dda7f92..74130a26 100644
--- a/autoload/ale/handlers/ols.vim
+++ b/autoload/ale/handlers/ols.vim
@@ -3,6 +3,7 @@
function! ale#handlers#ols#GetExecutable(buffer) abort
let l:ols_setting = ale#handlers#ols#GetLanguage(a:buffer) . '_ols'
+
return ale#node#FindExecutable(a:buffer, l:ols_setting, [
\ 'node_modules/.bin/ocaml-language-server',
\])
diff --git a/autoload/ale/handlers/pony.vim b/autoload/ale/handlers/pony.vim
index 0ac18e76..ea84ac4b 100644
--- a/autoload/ale/handlers/pony.vim
+++ b/autoload/ale/handlers/pony.vim
@@ -14,7 +14,6 @@ endfunction
function! ale#handlers#pony#HandlePonycFormat(buffer, lines) abort
" Look for lines like the following.
" /home/code/pony/classes/Wombat.pony:22:30: can't lookup private fields from outside the type
-
let l:pattern = '\v^([^:]+):(\d+):(\d+)?:? (.+)$'
let l:output = []
diff --git a/autoload/ale/handlers/redpen.vim b/autoload/ale/handlers/redpen.vim
index c136789c..84e331ed 100644
--- a/autoload/ale/handlers/redpen.vim
+++ b/autoload/ale/handlers/redpen.vim
@@ -6,15 +6,18 @@ function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
" element.
let l:res = json_decode(join(a:lines))[0]
let l:output = []
+
for l:err in l:res.errors
let l:item = {
\ 'text': l:err.message,
\ 'type': 'W',
\ 'code': l:err.validator,
\}
+
if has_key(l:err, 'startPosition')
let l:item.lnum = l:err.startPosition.lineNum
let l:item.col = l:err.startPosition.offset + 1
+
if has_key(l:err, 'endPosition')
let l:item.end_lnum = l:err.endPosition.lineNum
let l:item.end_col = l:err.endPosition.offset
@@ -28,29 +31,35 @@ function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
" Adjust column number for multibyte string
let l:line = getline(l:item.lnum)
+
if l:line is# ''
let l:line = l:err.sentence
endif
+
let l:line = split(l:line, '\zs')
if l:item.col >= 2
let l:col = 0
+
for l:strlen in map(l:line[0:(l:item.col - 2)], 'strlen(v:val)')
let l:col = l:col + l:strlen
endfor
+
let l:item.col = l:col + 1
endif
if has_key(l:item, 'end_col')
let l:col = 0
+
for l:strlen in map(l:line[0:(l:item.end_col - 1)], 'strlen(v:val)')
let l:col = l:col + l:strlen
endfor
+
let l:item.end_col = l:col
endif
call add(l:output, l:item)
endfor
+
return l:output
endfunction
-
diff --git a/autoload/ale/handlers/ruby.vim b/autoload/ale/handlers/ruby.vim
index 555c13b1..110fe156 100644
--- a/autoload/ale/handlers/ruby.vim
+++ b/autoload/ale/handlers/ruby.vim
@@ -13,8 +13,10 @@ function! s:HandleSyntaxError(buffer, lines) abort
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
+
if len(l:match) == 0
let l:match = matchlist(l:line, l:column)
+
if len(l:match) != 0
let l:output[len(l:output) - 1]['col'] = len(l:match[1])
endif
diff --git a/autoload/ale/handlers/sml.vim b/autoload/ale/handlers/sml.vim
index 377eade5..92c5f83b 100644
--- a/autoload/ale/handlers/sml.vim
+++ b/autoload/ale/handlers/sml.vim
@@ -11,8 +11,10 @@ function! ale#handlers#sml#GetCmFile(buffer) abort
let l:as_list = 1
let l:cmfile = ''
+
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
let l:results = glob(l:path . '/' . l:pattern, 0, l:as_list)
+
if len(l:results) > 0
" If there is more than one CM file, we take the first one
" See :help ale-sml-smlnj for how to configure this.
@@ -46,6 +48,7 @@ endfunction
function! ale#handlers#sml#GetExecutableSmlnjCm(buffer) abort
return s:GetExecutable(a:buffer, 'smlnj-cm')
endfunction
+
function! ale#handlers#sml#GetExecutableSmlnjFile(buffer) abort
return s:GetExecutable(a:buffer, 'smlnj-file')
endfunction
@@ -53,7 +56,6 @@ endfunction
function! ale#handlers#sml#Handle(buffer, lines) abort
" Try to match basic sml errors
" TODO(jez) We can get better errorfmt strings from Syntastic
-
let l:out = []
let l:pattern = '^.*\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)'
let l:pattern2 = '^.*\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)'
@@ -83,7 +85,6 @@ function! ale#handlers#sml#Handle(buffer, lines) abort
\})
continue
endif
-
endfor
return l:out
diff --git a/autoload/ale/handlers/vale.vim b/autoload/ale/handlers/vale.vim
index 9dc0872f..2da72fc7 100644
--- a/autoload/ale/handlers/vale.vim
+++ b/autoload/ale/handlers/vale.vim
@@ -23,6 +23,7 @@ function! ale#handlers#vale#Handle(buffer, lines) abort
endif
let l:output = []
+
for l:error in l:errors[keys(l:errors)[0]]
call add(l:output, {
\ 'lnum': l:error['Line'],
diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim
index e0266cba..1fe470f8 100644
--- a/autoload/ale/job.vim
+++ b/autoload/ale/job.vim
@@ -278,11 +278,13 @@ function! ale#job#IsRunning(job_id) abort
try
" In NeoVim, if the job isn't running, jobpid() will throw.
call jobpid(a:job_id)
+
return 1
catch
endtry
elseif has_key(s:job_map, a:job_id)
let l:job = s:job_map[a:job_id].job
+
return job_status(l:job) is# 'run'
endif
diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim
index 35304a09..3417575c 100644
--- a/autoload/ale/list.vim
+++ b/autoload/ale/list.vim
@@ -25,6 +25,7 @@ function! ale#list#IsQuickfixOpen() abort
return 1
endif
endfor
+
return 0
endfunction
@@ -112,9 +113,11 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
" open windows vertically instead of default horizontally
let l:open_type = ''
+
if ale#Var(a:buffer, 'list_vertical') == 1
let l:open_type = 'vert '
endif
+
if g:ale_set_quickfix
if !ale#list#IsQuickfixOpen()
silent! execute l:open_type . 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size'))
diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim
index dae45e70..196cbe80 100644
--- a/autoload/ale/lsp.vim
+++ b/autoload/ale/lsp.vim
@@ -99,6 +99,7 @@ function! s:CreateTSServerMessageData(message) abort
endif
let l:data = json_encode(l:obj) . "\n"
+
return [l:is_notification ? 0 : l:obj.seq, l:data]
endfunction
diff --git a/autoload/ale/socket.vim b/autoload/ale/socket.vim
index 0ca4dea6..5ea49c7b 100644
--- a/autoload/ale/socket.vim
+++ b/autoload/ale/socket.vim
@@ -104,6 +104,7 @@ function! ale#socket#IsOpen(channel_id) abort
endif
let l:channel = s:channel_map[a:channel_id].channel
+
return ch_status(l:channel) is# 'open'
endfunction
diff --git a/autoload/ale/toggle.vim b/autoload/ale/toggle.vim
index da108782..1d052b4f 100644
--- a/autoload/ale/toggle.vim
+++ b/autoload/ale/toggle.vim
@@ -76,6 +76,7 @@ function! ale#toggle#ToggleBuffer(buffer) abort
" linting locally when linting is disabled globally
if l:enabled && !g:ale_enabled
execute 'echom ''ALE cannot be enabled locally when disabled globally'''
+
return
endif
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 8c69c54f..58a2065e 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -54,6 +54,7 @@ endif
function! ale#util#JoinNeovimOutput(job, last_line, data, mode, callback) abort
if a:mode is# 'raw'
call a:callback(a:job, join(a:data, "\n"))
+
return ''
endif