Skip to content

tarides/ocaml.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocaml.nvim

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.

Installation using lazy.nvim

Add the plugin to your lazy.nvim setup:

require("lazy").setup({
  { "tarides/ocaml.nvim",
    config = function()
      require("ocaml").setup()
    end
  }
})

Features

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.

Construct expression

Enables you to navigate between typed-holes (_) in a document and interactively substitute them:

  • OCamlJumpPrevHole: jump to the next hole
  • OCamlJumpNextHole: jump to the previous hole
  • OCamlConstruct: open up a list of valid substitutions to fill the hole

Construct example

Source browsing

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

Jump example

  • OCamlPhrasePrev: jump to the beginning of the previous phrase
  • OCamlPhraseNext: jump to the beginning of the next phrase

Phrase example

Infer interface

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.

Infer example

Find alternate file

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.

Alternate file example

Find identifiers definition/declaration

It is possible to directly enter the name of an identifier (definition or declaration) using the following commands.

  • OCamlFindIdentifierDefinition
  • OCamlFindIdentifierDeclaration

Finds example

Get documentation

It is possible to get the document of the identifier given in the argument.

  • OCamlDocumentIdentifier

Documentation example

Search declaration/definition

  • SearchDeclaration searches for a value by its type or polarity and jump to its declaration
  • SearchDefinition searches for a value by its type or polarity and jump to its definition

Search example

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages