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

Is there a way to reconfigure a server's config after entering vim? #536

Open
kedodrill opened this issue Jul 9, 2024 · 0 comments
Open

Comments

@kedodrill
Copy link

Hi there, thank you for this plugin!

I'm trying to set the environment.phpVersion config for the intelephense (PHP) server dynamically. Unfortunately intelephense does not do this automatically.

In neovim, I did this using the on_init function provided by nvim-lspconfig. Is there something similar I can use here, or can I use some kind of vimscript to do this?

Conditionally adding the server if vim is opened in a directory where there is a composer.json file does work, but it would be nice to be able to set the version so I can move around to different projects within vim.

Here is what I have right now. (github doesn't support vim9script yet I don't think? this is all in vim9script).

def GetPHPVersion():string
" ...
enddef

var lspServers = []

if (filereadable('composer.json'))
    lspServers->add({
        " intelephense...
        workspaceConfig: { intelephense: { environment: { phpVersion: GetPHPVersion() } } }
    })
endif

What I would like to see is something like this (I think this is valid vim9script...but not sure. you get the idea though):

" ...
var lspServers = []
var intelephense = {
    " intelephense...
}
" onInit (optional): each time the server is started, execute an inline function that has the settings as a param and changes the settings
intelephense.onInit = (intelephense) => {
    intelephense.workspaceConfig = {
        intelephense: { environment: { phpVersion: GetPHPVersion() } }
    }
}
lspServers->add(intelephense)
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

No branches or pull requests

1 participant