-
Notifications
You must be signed in to change notification settings - Fork 375
feat: add docs for neovim setup #3322
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -175,29 +175,30 @@ vim.lsp.config['ocamllsp'] = { | |
| vim.lsp.enable 'ocamllsp' | ||
| ``` | ||
|
|
||
| You can also use `vim.lsp` with a modular config. | ||
| See `:h lsp-config` for more detail on configuration options. | ||
|
|
||
| Assume that your config has the following structure. The internal structure of `lua` does not matter much. | ||
| ```text | ||
| . | ||
| ├── init.lua | ||
| └── lua | ||
| ├── custom | ||
| │ └── plugins | ||
| │ └── some-plugin.lua | ||
| └── kickstart | ||
| ├── health.lua | ||
| └── plugins | ||
| └── some-plugin.lua | ||
| ``` | ||
| #### Modular Config With Runtimepath | ||
|
|
||
| You can also use `vim.lsp` with a modular config via `runtimepath`. Putting your config table inside `lsp/<some_name>.lua` or `after/lsp/<some_name>.lua` will allow Neovim to search for them automatically. | ||
|
|
||
| See `:h runtimepath` for more detail. | ||
|
|
||
| Then run the following at the root of your config. | ||
| Run the following at the root of your config. | ||
| ```text | ||
| mkdir lsp | ||
| touch lsp/ocamllsp.lua | ||
| ``` | ||
|
|
||
| We now add our LSP configs to `lsp/ocamllsp.lua`... | ||
| Your Neovim config should have the following structure now. | ||
| ```text | ||
| . | ||
| ├── init.lua | ||
| ├── lsp | ||
| │ └── ocamllsp.lua | ||
| └── ... | ||
| ``` | ||
|
|
||
| Add your LSP config to `lsp/ocamllsp.lua`. | ||
| ```lua | ||
| return { | ||
| cmd = { 'ocamllsp' }, | ||
|
|
@@ -207,7 +208,7 @@ return { | |
| } | ||
| ``` | ||
|
|
||
| ...and import them in the toplevel `init.lua`. | ||
| Then enable them in the toplevel `init.lua`. | ||
|
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. another nit: Can we explain what
Not sure if we want to mention
Contributor
Author
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. I feel like this is a bit out of scope for the purpose of this doc. I think the curious readers will go out and research this further on their own.
Contributor
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. Maybe instead of calling 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. We are already mentioning it. |
||
| ```lua | ||
| vim.lsp.enable 'ocamllsp' | ||
| ``` | ||
|
|
@@ -227,3 +228,5 @@ Add this to your `nvim-lspconfig` setup. | |
| }, | ||
| ``` | ||
|
|
||
| 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. | ||
|
|
||
|
Contributor
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. Should we explain about tree-sitter? (with It isn't strictly required, although might help with performance on large files, before the LSP finishes parsing it.
Contributor
Author
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. Sounds good. Let me know if you have more updates 👍
Contributor
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. I figured out how to configure tree-sitter for ocamllex, but it is quite complicated: ocaml/vim-ocaml#61 (comment). For now I'd leave out tree-sitter from the official docs, until that PR is merged (and an equivalent PR is merged into NeoVim). The workaround is (fixes both picking the right tree-sitter syntax and the LSP errors): vim.filetype.add({
extension = {
mll = 'ocamllex',
mly = 'menhir',
mli = 'ocamlinterface'
}
})followed by the usual tree-sitter config: local treesitter_langs = {
'menhir', 'ocaml', 'ocaml_interface', 'ocamllex'
}
require('nvim-treesitter').install(treesitter_langs)(This doesn't require a new release of NeoVim to work, but if your tree-sitter grammar fails to install you'll be without syntax highlighting, so I wouldn't propose it in the official docs, even though I'll start using it myself). |
||
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 term "modular" might confuse users with typical lua modules. They aren't. Lua modules in Neovim config only lives in
lua/directory andlsp/*.luaare just plain standalone lua files loaded by neovim directly.I think "multi-file" can be better for clarity.
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'm not sure if that distinction is strictly necessary 🤔 I think most people understand what a modular config means in general and are more familiar with that term. I've seen lots of modular config out there but not a single multi-file config.
Uh oh!
There was an error while loading. Please reload this page.
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.
People don't use runtimepath much for lsp/general config because of historical reasons.
But now they are available and is completely different thing from structuring everything under
lua/directory.Even though we clearly stated that they should put that file under
lsp/and notlua/lsp/, I think calling it as a "module" or saying this structure "modular" might confuse users between runtimepath and lua-modules.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.
@boltlessengineer I'll make the changes and request for another review 👍