-
Notifications
You must be signed in to change notification settings - Fork 381
Update installation instruction for 'ocaml.nvim. #3421
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
| ## Emacs | ||
|
|
||
| Using Emacs to work with OCaml requires at least two modes: | ||
|
|
@@ -73,7 +73,7 @@ | |
| :mode (("\\.ocamlinit\\'" . tuareg-mode))) | ||
| ``` | ||
|
|
||
|
|
||
|
Check failure on line 76 in data/tutorials/getting-started/2_00_editor_setup.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). | ||
|
|
@@ -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
|
||
| #### 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: | ||
|
|
@@ -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
|
||
| ## Vim | ||
|
|
||
| For Vim, we won't use the LSP server but rather directly talk to Merlin. | ||
|
|
@@ -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
|
||
|
|
||
|  | ||
|
|
||
|
|
@@ -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 | ||
|
|
@@ -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
|
||
|
|
||
| Add this to your toplevel `init.lua`. | ||
| ```lua | ||
| vim.lsp.config['ocamllsp'] = { | ||
| cmd = { 'ocamllsp' }, | ||
| filetypes = { | ||
| filetypes = { | ||
| 'ocaml', | ||
| 'ocaml.interface', | ||
| 'ocaml.menhir', | ||
|
|
@@ -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. | ||
|
|
||
|
|
@@ -235,7 +239,7 @@ | |
| vim.lsp.enable 'ocamllsp' | ||
| ``` | ||
|
|
||
| ### Using nvim-lspconfig | ||
| #### Using nvim-lspconfig | ||
|
|
||
| Add this to your `nvim-lspconfig` setup. | ||
| ```lua | ||
|
|
@@ -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
|
||
|
|
||
|
|
||
|
Check failure on line 259 in data/tutorials/getting-started/2_00_editor_setup.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. | ||
| ```lua | ||
| require("lazy").setup({ | ||
| {"tarides/ocaml.nvim", | ||
| config = function() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.nviminstallation. 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).There was a problem hiding this comment.
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.