@@ -74,16 +74,22 @@ local on_attach = function(client, bufnr)
74
74
vim .keymap .set (' n' , ' <Leader>td' , vim .lsp .buf .type_definition , bufopts )
75
75
end
76
76
77
- local bundle_path = ' <Path to where PowerShell Editor Services was installed>'
77
+ local home_directory = os.getenv (' HOME' )
78
+ if home_directory == nil then
79
+ home_directory = os.getenv (' USERPROFILE' )
80
+ end
81
+
82
+ -- The bundle_path is where PowerShell Editor Services was installed
83
+ local bundle_path = home_directory .. ' /Desktop/PowerShellEditorServices'
78
84
79
85
require (' lspconfig' )[' powershell_es' ].setup {
80
86
bundle_path = bundle_path ,
81
87
on_attach = on_attach
82
88
}
83
89
```
84
90
85
- > NOTE: Be sure to set the bundle_path variable, otherwise the server will not
86
- > know the path to start the server.
91
+ > NOTE: Be sure to set the bundle_path variable to the correct location,
92
+ > otherwise the server will not know the path to start the server.
87
93
88
94
To further configure the server, you can supply settings to the setup table.
89
95
For example, you can set the code formatting preset to one true brace style
@@ -99,9 +105,10 @@ require('lspconfig')['powershell_es'].setup {
99
105
As another example, you can set the bundled PSScriptAnalyzer's custom rule path
100
106
like so:
101
107
``` lua
108
+ local custom_settings_path = home_directory .. ' /PSScriptAnalyzerSettings.psd1'
102
109
require (' lspconfig' )[' powershell_es' ].setup {
103
110
bundle_path = bundle_path ,
104
111
on_attach = on_attach ,
105
- settings = { powershell = { scriptAnalysis = { settingsPath = os.getenv ( ' HOME ' ) .. ' PSScriptAnalyzerSettings.psd1 ' } } }
112
+ settings = { powershell = { scriptAnalysis = { settingsPath = custom_settings_path } } }
106
113
}
107
114
```
0 commit comments