-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
docs: update LSP quickstart #28954
docs: update LSP quickstart #28954
Conversation
The LSP quickstart can act as our true "entrypoint" for answering the question "How do I use LSP in Neovim?" As such, it can be a little more beginniner-friendly than other sections of our help docs by including explanatory comments and a more fleshed out example (including a `FileType` autocommand). This also includes some other minor wording updates and points users toward `:checkhealth lsp`.
@@ -25,24 +25,37 @@ Nvim provides an LSP client, but the servers are provided by third parties. | |||
Follow these steps to get LSP features: | |||
|
|||
1. Install language servers using your package manager or by following the | |||
upstream installation instruction. You can find language servers here: | |||
upstream installation instructions. You can find language servers here: | |||
https://microsoft.github.io/language-server-protocol/implementors/servers/ |
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.
Would it make sense to link to nvim-lspconfig
instead?
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.
Not all users will have nvim-lspconfig installed, and in any case the hope here is that we can get more users to use LSP without it.
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 was not suggesting replacing this by "use nvim-lspconfig
", but to use their list of available servers instead since I think it will better reflect which LSPs currently have neovim support.
I don't have strong feelings about it though so it's fine.
runtime/doc/lsp.txt
Outdated
@@ -25,24 +25,37 @@ Nvim provides an LSP client, but the servers are provided by third parties. | |||
Follow these steps to get LSP features: | |||
|
|||
1. Install language servers using your package manager or by following the | |||
upstream installation instruction. You can find language servers here: | |||
upstream installation instructions. You can find language servers here: | |||
https://microsoft.github.io/language-server-protocol/implementors/servers/ | |||
|
|||
2. Configure the LSP client per language server. See |vim.lsp.start()| or use |
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 a fan of this first sentence. If this is meant to be an introductory explanation, we should remain consistent of who's the client and who's the server.
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.
Which sentence in particular? Do you have a suggestion on how to reword it?
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.
Oh my bad, it seems like I didn't highlight the right line.
The sentence I don't like is "Configure the LSP client per language server". It makes the role of the client and server confusing IMO.
Maybe we can change it to "Configure each LSP server to communicate with the editor"?
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.
Reworded slightly in cd20761.
runtime/doc/lsp.txt
Outdated
|
||
4. Configure keymaps and autocmds to use LSP features. See |lsp-config|. | ||
4. (Optional) Configure keymaps and autocmds to use LSP features. |lsp-config| |
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.
For consistency with line 34:
4. (Optional) Configure keymaps and autocmds to use LSP features. |lsp-config| | |
4. (Optional) Configure keymaps and autocommands to use LSP features. |lsp-config| |
name = 'my-server-name', | ||
cmd = {'name-of-language-server-executable'}, | ||
root_dir = vim.fs.root(0, {'setup.py', 'pyproject.toml'}), | ||
-- Create an event handler for the FileType autocommand |
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.
Nitpick: the "event handler" is the "autocommand" (in Vimspeak) for the FileType
"event".
Of course, the question is how the audience is here -- whether we should "push" Vimspeak or generic protocol language.
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.
Trying to avoid Vim specific jargon here, where possible. We can leave lots of breadcrumbs (tags) to other help docs to guide the user to learn more, but at this point I want to assume as little a priori knowledge as possible.
runtime/doc/lsp.txt
Outdated
-- This handler will fire when the buffer's 'filetype' is "python" | ||
pattern = 'python', | ||
callback = function(ev) | ||
-- The buffer number this event is associated with |
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 would recommend structuring these comments around the intention rather than a technical description. In this case, I would actually not define this here but use the event structure where it is needed (see below).
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 intent here was to (hopefully) avoid confusion between "current buffer" and "buffer associated with the autocommand". Pulling the bufnr
declaration out allows us to add a separate comment explaining this distinction. But perhaps this is not an important distinction for new users.
runtime/doc/lsp.txt
Outdated
-- The "root directory" of the project is the parent directory, | ||
-- relative to the buffer's file, containing a "setup.py" or | ||
-- "pyproject.toml" file | ||
root_dir = vim.fs.root(bufnr, {'setup.py', 'pyproject.toml'}), |
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 "root directory" of the project is the parent directory, | |
-- relative to the buffer's file, containing a "setup.py" or | |
-- "pyproject.toml" file | |
root_dir = vim.fs.root(bufnr, {'setup.py', 'pyproject.toml'}), | |
-- Set the "root directory" to the parent directory of the | |
-- file in the current buffer (`ev.buf`) that contains either | |
-- a "setup.py" or a "pyproject.toml" file | |
root_dir = vim.fs.root(ev.buf, {'setup.py', 'pyproject.toml'}), |
The LSP quickstart can act as our true "entrypoint" for answering the question "How do I use LSP in Neovim?" As such, it can be a little more beginniner-friendly than other sections of our help docs by including explanatory comments and a more fleshed out example (including a `FileType` autocommand). This also includes some other minor wording updates and points users toward `:checkhealth lsp`. (cherry picked from commit 28c0494)
Successfully created backport PR for |
docs: update LSP quickstart (#28954) The LSP quickstart can act as our true "entrypoint" for answering the question "How do I use LSP in Neovim?" As such, it can be a little more beginniner-friendly than other sections of our help docs by including explanatory comments and a more fleshed out example (including a `FileType` autocommand). This also includes some other minor wording updates and points users toward `:checkhealth lsp`. (cherry picked from commit 28c0494) Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
The LSP quickstart can act as our true "entrypoint" for answering the question "How do I use LSP in Neovim?" As such, it can be a little more beginniner-friendly than other sections of our help docs by including explanatory comments and a more fleshed out example (including a `FileType` autocommand). This also includes some other minor wording updates and points users toward `:checkhealth lsp`.
The LSP quickstart can act as our true "entrypoint" for answering the question "How do I use LSP in Neovim?" As such, it can be a little more beginniner-friendly than other sections of our help docs by including explanatory comments and a more fleshed out example (including a
FileType
autocommand).This also includes some other minor wording updates and points users toward
:checkhealth lsp
.