diff options
| author | Páll Andrés Pálsson <drllap@gmail.com> | 2021-11-14 18:15:58 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-14 10:15:58 -0800 |
| commit | 48977e223fd1d112f49a9a40cf59b3bd667b70a7 (patch) | |
| tree | 50e64ab37668e8cf2c8609433cf5bf881234e59c /lua | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.tar nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.tar.gz nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.tar.bz2 nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.tar.lz nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.tar.xz nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.tar.zst nvim-lspconfig-48977e223fd1d112f49a9a40cf59b3bd667b70a7.zip | |
fix(powershell_es): do not overwrite cmd if present in new_config callback (#1383)
Diffstat (limited to 'lua')
| -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. |
