Skip to content

Commit

Permalink
it's working
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt committed Jun 25, 2019
1 parent 39a5529 commit fe396cb
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 45 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
}
]
}
89 changes: 45 additions & 44 deletions client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,57 @@ const bundledModulesPath = path.join(cocPowerShellRoot, "PowerShellEditorService
const logPath = path.join(cocPowerShellRoot, "/.pses/logs/1234");

export function activate(context: ExtensionContext) {
setTimeout(function () {
const pwshPath = getDefaultPowerShellPath(getPlatformDetails())

const pwshPath = getDefaultPowerShellPath(getPlatformDetails())

let serverOptions: ServerOptions = {
command: pwshPath,
args: [
"-NoProfile",
"-NonInteractive",
path.join(bundledModulesPath, "/PowerShellEditorServices/Start-EditorServices.ps1"),
"-HostName", "coc.vim",
"-HostProfileId", "0",
"-HostVersion", "2.0.0",
"-LogPath", path.join(logPath, "log.txt"),
"-LogLevel", "Diagnostic",
"-BundledModulesPath", bundledModulesPath,
"-Stdio",
"-SessionDetailsPath", path.join(logPath, "session")],
transport: TransportKind.stdio
}
let serverOptions: ServerOptions = {
command: pwshPath,
args: [
"-NoProfile",
"-NonInteractive",
path.join(bundledModulesPath, "/PowerShellEditorServices/Start-EditorServices.ps1"),
"-HostName", "coc.vim",
"-HostProfileId", "0",
"-HostVersion", "2.0.0",
"-LogPath", path.join(logPath, "log.txt"),
"-LogLevel", "Diagnostic",
"-BundledModulesPath", bundledModulesPath,
"-Stdio",
"-SessionDetailsPath", path.join(logPath, "session")],
transport: TransportKind.stdio
}

workspace.addRootPatterns('ps1', ['*.ps1', '*.psd1', '*.psm1', '.vim', '.git', '.hg'])

workspace.addRootPatterns('powershell', ['*.ps1', '*.psd1', '*.psm1', '.vim', '.git', '.hg'])

// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for F# documents
documentSelector: [{scheme: 'file', language: 'powershell'}],
synchronize: {
// Synchronize the setting section 'powershell' to the server
configurationSection: 'powershell',
// Notify the server about file changes to PowerShell files contain in the workspace
// TODO: is there a way to configure this via the language server protocol?
fileEvents: [
workspace.createFileSystemWatcher('**/*.ps1'),
workspace.createFileSystemWatcher('**/*.psd1'),
workspace.createFileSystemWatcher('**/*.psm1')
]
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for F# documents
documentSelector: [{ scheme: 'file', language: 'ps1' }],
synchronize: {
// Synchronize the setting section 'powershell' to the server
configurationSection: 'ps1',
// Notify the server about file changes to PowerShell files contain in the workspace
// TODO: is there a way to configure this via the language server protocol?
fileEvents: [
workspace.createFileSystemWatcher('**/*.ps1'),
workspace.createFileSystemWatcher('**/*.psd1'),
workspace.createFileSystemWatcher('**/*.psm1')
]
}
}
}

// Create the language client and start the client.
let client = new LanguageClient('powershell', 'PowerShell Language Server', serverOptions, clientOptions);
let disposable = client.start();

// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
commands.registerCommand('powershell.command.goto', goto);
// Create the language client and start the client.
let client = new LanguageClient('ps1', 'PowerShell Language Server', serverOptions, clientOptions);
let disposable = client.start();

// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
commands.registerCommand('powershell.command.goto', goto);
}, 10000);
}

function goto(file: string, startLine: number, startColumn: number, _endLine: number, _endColumn: number) {
let selection = Range.create(startLine, startColumn, startLine, startColumn);
workspace.jumpTo(file, selection.start);
workspace.jumpTo(file, selection.start);
}
Binary file removed coc-powershell-0.1.49.tgz
Binary file not shown.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@
},
"extensionDependencies": [],
"dependencies": {
"coc.nvim": "^0.0.71"
"coc.nvim": "^0.0.71",
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@types/node": "^10.3.3",
Expand Down

0 comments on commit fe396cb

Please sign in to comment.