commit
						584a441327
					
				@ -47,8 +47,8 @@ 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). |
 | 
			
		||||
| `zig_lib_path` | `?[]const u8` | `null` | zig library path, used to analyze std library imports. |
 | 
			
		||||
| `enable_snippets` | `bool` | `false` | Enables snippet completion, set to false for compatibility with language clients that do not support snippets (such as ale). |
 | 
			
		||||
| `zig_lib_path` | `?[]const u8` | `null` | zig library path, e.g. `/path/to/zig/lib/zig`, used to analyze std library imports. |
 | 
			
		||||
| `warn_style` | `bool` | `false` | Enables warnings for style *guideline* mismatches |
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
@ -298,7 +298,6 @@ pub fn resolveTypeOfNode(analysis_ctx: *AnalysisContext, node: *ast.Node) ?*ast.
 | 
			
		||||
        },
 | 
			
		||||
        .Identifier => {
 | 
			
		||||
            if (getChildOfSlice(analysis_ctx.tree, analysis_ctx.scope_nodes, analysis_ctx.tree.getNodeSource(node))) |child| {
 | 
			
		||||
                std.debug.warn("Found node {}\n", .{child});
 | 
			
		||||
                return resolveTypeOfNode(analysis_ctx, child);
 | 
			
		||||
            } else return null;
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								src/main.zig
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.zig
									
									
									
									
									
								
							@ -284,6 +284,7 @@ fn nodeToCompletion(list: *std.ArrayList(types.CompletionItem), analysis_ctx: *D
 | 
			
		||||
 | 
			
		||||
fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []const u8 {
 | 
			
		||||
    var start_idx = pos_index;
 | 
			
		||||
 | 
			
		||||
    while (start_idx > 0 and
 | 
			
		||||
        (std.ascii.isAlNum(handle.document.text[start_idx]) or handle.document.text[start_idx] == '_')) : (start_idx -= 1)
 | 
			
		||||
    {}
 | 
			
		||||
@ -301,6 +302,8 @@ fn gotoDefinitionGlobal(id: i64, pos_index: usize, handle: DocumentStore.Handle)
 | 
			
		||||
    defer tree.deinit();
 | 
			
		||||
 | 
			
		||||
    const name = identifierFromPosition(pos_index, handle);
 | 
			
		||||
    if (name.len == 0) return try respondGeneric(id, null_result_response);
 | 
			
		||||
 | 
			
		||||
    var arena = std.heap.ArenaAllocator.init(allocator);
 | 
			
		||||
    defer arena.deinit();
 | 
			
		||||
 | 
			
		||||
@ -328,15 +331,16 @@ fn gotoDefinitionFieldAccess(
 | 
			
		||||
    line_start_idx: usize,
 | 
			
		||||
    config: Config,
 | 
			
		||||
) !void {
 | 
			
		||||
    const pos_index = try handle.document.positionToIndex(position);
 | 
			
		||||
    var name = identifierFromPosition(pos_index, handle.*);
 | 
			
		||||
    if (name.len == 0) return try respondGeneric(id, null_result_response);
 | 
			
		||||
 | 
			
		||||
    var arena = std.heap.ArenaAllocator.init(allocator);
 | 
			
		||||
    defer arena.deinit();
 | 
			
		||||
 | 
			
		||||
    var analysis_ctx = try document_store.analysisContext(handle, &arena, position, config.zig_lib_path);
 | 
			
		||||
    defer analysis_ctx.deinit();
 | 
			
		||||
 | 
			
		||||
    const pos_index = try handle.document.positionToIndex(position);
 | 
			
		||||
    var name = identifierFromPosition(pos_index, handle.*);
 | 
			
		||||
 | 
			
		||||
    const line = try handle.document.getLine(@intCast(usize, position.line));
 | 
			
		||||
    var tokenizer = std.zig.Tokenizer.init(line[line_start_idx..]);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user