diff options
| -rw-r--r-- | lua/lspconfig/powershell_es.lua | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lua/lspconfig/powershell_es.lua b/lua/lspconfig/powershell_es.lua index e2fd86ef..377cdd23 100644 --- a/lua/lspconfig/powershell_es.lua +++ b/lua/lspconfig/powershell_es.lua @@ -4,21 +4,25 @@ local util = require 'lspconfig/util' local server_name = 'powershell_es' local temp_path = vim.fn.stdpath 'cache' -local function make_cmd(bundle_path) - if bundle_path ~= nil then +local function make_cmd(new_config) + if new_config.bundle_path ~= nil then local command_fmt = [[%s/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath %s -LogPath %s/powershell_es.log -SessionDetailsPath %s/powershell_es.session.json -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -Stdio -LogLevel Normal]] - local command = command_fmt:format(bundle_path, bundle_path, temp_path, temp_path) - return { 'pwsh', '-NoLogo', '-NoProfile', '-Command', command } + local command = command_fmt:format(new_config.bundle_path, new_config.bundle_path, temp_path, temp_path) + return { new_config.shell, '-NoLogo', '-NoProfile', '-Command', command } end end configs[server_name] = { default_config = { + shell = 'pwsh', on_new_config = function(new_config, _) - local bundle_path = new_config.bundle_path - new_config.cmd = make_cmd(bundle_path) + -- Don't overwrite cmd if already set + if not new_config.cmd then + new_config.cmd = make_cmd(new_config) + end end, + filetypes = { 'ps1' }, root_dir = util.find_git_ancestor, single_file_mode = true, @@ -42,6 +46,17 @@ require'lspconfig'.powershell_es.setup{ } ``` +By default the languageserver is started in `pwsh` (PowerShell Core). This can be changed by specifying `shell`. + +```lua +require'lspconfig'.powershell_es.setup{ + bundle_path = 'c:/w/PowerShellEditorServices', + shell = 'powershell.exe', +} +``` + +Note that the execution policy needs to be set to `Unrestricted` for the languageserver run under PowerShell + If necessary, specific `cmd` can be defined instead of `bundle_path`. See [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices#stdio) to learn more. |
