From 74dc3c3fdb37ab5b0016d820a69e65d1650e660c Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Thu, 10 Sep 2020 13:16:12 +0100 Subject: [PATCH 1/4] feature: create ocamlinterface filetype for mli files This is needed for supporting the tree-sitter parsers in ocaml because the interface parser is different from the implementation one one. --- README.md | 2 +- ftdetect/ocaml.vim | 2 +- ftdetect/ocamlinterface.vim | 1 + ftplugin/ocamlinterface.vim | 12 ++++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 ftdetect/ocamlinterface.vim create mode 100644 ftplugin/ocamlinterface.vim diff --git a/README.md b/README.md index d207a5c..077c334 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ NeoBundleInstall ocaml/vim-ocaml' " or use NeoBundleLazy NeoBundleLazy 'rgrinberg/vim-ocaml', {'autoload' : {'filetypes' : - \ ['ocaml', 'dune', 'opam', 'oasis', 'omake', 'ocamlbuild_tags', 'sexplib']}} + \ ['ocaml', 'ocamlinterface', 'dune', 'opam', 'oasis', 'omake', 'ocamlbuild_tags', 'sexplib']}} ``` ## History diff --git a/ftdetect/ocaml.vim b/ftdetect/ocaml.vim index ecb8f43..a043d86 100644 --- a/ftdetect/ocaml.vim +++ b/ftdetect/ocaml.vim @@ -1 +1 @@ -au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit,*.mlt,*.mlp,*.mlip,*.mli.cppo,*.ml.cppo setf ocaml +au BufNewFile,BufRead *.ml,*.mll,*.mly,.ocamlinit,*.mlt,*.mlp,*.ml.cppo setf ocaml diff --git a/ftdetect/ocamlinterface.vim b/ftdetect/ocamlinterface.vim new file mode 100644 index 0000000..d67c48d --- /dev/null +++ b/ftdetect/ocamlinterface.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.mli,*.mlip,*.mli.cppo setf ocamlinterface diff --git a/ftplugin/ocamlinterface.vim b/ftplugin/ocamlinterface.vim new file mode 100644 index 0000000..d7e2ae0 --- /dev/null +++ b/ftplugin/ocamlinterface.vim @@ -0,0 +1,12 @@ +" Language: OCaml Interface +" Maintainer: vim-ocaml maintainers +" URL: http://www.github.com/ocaml/vim-ocaml + +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/ocaml.vim +runtime! ftplugin/ocaml_*.vim ftplugin/ocaml/*.vim + +" vim:sw=2 fdm=indent From e176dbcb9739f3bcadabbfd66cf10c42f96a0e5d Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Mon, 28 Sep 2020 21:07:09 +0100 Subject: [PATCH 2/4] feature: create ocamllex filetype for mll files --- README.md | 2 +- ftdetect/ocaml.vim | 2 +- ftdetect/ocamllex.vim | 1 + ftplugin/ocamllex.vim | 12 ++++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 ftdetect/ocamllex.vim create mode 100644 ftplugin/ocamllex.vim diff --git a/README.md b/README.md index 077c334..ecb3512 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ NeoBundleInstall ocaml/vim-ocaml' " or use NeoBundleLazy NeoBundleLazy 'rgrinberg/vim-ocaml', {'autoload' : {'filetypes' : - \ ['ocaml', 'ocamlinterface', 'dune', 'opam', 'oasis', 'omake', 'ocamlbuild_tags', 'sexplib']}} + \ ['ocaml', 'ocamlinterface', 'ocamllex', 'dune', 'opam', 'oasis', 'omake', 'ocamlbuild_tags', 'sexplib']}} ``` ## History diff --git a/ftdetect/ocaml.vim b/ftdetect/ocaml.vim index a043d86..002f6f0 100644 --- a/ftdetect/ocaml.vim +++ b/ftdetect/ocaml.vim @@ -1 +1 @@ -au BufNewFile,BufRead *.ml,*.mll,*.mly,.ocamlinit,*.mlt,*.mlp,*.ml.cppo setf ocaml +au BufNewFile,BufRead *.ml,*.mly,.ocamlinit,*.mlt,*.mlp,*.ml.cppo setf ocaml diff --git a/ftdetect/ocamllex.vim b/ftdetect/ocamllex.vim new file mode 100644 index 0000000..cf35fd2 --- /dev/null +++ b/ftdetect/ocamllex.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.mll setf ocamllex diff --git a/ftplugin/ocamllex.vim b/ftplugin/ocamllex.vim new file mode 100644 index 0000000..f6b12f9 --- /dev/null +++ b/ftplugin/ocamllex.vim @@ -0,0 +1,12 @@ +" Language: OCamlLex +" Maintainer: vim-ocaml maintainers +" URL: http://www.github.com/ocaml/vim-ocaml + +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/ocaml.vim +runtime! ftplugin/ocaml_*.vim ftplugin/ocaml/*.vim + +" vim:sw=2 fdm=indent From c187037e3ff5ee0c08f6917cee23ee1f47a5d7c8 Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Sat, 10 Oct 2020 19:38:53 +0100 Subject: [PATCH 3/4] feature: create menhir filetype for mly files --- README.md | 5 +++-- ftdetect/menhir.vim | 1 + ftdetect/ocaml.vim | 2 +- ftplugin/menhir.vim | 12 ++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ftdetect/menhir.vim create mode 100644 ftplugin/menhir.vim diff --git a/README.md b/README.md index ecb3512..9d34e83 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,9 @@ Plugin 'ocaml/vim-ocaml' NeoBundleInstall ocaml/vim-ocaml' " or use NeoBundleLazy -NeoBundleLazy 'rgrinberg/vim-ocaml', {'autoload' : {'filetypes' : - \ ['ocaml', 'ocamlinterface', 'ocamllex', 'dune', 'opam', 'oasis', 'omake', 'ocamlbuild_tags', 'sexplib']}} +NeoBundleLazy 'ocaml/vim-ocaml', {'autoload' : {'filetypes' : [ + \ 'ocaml', 'ocamlinterface', 'ocamllex', 'menhir', 'dune', 'opam', + \ 'oasis', 'omake', 'ocamlbuild_tags', 'sexplib']}} ``` ## History diff --git a/ftdetect/menhir.vim b/ftdetect/menhir.vim new file mode 100644 index 0000000..46f5a1c --- /dev/null +++ b/ftdetect/menhir.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.mly setf menhir diff --git a/ftdetect/ocaml.vim b/ftdetect/ocaml.vim index 002f6f0..e7c9490 100644 --- a/ftdetect/ocaml.vim +++ b/ftdetect/ocaml.vim @@ -1 +1 @@ -au BufNewFile,BufRead *.ml,*.mly,.ocamlinit,*.mlt,*.mlp,*.ml.cppo setf ocaml +au BufNewFile,BufRead *.ml,.ocamlinit,*.mlt,*.mlp,*.ml.cppo setf ocaml diff --git a/ftplugin/menhir.vim b/ftplugin/menhir.vim new file mode 100644 index 0000000..e1b9e8f --- /dev/null +++ b/ftplugin/menhir.vim @@ -0,0 +1,12 @@ +" Language: Menhir +" Maintainer: vim-ocaml maintainers +" URL: http://www.github.com/ocaml/vim-ocaml + +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/ocaml.vim +runtime! ftplugin/ocaml_*.vim ftplugin/ocaml/*.vim + +" vim:sw=2 fdm=indent From 0302ed5ab6e4e3a0003ba41cfc9d39d677dc280a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 8 May 2022 00:08:22 +0100 Subject: [PATCH 4/4] Override filetypes that already exist in filetype.vim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some OCaml filetypes already exist in NeoVim's filetype.vim/filetype.lua. `setf` only sets the filetype if it is not already set. Because filetype.vim already set the filetype for *.mli/*.mll/*.mly and is loaded before this ftdetect plugin we have to override it using `set ft`. This is 'solution A' from https://neovim.io/doc/user/filetype.html#new-filetype The other filetypes are either new, or match what is already declared in filetype.vim so no need for overrides there. Signed-off-by: Edwin Török --- ftdetect/menhir.vim | 2 +- ftdetect/ocamlinterface.vim | 2 +- ftdetect/ocamllex.vim | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ftdetect/menhir.vim b/ftdetect/menhir.vim index 46f5a1c..8e1aff9 100644 --- a/ftdetect/menhir.vim +++ b/ftdetect/menhir.vim @@ -1 +1 @@ -au BufNewFile,BufRead *.mly setf menhir +au BufNewFile,BufRead *.mly set ft=menhir diff --git a/ftdetect/ocamlinterface.vim b/ftdetect/ocamlinterface.vim index d67c48d..488137e 100644 --- a/ftdetect/ocamlinterface.vim +++ b/ftdetect/ocamlinterface.vim @@ -1 +1 @@ -au BufNewFile,BufRead *.mli,*.mlip,*.mli.cppo setf ocamlinterface +au BufNewFile,BufRead *.mli,*.mlip,*.mli.cppo set ft=ocamlinterface diff --git a/ftdetect/ocamllex.vim b/ftdetect/ocamllex.vim index cf35fd2..dbf0ed4 100644 --- a/ftdetect/ocamllex.vim +++ b/ftdetect/ocamllex.vim @@ -1 +1 @@ -au BufNewFile,BufRead *.mll setf ocamllex +au BufNewFile,BufRead *.mll set ft=ocamllex