diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/assert.vim | 13 | ||||
-rw-r--r-- | autoload/ale/definition.vim | 2 | ||||
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/ocamlformat.vim | 18 | ||||
-rw-r--r-- | autoload/ale/java.vim | 20 | ||||
-rw-r--r-- | autoload/ale/lsp.vim | 1 | ||||
-rw-r--r-- | autoload/ale/ruby.vim | 22 |
7 files changed, 80 insertions, 1 deletions
diff --git a/autoload/ale/assert.vim b/autoload/ale/assert.vim index 87798520..a1bfd0b7 100644 --- a/autoload/ale/assert.vim +++ b/autoload/ale/assert.vim @@ -101,6 +101,14 @@ function! ale#assert#LSPProject(expected_root) abort AssertEqual a:expected_root, l:root endfunction +function! ale#assert#LSPAddress(expected_address) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:address = ale#util#GetFunction(l:linter.address_callback)(l:buffer) + + AssertEqual a:expected_address, l:address +endfunction + " A dummy function for making sure this module is loaded. function! ale#assert#SetUpLinterTest(filetype, name) abort " Set up a marker so ALE doesn't create real random temporary filenames. @@ -141,6 +149,7 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>) command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage(<args>) command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject(<args>) + command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress(<args>) endfunction function! ale#assert#TearDownLinterTest() abort @@ -171,6 +180,10 @@ function! ale#assert#TearDownLinterTest() abort delcommand AssertLSPProject endif + if exists(':AssertLSPAddress') + delcommand AssertLSPAddress + endif + if exists('g:dir') call ale#test#RestoreDirectory() endif diff --git a/autoload/ale/definition.vim b/autoload/ale/definition.vim index e68d279d..984a4f9d 100644 --- a/autoload/ale/definition.vim +++ b/autoload/ale/definition.vim @@ -49,7 +49,7 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort for l:item in l:result let l:filename = ale#path#FromURI(l:item.uri) let l:line = l:item.range.start.line + 1 - let l:column = l:item.range.start.character + let l:column = l:item.range.start.character + 1 call ale#util#Open(l:filename, l:line, l:column, l:options) break diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 7e9900b1..1ca54a86 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -180,6 +180,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Refactor Haskell files with stylish-haskell.', \ }, +\ 'ocamlformat': { +\ 'function': 'ale#fixers#ocamlformat#Fix', +\ 'suggested_filetypes': ['ocaml'], +\ 'description': 'Fix OCaml files with ocamlformat.', +\ }, \ 'refmt': { \ 'function': 'ale#fixers#refmt#Fix', \ 'suggested_filetypes': ['reason'], diff --git a/autoload/ale/fixers/ocamlformat.vim b/autoload/ale/fixers/ocamlformat.vim new file mode 100644 index 00000000..fac142aa --- /dev/null +++ b/autoload/ale/fixers/ocamlformat.vim @@ -0,0 +1,18 @@ +" Author: Stephen Lumenta <@sbl> +" Description: Integration of ocamlformat with ALE. + +call ale#Set('ocaml_ocamlformat_executable', 'ocamlformat') +call ale#Set('ocaml_ocamlformat_options', '') + +function! ale#fixers#ocamlformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ocaml_ocamlformat_executable') + let l:options = ale#Var(a:buffer, 'ocaml_ocamlformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --inplace' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/java.vim b/autoload/ale/java.vim new file mode 100644 index 00000000..b7fd10bd --- /dev/null +++ b/autoload/ale/java.vim @@ -0,0 +1,20 @@ +" Author: Horacio Sanson https://github.com/hsanson +" Description: Functions for integrating with Java tools + +" Find the nearest dir contining a gradle or pom file and asume it +" the root of a java app. +function! ale#java#FindProjectRoot(buffer) abort + let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:gradle_root) + return l:gradle_root + endif + + let l:maven_pom_file = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:maven_pom_file) + return fnamemodify(l:maven_pom_file, ':h') + endif + + return '' +endfunction diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim index 7f99422a..dae45e70 100644 --- a/autoload/ale/lsp.vim +++ b/autoload/ale/lsp.vim @@ -24,6 +24,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort " capabilities_queue: The list of callbacks to call with capabilities. " capabilities: Features the server supports. let s:connections[l:conn_id] = { + \ 'id': l:conn_id, \ 'is_tsserver': 0, \ 'data': '', \ 'root': a:project, diff --git a/autoload/ale/ruby.vim b/autoload/ale/ruby.vim index b981ded6..f0d84296 100644 --- a/autoload/ale/ruby.vim +++ b/autoload/ale/ruby.vim @@ -20,3 +20,25 @@ function! ale#ruby#FindRailsRoot(buffer) abort return '' endfunction + +" Find the nearest dir containing a potential ruby project. +function! ale#ruby#FindProjectRoot(buffer) abort + let l:dir = ale#ruby#FindRailsRoot(a:buffer) + + if isdirectory(l:dir) + return l:dir + endif + + for l:name in ['Rakefile', 'Gemfile'] + let l:dir = fnamemodify( + \ ale#path#FindNearestFile(a:buffer, l:name), + \ ':h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + endfor + + return '' +endfunction |