|
1 | 1 | ;;; lsp-v.el --- lsp-mode V integration -*- lexical-binding: t; -*-
|
2 | 2 |
|
3 | 3 | ;; Copyright (C) 2021 remimimimi
|
| 4 | +;; Copyright (C) 2024 niontrix |
4 | 5 |
|
5 | 6 | ;; Author: remimimimi
|
| 7 | +;; niontrix |
6 | 8 | ;; Keywords: languages,tools
|
7 | 9 |
|
8 | 10 | ;; This program is free software; you can redistribute it and/or modify
|
|
20 | 22 |
|
21 | 23 | ;;; Commentary:
|
22 | 24 |
|
23 |
| -;; client for vls, the V language server |
| 25 | +;; Basic configuration for V LSP support |
24 | 26 |
|
25 | 27 | ;;; Code:
|
26 | 28 |
|
27 | 29 | (require 'lsp-mode)
|
28 | 30 |
|
29 | 31 | (defgroup lsp-v nil
|
30 |
| - "LSP support for V via vls." |
| 32 | + "LSP support for V via vls. NOTICE!: `vls' is deprecated" |
31 | 33 | :group 'lsp-mode
|
32 | 34 | :link '(url-link "https://github.com/vlang/vls/tree/master"))
|
33 | 35 |
|
| 36 | +(defgroup lsp-v-analyzer nil |
| 37 | + "LSP support for V, using v-analyzer." |
| 38 | + :group 'lsp-mode |
| 39 | + :link '(url-link "https://github.com/vlang/v-analyzer")) |
| 40 | + |
34 | 41 | (defcustom lsp-v-vls-executable "vls"
|
35 |
| - "The vls executable to use. |
| 42 | + "NOTICE!: vls is deprecated you should use `v-analyzer' instead. |
| 43 | +The vls executable to use. |
36 | 44 | Leave as just the executable name to use the default behavior of
|
37 |
| -finding the executable with variable `exec-path'." |
| 45 | +finding the executable with variable `exec-path'. " |
38 | 46 | :group 'lsp-v
|
39 |
| - :type 'string) |
| 47 | + :type 'string |
| 48 | + :package-version '(lsp-mode . "8.0.0")) |
| 49 | + |
| 50 | +(defcustom lsp-v-analyzer-path "v-analyzer" |
| 51 | + "Path to `v-analyzer' |
| 52 | +Leave as just the executable name to use the default behavior of |
| 53 | +finding the executable with variable `exec-path'. " |
| 54 | + :type 'number |
| 55 | + :group 'lsp-nim |
| 56 | + :package-version '(lsp-mode . "9.0.0")) |
40 | 57 |
|
41 | 58 | (lsp-register-client
|
42 |
| - (make-lsp-client |
43 |
| - :new-connection (lsp-stdio-connection (lambda () lsp-v-vls-executable)) |
44 |
| - :activation-fn (lsp-activate-on "V") |
45 |
| - :server-id 'v-ls)) |
| 59 | + (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-v-vls-executable)) |
| 60 | + :activation-fn (lsp-activate-on "V") |
| 61 | + :priority -1 |
| 62 | + :server-id 'v-ls)) |
| 63 | + |
| 64 | +(lsp-register-client |
| 65 | + (make-lsp-client :new-connection (lsp-stdio-connection |
| 66 | + (lambda () lsp-v-analyzer-path)) |
| 67 | + :activation-fn (lsp-activate-on "v") |
| 68 | + :notification-handlers |
| 69 | + (ht ("experimental/serverStatus" #'ignore)) |
| 70 | + :language-id "v" |
| 71 | + :priority 1 |
| 72 | + :server-id 'v-analyzer)) |
| 73 | + |
| 74 | +(defun lsp-v-analyzer-init () |
| 75 | + "Runs the `v-analyzer init' command in the root folder of the current project. |
| 76 | +After this `v-analyzer' can be further configured through the file |
| 77 | +`.v-analyzer/config.toml'." |
| 78 | + (interactive) |
| 79 | + (let* ((project-root (lsp--suggest-project-root)) |
| 80 | + (default-directory project-root) |
| 81 | + (v-analyzer-config ".v-analyzer/config.toml")) |
| 82 | + (when (and project-root |
| 83 | + (not (file-exists-p v-analyzer-config))) |
| 84 | + (message |
| 85 | + (shell-command-to-string (concat lsp-v-analyzer-path " init")))))) |
46 | 86 |
|
47 | 87 | (lsp-consistency-check lsp-v)
|
48 | 88 |
|
|
0 commit comments