-
Notifications
You must be signed in to change notification settings - Fork 2.2k
PowerShell Editor Services - LSP client starts but doesn't attach to buffer #2810
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
Comments
Any updates on this? I'm basically having the same issue. Can't get Lsp to attach to the buffer even after manually setting |
So after examining LspLog, I got it to work using the following: local mason_registry = require("mason-registry")
installed_servers["powershell_es"] = {
bundle_path = mason_registry.get_package("powershell-editor-services"):get_install_path(),
} For my config its syntactically a little differnt as opposed to the example in e.g. mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
on_attach = require('config.keymaps').lsp_keymaps,
settings = installed_servers[server_name],
filetypes = (installed_servers[server_name] or {}).filetypes,
bundle_path = (installed_servers[server_name] or {}).bundle_path,
handlers = handlers,
}
end,
} |
Glad to hear you got this working, but unfortunately I've had no such luck. Here's my config based on your snippets: local mason_registry = require("mason-registry")
local bundle_path = mason_registry.get_package("powershell-editor-services"):get_install_path()
require("lspconfig").powershell_es.setup({
bundle_path = bundle_path,
settings = {
bundle_path = bundle_path,
},
}) The behaviour I'm seeing is no different from before, the client still does not attach to the buffer. Are your dotfiles somewhere public that I can check out? |
Unfortunately my config is currently private, but here are the full 9 yards if that helps local mason_lspconfig = require('mason-lspconfig')
local mason_registry = require("mason-registry")
-- Make server list from installed lsp servers
local installed_servers = {}
for _, key in ipairs(mason_lspconfig.get_installed_servers()) do
installed_servers[key] = {}
end
-- Modify installed servers options if needed
installed_servers["lua_ls"] = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
}
installed_servers["powershell_es"] = {
bundle_path = mason_registry.get_package("powershell-editor-services"):get_install_path(),
}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }),
}
mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
on_attach = require('config.keymaps').lsp_keymaps,
settings = installed_servers[server_name],
filetypes = (installed_servers[server_name] or {}).filetypes,
bundle_path = (installed_servers[server_name] or {}).bundle_path,
handlers = handlers,
}
end,
} |
Thanks for sharing. I didn't think there was anything I was missing. Still, no luck getting the PSES client attached sadly 😞 |
What does |
This is the full trace log: There's a warning at the bottom mentioning something about OmniSharp. Do you make anything of that? |
Don't see anything sus there. Have you tried removing settings = {
bundle_path = bundle_path,
}, |
Thanks for your help with this. I've just tried your suggested change but no difference, unfortunately. Nothing new in LSP log either. |
But you are sure that Mason has it installed? Otherwise my code wouldn't work. |
I spun up a VM to see if I could get any different behaviour than I've been seeing on the two machines I use regularly (both have the same problem). What I noticed with the VM is that PSES seemed to work initially after first opening Neovim after cloning my dotfiles, and then immediately stopped working the next time I opened it. Even after removing Just to be sure Mason was installing PSES correctly, I tried replacing the package with the latest release from the repo. No difference. The client starts but doesn't attach to the buffer. |
I've experienced the exact same behaviour in regards to the LSP starting but not attaching. I set the bundle path like you did and nothing changed. I kept the config as is but updated PowerShell to 7.3.8 and it fixed the issue. |
Thats neat. While fixing the issue I was already on pwsh 7.3.8 so I might not have run into these issues. |
Maybe this is related to this vscode issue (?) and maybe this omnisharp problem (?). This issues make me think that this may be a windows library problem and that's why it worked in a fresh VM install |
@TheLeoP I think you might be right. I'm now running PS 7.3.8 and PSES 3.13.0 with no change. |
@scottmckendry how did you install the language server in the VM? Is there a change that the VM came preinstalled with a version of the langauge server and your dotfiles downloaded a newer version throught mason? |
@TheLeoP the lang server was installed with Mason. I'd be very surprised if there was anything pre-existing on the VM that somehow made it work. It was a fresh Win11 install. All I did was install PS7 and git, then clone my dotfiles and test. Also the |
I can confirm the behavior. Before figuring the issue out, it was only working for me when I installed the lsp freshly with Mason and only for that nvim session. After restarting nvim the functionality was gone. |
Can you reproduce this reliably @scottmckendry @MarcoBuess? If yes, nvim-lspconfig creates a command similar to the following: & 'C:/Users/pcx/AppData/Local/nvim-data/mason/packages/powershell-editor-services/PowerShellEditorServices/Start-EditorServices.ps1' -Stdio -BundledModulesPath 'C:/Users/pcx/AppData/Local/nvim-data/mason/packages/powershell-editor-services' -LogPath 'C:/Users/pcx/AppData/Local/Temp/nvim/powershell_es.log' -SessionDetailsPath 'C:/Users/pcx/AppData/Local/Temp/nvim/powershell_es.session.json' -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -LogLevel Could you check the content of |
For me,
|
@scottmckendry @MarcoBuess @RichardEpure As per this comment, the issue (at least for me) was powershell_es trying to load my powershell profile and taking to long to do it. To make Neovim not load it you only need to do the following: require("lspconfig").powershell_es.setup {
bundle_path = "path/to/your/bundle_path",
init_options = {
enableProfileLoading = false,
},
} Maybe it would be worth adding this to the default powershell_es config? Or some mention to it in on its documentation? |
Nice find. As I mentioned, I currently have it working even if its loading the profile. I believe it does start the lsp with |
@MarcoBuess the comment I linked explains why |
Thanks @TheLeoP! That's worked for me. Curious to find out what's preventing my profile from loading. The VS Code extension shares the same server and it loads my profile with no issues. Either way, this is now resolved for me. |
This setting indeed solves the issue! Thanks! |
Description
This is a Windows-specific issue. Running Neovim in WSL or native Linux (Arch) in my tests I could not reproduce.
When editing .ps1 files in windows-native neovim, the client starts but does not attach to the open buffer.
Neovim version
NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Nvim-lspconfig version
No response
Operating system and version
Windows 11 22H2
Affected language servers
powershell_es
Steps to reproduce
Actual behavior
:LspLog shows the client has started - no errors or warnings.
:LspInfo shows that the client is not attached to the current buffer.
Expected behavior
The client should attach to the current buffer when a .ps1 file is opened.
Minimal config
LSP log
https://gist.github.com/scottmckendry/c3b502ba707aa9effbcca656e823d499
The text was updated successfully, but these errors were encountered: