Skip to content

Add configuration options for picking and choosing which servers are used for LSP features #4392

@w0rp

Description

@w0rp

ALE currently searches through all language servers configured with ale_linters and discovers which of them offer capabilities for specific features, such as code completion, "go to definition", hover information, and so on. ALE will then try to either combine the results of multiple tools together for a feature, or stop on the first one it can find where it doesn't make sense to combine the results together.

We should add support to configure which linters are used for which features, so you can explicitly prefer one tool over another one, in an order that is user-configured. At the moment the only similar option we have is ale_linters_ignore, which is for disabling specific linters, and overrides the selection from ale_linters. We will keep this option.

A new option could take the following forms.

" Globally configured
let g:ale_linter_features = {
\   'completion': ['pylsp', 'pyright', 'tsserver', 'gopls'],
\   'hover': ['pyright', 'pyslp', 'tsserver', 'gopls'],
\}
" Configured per-buffer
let b:ale_linter_features = {
\   'completion': ['pylsp', 'pyright'],
\   'hover': ['pylsp', 'pyright'],
\}

Because the setting will not cause ALE to go and enable a linter, which is already configured with ale_linters, we do not need to write the filetypes into the Dictionary, which will simplify the design and use of the setting. You could list out all of your preferences across all languages in a straight List for each feature globally, and list only options specific to one language in an ftplugin file or shared config. As always, I recommend writing b: configuration variables wherever possible instead of g: variables. (Except maybe in shared third party plugins that make it harder for you to set your own configuration specific to your system.)

NOTE: If anyone can think of a better name than ale_linter_features, give it to me. I might think of a better one along the way.

Metadata

Metadata

Assignees

Labels

LSPAny issue relating to LSP or tsserverenhancement

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions