backport: 14.5.0
This commit is contained in:
parent
db16c7d9b8
commit
ae40d4e2e1
16 changed files with 100 additions and 67 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -17,6 +17,25 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [14.5.0]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Project
|
||||||
|
- Updated new project templates to the latest Zig 0.13.0 init files
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Zig
|
||||||
|
- Fixed inconsistent caret indenting for switches and function parameters
|
||||||
|
- More robust highlighting when auto-formatting
|
||||||
|
- Fixed multiple grammar errors
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- LSP
|
||||||
|
- Notification spam about ZLS missing in non-zig projects
|
||||||
|
|
||||||
## [14.4.0]
|
## [14.4.0]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
4
LICENSE
4
LICENSE
|
@ -36,5 +36,5 @@ developed by HTGAzureX1212 (https://github.com/HTGAzureX1212), licensed under th
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
All of the licenses listed here are available in the following files, bundled with the plugin:
|
All of the licenses listed here are available in the following files, bundled with the plugin:
|
||||||
- APACHE_2.0.LICENSE
|
- licenses/APACHE_2.0.LICENSE
|
||||||
- CC_BY_SA_4.0.LICENSE
|
- licenses/CC_BY_SA_4.0.LICENSE
|
|
@ -23,11 +23,6 @@ through the built-in plugin browser:
|
||||||
4. Click `OK`, and your IDE should now automatically detect the latest version
|
4. Click `OK`, and your IDE should now automatically detect the latest version
|
||||||
(both in the Installed tab and in the Marketplace tab), even if it's not yet verified on the official JetBrains marketplace yet.
|
(both in the Installed tab and in the Marketplace tab), even if it's not yet verified on the official JetBrains marketplace yet.
|
||||||
|
|
||||||
(optional) If you want to access the latest development versions (`2024.2.*` ONLY), you can use this updater URL:
|
|
||||||
https://falsepattern.com/zigbrains/updatePlugins-dev.xml
|
|
||||||
|
|
||||||
These dev releases are based on the latest public commits on the `master` branch, so they're not backported to older IDE versions, only tagged releases are.
|
|
||||||
|
|
||||||
## Developer guide
|
## Developer guide
|
||||||
|
|
||||||
### All platforms
|
### All platforms
|
||||||
|
|
|
@ -770,7 +770,7 @@ public class EditorEventManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
context.commitDocument();
|
context.commitDocument();
|
||||||
applyEdit(Integer.MAX_VALUE, toEither(addTextEdits), "Completion : " + label, false, false);
|
applyEdit(Integer.MAX_VALUE, toEither(addTextEdits), "Completion : " + label, false);
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
executeCommands(Collections.singletonList(command));
|
executeCommands(Collections.singletonList(command));
|
||||||
}
|
}
|
||||||
|
@ -893,7 +893,7 @@ public class EditorEventManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean applyEdit(List<Either<TextEdit, InsertReplaceEdit>> edits, String name, boolean setCaret) {
|
boolean applyEdit(List<Either<TextEdit, InsertReplaceEdit>> edits, String name, boolean setCaret) {
|
||||||
return applyEdit(Integer.MAX_VALUE, edits, name, false, setCaret);
|
return applyEdit(Integer.MAX_VALUE, edits, name, setCaret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -902,26 +902,30 @@ public class EditorEventManager {
|
||||||
* @param version The version of the edits (will be discarded if older than current version)
|
* @param version The version of the edits (will be discarded if older than current version)
|
||||||
* @param edits The edits to apply
|
* @param edits The edits to apply
|
||||||
* @param name The name of the edits (Rename, for example)
|
* @param name The name of the edits (Rename, for example)
|
||||||
* @param closeAfter will close the file after edits if set to true
|
|
||||||
* @return True if the edits were applied, false otherwise
|
* @return True if the edits were applied, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean applyEdit(int version, List<Either<TextEdit, InsertReplaceEdit>> edits, String name, boolean closeAfter, boolean setCaret) {
|
boolean applyEdit(int version, List<Either<TextEdit, InsertReplaceEdit>> edits, String name, boolean setCaret) {
|
||||||
Runnable runnable = getEditsRunnable(version, edits, name, setCaret);
|
Runnable runnable = getEditsRunnable(version, edits, name, setCaret);
|
||||||
writeAction(() -> {
|
writeAction(() -> {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
CommandProcessor.getInstance()
|
CommandProcessor.getInstance()
|
||||||
.executeCommand(project, runnable, name, "LSPPlugin", editor.getDocument());
|
.executeCommand(project, runnable, name, "LSPPlugin", editor.getDocument());
|
||||||
}
|
}
|
||||||
if (closeAfter) {
|
postEdit();
|
||||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
// if (closeAfter) {
|
||||||
if (file != null) {
|
// PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||||
FileEditorManager.getInstance(project).closeFile(file.getVirtualFile());
|
// if (file != null) {
|
||||||
}
|
// FileEditorManager.getInstance(project).closeFile(file.getVirtualFile());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
return runnable != null;
|
return runnable != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void postEdit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Runnable used to apply the given edits and save the document
|
* Returns a Runnable used to apply the given edits and save the document
|
||||||
* Used by WorkspaceEditHandler (allows to revert a rename for example)
|
* Used by WorkspaceEditHandler (allows to revert a rename for example)
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "@@PROJECT_NAME@@",
|
.name = "@@PROJECT_NAME@@",
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,7 @@ pub fn build(b: *std.Build) void {
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
const exe_unit_tests = b.addTest(.{
|
const exe_unit_tests = b.addTest(.{
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,6 +37,11 @@
|
||||||
// // build root. In this case the package's hash is irrelevant and therefore not
|
// // build root. In this case the package's hash is irrelevant and therefore not
|
||||||
// // computed. This field and `url` are mutually exclusive.
|
// // computed. This field and `url` are mutually exclusive.
|
||||||
// .path = "foo",
|
// .path = "foo",
|
||||||
|
|
||||||
|
// // When this is set to `true`, a package is declared to be lazily
|
||||||
|
// // fetched. This makes the dependency only get fetched if it is
|
||||||
|
// // actually used.
|
||||||
|
// .lazy = false,
|
||||||
//},
|
//},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.name = "@@PROJECT_NAME@@",
|
.name = "@@PROJECT_NAME@@",
|
||||||
// In this case the main source file is merely a path, however, in more
|
// In this case the main source file is merely a path, however, in more
|
||||||
// complicated build scripts, this could be a generated file.
|
// complicated build scripts, this could be a generated file.
|
||||||
.root_source_file = .{ .path = "src/root.zig" },
|
.root_source_file = b.path("src/root.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void {
|
||||||
// Creates a step for unit testing. This only builds the test executable
|
// Creates a step for unit testing. This only builds the test executable
|
||||||
// but does not run it.
|
// but does not run it.
|
||||||
const lib_unit_tests = b.addTest(.{
|
const lib_unit_tests = b.addTest(.{
|
||||||
.root_source_file = .{ .path = "src/root.zig" },
|
.root_source_file = b.path("src/root.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
|
@ -177,7 +177,7 @@ TestDecl ::= DOC_COMMENT? KEYWORD_TEST (STRING_LITERAL_SINGLE | IDENTIFIER)? Blo
|
||||||
ComptimeDecl ::= KEYWORD_COMPTIME Block {pin=1}
|
ComptimeDecl ::= KEYWORD_COMPTIME Block {pin=1}
|
||||||
|
|
||||||
Decl
|
Decl
|
||||||
::= (KEYWORD_EXPORT | KEYWORD_EXTERN STRING_LITERAL_SINGLE? | KEYWORD_INLINE | KEYWORD_NOILINE)? FnProto (SEMICOLON | Block)
|
::= (KEYWORD_EXPORT | KEYWORD_EXTERN STRING_LITERAL_SINGLE? | KEYWORD_INLINE | KEYWORD_NOINLINE)? FnProto (SEMICOLON | Block)
|
||||||
| (KEYWORD_EXPORT | KEYWORD_EXTERN STRING_LITERAL_SINGLE?)? KEYWORD_THREADLOCAL? GlobalVarDecl
|
| (KEYWORD_EXPORT | KEYWORD_EXTERN STRING_LITERAL_SINGLE?)? KEYWORD_THREADLOCAL? GlobalVarDecl
|
||||||
| KEYWORD_USINGNAMESPACE Expr SEMICOLON
|
| KEYWORD_USINGNAMESPACE Expr SEMICOLON
|
||||||
|
|
||||||
|
@ -216,12 +216,18 @@ LabeledStatement ::= BlockLabel? (Block | LoopStatement)
|
||||||
LoopStatement ::= KEYWORD_INLINE? (ForStatement | WhileStatement)
|
LoopStatement ::= KEYWORD_INLINE? (ForStatement | WhileStatement)
|
||||||
|
|
||||||
ForStatement
|
ForStatement
|
||||||
::= ForPrefix BlockExpr ( KEYWORD_ELSE Statement )?
|
::= ForPrefix ZB_ForStatement_Body {pin(".*")=1}
|
||||||
| ForPrefix AssignExpr ( SEMICOLON | KEYWORD_ELSE Statement ) {pin(".*")=1}
|
|
||||||
|
private ZB_ForStatement_Body
|
||||||
|
::= BlockExpr ( KEYWORD_ELSE Statement )?
|
||||||
|
| AssignExpr ( SEMICOLON | KEYWORD_ELSE Statement )
|
||||||
|
|
||||||
WhileStatement
|
WhileStatement
|
||||||
::= WhilePrefix BlockExpr ( KEYWORD_ELSE Payload? Statement )?
|
::= WhilePrefix ZB_WhileStatement_Body {pin(".*") =1}
|
||||||
| WhilePrefix AssignExpr ( SEMICOLON | KEYWORD_ELSE Payload? Statement) {pin(".*") =1}
|
|
||||||
|
private ZB_WhileStatement_Body
|
||||||
|
::= BlockExpr ( KEYWORD_ELSE Payload? Statement )?
|
||||||
|
| AssignExpr ( SEMICOLON | KEYWORD_ELSE Payload? Statement)
|
||||||
|
|
||||||
BlockExprStatement
|
BlockExprStatement
|
||||||
::= BlockExpr
|
::= BlockExpr
|
||||||
|
@ -276,7 +282,7 @@ PrimaryExpr
|
||||||
|
|
||||||
IfExpr ::= IfPrefix Expr (KEYWORD_ELSE Payload? Expr)?
|
IfExpr ::= IfPrefix Expr (KEYWORD_ELSE Payload? Expr)?
|
||||||
|
|
||||||
Block ::= LBRACE ZB_Block_Statement RBRACE {pin(".*")=1}
|
Block ::= LBRACE ZB_Block_Statement RBRACE {pin=1}
|
||||||
|
|
||||||
private ZB_Block_Statement ::= Statement* {recoverWhile="ZB_Block_Statement_recover"}
|
private ZB_Block_Statement ::= Statement* {recoverWhile="ZB_Block_Statement_recover"}
|
||||||
|
|
||||||
|
@ -291,9 +297,12 @@ WhileExpr ::= WhilePrefix Expr (KEYWORD_ELSE Payload? Expr)?
|
||||||
CurlySuffixExpr ::= TypeExpr InitList?
|
CurlySuffixExpr ::= TypeExpr InitList?
|
||||||
|
|
||||||
InitList
|
InitList
|
||||||
::= LBRACE FieldInit (COMMA ZB_InitList_FieldInit)* COMMA? RBRACE
|
::= LBRACE ZB_InitList_Body {pin=1}
|
||||||
| LBRACE Expr (COMMA ZB_InitList_Expr)* COMMA? RBRACE
|
|
||||||
| LBRACE RBRACE {pin=1}
|
private ZB_InitList_Body
|
||||||
|
::= FieldInit (COMMA ZB_InitList_FieldInit)* COMMA? RBRACE
|
||||||
|
| Expr (COMMA ZB_InitList_Expr)* COMMA? RBRACE
|
||||||
|
| RBRACE {pin(".*")=1}
|
||||||
|
|
||||||
private ZB_InitList_FieldInit ::= FieldInit {recoverWhile="#auto"}
|
private ZB_InitList_FieldInit ::= FieldInit {recoverWhile="#auto"}
|
||||||
private ZB_InitList_Expr ::= Expr {recoverWhile="#auto"}
|
private ZB_InitList_Expr ::= Expr {recoverWhile="#auto"}
|
||||||
|
@ -404,7 +413,7 @@ PtrPayload ::= PIPE ASTERISK? IDENTIFIER PIPE
|
||||||
PtrIndexPayload ::= PIPE (ASTERISK? IDENTIFIER COMMA)* (ASTERISK? IDENTIFIER) PIPE
|
PtrIndexPayload ::= PIPE (ASTERISK? IDENTIFIER COMMA)* (ASTERISK? IDENTIFIER) PIPE
|
||||||
|
|
||||||
// Switch specific
|
// Switch specific
|
||||||
SwitchProng ::= KEYWORD_INLINE? SwitchCase EQUALRARROW PtrIndexPayload? SingleAssignExpr
|
SwitchProng ::= KEYWORD_INLINE? SwitchCase EQUALRARROW PtrIndexPayload? SingleAssignExpr {pin=3}
|
||||||
|
|
||||||
SwitchCase
|
SwitchCase
|
||||||
::= SwitchItem (COMMA SwitchItem)* COMMA?
|
::= SwitchItem (COMMA SwitchItem)* COMMA?
|
||||||
|
@ -493,11 +502,7 @@ SuffixOp
|
||||||
| DOTASTERISK
|
| DOTASTERISK
|
||||||
| DOTQUESTIONMARK
|
| DOTQUESTIONMARK
|
||||||
|
|
||||||
FnCallArguments ::= LPAREN ZB_FnCallArguments_ExprList RPAREN {pin=1}
|
FnCallArguments ::= LPAREN ExprList RPAREN {pin=1}
|
||||||
|
|
||||||
private ZB_FnCallArguments_ExprList ::= ExprList {recoverWhile="ZB_FnCallArguments_ExprList_recover"}
|
|
||||||
|
|
||||||
private ZB_FnCallArguments_ExprList_recover ::= !(RPAREN)
|
|
||||||
|
|
||||||
// Ptr specific
|
// Ptr specific
|
||||||
SliceTypeStart ::= LBRACKET (COLON Expr)? RBRACKET
|
SliceTypeStart ::= LBRACKET (COLON Expr)? RBRACKET
|
||||||
|
@ -530,7 +535,7 @@ ByteAlign ::= KEYWORD_ALIGN LPAREN Expr RPAREN
|
||||||
// Lists
|
// Lists
|
||||||
IdentifierList ::= (DOC_COMMENT? IDENTIFIER COMMA)* (DOC_COMMENT? IDENTIFIER)?
|
IdentifierList ::= (DOC_COMMENT? IDENTIFIER COMMA)* (DOC_COMMENT? IDENTIFIER)?
|
||||||
|
|
||||||
SwitchProngList ::= (SwitchProng COMMA)* SwitchProng?
|
SwitchProngList ::= (SwitchProng COMMA)* SwitchProng? {recoverWhile="#auto"}
|
||||||
|
|
||||||
AsmOutputList ::= (AsmOutputItem COMMA)* AsmOutputItem?
|
AsmOutputList ::= (AsmOutputItem COMMA)* AsmOutputItem?
|
||||||
|
|
||||||
|
@ -540,6 +545,9 @@ StringList ::= (StringLiteral COMMA)* StringLiteral?
|
||||||
|
|
||||||
ParamDeclList ::= (ParamDecl COMMA)* ParamDecl?
|
ParamDeclList ::= (ParamDecl COMMA)* ParamDecl?
|
||||||
|
|
||||||
ExprList ::= (Expr COMMA)* Expr?
|
ExprList ::= (ZB_ExprList_Expr COMMA)* ZB_ExprList_Expr?
|
||||||
|
|
||||||
|
private ZB_ExprList_Expr ::= Expr {recoverWhile="ZB_ExprList_recover"}
|
||||||
|
private ZB_ExprList_recover ::= !(RPAREN | COMMA)
|
||||||
|
|
||||||
StringLiteral ::= STRING_LITERAL_SINGLE | STRING_LITERAL_MULTI
|
StringLiteral ::= STRING_LITERAL_SINGLE | STRING_LITERAL_MULTI
|
|
@ -39,6 +39,7 @@ import static com.falsepattern.zigbrains.zig.psi.ZigTypes.CONTAINER_DECL_TYPE;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.CONTAINER_DOC_COMMENT;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.CONTAINER_DOC_COMMENT;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.EXPR_LIST;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.EXPR_LIST;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.FN_CALL_ARGUMENTS;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.FN_CALL_ARGUMENTS;
|
||||||
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.FN_PROTO;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.IF_EXPR;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.IF_EXPR;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.IF_PREFIX;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.IF_PREFIX;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.IF_STATEMENT;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.IF_STATEMENT;
|
||||||
|
@ -46,10 +47,10 @@ import static com.falsepattern.zigbrains.zig.psi.ZigTypes.INIT_LIST;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.KEYWORD_ELSE;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.KEYWORD_ELSE;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.LBRACE;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.LBRACE;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.LPAREN;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.LPAREN;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.PARAM_DECL;
|
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.PARAM_DECL_LIST;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.PARAM_DECL_LIST;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.RBRACE;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.RBRACE;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.RPAREN;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.RPAREN;
|
||||||
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.SWITCH_EXPR;
|
||||||
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.SWITCH_PRONG_LIST;
|
import static com.falsepattern.zigbrains.zig.psi.ZigTypes.SWITCH_PRONG_LIST;
|
||||||
|
|
||||||
public class ZigBlock extends AbstractBlock {
|
public class ZigBlock extends AbstractBlock {
|
||||||
|
@ -87,9 +88,11 @@ public class ZigBlock extends AbstractBlock {
|
||||||
return myNode.getFirstChildNode() == null;
|
return myNode.getFirstChildNode() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final IElementType PLACEHOLDER = new IElementType("placeholder", null);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable Indent getChildIndent() {
|
protected @Nullable Indent getChildIndent() {
|
||||||
return getIndentBasedOnParentType(getNode().getElementType(), null);
|
return getIndentBasedOnParentType(getNode().getElementType(), PLACEHOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,36 +104,44 @@ public class ZigBlock extends AbstractBlock {
|
||||||
return Indent.getNoneIndent();
|
return Indent.getNoneIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isBrace(IElementType element) {
|
||||||
|
return element == LBRACE || element == RBRACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isParen(IElementType element) {
|
||||||
|
return element == LPAREN || element == RPAREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Indent getIndentBasedOnParentType(IElementType parentElementType, IElementType childElementType) {
|
private static Indent getIndentBasedOnParentType(IElementType parentElementType, IElementType childElementType) {
|
||||||
//Statement blocks
|
//Statement blocks
|
||||||
if (parentElementType == BLOCK && childElementType != LBRACE && childElementType != RBRACE)
|
if (parentElementType == BLOCK && !isBrace(childElementType))
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
//Struct/tuple initializers
|
//Struct/tuple initializers
|
||||||
if (parentElementType == INIT_LIST && childElementType != LBRACE && childElementType != RBRACE)
|
if (parentElementType == INIT_LIST && !isBrace(childElementType))
|
||||||
return Indent.getNormalIndent();
|
|
||||||
|
|
||||||
//Comma expressions
|
|
||||||
if (parentElementType == EXPR_LIST)
|
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
//Function call args
|
//Function call args
|
||||||
if (parentElementType == FN_CALL_ARGUMENTS && childElementType != LPAREN && childElementType != RPAREN)
|
if (parentElementType == EXPR_LIST ||
|
||||||
|
parentElementType == FN_CALL_ARGUMENTS && childElementType == PLACEHOLDER)
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
//Function declaration parameters
|
//Function declaration parameters
|
||||||
if (parentElementType == PARAM_DECL_LIST)
|
if (parentElementType == PARAM_DECL_LIST ||
|
||||||
|
parentElementType == FN_PROTO && childElementType == PLACEHOLDER)
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
//Switch prongs
|
//Switch prongs
|
||||||
if (parentElementType == SWITCH_PRONG_LIST)
|
if (parentElementType == SWITCH_PRONG_LIST ||
|
||||||
|
parentElementType == SWITCH_EXPR && childElementType == PLACEHOLDER)
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
//If expressions/statements
|
//If expressions/statements
|
||||||
if ((parentElementType == IF_EXPR || parentElementType == IF_STATEMENT) && childElementType != KEYWORD_ELSE && childElementType != IF_PREFIX)
|
if ((parentElementType == IF_EXPR || parentElementType == IF_STATEMENT) && childElementType != KEYWORD_ELSE && childElementType != IF_PREFIX)
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
if (parentElementType == CONTAINER_DECL_AUTO && childElementType != CONTAINER_DECL_TYPE && childElementType != LBRACE && childElementType != CONTAINER_DOC_COMMENT && childElementType != RBRACE)
|
if (parentElementType == CONTAINER_DECL_AUTO && childElementType != CONTAINER_DECL_TYPE && childElementType != CONTAINER_DOC_COMMENT && !isBrace(childElementType))
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
|
|
||||||
return Indent.getNoneIndent();
|
return Indent.getNoneIndent();
|
||||||
|
|
|
@ -29,14 +29,11 @@ import com.falsepattern.zigbrains.zig.util.TokenDecoder;
|
||||||
import com.intellij.lang.annotation.Annotation;
|
import com.intellij.lang.annotation.Annotation;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.editor.event.DocumentListener;
|
import com.intellij.openapi.editor.event.DocumentListener;
|
||||||
import lombok.val;
|
|
||||||
import org.eclipse.lsp4j.InsertReplaceEdit;
|
|
||||||
import org.eclipse.lsp4j.SemanticTokens;
|
import org.eclipse.lsp4j.SemanticTokens;
|
||||||
import org.eclipse.lsp4j.SemanticTokensDelta;
|
import org.eclipse.lsp4j.SemanticTokensDelta;
|
||||||
import org.eclipse.lsp4j.SemanticTokensDeltaParams;
|
import org.eclipse.lsp4j.SemanticTokensDeltaParams;
|
||||||
import org.eclipse.lsp4j.SemanticTokensEdit;
|
import org.eclipse.lsp4j.SemanticTokensEdit;
|
||||||
import org.eclipse.lsp4j.SemanticTokensParams;
|
import org.eclipse.lsp4j.SemanticTokensParams;
|
||||||
import org.eclipse.lsp4j.TextEdit;
|
|
||||||
import org.eclipse.lsp4j.jsonrpc.JsonRpcException;
|
import org.eclipse.lsp4j.jsonrpc.JsonRpcException;
|
||||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||||
|
|
||||||
|
@ -118,13 +115,7 @@ public class ZLSEditorEventManager extends EditorEventManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Runnable getEditsRunnable(int version, List<Either<TextEdit, InsertReplaceEdit>> edits, String name, boolean setCaret) {
|
protected void postEdit() {
|
||||||
val run = super.getEditsRunnable(version, edits, name, setCaret);
|
HighlightingUtil.refreshHighlighting(this);
|
||||||
return () -> {
|
|
||||||
run.run();
|
|
||||||
if (!editor.isDisposed()) {
|
|
||||||
HighlightingUtil.refreshHighlighting(this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ZLSStartupActivity implements ProjectActivity {
|
||||||
}
|
}
|
||||||
var configPath = state.zlsConfigPath;
|
var configPath = state.zlsConfigPath;
|
||||||
boolean configOK = true;
|
boolean configOK = true;
|
||||||
if (!configPath.isEmpty() && !validatePath("ZLS Config", configPath, false)) {
|
if (!configPath.isBlank() && !validatePath("ZLS Config", configPath, false)) {
|
||||||
Notifications.Bus.notify(new Notification("ZigBrains.ZLS", "Using default config path.",
|
Notifications.Bus.notify(new Notification("ZigBrains.ZLS", "Using default config path.",
|
||||||
NotificationType.INFORMATION));
|
NotificationType.INFORMATION));
|
||||||
configPath = null;
|
configPath = null;
|
||||||
|
@ -138,7 +138,6 @@ public class ZLSStartupActivity implements ProjectActivity {
|
||||||
|
|
||||||
private static boolean validatePath(String name, String pathTxt, boolean dir) {
|
private static boolean validatePath(String name, String pathTxt, boolean dir) {
|
||||||
if (pathTxt == null || pathTxt.isBlank()) {
|
if (pathTxt == null || pathTxt.isBlank()) {
|
||||||
Notifications.Bus.notify(new Notification("ZigBrains.ZLS", "Missing " + name, "No path was specified", NotificationType.WARNING));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Path path;
|
Path path;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
All code in this project, unless specified differently, is licensed under the `Apache 2.0` license.
|
All code in this project, unless specified differently, is licensed under the Apache 2.0 license.
|
||||||
|
Graphical assets derived from the Zig logo are governed by a different license, included below.
|
||||||
|
--------------------------------
|
||||||
ZigBrains
|
ZigBrains
|
||||||
|
|
||||||
Copyright 2023-2024 FalsePattern
|
Copyright 2023-2024 FalsePattern
|
||||||
|
@ -35,5 +36,5 @@ developed by HTGAzureX1212 (https://github.com/HTGAzureX1212), licensed under th
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
All of the licenses listed here are available in the following files, bundled with the plugin:
|
All of the licenses listed here are available in the following files, bundled with the plugin:
|
||||||
- APACHE_2.0.LICENSE
|
- licenses/APACHE_2.0.LICENSE
|
||||||
- CC_BY_SA_4.0.LICENSE
|
- licenses/CC_BY_SA_4.0.LICENSE
|
Loading…
Add table
Reference in a new issue