vlang / v-analyzer

The @vlang language server, for all your editing needs like go-to-definition, code completion, type hints, and more.
MIT License
84 stars 9 forks source link

Rename, hover, go to definition and completion are not working properly for this sample code #105

Open resolritter opened 1 month ago

resolritter commented 1 month ago

Describe the bug

Consider the sample code below

module main

struct Foo { val string }

type Type = Foo | int

fn (x Type) bar() {
    match x {
        Foo { println('Foo ${x.val}') }
        int { println('int $x') }
    }
}

fn main() {
    x := Type(int(3))
    x.bar()
}

Expected Behavior

  1. I should be able to go to the definition of bar when my cursor is at the a of x.bar()
  2. I should be able to hover over the definition of bar when my cursor is at the a of x.bar()
  3. If I rename fn (x Type) bar() to fn (x Type) baz() through the LSP, the change should be propagated to the usage site (x.bar())
  4. When I type x., bar should be listed as a completion suggestion

Current Behavior

  1. The "Go To Definition" command does not work when my cursor is at x.bar
  2. The "Hover" command does not work when my cursor is at x.bar
  3. If I rename fn (x Type) bar() to fn (x Type) baz() through the LSP, the change is not propagated to the usage site (it remains as x.bar inside of main)
  4. When I type x., only str() is listed as a completion suggestion (bar() is missing)

Reproduction Steps

  1. Initialize a project with v init
  2. Copy the sample code into src/main.v
  3. Open src/main.v in the editor

Possible Solution

No response

Additional Information/Context

No response

Environment details (v doctor output)

V full version: V 0.4.6 f24abd7.6197140
OS: linux, Linux version 6.8.7-arch1-2 (linux@archlinux) (gcc (GCC) 13.2.1 20240417, GNU ld (GNU Binutils) 2.42.0) #1 SMP PREEMPT_DYNAMIC Fri, 19 Apr 2024 09:51:31 +0000
Processor: 24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor

getwd: /home/user/programs
vexe: /home/user/programs/v/v
vexe mtime: 2024-05-21 21:43:22

vroot: OK, value: /home/user/programs/v
VMODULES: OK, value: /home/user/.vmodules
VTMP: OK, value: /dev/shm/tmp/v_1000

Git version: git version 2.44.0
Git vroot status: 0.4.6-10-g61971400 (1 commit(s) behind V master)
.git/config present: true

CC version: cc (GCC) 13.2.1 20240417
thirdparty/tcc: N/A

Editor name

Neovim

v-analyzer Version

v-analyzer version 0.0.4-beta.1.7e11a6f

VS Code Extension Version

No response

resolritter commented 1 month ago

.v-analyzer/config.toml

custom_vroot = "/home/user/programs/v"
enable_semantic_tokens = "none"

[inlay_hints]
enable = true
enable_range_hints = true
enable_type_hints = true
enable_implicit_err_hints = true
enable_parameter_name_hints = true
enable_constant_type_hints = true
enable_enum_field_value_hints = true

[code_lens]
enable = false
enable_run_lens = true
enable_inheritors_lens = true
enable_super_interfaces_lens = true
enable_run_tests_lens = true
tomialagbe commented 1 month ago

+1

jacknicklenson commented 4 weeks ago

yep, same issue, at line 384 when I press SHIFT + K which is document hover command in neovim, as you can see at the bottom of screenshot, it says No information available. However, function definition is actually just right below the cursor. so obviously not working and also this happens across the whole document as well. Some symbols work, some does not. For example, all grid, row and col identifiers are also did not recognized by the v-analyzer as well. Hover and GoToDefinition commands do nothing.

image

v doctor:

V full version: V 0.4.6 0d52a7d
OS: windows, Microsoft Windows 11 Pro v22621 64-bit
Processor: 12 cpus, 64bit, little endian, 

getwd: C:\Users\user\Documents\Github\v_test
vexe: C:\Users\user\Documents\Github\v\v.exe
vexe mtime: 2024-06-07 09:54:37

vroot: OK, value: C:\Users\user\Documents\Github\v
VMODULES: OK, value: C:\Users\user\.vmodules
VTMP: OK, value: C:\Users\user\AppData\Local\Temp\v_0

Git version: git version 2.45.2.windows.1
Git vroot status: 0d52a7d9 (4 commit(s) behind V master)
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

v-analyzer -v:

v-analyzer version 0.0.4-beta.1.2d5d12e
jacknicklenson commented 4 weeks ago

When open document symbol picker, there is no set_cell_type function symbol.

image