Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

feat(middleware): add 'ignore_in_path' feature to ignore unnecessary automatic installations #645

Closed
wants to merge 1 commit into from

Conversation

mehalter
Copy link

This adds the ability to ignore automatic installations if an language server command is already available on the user's PATH. I currently have it in place to only be regarding the automatic installer. If the user manually installs an LSP then it should still install as they are specifically choosing to install it.

@mehalter
Copy link
Author

If the user provides the LSP in the ensure_installed list it also ignores the check for if the executable is found in the path because it would make sense to respect the user's decision to "ensure the server is installed" with nvim-lsp-installer

@kabinspace
Copy link

I agree with @mehalter, this would be really great.

Copy link
Owner

@williamboman williamboman left a comment

Choose a reason for hiding this comment

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

Thanks! While this would work for a majority of servers, there are servers where this logic would not really work, for example:

I think for a feature like this to really work, it'd need to be hosted in a different layer that have the necessary capabilities to properly determine whether something is already available or not. I also can't help but feel like this "smartness" would carry a bunch of edge cases (can you tell, I'm not exactly a fan haha :D).

In the past days there's been more changes and new features than I'm comfortable with haha, so I'll let this one sit for a while (the feature itself, not this implementation per se).

I'd love to know more about concrete examples of use cases behind this?

@williamboman
Copy link
Owner

williamboman commented May 25, 2022

For the time being I'd like to not include something like this out of the box. It should be fairly straight forward to add this to your own config btw, through something like:

local util = require("lspconfig.util")
local servers = require("nvim-lsp-installer.servers")

util.on_setup = util.add_hook_after(util.on_setup, function(config)
    local ok, server = servers.get_server(config.name)
    if ok and not server:is_installed() then
        local server_config = require("lspconfig.server_configurations." .. config.name)
        if vim.fn.executable(server_config.default_config.cmd[1]) ~= 1 then
            server:install()
        end
    end
end)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants