Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 1 addition & 65 deletions handlers.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,9 @@ fn (mut app App) completion(request Request) Response {
col := request.params.position.char
var_ac := app.run_v_line_info(path, line_nr, col)
log('var_ac=${var_ac}')
mut details := []Detail{cap: 3}

$for f in var_ac.fields {
kind := $match f.name {
'methods' {
DetailKind.method
}
'functions' {
.function
}
'fields' {
.field
}
'type_alias' {
.type_alias
}
'interfaces' {
.interface
}
'enums' {
.enum
}
'constants' {
.constant
}
'structs' {
.struct
}
'name', 'type' {
.text
}
$else {
log('unsupport JsonVarAC field')
DetailKind.text
}
}
kind_int := int(kind)
for field in var_ac.$(f.name) {
$match f.name {
'methods', 'functions', 'fields', 'constants' {
if !field.contains(':') {
continue
}
vals := field.split(':')
field_name := vals[0]
typ := vals[1]
details << Detail{
detail: typ // app.type_to_str(field.typ)
kind: kind_int
label: field_name // field.name
documentation: 'MY DOCS' // TODO fetch docs
}
}
'type_alias', 'interfaces', 'enums', 'structs' {
details << Detail{
kind: kind_int
label: field
documentation: 'MY DOCS'
}
}
$else {}
}
}
}
resp := Response{
id: request.id
result: details
result: var_ac.details
}
return resp
}
Expand Down
12 changes: 0 additions & 12 deletions lsp.v
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ struct LSPRange {
end Position
}

enum DetailKind {
text = 1
method = 2
function = 3
field = 5
type_alias = 7
interface = 8
enum = 13
constant = 21
struct = 22
}

struct Detail {
kind int // The type of item (e.g., Method, Function, Field)
label string // The name of the completion item
Expand Down
11 changes: 1 addition & 10 deletions main.v
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,7 @@ struct JsonError {
}

struct JsonVarAC {
name string
type string
methods []string // "name:type" strings
functions []string // "name:type" strings
fields []string // "name:type" strings
type_alias []string // "name" strings
interfaces []string // "name" strings
enums []string // "name" strings
constants []string // "name:type" strings
structs []string // "name" strings
details []Detail
}

fn v_error_to_lsp_diagnostic(e JsonError) LSPDiagnostic {
Expand Down