vlang / vls

V language server. (Old V language server - see v-analyzer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vls doesnt do anything in nvim

oscgu opened this issue · comments

commented

System Information

V doctor

OS: linux, Linux version 5.18.12-artix1-1 (linux@artixlinux) (gcc (GCC) 12.1.0, GNU ld (GNU Binutils) 2.38) #1 SMP PREEMPT_DYNAMIC Fri, 15 Jul 2022 21:11:59 +0000
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
CC version: cc (GCC) 12.1.0

getwd: /home/bort/programs/v/examples
vmodules: /home/bort/.vmodules
vroot: /home/bort/programs/v
vexe: /home/bort/programs/v/v
vexe mtime: 2022-08-20 12:45:22
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.0 c356882

Git version: git version 2.37.1
Git vroot status: weekly.2022.33-36-gc3568823-dirty
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 827f7452

VLS info

V 0.3.0 c356882

Problem Description

Vls doesnt do anything when I type invalid code and doesn't do text completion

Expected Output

Warnings/Errors and text completion

Actual Output

None

Steps to Reproduce

Set nvim up with nvim-cmp, cmp-nvim-lsp and nvim-lspconfig
Installed the language server with v ls --install and added the following to my nvim config:

require('lspconfig')['vls'].setup {
       cmd = {"v", "ls" },
       filetypes = {"vlang", "v"},
     capabilities = capabilities
  }

When opening a .v file :LspInfo yields the following:
image

Last Recorded LSP Requests

{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":2,"message":"VLS is early software. Please report your issue to github.com/vlang/vls if you encounter any problems."}}}
{"kind":"recv-request","timestamp":1661019778,"payload":{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"initializationOptions":{},"capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"resourceOperations":["rename","create","delete"]},"workspaceFolders":true,"symbol":{"hierarchicalWorkspaceSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":false},"configuration":true},"callHierarchy":{"dynamicRegistration":false},"textDocument":{"typeDefinition":{"linkSupport":true},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"activeParameterSupport":true,"parameterInformation":{"labelOffsetSupport":true},"documentationFormat":["markdown","plaintext"]}},"implementation":{"linkSupport":true},"completion":{"completionItem":{"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertReplaceSupport":true,"snippetSupport":true,"commitCharactersSupport":true,"preselectSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"labelDetailsSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"contextSupport":false,"dynamicRegistration":false},"rename":{"prepareSupport":true,"dynamicRegistration":false},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"synchronization":{"willSave":false,"willSaveWaitUntil":false,"didSave":true,"dynamicRegistration":false},"declaration":{"linkSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]}},"definition":{"linkSupport":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","Empty","QuickFix","Refactor","RefactorExtract","RefactorInline","RefactorRewrite","Source","SourceOrganizeImports","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"resolveSupport":{"properties":["edit"]},"dataSupport":true,"dynamicRegistration":false}},"window":{"workDoneProgress":true,"showDocument":{"support":false},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":false}}}},"trace":"off","rootPath":"/home/bort/programs/v","rootUri":"file:///home/bort/programs/v","processId":29858,"clientInfo":{"name":"Neovim","version":"0.7.2"},"workspaceFolders":[{"name":"/home/bort/programs/v","uri":"file:///home/bort/programs/v"}]}}}
{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"VLS Version: 0.0.1.6a5fce4, OS: linux 64"}}}
{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"VLS executable path: /home/bort/.vls/bin/vls_linux_x64"}}}
{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"VLS build with V 6062708"}}}
{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Client / Editor: Neovim 0.7.2 (PID: 29858)"}}}
{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using V path (VROOT): /home/bort/programs/v"}}}
{"kind":"send-notification","timestamp":1661019778,"payload":{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"is_logger_installed: true | is_logger_enabled: true | params.trace: off"}}}
{"kind":"send-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["=",".",":","{",",","("," "]},"signatureHelpProvider":{"triggerCharacters":["("],"retriggerCharacters":[","," "]},"definitionProvider":true,"typeDefinitionProvider":false,"implementationProvider":true,"referencesProvider":false,"documentHighlightProvider":false,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":false,"codeLensProvider":{"resolveProvider":false},"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"","moreTriggerCharacter":[]},"renameProvider":false,"documentLinkProvider":{"resolveProvider":false},"colorProvider":false,"declarationProvider":false,"executeCommandProvider":{"commands":[]},"foldingRangeProvider":true,"experimental":{}}}}}
{"kind":"recv-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"initialized","params":{}}}
{"kind":"recv-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"v","version":0,"text":"// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.\n// Use of this source code is governed by an MIT license\n// that can be found in the LICENSE file.\nimport net.http\nimport json\n\nstruct Story {\n    title string\n        url   string\n}\n\nfn worker_fetch(p &pool.PoolProcessor, cursor int, worker_id int) voidptr {\nid := p.get_item<int>(cursor)\n        resp := http.get('https://hacker-news.firebaseio.com/v0/item/${id}.json') or {\n        println('failed to fetch data from /v0/item/${id}.json')\n        return pool.no_result\n}\nstory := json.decode(Story, resp.body) or {\n           println('failed to decode a
story')\n               return pool.no_result\n               return pool\n       }\n\nprintln('# $cursor) $story.title | $story.url')\nreturn pool.no_result\n}\n\n// Fetches top HN stories in parallel, depending on how many cores you have\nfn main() {\nresp := http.get('https://hacker-news.firebaseio.com/v0/topstories.json') or {\n          println('failed to fetch data from /v0/topstories.json')\n          return\n}\nids := json.decode([]int, resp.body) or {\n         println('failed to decode topstories.json')\n             return\n
}#[0..10]\nmut fetcher_pool := pool.new_pool_processor(\n        callback: worker_fetch\n        )\n// Note: if you do not call set_max_jobs, the pool will try to use an optimal\n// number of threads, one per each core in your system, which in most\n// cases is what you want anyway... You can override the automatic choice\n// by setting the VJOBS environment variable too.\n// fetcher_pool.set_max_jobs( 4 )\nfetcher_pool.work_on_items(ids)\n    }\n","uri":"file:///home/bort/programs/v/examples/news_fetcher.v"}}}}
{"kind":"send-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/bort/programs/v/examples/news_fetcher.v","diagnostics":[]}}}
{"kind":"send-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/bort/programs/v/examples/net_failconnect.v","diagnostics":[]}}}
{"kind":"send-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/bort/programs/v/examples/fetch.v","diagnostics":[]}}}
{"kind":"send-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/bort/programs/v/examples/tcp_notify_echo_server.v","diagnostics":[]}}}
{"kind":"send-notification","timestamp":1661019779,"payload":{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/bort/programs/v/examples/rule110.v","diagnostics":[]}}}
{"kind":"send-notification","timestamp":1661019907,"payload":{"jsonrpc":"2.0","id":null,"result":null}}

I'm running into a very similar issue.
v doctor:

OS: linux, "Manjaro Linux"
Processor: 12 cpus, 64bit, little endian, AMD Ryzen 5 1600X Six-Core Processor
CC version: cc (GCC) 12.2.0

getwd: /home/charlie/.../my_current_v_project_directory
vmodules: /home/charlie/.vmodules
vroot: /home/charlie/v
vexe: /home/charlie/v/v
vexe mtime: 2022-10-26 04:19:03
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.1 d781396.572e262

Git version: git version 2.38.0
Git vroot status: weekly.2022.43-4-g572e2620
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

Additionally, for one of my school projects, I'm using a custom module for called gfx. Whenever it's imported, it's import line throws is marked with this error:

Diagnostics:
1. Module `[analyzer.Import{
       resolved: false
       imported: false
       absolute_module_name: 'gfx'
       module_name: 'gfx'
       path: ''
       ranges: {'/home/charlie/.../path_to_current_v_file.v': TSRange{
           start_point: TSPoint{
               row: 2
               column: 7
           }
           end_point: TSPoint{
               row: 2
               column: 10
           }
           start_byte: 20
           end_byte: 23
       }}
       aliases: {}
       symbols: {}
   }][import_idx].absolute_module_name` not found

When other modules are imported, the array in the error includes those modules as well.
However, saving the document suppresses the error. Then and VLS doesn't do anything else until I restart the editor, where it throws that error again.

Edit: Running v ls in a seperate terminal has a different behavior. With with this setup, nvim prints Client 1 quit with exit code 1 and signal 0 in the status aria. Then the v ls terminal prints

Content-Length: 182

{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":2,"message":"VLS is early software. Please report your issue to github.com/vlang/vls if you encounter any problems."}}Content-Length: 41

{"jsonrpc":"2.0","id":null,"result":null}%  

and crashes.

does anyone still having this issues.. vls currently do nothing on my setup

The behavior I observe with vls in nvim is that it indeed works. Though running v fmt on save (while vls simultaneously re-scans) temporary disables it. I hope fixing this can be done by with little optimizations to the event-loop eventually.

Until then, to have a running vls I need to disable v fmt auto formatting when working in v files and run it via a LspFormat "manually" occasionally.
Does this do anything in your cases guys?

Try https://blog.vosca.dev/meet-v-analyzer/ instead, now that it is released.