Skip to content
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

fix(docs): Reduce scope of lspconfig example to quick-lint-js #1072

Closed
wants to merge 2 commits into from

Conversation

RossBarnie
Copy link
Contributor

Fixes #909

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

CLA Assistant Lite bot Thank you for your contribution! Like many free software projects, you must sign our Contributor License Agreement before we can accept your contribution.

EDIT: All contributors have signed quick-lint-js' Contributor License Agreement (CLA-v1.md).

@RossBarnie
Copy link
Contributor Author

I have read and hereby agree to quick-lint-js' Contributor License Agreement (CLA-v1.md).

vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
update_in_insert = true,
local nvim_lsp = require('lspconfig')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must fix: When I tried this, I got the following error:

Error detected while processing /nix/store/01pnpqhja7iinp0xl74sygvsiixcr2i6-init.vim:
line   16:
E5108: Error executing lua [string ":lua"]:6: attempt to index global 'nvm_lsp' (a nil value)
stack traceback:
        [string ":lua"]:6: in main chunk

Here's the vimrc (Nix template; ${packages.quick-lint-js} is replaced with a full path):

              lua << EOF
              require('lspconfig/quick_lint_js').setup {
                cmd = {"${packages.quick-lint-js}/bin/quick-lint-js", "--lsp-server"},
              }

              local nvim_lsp = require('lspconfig')
              nvm_lsp.quick_lint_js.setup {
                handlers = {
                  ['textDocument/publishDiagnostics'] = vim.lsp.with(
                    vim.lsp.diagnostic.on_publish_diagnostics, {
                      update_in_insert = true
                    }
                  )
                }
              }
              EOF

Did I do something wrong?


This vimrc works without issues:

              lua << EOF
              require('lspconfig/quick_lint_js').setup {
                cmd = {"${packages.quick-lint-js}/bin/quick-lint-js", "--lsp-server"},
                handlers = {
                  ['textDocument/publishDiagnostics'] = vim.lsp.with(
                    vim.lsp.diagnostic.on_publish_diagnostics, {
                      update_in_insert = true
                    }
                  )
                },
              }
              EOF

I think we should put the setup code inside the existing setup block instead of making a separate setup block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that was my intention and this is consistent with the documentation below this section which shows new options but with the call to the setup call. I've added a new commit which should be more consistent and edited the sentence before to further clarify, let me know what you think. I'd be happy to make more changes if needed. The section below this for example covers some specific examples of options available to all language servers via the lspconfig vim API, so maybe we could move this configuration to its own tagged section, and/or link to the lspconfig docs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've added a new commit which should be more consistent and edited the sentence before to further clarify, let me know what you think.

New version looks great!

The section below this for example covers some specific examples of options available to all language servers via the lspconfig vim API, so maybe we could move this configuration to its own tagged section, and/or link to the lspconfig docs.

Some config options should be set by our plugin and shouldn't normally be customized by the user (for example name, root_dir, on_new_config, and single_file_support (from nvim-lspconfig), and capabilities (from Neovim itself)).

Keeping our current docs, but referencing nvim-lspconfig's docs, sounds like a good idea. It's not necessary for this PR though.

@strager
Copy link
Collaborator

strager commented Sep 15, 2023

Is this ready to merge?

@RossBarnie
Copy link
Contributor Author

Yes, unless you want the commits squashed.

@strager
Copy link
Collaborator

strager commented Sep 18, 2023

Landed as commit b7aa1c8.

@strager strager closed this Sep 18, 2023
@RossBarnie RossBarnie deleted the issue-909 branch November 2, 2023 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

105$: [nvim-lspconfig] Only lint on insert with quick-lint
2 participants