ocaml.nvim provides direct access to advanced ocamllsp features without
requiring complex editor-side logic.
ocaml.nvim aims to offer a fast, simple, and modular workflow in Neovim.
This plugin gives access to all the advanced Merlin commands not supported by
generic LSP clients, such as Construct, alternate between .mli and .ml
files, etc.
Add the plugin to your lazy.nvim setup:
require("lazy").setup({
{ "tarides/ocaml.nvim",
config = function()
require("ocaml").setup()
end
}
})Here is the list of commands offered by ocaml.nvim and their key binding.
All of the commands are detailed and illustrated in the following sections.
Important
This section only covers features specific to ocaml.nvim.
However, the builtin LSP of Neovim already provides standards commands such as
go-to-definition and hover documentation.
| Command | Default Binding | Available | Tests | Description |
|---|---|---|---|---|
OCamlJumpPrevHole |
-- | ✅ | ✅ | Jump to the previous hole. |
OCamlJumpNextHole |
-- | ✅ | ✅ | Jump to the next hole. |
OCamlConstruct |
-- | ✅ | ✅ | Open up a list of valid substitutions to fill the hole. |
OCamlJump |
-- | ✅ | ❌ | Jumps to the referenced expression. |
OCamlPhraseNext |
-- | ✅ | ❌ | Jump to the beginnning of the previous phrase. |
OCamlPhrasePrev |
-- | ✅ | ❌ | Jump to the beginning of the next phrase. |
OCamlInferIntf |
-- | ✅ | ❌ | Infer the interface for the current implementation file. |
OCamlAlternateFile |
-- | ✅ | ❌ | Switch from the implementation file to the interface file and vice versa. |
OCamlFindIdentifierDefinition |
-- | ✅ | ❌ | -- |
OCamlFindIdentifierDeclaration |
-- | ✅ | ❌ | -- |
OCamlDocumentIdentifier |
-- | ✅ | ❌ | Enables you to enter an identifier (present in the environment) and return its documentation. |
OCamlErrorNext |
-- | ❌ | ❌ | Jump to the next error. |
OCamlErrorPrev |
-- | ❌ | ❌ | Jump to the previous error. |
OCamlFindDefinition |
-- | ❌ | ❌ | Jump to definition (the implementation). |
OCamlFindDefinitionInNewWindow |
-- | ❌ | ❌ | -- |
OCamlFindDefinitionInCurrentWindow |
-- | ❌ | ❌ | -- |
OCamlFindDeclaration |
-- | ❌ | ❌ | Jump to declaration (the signature). |
OCamlFindDeclarationInNewWindow |
-- | ❌ | ❌ | -- |
OCamlFindDefinitionInCurrentWindow |
-- | ❌ | ❌ | -- |
OCamlFindTypeDefinition |
-- | ❌ | ❌ | Jump to the type definition of the expression. |
OCamlFindTypeDefinitionInNewWindow |
-- | ❌ | ❌ | -- |
OCamlFindTypeDefinitionInCurrentWindow |
-- | ❌ | ❌ | -- |
OCamlSearch |
-- | ❌ | ❌ | Searches for a value by its type or polarity to included in the current buffer. |
OCamlSearchDefinition |
-- | ❌ | ❌ | Searches for a value definition by its type or polarity. |
OCamlSearchDefinitionInNewWindow |
-- | ❌ | ❌ | -- |
OCamlSearchDefinitionInCurrentWindow |
-- | ❌ | ❌ | -- |
OCamlSearchDeclaration |
-- | ❌ | ❌ | Searches for a value declaration by its type or polarity. |
OCamlSearchDeclarationInNewWindow |
-- | ❌ | ❌ | -- |
OCamlSearchDeclarationInCurrentWindow |
-- | ❌ | ❌ | -- |
OCamlDocument |
-- | ❌ | ❌ | Documents the expression below the cursor. |
OCamlDestruct |
-- | ❌ | ❌ | Allows you to generate and manipulate pattern matching expressions. |
OCamlTypeExpression |
-- | ❌ | ❌ | -- |
OCamlTypeEnclosing |
-- | ❌ | ❌ | Display the type of the selection and start a "type enclosing" session. |
OCamlOccurences |
-- | ❌ | ❌ | Returns all occurrences of the identifier under the cursor. |
OCamlRename |
-- | ❌ | ❌ | Rename the symbol under the cursor. |
Enables you to navigate between typed-holes (_) in a document and
interactively substitute them:
OCamlJumpPrevHole: jump to the next holeOCamlJumpNextHole: jump to the previous holeOCamlConstruct: open up a list of valid substitutions to fill the hole
Allows you to navigate semantically in a buffer, passing from an expression to
the parent let, the parent module, the parent fun and the parent match expression.
It is also possible to navigate between pattern matching cases:
OCamlJump: jumps to the referenced expression
OCamlPhrasePrev: jump to the beginning of the previous phraseOCamlPhraseNext: jump to the beginning of the next phrase
Used to infer the type of an interface file. If the buffer is not empty, a prompt will ask for confirmation to overwrite the buffer contents.
Quickly switch from the implementation file to the interface file and vice versa. If the interface file does not exist, a prompt can be used to generate it.
It is possible to directly enter the name of an identifier (definition or declaration) using the following commands.
OCamlFindIdentifierDefinitionOCamlFindIdentifierDeclaration
It is possible to get the document of the identifier given in the argument.
OCamlDocumentIdentifier
SearchDeclarationsearches for a value by its type or polarity and jump to its declarationSearchDefinitionsearches for a value by its type or polarity and jump to its definition







