Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support qmlls #251

Closed
9 tasks done
seanwu1105 opened this issue Sep 30, 2022 · 2 comments · Fixed by #267, #268 or #269
Closed
9 tasks done

Support qmlls #251

seanwu1105 opened this issue Sep 30, 2022 · 2 comments · Fixed by #267, #268 or #269
Assignees
Labels
enhancement New feature or request

Comments

@seanwu1105
Copy link
Owner

seanwu1105 commented Sep 30, 2022

  • Setup client to qmlls
  • Replace extensionPath with extensionUri
  • Remove qmllint as qmlls includes the linting feature
  • Add configurations to set qmlls path
  • Add configurations to set qmlls CLI options
  • Add configuration to enable/disable qmlls
  • E2E tests
    • qmlls is working with default configurations
    • Change configuration in qmlls scope
@seanwu1105 seanwu1105 added the enhancement New feature or request label Nov 26, 2022
@kelteseth
Copy link

kelteseth commented Dec 23, 2022

So let me share my experience with adding a minimal qmlls support to vscode @seanwu1105 . The current state ( Qt 6.6 development branch) is quite bare bone. It does basic autocompletion, but no syntax highlighting. See Qt issue https://bugreports.qt.io/browse/QTBUG-97637

firefox_Ox1nErgg48.mp4

Adding support via:

  1. Create a new VSCode plugin via the yo wizard
  2. Add activationEvents and qml as a language id to languages package.json
  "activationEvents": [
    "onLanguage:qml"
  ],
  "contributes": {
    "commands": [
      {
        "command": "testy.helloWorld",
        "title": "Hello World"
      }
    ],
    "languages": [
      {
        "id": "qml",
        "extensions": [".qml"],
        "aliases": [ "qml"],
        "filenames": [],
        "firstLine": "^#!/.*\\bpython[0-9.-]*\\b",
        "configuration": "./language-configuration.json",
        "icon": {
          "light": "./icons/qml-light.png",
          "dark": "./icons/qmldark.png"
        }
      }
    ]
  },

Then start the language server in the extension.ts:

// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import { workspace, ExtensionContext } from 'vscode';
import * as vscode from 'vscode';
import {
	LanguageClient,
	LanguageClientOptions,
	ServerOptions,
	Executable,
	ExecutableOptions
} from 'vscode-languageclient/node';

let client: LanguageClient;
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
	// If the extension is launched in debug mode then the debug server options are used
	// Otherwise the run options are used
	const execOpt: ExecutableOptions = { cwd: 'C:/build_qt_debug/qtbase/bin/', env:"QT_LOGGING_RULES='qt.languageserver.*=true'"};
	const execArgs: string[] = ["-l", "C:/Users/Eli/Desktop/test.txt"];
	const exec: Executable = { command: "C:/build_qt_debug/qtbase/bin/qmlls.exe", args: execArgs, options: execOpt };
	const serverOptions: ServerOptions = {
		run: exec,
		debug: exec
	};

	// Options to control the language client
	const clientOptions: LanguageClientOptions = {
		// Register the server for plain text documents
		documentSelector: [{  scheme: 'file', language: 'qml'}]
	};
	// Create the language client and start the client.
	client = new LanguageClient(
		'qml',
		'QML Language Server',
		serverOptions,
		clientOptions,
		true
	);
	
	// Start the client. This will also launch the server
	client.start();
}

// This method is called when your extension is deactivated
export function deactivate() {}

@seanwu1105
Copy link
Owner Author

Hi @kelteseth, thanks for sharing. I know the way to build a language server as I use it to build the linter in the current extension. I don't have time to add this feature for now. It would be great if you can create a PR adding qmlls support to the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment