summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/cursor.vim15
-rw-r--r--autoload/ale/d.vim16
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/google_java_format.vim10
-rw-r--r--autoload/ale/fixers/jq.vim9
-rw-r--r--autoload/ale/fixers/terraform.vim17
-rw-r--r--autoload/ale/handlers/elixir.vim13
-rw-r--r--autoload/ale/handlers/haskell.vim10
-rw-r--r--autoload/ale/linter.vim8
-rw-r--r--autoload/ale/lsp/message.vim6
-rw-r--r--autoload/ale/lsp_linter.vim6
-rw-r--r--autoload/ale/path.vim6
12 files changed, 113 insertions, 8 deletions
diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim
index c3b48ca3..32ce8c84 100644
--- a/autoload/ale/cursor.vim
+++ b/autoload/ale/cursor.vim
@@ -26,7 +26,20 @@ function! ale#cursor#TruncatedEcho(original_message) abort
" The message is truncated and saved to the history.
setlocal shortmess+=T
- exec "norm! :echomsg l:message\n"
+
+ try
+ exec "norm! :echomsg l:message\n"
+ catch /^Vim\%((\a\+)\)\=:E523/
+ " Fallback into manual truncate (#1987)
+ let l:winwidth = winwidth(0)
+
+ if l:winwidth < strdisplaywidth(l:message)
+ " Truncate message longer than window width with trailing '...'
+ let l:message = l:message[:l:winwidth - 4] . '...'
+ endif
+
+ exec 'echomsg l:message'
+ endtry
" Reset the cursor position if we moved off the end of the line.
" Using :norm and :echomsg can move the cursor off the end of the
diff --git a/autoload/ale/d.vim b/autoload/ale/d.vim
new file mode 100644
index 00000000..0e232203
--- /dev/null
+++ b/autoload/ale/d.vim
@@ -0,0 +1,16 @@
+" Author: Auri <me@aurieh.me>
+" Description: Functions for integrating with D linters.
+
+function! ale#d#FindDUBConfig(buffer) abort
+ " Find a DUB configuration file in ancestor paths.
+ " The most DUB-specific names will be tried first.
+ for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json']
+ let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename)
+
+ if !empty(l:dub_file)
+ return l:dub_file
+ endif
+ endfor
+
+ return ''
+endfunction
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 76cce87f..98f52232 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -250,6 +250,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['c', 'cpp', 'cs', 'objc', 'objcpp', 'd', 'java', 'p', 'vala' ],
\ 'description': 'Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.',
\ },
+\ 'terraform': {
+\ 'function': 'ale#fixers#terraform#Fix',
+\ 'suggested_filetypes': ['hcl', 'terraform'],
+\ 'description': 'Fix tf and hcl files with terraform fmt.',
+\ },
\}
" Reset the function registry to the default entries.
diff --git a/autoload/ale/fixers/google_java_format.vim b/autoload/ale/fixers/google_java_format.vim
index 6a2f5491..20086c73 100644
--- a/autoload/ale/fixers/google_java_format.vim
+++ b/autoload/ale/fixers/google_java_format.vim
@@ -1,13 +1,13 @@
" Author: butlerx <butlerx@notthe,cloud>
" Description: Integration of Google-java-format with ALE.
-call ale#Set('google_java_format_executable', 'google-java-format')
-call ale#Set('google_java_format_use_global', get(g:, 'ale_use_global_executables', 0))
-call ale#Set('google_java_format_options', '')
+call ale#Set('java_google_java_format_executable', 'google-java-format')
+call ale#Set('java_google_java_format_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('java_google_java_format_options', '')
function! ale#fixers#google_java_format#Fix(buffer) abort
- let l:options = ale#Var(a:buffer, 'google_java_format_options')
- let l:executable = ale#Var(a:buffer, 'google_java_format_executable')
+ let l:options = ale#Var(a:buffer, 'java_google_java_format_options')
+ let l:executable = ale#Var(a:buffer, 'java_google_java_format_executable')
if !executable(l:executable)
return 0
diff --git a/autoload/ale/fixers/jq.vim b/autoload/ale/fixers/jq.vim
index b0a43fe2..1b743e49 100644
--- a/autoload/ale/fixers/jq.vim
+++ b/autoload/ale/fixers/jq.vim
@@ -1,5 +1,6 @@
call ale#Set('json_jq_executable', 'jq')
call ale#Set('json_jq_options', '')
+call ale#Set('json_jq_filters', '.')
function! ale#fixers#jq#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'json_jq_executable')
@@ -7,9 +8,15 @@ endfunction
function! ale#fixers#jq#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'json_jq_options')
+ let l:filters = ale#Var(a:buffer, 'json_jq_filters')
+
+ if empty(l:filters)
+ return 0
+ endif
return {
\ 'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer))
- \ . ' . ' . l:options,
+ \ . ' ' . l:filters . ' '
+ \ . l:options,
\}
endfunction
diff --git a/autoload/ale/fixers/terraform.vim b/autoload/ale/fixers/terraform.vim
new file mode 100644
index 00000000..bc05380a
--- /dev/null
+++ b/autoload/ale/fixers/terraform.vim
@@ -0,0 +1,17 @@
+" Author: dsifford <dereksifford@gmail.com>
+" Description: Fixer for terraform and .hcl files
+
+call ale#Set('terraform_fmt_executable', 'terraform')
+call ale#Set('terraform_fmt_options', '')
+
+function! ale#fixers#terraform#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'terraform_fmt_executable')
+ let l:options = ale#Var(a:buffer, 'terraform_fmt_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . ' fmt'
+ \ . (empty(l:options) ? '' : ' ' . l:options)
+ \ . ' -'
+ \}
+endfunction
diff --git a/autoload/ale/handlers/elixir.vim b/autoload/ale/handlers/elixir.vim
new file mode 100644
index 00000000..91b75aac
--- /dev/null
+++ b/autoload/ale/handlers/elixir.vim
@@ -0,0 +1,13 @@
+" Author: Matteo Centenaro (bugant) - https://github.com/bugant
+"
+" Description: find the root directory for an elixir project that uses mix
+
+function! ale#handlers#elixir#FindMixProjectRoot(buffer) abort
+ let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs')
+
+ if !empty(l:mix_file)
+ return fnamemodify(l:mix_file, ':p:h')
+ endif
+
+ return '.'
+endfunction
diff --git a/autoload/ale/handlers/haskell.vim b/autoload/ale/handlers/haskell.vim
index 9223b650..9e495b36 100644
--- a/autoload/ale/handlers/haskell.vim
+++ b/autoload/ale/handlers/haskell.vim
@@ -1,5 +1,15 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Error handling for the format GHC outputs.
+"
+function! ale#handlers#haskell#GetStackExecutable(bufnr) abort
+ if ale#path#FindNearestFile(a:bufnr, 'stack.yaml') isnot# ''
+ return 'stack'
+ endif
+
+ " if there is no stack.yaml file, we don't use stack even if it exists,
+ " so we return '', because executable('') apparently always fails
+ return ''
+endfunction
" Remember the directory used for temporary files for Vim.
let s:temp_dir = fnamemodify(ale#util#Tempname(), ':h')
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 6c61e3db..7c1dc53e 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -256,6 +256,14 @@ function! ale#linter#PreProcess(filetype, linter) abort
elseif has_key(a:linter, 'initialization_options')
let l:obj.initialization_options = a:linter.initialization_options
endif
+
+ if has_key(a:linter, 'lsp_config')
+ if type(a:linter.lsp_config) isnot v:t_dict
+ throw '`lsp_config` must be a Dictionary'
+ endif
+
+ let l:obj.lsp_config = a:linter.lsp_config
+ endif
endif
let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout')
diff --git a/autoload/ale/lsp/message.vim b/autoload/ale/lsp/message.vim
index 9e05156d..9ed41ac4 100644
--- a/autoload/ale/lsp/message.vim
+++ b/autoload/ale/lsp/message.vim
@@ -138,3 +138,9 @@ function! ale#lsp#message#Hover(buffer, line, column) abort
\ 'position': {'line': a:line - 1, 'character': a:column},
\}]
endfunction
+
+function! ale#lsp#message#DidChangeConfiguration(buffer, config) abort
+ return [0, 'workspace/didChangeConfiguration', {
+ \ 'settings': a:config,
+ \}]
+endfunction
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index a11c76bc..55190483 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -190,6 +190,12 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort
let l:language_id = ale#util#GetFunction(a:linter.language_callback)(a:buffer)
+ if !empty(get(a:linter, 'lsp_config'))
+ " set LSP configuration options (workspace/didChangeConfiguration)
+ let l:config_message = ale#lsp#message#DidChangeConfiguration(a:buffer, a:linter.lsp_config)
+ call ale#lsp#Send(l:conn_id, l:config_message)
+ endif
+
let l:details = {
\ 'buffer': a:buffer,
\ 'connection_id': l:conn_id,
diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim
index 2d8a6ac7..89b119f4 100644
--- a/autoload/ale/path.vim
+++ b/autoload/ale/path.vim
@@ -65,7 +65,11 @@ endfunction
" Output 'cd <directory> && '
" This function can be used changing the directory for a linter command.
function! ale#path#CdString(directory) abort
- return 'cd ' . ale#Escape(a:directory) . ' && '
+ if has('win32')
+ return 'cd /d ' . ale#Escape(a:directory) . ' && '
+ else
+ return 'cd ' . ale#Escape(a:directory) . ' && '
+ endif
endfunction
" Output 'cd <buffer_filename_directory> && '