33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 * ------------------------------------------------------------------------------------------ */
55
6+ import { dirname } from "node:path" ;
67import {
78 // languages,
89 workspace ,
910 window ,
10- commands ,
11- EventEmitter ,
11+ // commands,
12+ // EventEmitter,
1213 ExtensionContext ,
1314 // InlayHintsProvider,
1415 // TextDocument,
1516 // CancellationToken,
16- Range ,
17+ // Range,
1718 // InlayHint,
18- TextDocumentChangeEvent ,
19+ // TextDocumentChangeEvent,
1920 // ProviderResult,
2021 // WorkspaceEdit,
2122 // TextEdit,
22- Selection ,
23- Uri ,
23+ // Selection,
24+ // Uri,
2425} from "vscode" ;
2526
2627import {
2728 // CloseAction,
2829 // CloseHandlerResult,
29- Disposable ,
30+ // Disposable,
3031 // ErrorAction,
3132 // ErrorHandlerResult,
3233 Executable ,
@@ -39,28 +40,29 @@ import {
3940let client : LanguageClient ;
4041// type a = Parameters<>;
4142
42- export async function activate ( context : ExtensionContext ) {
43- let disposable = commands . registerCommand ( "helloworld.helloWorld" , async ( uri ) => {
44- // The code you place here will be executed every time your command is executed
45- // Display a message box to the user
46- const url = Uri . parse ( "/home/victor/Documents/test-dir/nrs/another.nrs" ) ;
47- let document = await workspace . openTextDocument ( uri ) ;
48- await window . showTextDocument ( document ) ;
43+ export async function activate ( _context : ExtensionContext ) {
44+ // let disposable = commands.registerCommand("helloworld.helloWorld", async (uri) => {
45+ // // The code you place here will be executed every time your command is executed
46+ // // Display a message box to the user
47+ // const url = Uri.parse("/home/victor/Documents/test-dir/nrs/another.nrs");
48+ // let document = await workspace.openTextDocument(uri);
49+ // await window.showTextDocument(document);
4950
50- // console.log(uri)
51- window . activeTextEditor . document ;
52- let editor = window . activeTextEditor ;
53- let range = new Range ( 1 , 1 , 1 , 1 ) ;
54- editor . selection = new Selection ( range . start , range . end ) ;
55- } ) ;
51+ // // console.log(uri)
52+ // window.activeTextEditor.document;
53+ // let editor = window.activeTextEditor;
54+ // let range = new Range(1, 1, 1, 1);
55+ // editor.selection = new Selection(range.start, range.end);
56+ // });
5657
57- context . subscriptions . push ( disposable ) ;
58+ // context.subscriptions.push(disposable);
5859
5960 const traceOutputChannel = window . createOutputChannel ( "Odoo LSP" ) ;
6061 const command = process . env . SERVER_PATH || "odoo-lsp" ;
6162 const run : Executable = {
6263 command,
6364 options : {
65+ cwd : workspace . workspaceFolders . length ? dirname ( workspace . workspaceFolders [ 0 ] . uri . fsPath ) : void 0 ,
6466 env : {
6567 ...process . env ,
6668 // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -84,7 +86,7 @@ export async function activate(context: ExtensionContext) {
8486 ] ,
8587 synchronize : {
8688 // Notify the server about file changes to '.clientrc files contained in the workspace
87- fileEvents : workspace . createFileSystemWatcher ( "**/.clientrc " ) ,
89+ fileEvents : workspace . createFileSystemWatcher ( "**/.odoo_lsp* " ) ,
8890 } ,
8991 traceOutputChannel,
9092 } ;
@@ -102,80 +104,80 @@ export function deactivate(): Thenable<void> | undefined {
102104 return client . stop ( ) ;
103105}
104106
105- export function activateInlayHints ( ctx : ExtensionContext ) {
106- const maybeUpdater = {
107- hintsProvider : null as Disposable | null ,
108- updateHintsEventEmitter : new EventEmitter < void > ( ) ,
109-
110- async onConfigChange ( ) {
111- this . dispose ( ) ;
112-
113- const event = this . updateHintsEventEmitter . event ;
114- // this.hintsProvider = languages.registerInlayHintsProvider(
115- // { scheme: "file", language: "nrs" },
116- // // new (class implements InlayHintsProvider {
117- // // onDidChangeInlayHints = event;
118- // // resolveInlayHint(hint: InlayHint, token: CancellationToken): ProviderResult<InlayHint> {
119- // // const ret = {
120- // // label: hint.label,
121- // // ...hint,
122- // // };
123- // // return ret;
124- // // }
125- // // async provideInlayHints(
126- // // document: TextDocument,
127- // // range: Range,
128- // // token: CancellationToken
129- // // ): Promise<InlayHint[]> {
130- // // const hints = (await client
131- // // .sendRequest("custom/inlay_hint", { path: document.uri.toString() })
132- // // .catch(err => null)) as [number, number, string][];
133- // // if (hints == null) {
134- // // return [];
135- // // } else {
136- // // return hints.map(item => {
137- // // const [start, end, label] = item;
138- // // let startPosition = document.positionAt(start);
139- // // let endPosition = document.positionAt(end);
140- // // return {
141- // // position: endPosition,
142- // // paddingLeft: true,
143- // // label: [
144- // // {
145- // // value: `${label}`,
146- // // // location: {
147- // // // uri: document.uri,
148- // // // range: new Range(1, 0, 1, 0)
149- // // // }
150- // // command: {
151- // // title: "hello world",
152- // // command: "helloworld.helloWorld",
153- // // arguments: [document.uri],
154- // // },
155- // // },
156- // // ],
157- // // };
158- // // });
159- // // }
160- // // }
161- // // })()
162- // );
163- } ,
164-
165- onDidChangeTextDocument ( { contentChanges, document } : TextDocumentChangeEvent ) {
166- // debugger
167- // this.updateHintsEventEmitter.fire();
168- } ,
169-
170- dispose ( ) {
171- this . hintsProvider ?. dispose ( ) ;
172- this . hintsProvider = null ;
173- this . updateHintsEventEmitter . dispose ( ) ;
174- } ,
175- } ;
176-
177- workspace . onDidChangeConfiguration ( maybeUpdater . onConfigChange , maybeUpdater , ctx . subscriptions ) ;
178- workspace . onDidChangeTextDocument ( maybeUpdater . onDidChangeTextDocument , maybeUpdater , ctx . subscriptions ) ;
179-
180- maybeUpdater . onConfigChange ( ) . catch ( console . error ) ;
181- }
107+ // export function activateInlayHints(ctx: ExtensionContext) {
108+ // const maybeUpdater = {
109+ // hintsProvider: null as Disposable | null,
110+ // updateHintsEventEmitter: new EventEmitter<void>(),
111+
112+ // async onConfigChange() {
113+ // this.dispose();
114+
115+ // const event = this.updateHintsEventEmitter.event;
116+ // // this.hintsProvider = languages.registerInlayHintsProvider(
117+ // // { scheme: "file", language: "nrs" },
118+ // // // new (class implements InlayHintsProvider {
119+ // // // onDidChangeInlayHints = event;
120+ // // // resolveInlayHint(hint: InlayHint, token: CancellationToken): ProviderResult<InlayHint> {
121+ // // // const ret = {
122+ // // // label: hint.label,
123+ // // // ...hint,
124+ // // // };
125+ // // // return ret;
126+ // // // }
127+ // // // async provideInlayHints(
128+ // // // document: TextDocument,
129+ // // // range: Range,
130+ // // // token: CancellationToken
131+ // // // ): Promise<InlayHint[]> {
132+ // // // const hints = (await client
133+ // // // .sendRequest("custom/inlay_hint", { path: document.uri.toString() })
134+ // // // .catch(err => null)) as [number, number, string][];
135+ // // // if (hints == null) {
136+ // // // return [];
137+ // // // } else {
138+ // // // return hints.map(item => {
139+ // // // const [start, end, label] = item;
140+ // // // let startPosition = document.positionAt(start);
141+ // // // let endPosition = document.positionAt(end);
142+ // // // return {
143+ // // // position: endPosition,
144+ // // // paddingLeft: true,
145+ // // // label: [
146+ // // // {
147+ // // // value: `${label}`,
148+ // // // // location: {
149+ // // // // uri: document.uri,
150+ // // // // range: new Range(1, 0, 1, 0)
151+ // // // // }
152+ // // // command: {
153+ // // // title: "hello world",
154+ // // // command: "helloworld.helloWorld",
155+ // // // arguments: [document.uri],
156+ // // // },
157+ // // // },
158+ // // // ],
159+ // // // };
160+ // // // });
161+ // // // }
162+ // // // }
163+ // // // })()
164+ // // );
165+ // },
166+
167+ // onDidChangeTextDocument({ contentChanges, document }: TextDocumentChangeEvent) {
168+ // // debugger
169+ // // this.updateHintsEventEmitter.fire();
170+ // },
171+
172+ // dispose() {
173+ // this.hintsProvider?.dispose();
174+ // this.hintsProvider = null;
175+ // this.updateHintsEventEmitter.dispose();
176+ // },
177+ // };
178+
179+ // workspace.onDidChangeConfiguration(maybeUpdater.onConfigChange, maybeUpdater, ctx.subscriptions);
180+ // workspace.onDidChangeTextDocument(maybeUpdater.onDidChangeTextDocument, maybeUpdater, ctx.subscriptions);
181+
182+ // maybeUpdater.onConfigChange().catch(console.error);
183+ // }
0 commit comments