Global completions now check config for snippet support, modified readme to reflect changes.
This commit is contained in:
parent
25cc662bcc
commit
86fbf5fe7e
10
README.md
10
README.md
@ -16,11 +16,19 @@ zig build
|
|||||||
|
|
||||||
| Option | Type | What it Does |
|
| Option | Type | What it Does |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `-Dno_snippets` | `bool` | Enables "no snippets" mode for compatibility with language clients that do not support snippets (such as ale). |
|
|
||||||
| `-Ddata_version` | `string` | The data file version. Any files in the `src/data` file that correspond with the Zig version you want the language server to build for (0.6.0, master).
|
| `-Ddata_version` | `string` | The data file version. Any files in the `src/data` file that correspond with the Zig version you want the language server to build for (0.6.0, master).
|
||||||
|
|
||||||
Then, you can use the `zls` executable in an editor of your choice that has a Zig language server client!
|
Then, you can use the `zls` executable in an editor of your choice that has a Zig language server client!
|
||||||
|
|
||||||
|
### Configuration options
|
||||||
|
|
||||||
|
You can configure zls by providing a zls.json file in the same directory as the executable.
|
||||||
|
The following options are currently available.
|
||||||
|
|
||||||
|
| Option | Type | Default value | What it Does |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `enable_snippets` | `bool` | `true` | Enables snippet completion, set to false for compatibility with language clients that do not support snippets (such as ale). |
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
`zls` is in its early stages, with a full analysis/completion engine coming soon, but it is still usable.
|
`zls` is in its early stages, with a full analysis/completion engine coming soon, but it is still usable.
|
||||||
|
@ -248,10 +248,10 @@ fn completeGlobal(id: i64, document: *types.TextDocument, config: Config) !void
|
|||||||
.FnProto => {
|
.FnProto => {
|
||||||
const func = decl.cast(std.zig.ast.Node.FnProto).?;
|
const func = decl.cast(std.zig.ast.Node.FnProto).?;
|
||||||
if (func.name_token) |name_token| {
|
if (func.name_token) |name_token| {
|
||||||
const insert_text = if (build_options.no_snippets)
|
const insert_text = if(config.enable_snippets)
|
||||||
null
|
try analysis.getFunctionSnippet(&arena.allocator, tree, func)
|
||||||
else
|
else
|
||||||
try analysis.getFunctionSnippet(&arena.allocator, tree, func);
|
null;
|
||||||
|
|
||||||
var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
|
var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
|
||||||
var doc = types.MarkupContent{
|
var doc = types.MarkupContent{
|
||||||
@ -264,7 +264,7 @@ fn completeGlobal(id: i64, document: *types.TextDocument, config: Config) !void
|
|||||||
.documentation = doc,
|
.documentation = doc,
|
||||||
.detail = analysis.getFunctionSignature(tree, func),
|
.detail = analysis.getFunctionSignature(tree, func),
|
||||||
.insertText = insert_text,
|
.insertText = insert_text,
|
||||||
.insertTextFormat = if(build_options.no_snippets) .PlainText else .Snippet,
|
.insertTextFormat = if(config.enable_snippets) .Snippet else .PlainText,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user