Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e18c0b2
Adding LanguageConfiguration.
jlahoda Jul 19, 2026
413f55f
Adding configuration toggle comment action.
jlahoda Jul 19, 2026
cbbe31b
Adding test; adding ability to register language configuration.
Jul 26, 2026
5535ea5
Improving the language-configuration-based toggle line comment action.
jlahoda Aug 9, 2026
5e292cb
Merge remote-tracking branch 'origin/language-configuration-support' …
Aug 11, 2026
1bb6abd
language-configuration based brace matching
jlahoda Aug 15, 2026
e0e300a
Merge remote-tracking branch 'origin/language-configuration-support' …
Aug 16, 2026
cf1acef
Sketch of typing completion.
jlahoda Aug 23, 2026
9a0c164
Adding test.
Aug 25, 2026
5481e0f
Optimization.
Sep 5, 2026
ccca35b
Improving typing completion.
jlahoda Sep 12, 2026
cd20de9
Fixes.
jlahoda Sep 12, 2026
dfe4415
Support for autoCloseBefore.
jlahoda Sep 12, 2026
c2b1a47
Surrounding pairs.
jlahoda Sep 13, 2026
cfc20b3
Merge remote-tracking branch 'upstream' into language-configuration-s…
jlahoda Oct 17, 2026
f53bbdb
Working on making the language-configuration.json support usable.
jlahoda Oct 25, 2026
1f05b50
Improving javadoc, by qwen3.8.
jlahoda Oct 25, 2026
72416ca
Filling in an api change.
jlahoda Oct 25, 2026
5671bbe
Moving LanguageConfiguration out of the 'friend' package.
jlahoda Nov 1, 2026
b4a172e
Update ide/lsp.client/src/org/netbeans/modules/lsp/client/api/Languag…
lahodaj Nov 1, 2026
32d0dd9
Merge remote-tracking branch 'lahodaj/language-configuration-support'…
Nov 1, 2026
58f12bc
Review feedback: use sharper types for the Lookup API.
Nov 7, 2026
9c8109e
Reflecting review feedback: adding links between GrammarRegistration …
Nov 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cpplite/cpplite.editor/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<license ref="MIT-cpp-textmate-grammars" />
<comment type="COMMENT_UNSUPPORTED">Source: https://github.com/jeff-hykin/cpp-textmate-grammar</comment>
</fileset>
<fileset>
<file>src/org/netbeans/modules/cpplite/editor/file/resources/language-configuration.json</file>
<license ref="MIT-vscode" />
<comment type="COMMENT_UNSUPPORTED">Source: https://github.com/microsoft/vscode/blob/main/extensions/cpp/language-configuration.json</comment>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • What's the relation between TextMate grammar and this language configuration?
  • Couldn't both these files be consumed by @GrammarRegistration?
  • e.g. add an optional languageConfiguration attribute to @GrammarRegistration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, the language configuration and grammars are independent (after all, they are two independent files). I admit that in practice, it is hard to image a language configuration for a language with a non-Textmate lexer lexer, so, in practice, these are likely to be used together.

I am, however, not convinced that putting "language configuration" into "GrammarRegistration" is appropriate: the language configuration is not really a grammar, and it is certainly not a place where I would look for the registration of the language configuration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

language configuration and grammars are independent ... they are two independent files

I was suggesting another attribute, not putting both into the same file...

...in practice, these are likely to be used together....

Yeah, that was the reason why I wanted to collocate them.

If you think collocating them isn't appropriate then at least hyperlink them in Javadoc strongly suggesting to implement both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Do we have such a file also for Kotlin?

Please consider expanding the Kotlin language support with language-configuration.json too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

language configuration and grammars are independent ... they are two independent files

I was suggesting another attribute, not putting both into the same file...

I know, but they are still separate files with separate, although connected, purposes. We have plenty of other separate annotations on the DatObjects - should extension and icon definition also be merged as optional attributes into GrammarRegistration? Because the link between an extension, icon and grammar is not much weaker than between the language configuration and the grammar.

...in practice, these are likely to be used together....

Yeah, that was the reason why I wanted to collocate them.

If you think collocating them isn't appropriate then at least hyperlink them in Javadoc strongly suggesting to implement both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Do we have such a file also for Kotlin?

Please consider expanding the Kotlin language support with language-configuration.json too.

I don't think this PR is an appropriate venue for this. I can remove the C/C++ language configuration and keep just the actual effective code if adding C/C++ config is seen as inappropriate here.

</fileset>
<fileset>
<file>src/org/netbeans/modules/cpplite/editor/file/resources/CCSrcIcon.gif</file>
<file>src/org/netbeans/modules/cpplite/editor/file/resources/HDataIcon.gif</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/c.tmLanguage.json", mimeType=MIMETypes.C)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.C)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice API.

public class CDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/cpp.tmLanguage.json", mimeType=MIMETypes.CPP)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.CPP)
public class CPPDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/c.tmLanguage.json", mimeType=MIMETypes.H)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.H)
public class HDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.netbeans.modules.lsp.client.api.LanguageConfigurationRegistration;
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -115,6 +116,7 @@
)
})
@GrammarRegistration(grammar="resources/cpp.tmLanguage.json", mimeType=MIMETypes.HPP)
@LanguageConfigurationRegistration(languageConfiguration="resources/language-configuration.json", mimeType=MIMETypes.HPP)
public class HPPDataObject extends MultiDataObject {

@StaticResource
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"comments": {
"lineComment": "//",
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{
"open": "[",
"close": "]"
},
{
"open": "{",
"close": "}"
},
{
"open": "(",
"close": ")"
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "/*",
"close": "*/",
"notIn": [
"string",
"comment"
]
},
{
"open": "/**",
"close": " */",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
],
[
"<",
">"
]
],
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
"folding": {
"markers": {
"start": "^\\s*#\\s*pragma\\s+region\\b",
"end": "^\\s*#\\s*pragma\\s+endregion\\b"
}
},
"indentationRules": {
"decreaseIndentPattern": {
"pattern": "^\\s*[\\}\\]\\)].*$"
},
"increaseIndentPattern": {
"pattern": "^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$"
},
},
"onEnterRules": [
{
// Decrease indentation after single line if/else if/else, for, or while
"previousLineText": "^\\s*(((else ?)?if|for|while)\\s*\\(.*\\)\\s*|else\\s*)$",
// But make sure line doesn't have braces or is not another if statement
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
"action": {
"indent": "outdent"
}
},
// Add // when pressing enter from inside line comment
{
"beforeText": "^\\s*//\\s*\\S|\\s//\\s+\\S",
"afterText": "^(?!\\s*$)",
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
under the License.

-->
<project basedir="." default="build" name="enterprise/libs.jackson">
<project basedir="." default="build" name="ide/libs.jackson">
<import file="../../nbbuild/templates/projectized.xml"/>
</project>
File renamed without changes.
Comment thread
jtulach marked this conversation as resolved.
Resolved
File renamed without changes.
17 changes: 16 additions & 1 deletion ide/lsp.client/apichanges.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,27 @@
under the License.

-->
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../../nbbuild/javadoctools/apichanges.dtd">
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.1//EN" "../../nbbuild/javadoctools/apichanges-1.1.dtd">
<apichanges>
<apidefs>
<apidef name="lsp_client">LSP Client API</apidef>
</apidefs>
<changes>
<change id="LanguageConfigurationJSON">
<api name="lsp_client" />
<summary>Adding LanguageIdProvider</summary>
<version major="0" minor="1.38" />
<date day="2" month="11" year="2026" />
<author login="jlahoda" />
<compatibility addition="yes" binary="compatible" source="compatible" />
<description>
<p>
Basic support for language-configuration.json added.
</p>
</description>
<class name="LanguageFeatures" package="org.netbeans.modules.lsp.client.api"/>
<class name="LanguageConfiguration" package="org.netbeans.modules.lsp.client.spi"/>
</change>
<change id="LanguageIdProvider">
<api name="lsp_client" />
<summary>Adding LanguageIdProvider</summary>
Expand Down
5 changes: 5 additions & 0 deletions ide/lsp.client/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@
<license ref="Apache-2.0-ASF" />
<comment type="COMMENT_UNSUPPORTED" />
</fileset>
<fileset>
<file>test/unit/src/org/netbeans/modules/lsp/client/bindings/configuration/c.tmLanguage.json</file>
<license ref="MIT-cpp-textmate-grammars" />
<comment type="COMMENT_UNSUPPORTED">Source: https://github.com/jeff-hykin/cpp-textmate-grammar</comment>
</fileset>
</licenseinfo>
3 changes: 2 additions & 1 deletion ide/lsp.client/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
javac.release=17
javac.compilerargs=-Xlint -Xlint:-serial
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml

@jtulach jtulach Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am always glad, when a module with an API offers apichanges.xml and they are actually used. It helps to run ant javadoc and read thru the result.

release.external/org.eclipse.lsp4j-0.24.0.jar=modules/ext/org.eclipse.lsp4j-0.24.0.jar
release.external/org.eclipse.lsp4j.generator-0.24.0.jar=modules/ext/org.eclipse.lsp4j.generator-0.24.0.jar
release.external/org.eclipse.lsp4j.jsonrpc-0.24.0.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.24.0.jar
Expand All @@ -26,4 +27,4 @@ release.external/org.eclipse.lsp4j.jsonrpc.debug-0.24.0.jar=modules/ext/org.ecli
release.external/org.eclipse.xtend.lib-2.32.0.jar=modules/ext/org.eclipse.xtend.lib-2.32.0.jar
release.external/org.eclipse.xtend.lib.macro-2.32.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.32.0.jar
release.external/org.eclipse.xtext.xbase.lib-2.32.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.32.0.jar
spec.version.base=1.37.0
spec.version.base=1.38.0
22 changes: 22 additions & 0 deletions ide/lsp.client/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.jackson</code-name-base>
Comment thread
jtulach marked this conversation as resolved.
Resolved
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>2</release-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor</code-name-base>
<build-prerequisite/>
Expand All @@ -111,6 +119,15 @@
<specification-version>1.90</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.bracesmatching</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>0</release-version>
<specification-version>1.72</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.breadcrumbs</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -445,6 +462,10 @@
<recursive/>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.lexer.nbbridge</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.masterfs</code-name-base>
<compile-dependency/>
Expand Down Expand Up @@ -474,6 +495,7 @@
</test-type>
</test-dependencies>
<public-packages>
<package>org.netbeans.modules.lsp.client.api</package>
<package>org.netbeans.modules.lsp.client.debugger.api</package>
<package>org.netbeans.modules.lsp.client.debugger.spi</package>
<package>org.netbeans.modules.lsp.client.spi</package>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.lsp.client.api;

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Target;

/**Register a {@code language-configuration.json} for a given mime type.
*
* Will also register language features defined in {@link LanguageFeatures}
* as appropriate.
*
* <p>Also consider using <a href="@TOP@../org-netbeans-modules-textmate-lexer/org/netbeans/modules/textmate/lexer/api/GrammarRegistration.html">GrammarRegistration</a>
*
* @since 1.38
*/
@Repeatable(LanguageConfigurationRegistrations.class)
@Target({ElementType.PACKAGE, ElementType.TYPE})
public @interface LanguageConfigurationRegistration {
/** The mime-type under which the grammar should be registered.
*
* @return mime-type
*/
public String mimeType();

/** The language configuration to register.
*
* @return language configuration
*/
public String languageConfiguration();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


}
Loading
Loading