summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/c.vim1
-rw-r--r--autoload/ale/dhall.vim24
-rw-r--r--autoload/ale/fix/registry.vim30
-rw-r--r--autoload/ale/fixers/dhall.vim23
-rw-r--r--autoload/ale/fixers/dhall_format.vim14
-rw-r--r--autoload/ale/fixers/dhall_freeze.vim18
-rw-r--r--autoload/ale/fixers/dhall_lint.vim14
-rw-r--r--autoload/ale/lsp_linter.vim13
8 files changed, 106 insertions, 31 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index cff53125..c7b1e20a 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -152,6 +152,7 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort
\ || stridx(l:option, '-idirafter') == 0
\ || stridx(l:option, '-iframework') == 0
\ || stridx(l:option, '-include') == 0
+ \ || stridx(l:option, '-imacros') == 0
if stridx(l:option, '-I') == 0 && l:option isnot# '-I'
let l:arg = join(split(l:option, '\zs')[2:], '')
let l:option = '-I'
diff --git a/autoload/ale/dhall.vim b/autoload/ale/dhall.vim
new file mode 100644
index 00000000..cc54418f
--- /dev/null
+++ b/autoload/ale/dhall.vim
@@ -0,0 +1,24 @@
+" Author: Pat Brisbin <pbrisbin@gmail.com>, toastal <toastal@protonmail.com>
+" Description: Functions for working with Dhall’s executable
+
+call ale#Set('dhall_executable', 'dhall')
+call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('dhall_options', '')
+
+function! ale#dhall#GetExecutable(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'dhall_executable')
+
+ " Dhall is written in Haskell and commonly installed with Stack
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall')
+endfunction
+
+function! ale#dhall#GetExecutableWithOptions(buffer) abort
+ let l:executable = ale#dhall#GetExecutable(a:buffer)
+
+ return l:executable
+ \ . ale#Pad(ale#Var(a:buffer, 'dhall_options'))
+endfunction
+
+function! ale#dhall#GetCommand(buffer) abort
+ return '%e ' . ale#Pad(ale#Var(a:buffer, 'dhall_options'))
+endfunction
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 47f978e8..f514466e 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -37,6 +37,27 @@ let s:default_registry = {
\ 'suggested_filetypes': ['d'],
\ 'description': 'Fix D files with dfmt.',
\ },
+\ 'dhall': {
+\ 'function': 'ale#fixers#dhall#Fix',
+\ 'suggested_filetypes': ['dhall'],
+\ 'description': 'Fix Dhall files with dhall-format.',
+\ },
+\ 'dhall-format': {
+\ 'function': 'ale#fixers#dhall_format#Fix',
+\ 'suggested_filetypes': ['dhall'],
+\ 'description': 'Standard code formatter for the Dhall language',
+\ 'aliases': ['dhall'],
+\ },
+\ 'dhall-freeze': {
+\ 'function': 'ale#fixers#dhall_freeze#Freeze',
+\ 'suggested_filetypes': ['dhall'],
+\ 'description': 'Add integrity checks to remote import statements of an expression for the Dhall language',
+\ },
+\ 'dhall-lint': {
+\ 'function': 'ale#fixers#dhall_lint#Fix',
+\ 'suggested_filetypes': ['dhall'],
+\ 'description': 'Standard code formatter for the Dhall language and removing dead code',
+\ },
\ 'fecs': {
\ 'function': 'ale#fixers#fecs#Fix',
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
@@ -342,7 +363,7 @@ let s:default_registry = {
\ },
\ 'ktlint': {
\ 'function': 'ale#fixers#ktlint#Fix',
-\ 'suggested_filetypes': ['kt'],
+\ 'suggested_filetypes': ['kt', 'kotlin'],
\ 'description': 'Fix Kotlin files with ktlint.',
\ },
\ 'styler': {
@@ -390,16 +411,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['lua'],
\ 'description': 'Fix Lua files with luafmt.',
\ },
-\ 'dhall': {
-\ 'function': 'ale#fixers#dhall#Fix',
-\ 'suggested_filetypes': ['dhall'],
-\ 'description': 'Fix Dhall files with dhall-format.',
-\ },
\ 'ormolu': {
\ 'function': 'ale#fixers#ormolu#Fix',
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'A formatter for Haskell source code.',
-\ },
+\ }
\}
" Reset the function registry to the default entries.
diff --git a/autoload/ale/fixers/dhall.vim b/autoload/ale/fixers/dhall.vim
deleted file mode 100644
index 18f6006c..00000000
--- a/autoload/ale/fixers/dhall.vim
+++ /dev/null
@@ -1,23 +0,0 @@
-" Author: Pat Brisbin <pbrisbin@gmail.com>
-" Description: Integration of dhall-format with ALE.
-
-call ale#Set('dhall_format_executable', 'dhall')
-
-function! ale#fixers#dhall#GetExecutable(buffer) abort
- let l:executable = ale#Var(a:buffer, 'dhall_format_executable')
-
- " Dhall is written in Haskell and commonly installed with Stack
- return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall')
-endfunction
-
-function! ale#fixers#dhall#Fix(buffer) abort
- let l:executable = ale#fixers#dhall#GetExecutable(a:buffer)
-
- return {
- \ 'command': l:executable
- \ . ' format'
- \ . ' --inplace'
- \ . ' %t',
- \ 'read_temporary_file': 1,
- \}
-endfunction
diff --git a/autoload/ale/fixers/dhall_format.vim b/autoload/ale/fixers/dhall_format.vim
new file mode 100644
index 00000000..d4021983
--- /dev/null
+++ b/autoload/ale/fixers/dhall_format.vim
@@ -0,0 +1,14 @@
+" Author: toastal <toastal@protonmail.com>
+" Description: Dhall’s built-in formatter
+"
+function! ale#fixers#dhall_format#Fix(buffer) abort
+ let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
+ let l:command = l:executable
+ \ . ' format'
+ \ . ' --inplace %t'
+
+ return {
+ \ 'command': l:command,
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/fixers/dhall_freeze.vim b/autoload/ale/fixers/dhall_freeze.vim
new file mode 100644
index 00000000..74ae7530
--- /dev/null
+++ b/autoload/ale/fixers/dhall_freeze.vim
@@ -0,0 +1,18 @@
+" Author: toastal <toastal@protonmail.com>
+" Description: Dhall’s package freezing
+
+call ale#Set('dhall_freeze_options', '')
+
+function! ale#fixers#dhall_freeze#Freeze(buffer) abort
+ let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
+ let l:command = l:executable
+ \ . ' freeze'
+ \ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options'))
+ \ . ' --inplace %t'
+
+
+ return {
+ \ 'command': l:command,
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/fixers/dhall_lint.vim b/autoload/ale/fixers/dhall_lint.vim
new file mode 100644
index 00000000..2abbe6f7
--- /dev/null
+++ b/autoload/ale/fixers/dhall_lint.vim
@@ -0,0 +1,14 @@
+" Author: toastal <toastal@protonmail.com>
+" Description: Dhall’s built-in linter/formatter
+
+function! ale#fixers#dhall_lint#Fix(buffer) abort
+ let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
+ let l:command = l:executable
+ \ . ' lint'
+ \ . ' --inplace %t'
+
+ return {
+ \ 'command': l:command,
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim
index dcd76e8f..628dde78 100644
--- a/autoload/ale/lsp_linter.vim
+++ b/autoload/ale/lsp_linter.vim
@@ -85,12 +85,18 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
endif
let l:info.syntax_loclist = l:thislist
- else
+ elseif a:error_type is# 'semantic'
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
+ else
+ if len(l:thislist) is 0 && len(get(l:info, 'suggestion_loclist', [])) is 0
+ let l:no_changes = 1
+ endif
+
+ let l:info.suggestion_loclist = l:thislist
endif
if l:no_changes
@@ -98,6 +104,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort
endif
let l:loclist = get(l:info, 'semantic_loclist', [])
+ \ + get(l:info, 'suggestion_loclist', [])
\ + get(l:info, 'syntax_loclist', [])
call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0)
@@ -150,6 +157,10 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort
elseif get(a:response, 'type', '') is# 'event'
\&& get(a:response, 'event', '') is# 'syntaxDiag'
call s:HandleTSServerDiagnostics(a:response, 'syntax')
+ elseif get(a:response, 'type', '') is# 'event'
+ \&& get(a:response, 'event', '') is# 'suggestionDiag'
+ \&& get(g:, 'ale_lsp_suggestions', '1') == 1
+ call s:HandleTSServerDiagnostics(a:response, 'suggestion')
endif
endfunction