-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ocamlinterface (mli), ocamllex (mll) and menhir (mly) filetypes #61
base: master
Are you sure you want to change the base?
Conversation
I've only done a short test of these changes, and there is still need for some improvements. The syntax highlighting of |
Sorry I didn't create the file(s), I tested it on neovim and highlighting was working as expected. |
Thanks, the highlighting of interface files is now working again. Another problem I've just run into is that syntax errors are not being highlighted anymore by Ale in interface files. I suppose it would require changes to some Vim-packages to fully support the proposed changes. I'm not sure how much work it would be to update other packages. I believe it could even be done before we merge these changes, which would otherwise cause problems for some people. If at all possible, maybe it would be best to allow tree-sitter to depend on flags other than the Vim filetype? This may allow you to add full OCaml support without breaking 3rd party Vim packages. |
I'll ask around the tree-sitter community, I'm not sure if that's possible (or wanted) I don't mind spending some effort making other plugins compatible to get this PR integrated. I think it's valuable to have a more accurate filetype for these different types of files. I've read people complaining about existing syntax problems for |
Sounds reasonable. It may be a good idea long term to have different filetypes for interface and implementation files as well as for other files that incorporate OCaml code. Since the proposed changes are conceivably intrusive, I should probably not be the only person to weigh in on that. Any other suggestions or opinions here on how to proceed? |
I do think this is the right way forward, since it also fixes several oddities that vim users come across every now and then:
I would suggest announcing this change ahead of time on discuss.ocaml.org and/or the mailing lists to make people aware of this breaking change and give some time for other plugins to merge support for the new filetypes. |
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
These are ocamlinterface, ocamllex and menhir. This is in preparation when these filetypes will be introduced in order to keep lsp working on them. The change is backwards compatible. For more information about the rationale of this change please read ocaml/vim-ocaml#61
These are ocamlinterface, ocamllex and menhir. This is in preparation when these filetypes will be introduced in order to keep lsp working on them. The change is backwards compatible. For more information about the rationale of this change please read ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. The filetypes are introduced by ocaml/vim-ocaml#61
cb21f61
to
c187037
Compare
FWIW neovim-lsp-config uses "ocaml.ocamllex" and "ocaml.menhir" and "ocaml.interface". |
It's correct, that mapping is needed to translate between the vim filetype (key) and the filetype reported by LSP (the value) |
@undu is this PR ready for review? |
The merlin PR should be reviewed first: ocaml/merlin#1340 Please do test the branch and let me know if you find anything broken |
I have tested this with NeoVim v0.6.1 and the new filetype detection didn't take effect (when vim-ocaml is used as a plugin). That is because Changing ocamlinterface.vim to this makes it detect the new filetype though:
I haven't tested NeoVim 0.7 yet which adds a filetype.lua (and changes how filetypes are detected instead of having N autocommands for each filetype it has one autocommand that triggers on all BufNewFile,BufRead and then checks the extension there and decides, this mode is not yet active by default though). Overriding the filetype should in theory work with both approaches. OCamllex and menhir I can't really test yet:
Prior to this PR I did get some highlighting for both .mll and .mly but it was often slightly wrong. More information on how filetype works in Neovim is available here: https://neovim.io/doc/user/filetype.html#new-filetype, and for Vim here http://vimdoc.sourceforge.net/htmldoc/filetype.html#new-filetype |
Now ocamlinterface ocamllex and menhir types must be taken into account as well. Menhir filetype is not included as there seem to be no plans to include it and even then it would take a big effort. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. Menhir filetype is not included as there seem to be no plans to include it and even then it would take a big effort. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. Menhir filetype is not included as there seem to be no plans to include it and even then it would take a big effort. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. Menhir filetype is not included as there seem to be no plans to include it and even then it would take a big effort. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. Menhir filetype is not included as there seem to be no plans to include it and even then it would take a big effort. The filetypes are introduced by ocaml/vim-ocaml#61
Now ocamlinterface ocamllex and menhir types must be taken into account as well. Menhir filetype is not included as there seem to be no plans to include it and even then it would take a big effort. The filetypes are introduced by ocaml/vim-ocaml#61
This is needed for supporting the tree-sitter parsers in ocaml because the interface parser is different from the implementation one one.
c187037
to
e9b95e0
Compare
Some ocaml extensions share the same vim filetype. This is an issue when trying to enable structural highlighting using the official ocaml tree-sitter parsers: https://github.com/tree-sitter/tree-sitter-ocaml on neovim.
In tree-sitter-ocaml there are two parsers, oner for implementation files and another for interfaces. Initially there was a single, shared one but this caused conflicts in the grammar, so it was split. The current situation makes the nvim-plugin to interpret all
ocaml
files as implementation files, having a separate filetype for interfaces solves the issue.This PR adds the new filetype and at the same time tries to maintain previous behaviour, so only external plugins and scripts depending on the
ocaml
filetype would be affected.The change breaks current vim plugins that only expect a single filetype for all those kind of files, this includes ocaml/merlin, for example.
The plan to have a smooth transition is:
The same situation happens with ocamllex files. And although there's not a tree-sitter syntax for ocamlyacc/menhir, I've split it to the
menhir
filetype to avoid merlin from parsing them.