Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions data/tutorials/getting-started/2_00_editor_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
1. Go to `File` > `Preferences` > `Settings` view (or press `Ctrl ,`)
2. Select `User` > `Extensions` > `OCaml Platform`
3. Uncheck `OCaml: Use OCaml Env`. That's it!

Check failure on line 52 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

data/tutorials/getting-started/2_00_editor_setup.md:52:1 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 4] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md009.md
## Emacs

Using Emacs to work with OCaml requires at least two modes:
Expand All @@ -73,7 +73,7 @@
:mode (("\\.ocamlinit\\'" . tuareg-mode)))
```


Check failure on line 76 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Multiple consecutive blank lines

data/tutorials/getting-started/2_00_editor_setup.md:76 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md012.md
#### Melpa and `use-package`

If your version of Emacs does not support the `use-package` macro (or is not set up to take MELPA packages into account), please update it and follow these instructions to install [`use-package`](https://github.com/jwiegley/use-package) and [MELPA](https://melpa.org/#/getting-started).
Expand Down Expand Up @@ -110,7 +110,7 @@

OCaml-eglot can be finely configured, the project [README](https://github.com/tarides/ocaml-eglot/blob/main/README.md) gives several configuration paths to adapt perfectly to your workflow. You will also find there an exhaustive presentation of the different functions offered by the mode.


Check failure on line 113 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Multiple consecutive blank lines

data/tutorials/getting-started/2_00_editor_setup.md:113 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md012.md
#### Getting Type Information

Opening an OCaml file should launch an `ocaml-lsp` server, and you can convince yourself that it's working by using, for example, the `ocaml-eglot-type-enclosing` command (or using the `C-c C-t` binding) on an expression of your choice:
Expand All @@ -119,7 +119,7 @@

OCaml-eglot [README](https://github.com/tarides/ocaml-eglot/blob/main/README.md) provides a comprehensive overview of all the functions available in this mode!


Check failure on line 122 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Multiple consecutive blank lines

data/tutorials/getting-started/2_00_editor_setup.md:122 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md012.md
## Vim

For Vim, we won't use the LSP server but rather directly talk to Merlin.
Expand All @@ -136,7 +136,7 @@

### Talking to Merlin

#### Getting Type Information

Check failure on line 139 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Multiple headings with the same content

data/tutorials/getting-started/2_00_editor_setup.md:139 MD024/no-duplicate-heading Multiple headings with the same content [Context: "Getting Type Information"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md024.md

![Vim Type information](/media/tutorials/vim-type-info.gif)

Expand All @@ -148,9 +148,13 @@

## Neovim

Neovim comes with an LSP client.
Neovim comes with an LSP client for basic features, such as code navigation and diagnostics.
For the advanced Merlin features, you can also install the dedicated [`ocaml.nvim` plugin](https://github.com/tarides/ocaml.nvim).

One note here is that is that `ocaml-lsp-server` is sensitive to versioning, and often does not play well with the sometimes outdated sources in Mason, a popular package manager for language services. We recommend you install the LSP server directly in the switch, and pointing your Neovim config to use that.
### Installing and configuring the LSP

> [!NOTE]
> One note here is that is that `ocaml-lsp-server` is sensitive to versioning, and often does not play well with the sometimes outdated sources in Mason, a package manager for language services. We recommend you install the LSP server directly in the switch, and pointing your Neovim config to use that.

To install the LSP server and the formatter, run the following.
```shell
Expand All @@ -161,13 +165,13 @@
- A newer, more recommended way is to use the new Neovim LSP API for versions newer than v0.11.0 via `vim.lsp`.
- A more traditional way is to use `nvim-lspconfig`. For more info, `kickstart.nvim` has a great example setup.

### Using vim.lsp:
#### Using vim.lsp:

Check failure on line 168 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Trailing punctuation in heading

data/tutorials/getting-started/2_00_editor_setup.md:168:19 MD026/no-trailing-punctuation Trailing punctuation in heading [Punctuation: ':'] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md026.md

Add this to your toplevel `init.lua`.
```lua
vim.lsp.config['ocamllsp'] = {
cmd = { 'ocamllsp' },
filetypes = {
filetypes = {
'ocaml',
'ocaml.interface',
'ocaml.menhir',
Expand All @@ -188,7 +192,7 @@

See `:h lsp-config` for more detail on configuration options.

#### Using vim.lsp With runtimepath
##### Using vim.lsp With runtimepath

You can also move your LSP config to a separate file via `runtimepath` if you'd like to keep your `init.lua` minimal. Putting your config table inside `lsp/<some_name>.lua` or `after/lsp/<some_name>.lua` will allow Neovim to search for them automatically.

Expand Down Expand Up @@ -235,7 +239,7 @@
vim.lsp.enable 'ocamllsp'
```

### Using nvim-lspconfig
#### Using nvim-lspconfig

Add this to your `nvim-lspconfig` setup.
```lua
Expand All @@ -250,5 +254,30 @@
},
```

There is no need to pass more settings to `setup` because `nvim-lspconfig` provides reasonable defaults. See [here](https://github.com/neovim/nvim-lspconfig/blob/master/lsp/ocamllsp.lua) for more info.

Check failure on line 257 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Link text should be descriptive

data/tutorials/getting-started/2_00_editor_setup.md:257:111 MD059/descriptive-link-text Link text should be descriptive [Context: "[here]"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md059.md


Check failure on line 259 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Multiple consecutive blank lines

data/tutorials/getting-started/2_00_editor_setup.md:259 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md012.md
### Installing `ocaml.nvim`

You can install this plugin easily using [lazy.nvim](https://github.com/folke/lazy.nvim) by adding the following to your `ocaml.nvim` setup.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is everyone expected to use lazy.nvim ? If not we should also provide standalone installation instructions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The majority of existing Neovim plugins provide only installation instructions with lazy.nvim.
What do you think @maiste?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree most of the NeoVIM plugins I know tend to provide the lazy.nvim installation. I don't recall any plugin providing the standalone installation. The NeoVIM ecosystem is still maturing as NeoVIM is not yet stable. They are starting to provide a built-in package manager but it is not yet mature (maybe at some built it will be the default).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the new built-in plugin manager (inspired by mini) that's going to be the standard going forward. Generally, I think it's better to at least mention it as well.

```lua
require("lazy").setup({
{"tarides/ocaml.nvim",
config = function()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the simple instruction is:

require('lazy').setup({
  {"tarides/ocaml.nvim"},
  opts = {
    -- add your options here, or leave empty
    -- to use the default one
 },
})

require("ocaml").setup()
end
}
})
```

#### Features

This plugin adds the following features :
- Type enclosing: inspect types with adjustable scope and verbosity
- Holes handling: jump between holes and propose valid substitutions
- Code navigation: jump to expressions or phrases
- Interface management: switch or infer `.mli` files
- Identifier information: find definitions, declarations, documentation
- Type queries: search by type or polarity for definition or declaration

You will find the complete plugin documentation with a list of commands and key bindings in [the project's readme](https://github.com/tarides/ocaml.nvim).

Check failure on line 283 in data/tutorials/getting-started/2_00_editor_setup.md

View workflow job for this annotation

GitHub Actions / lint

Files should end with a single newline character

data/tutorials/getting-started/2_00_editor_setup.md:283:154 MD047/single-trailing-newline Files should end with a single newline character https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md047.md
Loading