summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/c.vim2
-rw-r--r--autoload/ale/engine.vim16
-rw-r--r--autoload/ale/fix.vim9
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/gomod.vim10
-rw-r--r--autoload/ale/lsp_linter.vim16
-rw-r--r--autoload/ale/python.vim7
-rw-r--r--autoload/ale/toggle.vim19
-rw-r--r--autoload/ale/util.vim2
9 files changed, 65 insertions, 21 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index e7b43d88..ce59ae31 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -55,7 +55,7 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
" 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# ' '
+ if len(l:option_list) > 0 && l:option_list[-1] isnot# ' '
continue
endif
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index b6c2d3c9..05db0e49 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -18,6 +18,22 @@ if !has_key(s:, 'executable_cache_map')
let s:executable_cache_map = {}
endif
+
+function! ale#engine#CleanupEveryBuffer() abort
+ for l:key in keys(g:ale_buffer_info)
+ " The key could be a filename or a buffer number, so try and
+ " convert it to a number. We need a number for the other
+ " functions.
+ let l:buffer = str2nr(l:key)
+
+ if l:buffer > 0
+ " Stop all jobs and clear the results for everything, and delete
+ " all of the data we stored for the buffer.
+ call ale#engine#Cleanup(l:buffer)
+ endif
+ endfor
+endfunction
+
function! ale#engine#ResetExecutableCache() abort
let s:executable_cache_map = {}
endfunction
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 1ae1a4a1..03652ecf 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -30,7 +30,14 @@ function! ale#fix#ApplyQueuedFixes() abort
call winrestview(l:save)
endif
- call setline(1, l:data.output)
+ " If the file is in DOS mode, we have to remove carriage returns from
+ " the ends of lines before calling setline(), or we will see them
+ " twice.
+ let l:lines_to_set = getbufvar(l:buffer, '&fileformat') is# 'dos'
+ \ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')')
+ \ : l:data.output
+
+ call setline(1, l:lines_to_set)
if l:data.should_save
if empty(&buftype)
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index eb12f22d..76cce87f 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -145,6 +145,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['go'],
\ 'description': 'Fix Go files imports with goimports.',
\ },
+\ 'gomod': {
+\ 'function': 'ale#fixers#gomod#Fix',
+\ 'suggested_filetypes': ['gomod'],
+\ 'description': 'Fix Go module files with go mod edit -fmt.',
+\ },
\ 'tslint': {
\ 'function': 'ale#fixers#tslint#Fix',
\ 'suggested_filetypes': ['typescript'],
diff --git a/autoload/ale/fixers/gomod.vim b/autoload/ale/fixers/gomod.vim
new file mode 100644
index 00000000..68895f9b
--- /dev/null
+++ b/autoload/ale/fixers/gomod.vim
@@ -0,0 +1,10 @@
+call ale#Set('go_go_executable', 'go')
+
+function! ale#fixers#gomod#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'go_go_executable')
+
+ return {
+ \ 'command': ale#Escape(l:executable) . ' mod edit -fmt %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index 8fbad12f..a11c76bc 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -55,16 +55,29 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
endif
let l:thislist = ale#lsp#response#ReadTSServerDiagnostics(a:response)
+ let l:no_changes = 0
" tsserver sends syntax and semantic errors in separate messages, so we
" have to collect the messages separately for each buffer and join them
" back together again.
if a:error_type is# 'syntax'
+ if len(l:thislist) is 0 && len(get(l:info, 'syntax_loclist', [])) is 0
+ let l:no_changes = 1
+ endif
+
let l:info.syntax_loclist = l:thislist
else
+ if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0
+ let l:no_changes = 1
+ endif
+
let l:info.semantic_loclist = l:thislist
endif
+ if l:no_changes
+ return
+ endif
+
let l:loclist = get(l:info, 'semantic_loclist', [])
\ + get(l:info, 'syntax_loclist', [])
@@ -99,9 +112,10 @@ endfunction
function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
let l:method = get(a:response, 'method', '')
- let l:linter_name = get(s:lsp_linter_map, a:conn_id, '')
if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error')
+ let l:linter_name = get(s:lsp_linter_map, a:conn_id, '')
+
call s:HandleLSPErrorMessage(l:linter_name, a:response)
elseif l:method is# 'textDocument/publishDiagnostics'
call s:HandleLSPDiagnostics(a:conn_id, a:response)
diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index 1f963431..8d6bf1f0 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -1,6 +1,8 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Functions for integrating with Python linters.
+call ale#Set('python_auto_pipenv', '0')
+
let s:sep = has('win32') ? '\' : '/'
" bin is used for Unix virtualenv directories, and Scripts is for Windows.
let s:bin_dir = has('unix') ? 'bin' : 'Scripts'
@@ -107,3 +109,8 @@ function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort
return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
+
+" Detects whether a pipenv environment is present.
+function! ale#python#PipenvPresent(buffer) abort
+ return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# ''
+endfunction
diff --git a/autoload/ale/toggle.vim b/autoload/ale/toggle.vim
index 1d052b4f..8e642b3f 100644
--- a/autoload/ale/toggle.vim
+++ b/autoload/ale/toggle.vim
@@ -15,21 +15,6 @@ function! s:DisablePostamble() abort
endif
endfunction
-function! s:CleanupEveryBuffer() abort
- for l:key in keys(g:ale_buffer_info)
- " The key could be a filename or a buffer number, so try and
- " convert it to a number. We need a number for the other
- " functions.
- let l:buffer = str2nr(l:key)
-
- if l:buffer > 0
- " Stop all jobs and clear the results for everything, and delete
- " all of the data we stored for the buffer.
- call ale#engine#Cleanup(l:buffer)
- endif
- endfor
-endfunction
-
function! ale#toggle#Toggle() abort
let g:ale_enabled = !get(g:, 'ale_enabled')
@@ -40,7 +25,7 @@ function! ale#toggle#Toggle() abort
call ale#balloon#Enable()
endif
else
- call s:CleanupEveryBuffer()
+ call ale#engine#CleanupEveryBuffer()
call s:DisablePostamble()
if exists('*ale#balloon#Disable')
@@ -64,7 +49,7 @@ function! ale#toggle#Disable() abort
endfunction
function! ale#toggle#Reset() abort
- call s:CleanupEveryBuffer()
+ call ale#engine#CleanupEveryBuffer()
call ale#highlight#UpdateHighlights()
endfunction
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 58a2065e..e0491653 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -405,7 +405,7 @@ endfunction
" the buffer.
function! ale#util#Writefile(buffer, lines, filename) abort
let l:corrected_lines = getbufvar(a:buffer, '&fileformat') is# 'dos'
- \ ? map(copy(a:lines), 'v:val . "\r"')
+ \ ? map(copy(a:lines), 'substitute(v:val, ''\r*$'', ''\r'', '''')')
\ : a:lines
call writefile(l:corrected_lines, a:filename) " no-custom-checks