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

Commands interface #1937

Closed
Shatur opened this issue Jun 1, 2022 · 21 comments
Closed

Commands interface #1937

Shatur opened this issue Jun 1, 2022 · 21 comments
Labels
enhancement New feature or request

Comments

@Shatur
Copy link
Contributor

Shatur commented Jun 1, 2022

We currently have API which allows to set language server specific commands. Example from clangd:

commands = {
ClangdSwitchSourceHeader = {
function()
switch_source_header(0)
end,
description = 'Switch between source/header',
},
},

But @justinmk suggested to remove them.
I personally find them useful, especially ClangdSwitchSourceHeader. I don't think it's good for users to copy them from other people's configs. And having a separate plugin for a few lines of code for ClangdSwitchSourceHeader is also weird. So I think having them here is the right place.

So it's more like a feature keep request :)

@Shatur Shatur added the enhancement New feature or request label Jun 1, 2022
@justinmk
Copy link
Member

justinmk commented Jun 1, 2022

#1921 (comment)

@mellery451
Copy link

I very much like and need this specific functionality, but I can understand wanting to keep the core clean. If anything, maybe we can come up with a plan to move this to a community plugin like https://github.com/p00f/clangd_extensions.nvim

@Shatur
Copy link
Contributor Author

Shatur commented Jun 3, 2022

There are extensions for other LSP servers, having a separate plugin for some additional commands doesn't sound very convenient. Many people complain about the complexity of nvim-lspconfig, so forcing them to install additional plugins to get basic functionality, like ClangdSwitchSourceHeader, will make things worse.

And I don't understand how the commands feature can be a maintenance issue. It's just a few lines of code and many people maintain the language servers they use. If a command breaks - the people who use it will fix it. Basically, the configurations in this plugin are maintained in exactly this way.

@justinmk
Copy link
Member

justinmk commented Jun 6, 2022

And I don't understand how the commands feature can be a maintenance issue. It's just a few lines of code

Multiplied by 100 or more--on top of the other activity already in this repo, which is, again, strictly a set of quickstart configs, not a factory for all things that could possibly be useful for each random langserver.

I would like to know if we can auto-complete server extensions instead. That's worth having in core.

@Shatur
Copy link
Contributor Author

Shatur commented Jun 6, 2022

Multiplied by 100 or more--on top of the other activity already.

Users maintain language servers they add. Why it becomes a problem to maintain 1-2 commands (if they exists, most servers don't have it) for the language server they use? How it different from maintaining the language server configuration?

which is, again, strictly a set of quickstart configs, not a factory for all things that could possibly be useful for each random langserver.

Commands was always here. Why break people configs? Is there any maintenance problem with this feature? I would consider commands as a part of server configuration (as it was in VSCode when you installing a plugin for specific language).

I would like to know if we can auto-complete server extensions instead. That's worth having in core.

Not sure how it could work.

@justinmk
Copy link
Member

justinmk commented Jun 19, 2022

Just noticed something (added 8 months ago: ba90dc2) in CONTRIBUTING.md: https://github.com/neovim/nvim-lspconfig/blob/d57b24c3f46c92cf7e1d93919678565ae49e1e23/CONTRIBUTING.md#scope-of-lspconfig

The point of lspconfig is to provide the minimal configuration necessary for a server to act in compliance with the language server protocol. In general, if a server requires custom client-side commands or off-spec handlers, then the server configuration should be added without those in lspconfig and receive a dedicated plugin such as nvim-jdtls, nvim-metals, etc.

But the example given later in CONTRIBUTING.md mentions PyrightOrganizeImports ... 😕

@glepnir
Copy link
Member

glepnir commented Aug 25, 2022

closed duplicate #1750 . I will implement it later.

@glepnir glepnir closed this as completed Aug 25, 2022
@Shatur
Copy link
Contributor Author

Shatur commented Aug 25, 2022

@glepnir how it is this related? It's a different issue.

@glepnir
Copy link
Member

glepnir commented Aug 25, 2022

that can support custom command in server settings then you can do it right?

@Shatur
Copy link
Contributor Author

Shatur commented Aug 25, 2022

that can support custom command in server settings then you can do it right?

The issue you mentioned is about custom command handlers, if I understand correctly. This issue is about Neovim commands specific to a server. For example, rust_analyzer (see below in Commands section) have CargoReload.
And users can define their own commands, for example here is my config. But this feature was proposed for removal and I decided to open an issue to ask developers to keep it.

@glepnir
Copy link
Member

glepnir commented Aug 25, 2022

not a command handler. you can custom a command in server setting.then you can use this command in neovim cmdline.

@Shatur
Copy link
Contributor Author

Shatur commented Aug 25, 2022

you can custom a command in server setting.then you can use this command in neovim cmdline.

This is how it currently works as far as I know.

@glepnir
Copy link
Member

glepnir commented Aug 25, 2022

maybe I understand wrong you want the comand clangd switch source header in default? i am on mobile phone.now.sry

@glepnir glepnir reopened this Aug 25, 2022
@Shatur
Copy link
Contributor Author

Shatur commented Aug 25, 2022

maybe I understand wrong you want the comand clangd switch source header in default?

No, I like how commands works right now.
And I submitted a PR that adds another command for rust_analyzer, see #1921
But it was rejected due to "out of scope, all current commands will be removed" (see #1921 (comment)). And then I opened this issue asking to keep it.

@glepnir
Copy link
Member

glepnir commented Aug 26, 2022

Oh I think I understand. sorry for closed it before. I've been away for a while due to physical problems. Missed some progress on lsp in neovim. I've been trying to look at these codes recently. Check out the roadmap with lspconfig and some justin's comments. I thought I could explain a little bit about the purpose of this project. Please correct me if I am wrong @justinmk. I will hide or delete this comment. so as not to confuse others about this project.

lspconfig provides basic settings for all servers. And do some actions around the lsp service such as start shutdown etc . Why does this project exist. Consider not all users have knowledge of lsp and server settings. We create this project. It is convenient for any neovimer to simply enable the language server. But please note that lspconfig should only provide the most basic settings. Now some people understand that if you want to use neovim's lsp, you must use lspconfig. Do not. Anyone can make any language server plugin around neovim's lsp api. We would prefer to see some neovim lsp plugins in the future that will focus on setting up one or more language servers. In-depth development to adapt to more users of the language. like nvim-jtdls or some other plugins. maybe in future you will see like nvim-gopls nvim-tsserver such as plugin that do most work in server config. Currently the project is bloated. You can see that a large number of language server configurations exist. Maybe you may only use a few of these servers. So that's why you see some commands or something getting deleted. Because we cannot guarantee that it will be needed by all users of that language (personal opinion) . But based on some api of lspconfig you can fully implement it on your personal configuration.

At present our main work is to promote the progress of lsp on the neovim core. Development of some features. Currently known backward features such as inlay hint smantictoken are not implemented yet. These will have higher priority.

cc @bennypowers #2089 also do same thing , explain in there.

@Shatur
Copy link
Contributor Author

Shatur commented Aug 26, 2022

Currently the project is bloated. You can see that a large number of language server configurations exist.

Yes, there are a lot of configs in the repo... But aren't servers loading lazily?

So that's why you see some commands or something getting deleted. Because we cannot guarantee that it will be needed by all users of that language (personal opinion) . But based on some api of lspconfig you can fully implement it on your personal configuration.

Of course, I can and have already added the commands I need to my config. But if I understand correctly, then the API for such a command is planned to be removed. So I won't be able to define my custom commands in my config either :(

@glepnir
Copy link
Member

glepnir commented Aug 26, 2022

API can be open. I'll check if it's missing. I'll re-add it if I can. Yes, most people use lspconfig as lazyload use autocmd event.
but there still many server configurations file in your disk. this project still accept the new lsp server config. So it will only get bigger and not smaller. :) Thanks for your understand.

@justinmk
Copy link
Member

justinmk commented Mar 23, 2023

I'm thinking we might want some sort of "sub-command" entrypoint so that langserver-specific commands can be discovered. E.g.

  • :Lsp <tab> would complete available langserver-specific commands.
  • :LspCapabilties <tab> would show... something.

@glepnir
Copy link
Member

glepnir commented Mar 23, 2023

I will think about this then make a pr for it .

@justinmk
Copy link
Member

justinmk commented Mar 23, 2023

Note: this would be a core vim.lsp feature. Start small, in case others have objections or better ideas :)

@justinmk
Copy link
Member

Tracked in Nvim core at neovim/neovim#28329

@justinmk justinmk closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants