mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-21 09:08:34 +08:00
ocaml: prepare for filetype separation (#3732)
The ocaml filetype is currently used for several, different file formats. This causes problems as not all tools support all formats. New filetypes are introduced to support this separation, this needs some changes in ale that are fortunately backwards-compatible. These change add ocamlinterface file support for ocp-indent, merlin, ocamlformat and ocaml-lsp. For ocaml-lsp I took the liberty to add all recognised language ids, even if they are not supported. ols has not been changed as the project has been abandoned since 2019.
This commit is contained in:
@@ -303,12 +303,12 @@ let s:default_registry = {
|
||||
\ },
|
||||
\ 'ocamlformat': {
|
||||
\ 'function': 'ale#fixers#ocamlformat#Fix',
|
||||
\ 'suggested_filetypes': ['ocaml'],
|
||||
\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'],
|
||||
\ 'description': 'Fix OCaml files with ocamlformat.',
|
||||
\ },
|
||||
\ 'ocp-indent': {
|
||||
\ 'function': 'ale#fixers#ocp_indent#Fix',
|
||||
\ 'suggested_filetypes': ['ocaml'],
|
||||
\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'],
|
||||
\ 'description': 'Fix OCaml files with ocp-indent.',
|
||||
\ },
|
||||
\ 'refmt': {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
" Author: Risto Stevcev <me@risto.codes>
|
||||
" Description: Handlers for the official OCaml language server
|
||||
|
||||
let s:language_id_of_filetype = {
|
||||
\ 'menhir': 'ocaml.menhir',
|
||||
\ 'ocaml': 'ocaml',
|
||||
\ 'ocamlinterface': 'ocaml.interface',
|
||||
\ 'ocamllex': 'ocaml.lex'
|
||||
\}
|
||||
|
||||
function! ale#handlers#ocamllsp#GetExecutable(buffer) abort
|
||||
return 'ocamllsp'
|
||||
endfunction
|
||||
@@ -13,7 +20,7 @@ function! ale#handlers#ocamllsp#GetCommand(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#ocamllsp#GetLanguage(buffer) abort
|
||||
return getbufvar(a:buffer, '&filetype')
|
||||
return s:language_id_of_filetype[getbufvar(a:buffer, '&filetype')]
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#ocamllsp#GetProjectRoot(buffer) abort
|
||||
|
||||
Reference in New Issue
Block a user