Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neovim Volar LSP broken for 2.0.7 #4159

Closed
ASoldo opened this issue Mar 26, 2024 · 33 comments
Closed

Neovim Volar LSP broken for 2.0.7 #4159

ASoldo opened this issue Mar 26, 2024 · 33 comments
Labels
question Further information is requested

Comments

@ASoldo
Copy link

ASoldo commented Mar 26, 2024

Hi, I just noticed that when I open any of my projects new or old I don't have any TS/JS/Vue completions even tho it shows as running. But I am not able to hover, jump to definitions, etc... anybody know why and how to fix it?

Thank you!

@ASoldo
Copy link
Author

ASoldo commented Mar 26, 2024

I solved it with this snippet for 2.x version in my init.lua:

local lspconfig = require('lspconfig')
  lspconfig.volar.setup {
    filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
    init_options = {
      vue = {
        hybridMode = false,
      },
    },
  }

I was not aware of upgrade to 2.x and my problem is fixed by following docs for nvim integration.

@ASoldo ASoldo closed this as completed Mar 26, 2024
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Mar 26, 2024

2.0 was recommanded to use with @vue/typescript-plugin, you can reference the "How to configure vue language server with neovim and lsp?" section at: https://github.com/vuejs/language-tools#community-integration

Or the full discuss: #3925

@johnsoncodehk johnsoncodehk added the question Further information is requested label Mar 26, 2024
@CofCat456
Copy link
Contributor

If you could share your nvim config, it would be better to solve your problem.

@ASoldo
Copy link
Author

ASoldo commented Mar 27, 2024

If you could share your nvim config, it would be better to solve your problem.

return {
  -- Configure AstroNvim updates
  updater = {
    remote = "origin",     -- remote to use
    channel = "stable",    -- "stable" or "nightly"
    version = "latest",    -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
    branch = "nightly",    -- branch name (NIGHTLY ONLY)
    commit = nil,          -- commit hash (NIGHTLY ONLY)
    pin_plugins = nil,     -- nil, true, false (nil will pin plugins on stable only)
    skip_prompts = false,  -- skip prompts about breaking changes
    show_changelog = true, -- show the changelog after performing an update
    auto_quit = false,     -- automatically quit the current session after a successful update
    remotes = {            -- easily add new remotes to track
      --   ["remote_name"] = "https://remote_url.come/repo.git", -- full remote url
      --   ["remote2"] = "github_user/repo", -- GitHub user/repo shortcut,
      --   ["remote3"] = "github_user", -- GitHub user assume AstroNvim fork
    },
  },
  -- Set colorscheme to use
  colorscheme = "astrodark",
  -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
  diagnostics = {
    virtual_text = true,
    underline = true,
  },
  lsp = {
    -- customize lsp formatting options
    formatting = {
      -- control auto formatting on save
      format_on_save = {
        enabled = true,     -- enable or disable format on save globally
        allow_filetypes = { -- enable format on save for specified filetypes only
          -- "go",
        },
        ignore_filetypes = { -- disable format on save for specified filetypes
          -- "python",
        },
      },
      disabled = { -- disable formatting capabilities for the listed language servers
        -- "sumneko_lua",
      },
      timeout_ms = 1000, -- default format timeout
      -- filter = function(client) -- fully override the default formatting function
      --   return true
      -- end
    },
    -- enable servers that you already have installed without mason
    servers = {
      -- "pyright"
    },
  },
  -- Configure require("lazy").setup() options
  lazy = {
    defaults = { lazy = true },
    performance = {
      rtp = {
        -- customize default disabled vim plugins
        disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin" },
      },
    },
  },
  presence = {
    -- General options
    auto_update         = true,                       -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`)
    neovim_image_text   = "The One True Code Editor", -- Text displayed when hovered over the Neovim image
    main_image          = "neovim",                   -- Main image display (either "neovim" or "file")
    client_id           = "793271441293967371",       -- Use your own Discord application client id (not recommended)
    log_level           = nil,                        -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
    debounce_timeout    = 10,                         -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
    enable_line_number  = false,                      -- Displays the current line number instead of the current project
    blacklist           = {},                         -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
    buttons             = true,                       -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
    file_assets         = {},                         -- Custom file asset definitions keyed by file names and extensions (see default config at `lua/presence/file_assets.lua` for reference)
    show_time           = true,                       -- Show the timer
    -- Rich Presence text options
    editing_text        = "Editing %s",               -- Format string rendered when an editable file is loaded in the buffer (either string or function(filename: string): string)
    file_explorer_text  = "Browsing %s",              -- Format string rendered when browsing a file explorer (either string or function(file_explorer_name: string): string)
    git_commit_text     = "Committing changes",       -- Format string rendered when committing changes in git (either string or function(filename: string): string)
    plugin_manager_text = "Managing plugins",         -- Format string rendered when managing plugins (either string or function(plugin_manager_name: string): string)
    reading_text        = "Reading %s",               -- Format string rendered when a read-only or unmodifiable file is loaded in the buffer (either string or function(filename: string): string)
    workspace_text      = "Working on %s",            -- Format string rendered when in a git repository (either string or function(project_name: string|nil, filename: string): string)
    line_number_text    = "Line %s out of %s",        -- Format string rendered when `enable_line_number` is set to true (either string or function(line_number: number, line_count: number): string)
  },
  -- This function is run last and is a good place to configuring
  -- augroups/autocommands and custom filetypes also this just pure lua so
  -- anything that doesn't fit in the normal config locations above can go here
  polish = function()
    -- Set up custom filetypes
    -- vim.filetype.add {
    --   extension = {
    --     foo = "fooscript",
    --   },
    --   filename = {
    --     ["Foofile"] = "fooscript",
    --   },
    --   pattern = {
    --     ["~/%.config/foo/.*"] = "fooscript",
    --   },
    -- }
  vim.o.scrolloff = 8  -- You can adjust the number to your preference
  vim.o.colorcolumn = "80"  -- You can adjust the number to your preference

  vim.filetype.add {
      extension = {
        tera = "tera",
      },
    }

  vim.filetype.add {
    extension = {
      html = "html",
    }
  }

  local lspconfig = require('lspconfig')
  lspconfig.volar.setup {
    filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
    init_options = {
      vue = {
        hybridMode = false,
      },
    },
  }

  local dap = require('dap')

    dap.adapters.rust = {
      type = 'executable',
      command = 'lldb-vscode',
      name = "lldb"
    }

    dap.configurations.rust = {
      {
        type = 'rust',
        request = 'launch',
        name = "Launch Rust",
        program = function()
            -- This function allows you to specify the binary to debug.
            -- You can hardcode it or use vim.fn.input to prompt for it.
            return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/target/debug/', 'file')
          end,
        cwd = "${workspaceFolder}",
        stopOnEntry = false,
        runtimeArgs = { "run" },
        env = {},
      },
    }
    require("dapui").setup()

    require("tree-sitter-surrealdb").setup()

  end,
}

This is AstroNvim init.lua file. I had issue that none of my new or old projects respond to lsp. But after adding this snippet it started to work again with no issues. Is this the solution?

@ASoldo ASoldo reopened this Mar 27, 2024
@CofCat456
Copy link
Contributor

如果您能夠分享您的 nvim 配置,那就更好地解決您的問題了。

return {
  -- Configure AstroNvim updates
  updater = {
    remote = "origin",     -- remote to use
    channel = "stable",    -- "stable" or "nightly"
    version = "latest",    -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
    branch = "nightly",    -- branch name (NIGHTLY ONLY)
    commit = nil,          -- commit hash (NIGHTLY ONLY)
    pin_plugins = nil,     -- nil, true, false (nil will pin plugins on stable only)
    skip_prompts = false,  -- skip prompts about breaking changes
    show_changelog = true, -- show the changelog after performing an update
    auto_quit = false,     -- automatically quit the current session after a successful update
    remotes = {            -- easily add new remotes to track
      --   ["remote_name"] = "https://remote_url.come/repo.git", -- full remote url
      --   ["remote2"] = "github_user/repo", -- GitHub user/repo shortcut,
      --   ["remote3"] = "github_user", -- GitHub user assume AstroNvim fork
    },
  },
  -- Set colorscheme to use
  colorscheme = "astrodark",
  -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
  diagnostics = {
    virtual_text = true,
    underline = true,
  },
  lsp = {
    -- customize lsp formatting options
    formatting = {
      -- control auto formatting on save
      format_on_save = {
        enabled = true,     -- enable or disable format on save globally
        allow_filetypes = { -- enable format on save for specified filetypes only
          -- "go",
        },
        ignore_filetypes = { -- disable format on save for specified filetypes
          -- "python",
        },
      },
      disabled = { -- disable formatting capabilities for the listed language servers
        -- "sumneko_lua",
      },
      timeout_ms = 1000, -- default format timeout
      -- filter = function(client) -- fully override the default formatting function
      --   return true
      -- end
    },
    -- enable servers that you already have installed without mason
    servers = {
      -- "pyright"
    },
  },
  -- Configure require("lazy").setup() options
  lazy = {
    defaults = { lazy = true },
    performance = {
      rtp = {
        -- customize default disabled vim plugins
        disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin" },
      },
    },
  },
  presence = {
    -- General options
    auto_update         = true,                       -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`)
    neovim_image_text   = "The One True Code Editor", -- Text displayed when hovered over the Neovim image
    main_image          = "neovim",                   -- Main image display (either "neovim" or "file")
    client_id           = "793271441293967371",       -- Use your own Discord application client id (not recommended)
    log_level           = nil,                        -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
    debounce_timeout    = 10,                         -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
    enable_line_number  = false,                      -- Displays the current line number instead of the current project
    blacklist           = {},                         -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
    buttons             = true,                       -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
    file_assets         = {},                         -- Custom file asset definitions keyed by file names and extensions (see default config at `lua/presence/file_assets.lua` for reference)
    show_time           = true,                       -- Show the timer
    -- Rich Presence text options
    editing_text        = "Editing %s",               -- Format string rendered when an editable file is loaded in the buffer (either string or function(filename: string): string)
    file_explorer_text  = "Browsing %s",              -- Format string rendered when browsing a file explorer (either string or function(file_explorer_name: string): string)
    git_commit_text     = "Committing changes",       -- Format string rendered when committing changes in git (either string or function(filename: string): string)
    plugin_manager_text = "Managing plugins",         -- Format string rendered when managing plugins (either string or function(plugin_manager_name: string): string)
    reading_text        = "Reading %s",               -- Format string rendered when a read-only or unmodifiable file is loaded in the buffer (either string or function(filename: string): string)
    workspace_text      = "Working on %s",            -- Format string rendered when in a git repository (either string or function(project_name: string|nil, filename: string): string)
    line_number_text    = "Line %s out of %s",        -- Format string rendered when `enable_line_number` is set to true (either string or function(line_number: number, line_count: number): string)
  },
  -- This function is run last and is a good place to configuring
  -- augroups/autocommands and custom filetypes also this just pure lua so
  -- anything that doesn't fit in the normal config locations above can go here
  polish = function()
    -- Set up custom filetypes
    -- vim.filetype.add {
    --   extension = {
    --     foo = "fooscript",
    --   },
    --   filename = {
    --     ["Foofile"] = "fooscript",
    --   },
    --   pattern = {
    --     ["~/%.config/foo/.*"] = "fooscript",
    --   },
    -- }
  vim.o.scrolloff = 8  -- You can adjust the number to your preference
  vim.o.colorcolumn = "80"  -- You can adjust the number to your preference

  vim.filetype.add {
      extension = {
        tera = "tera",
      },
    }

  vim.filetype.add {
    extension = {
      html = "html",
    }
  }

  local lspconfig = require('lspconfig')
  lspconfig.volar.setup {
    filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
    init_options = {
      vue = {
        hybridMode = false,
      },
    },
  }

  local dap = require('dap')

    dap.adapters.rust = {
      type = 'executable',
      command = 'lldb-vscode',
      name = "lldb"
    }

    dap.configurations.rust = {
      {
        type = 'rust',
        request = 'launch',
        name = "Launch Rust",
        program = function()
            -- This function allows you to specify the binary to debug.
            -- You can hardcode it or use vim.fn.input to prompt for it.
            return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/target/debug/', 'file')
          end,
        cwd = "${workspaceFolder}",
        stopOnEntry = false,
        runtimeArgs = { "run" },
        env = {},
      },
    }
    require("dapui").setup()

    require("tree-sitter-surrealdb").setup()

  end,
}

這是 AstroNvim init.lua 檔案。我遇到的問題是我的新專案或舊專案都沒有回應 lsp。但在添加此程式碼片段後,它再次開始工作,沒有任何問題。這是解決方案嗎?

I haven't seen any settings related to tsserver, have you installed it?

@ASoldo ASoldo closed this as completed Mar 27, 2024
@wcheek
Copy link

wcheek commented Mar 29, 2024

I solved it with this snippet for 2.x version in my init.lua:

local lspconfig = require('lspconfig')
  lspconfig.volar.setup {
    filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
    init_options = {
      vue = {
        hybridMode = false,
      },
    },
  }

I was not aware of upgrade to 2.x and my problem is fixed by following docs for nvim integration.

@ASoldo you actually solved my problem with this snippet! As mentioned by @johnsoncodehk, this is indeed in the new documentation https://github.com/vuejs/language-tools#community-integration

Edit: Actually, this gave me some LSP capabilities but not all.

I found another suggested config in nvim-lspconfig documentation that seems to be working. You will have to install @vue/typescript-plugin globally and edit the location for your case.

-- init.lua
local lspconfig = require("lspconfig")

lspconfig.volar.setup({})
lspconfig.tsserver.setup({
  init_options = {
    plugins = {
      {
        name = "@vue/typescript-plugin",
        location = "C:\\Users\\wcheek\\AppData\\Roaming\\npm\\node_modules\\@vue\\typescript-plugin\\",
        languages = { "javascript", "typescript", "vue" },
      },
    },
  },
  filetypes = {
    "javascript",
    "typescript",
    "vue",
  },
})

@ASoldo
Copy link
Author

ASoldo commented Apr 16, 2024

@wcheek hi, just wanted to share with you config for AstroNvim that works.

I have AstroNvim v4, and with that i have new plugins/astrolsp.lua and by adding this config there Volar works great with Vue3 and Nuxt3 projects. For AstroNvim this will be defaulted in the next versions since I raised that issue there.

...
    -- customize language server configuration options passed to `lspconfig`
    ---@diagnostic disable: missing-fields
    config = {
      volar = {
        filetypes = { "vue" },
        init_options = {
          vue = {
            hybridMode = false,
          },
        },
      },
    },
...

@ASoldo
Copy link
Author

ASoldo commented Jul 2, 2024

this config doesn't work no more, does anybody know why when i set hybridMode to false i get this. and if I set hybid mode to true it can attach but it is not doing any operations like hover symbol, jump to definitions, rename symbol...

image

    -- customize language server configuration options passed to `lspconfig`
    ---@diagnostic disable: missing-fields
    config = {
      tsserver = {
        init_options = {
          plugins = {
            {
              name = "@vue/typescript-plugin",
              location = "/usr/lib/node_modules/@vue/typescript-plugin/",
              languages = { "vue" },
            },
          },
        },
      },
      volar = {
        filetypes = { "vue" },
        init_options = {
          vue = {
            hybridMode = false,
          },
        },
      },
    },

anybody know how to fix this?

@ASoldo ASoldo reopened this Jul 2, 2024
@so1ve
Copy link
Member

so1ve commented Jul 3, 2024

#4520?

@ASoldo
Copy link
Author

ASoldo commented Jul 3, 2024

@wcheek does your setup still work?

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Jul 3, 2024

    -- customize language server configuration options passed to `lspconfig`
    ---@diagnostic disable: missing-fields
    config = {
      tsserver = {
        init_options = {
          plugins = {
            {
              name = "@vue/typescript-plugin",
              location = "/usr/lib/node_modules/@vue/typescript-plugin/",
              languages = { "vue" },
            },
          },
        },
      },
      volar = {
        filetypes = { "vue" },
        init_options = {
          vue = {
            hybridMode = false,
          },
        },
      },
    },

anybody know how to fix this?

Not sure if this is the cause, but I found some issues:

  • location = "/usr/lib/node_modules/@vue/typescript-plugin/" should be location = "xxx/node_modules/@vue/language-server"
  • volar.init_options is missing typescript.tsdk option.
      volar = {
        filetypes = { "vue" },
        init_options = {
+          typescript = {
+            tsdk = "path/to/node_modules/typescript/lib",
+          },
          vue = {
            hybridMode = false,
          },
        },
      },

@ASoldo
Copy link
Author

ASoldo commented Jul 3, 2024

       config = {
      tsserver = {
        init_options = {
          plugins = {
            {
              name = "@vue/typescript-plugin",
              location = "/usr/lib/node_modules/@vue/language-server/",
              languages = { "vue" },
            },
          },
        },
      },
      volar = {
        filetypes = { "vue" },
        init_options = {
          typescript = {
            tsdk = "/usr/lib/node_modules/typescript/lib/",
          },
          vue = {
            hybridMode = false,
          },
        },
      },
    },

This is config I have so far and this is the error i get when I set hybridMode to false:

    [START][2024-07-04 00:29:04] LSP logging initiated
[ERROR][2024-07-04 00:29:04] .../vim/lsp/rpc.lua:770	"rpc"	"/home/rootster/.local/share/nvim/mason/bin/vue-language-server"	"stderr"	"/home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/language-core/lib/languageModule.js:63\n            if (vueCompilerOptions.extensions.some(ext => asFileName(scriptId).endsWith(ext))) {\n                                                          ^\n\nTypeError: asFileName is not a function\n    at /home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/language-core/lib/languageModule.js:63:59\n    at Array.some (<anonymous>)\n    at Object.getLanguageId (/home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/language-core/lib/languageModule.js:63:47)\n    at Object.set (/home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/language-core/index.js:53:60)\n    at /home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/language-server/lib/project/typescriptProjectLs.js:83:30\n    at Object.get (/home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/language-core/index.js:42:17)\n    at sync (/home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/typescript/lib/protocol/createProject.js:171:51)\n    at Object.getProjectVersion (/home/rootster/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/typescript/lib/protocol/createProject.js:81:13)\n    at synchronizeHostData (/home/rootster/Documents/nuxt3-sanity/node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/typescript.js:142750:41)\n    at Object.getProgram (/home/rootster/Documents/nuxt3-sanity/node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/typescript.js:142921:7)\n\nNode.js v22.4.0\n"

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Jul 3, 2024

@ASoldo What is your @vue/language-server version in /usr/lib/node_modules/? If it's not the latest, would it be helpful to be more recent to v2.0.24?

@ASoldo
Copy link
Author

ASoldo commented Jul 3, 2024

❯ vue-language-server --version
2.0.24

its the latest.

@johnsoncodehk
Copy link
Member

@ASoldo Can you try updating to v2.0.26-alpha.2?

@ASoldo
Copy link
Author

ASoldo commented Jul 3, 2024

How do i do that since it's not in the npm registry yet?

@johnsoncodehk
Copy link
Member

How do i do that since it's not in the npm registry yet?我該怎麼做,因為它還沒有在 npm 註冊表中?

Please try execute npm install -g @vue/language-server@2.0.26-alpha.2.

@ASoldo
Copy link
Author

ASoldo commented Jul 3, 2024

❯ vue-language-server --version
2.0.26-alpha.2

It still throws error when loading vue file.

@wcheek
Copy link

wcheek commented Jul 3, 2024

@ASoldo I'm using LazyVim these days so I'm not sure how helpful my setup will be for you. I'm depending on the default configuration and it's working fine for me with vue-language-server@2.0.24 installed via Mason and configured with nvim-lspconfig:

{
  "neovim/nvim-lspconfig",
  opts = {
    servers = {
      volar = {
        init_options = {
          vue = {
            hybridMode = false,
          },
        },
      },
      vtsls = {},
    },
  },
}

@ASoldo
Copy link
Author

ASoldo commented Jul 4, 2024

Once again thank you all for helping me, this is the latest config i have now:

    -- enable servers that you already have installed without mason
    servers = {
      -- "pyright"
      "volar",
    },
    -- customize language server configuration options passed to `lspconfig`
    ---@diagnostic disable: missing-fields
    config = {
      tsserver = {
        init_options = {
          plugins = {
            {
              name = "@vue/typescript-plugin",
              location = "/usr/lib/node_modules/@vue/language-server/",
              languages = { "vue" },
            },
          },
        },
      },
      volar = {
        filetypes = { "vue" },
        init_options = {
          typescript = {
            tsdk = "/usr/lib/node_modules/typescript/lib/",
          },
          vue = {
            hybridMode = false,
          },
        },
      },
    },

but I uninstalled the vue-language-server with Mason and it works now. So take away from this is not to install it with Mason?

@RayGuo-ergou
Copy link
Contributor

with hybridMode = true, you have to pass the filetype to vtsls or tsserver that's why it's not working for you.
with hybridMode = false, I am also think it's your tskd not pass correctly, can you try which(vue-language-server)

btw seems lazyvim's vue config has a performance issue as it set hybrid mode to false but still run a vtsls for vue separately. This will result in 2 typescript lsp running at the same time. I will create an issue or PR later. ( you can also do if you want to :) )

@ASoldo
Copy link
Author

ASoldo commented Jul 4, 2024

❯ which vue-language-server
/usr/bin/vue-language-server

This is what i have and also removed vue-language-server(volar) from Mason.

@RayGuo-ergou
Copy link
Contributor

ops my bad tskd should be typescript not vue language server.

@RayGuo-ergou
Copy link
Contributor

maybe try to remove tsdk as lspconfig.nvim will automatically find the path.

https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/volar.lua#L21-L30

@jblyberg
Copy link

jblyberg commented Jul 4, 2024

I am also getting this error. Using LazyVim with volar 2.0.24 in hybrid mode and vtsls disabled.

Client volar quit with exit code 1 and signal 0. Check log for errors: /Users/<my username>/.local/state/nvim/lsp.log

Output of lsp.log:

[ERROR][2024-07-03 21:02:36] .../vim/lsp/rpc.lua:770	"rpc"	"/Users/myhome/.local/share/nvim/mason/bin/vue-language-server"	"stderr"	"/Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/language-core/lib/languageModule.js:63\n            if (vueCompilerOptions.extensions.some(ext => asFileName(scriptId).endsWith(ext))) {\n                                                          ^\n\nTypeError: asFileName is not a function\n    at /Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/language-core/lib/languageModule.js:63:59\n    at Array.some (<anonymous>)\n    at Object.getLanguageId (/Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@vue/language-core/lib/languageModule.js:63:47)\n    at Object.set (/Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/language-core/index.js:53:60)\n    at /Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/language-server/lib/project/typescriptProjectLs.js:83:30\n    at Object.get (/Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/language-core/index.js:42:17)\n    at sync (/Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/typescript/lib/protocol/createProject.js:171:51)\n    at Object.getProjectVersion (/Users/myhome/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/node_modules/@volar/typescript/lib/protocol/createProject.js:81:13)\n    at synchronizeHostDataWorker (/Users/myhome/code/projects/inkleaf/ui-intranet/node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/typescript.js:148836:39)\n    at synchronizeHostData (/Users/myhome/code/projects/inkleaf/ui-intranet/node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/typescript.js:148829:7)\n\nNode.js v22.4.0\n"

My lsp config:

        volar = {
          init_options = {
            vue = {
              hybridMode = false,
            },
          },
        },

@RayGuo-ergou
Copy link
Contributor

Also tried with 2.0.24, it's indeed crash, but upgrade to 2.0.26 alpha2 works fine for me.

@jblyberg
Copy link

jblyberg commented Jul 4, 2024

Can confirm that 2.0.26-alpha.2 works for me as well.

@hirotaka
Copy link

hirotaka commented Jul 4, 2024

I'm using LazyVim and Vue Extra. I installed it via Mason, and it worked for me.

:MasonInstall vue-language-server@2.0.26-alpha.2

@ASoldo
Copy link
Author

ASoldo commented Jul 4, 2024

I'm using LazyVim and Vue Extra. I installed it via Mason, and it worked for me.

:MasonInstall vue-language-server@2.0.26-alpha.2

I've done the same and it works just by having this:

   volar = {
        filetypes = { "vue" },
        init_options = {
          vue = {
            hybridMode = false,
          },
        },
      },

So is it a bug with 2.0.24?

@hirotaka
Copy link

hirotaka commented Jul 4, 2024

In my case, the error occurred when I upgraded the project's Typescript version from 4 to 5.
I've not checked properly, but I suspect this problem is related to the 2.0.24 and Typescript versions.

@wcheek
Copy link

wcheek commented Jul 4, 2024

with hybridMode = true, you have to pass the filetype to vtsls or tsserver that's why it's not working for you. with hybridMode = false, I am also think it's your tskd not pass correctly, can you try which(vue-language-server)

btw seems lazyvim's vue config has a performance issue as it set hybrid mode to false but still run a vtsls for vue separately. This will result in 2 typescript lsp running at the same time. I will create an issue or PR later. ( you can also do if you want to :) )

I'd really appreciate if you did - I've noticed the duplicate diagnostics in vue files ever since LazyVim moved to vtsls but haven't had the expertise to properly diagnose and file an issue about it.

@RayGuo-ergou
Copy link
Contributor

I have created a PR in lazyvim: LazyVim/LazyVim#3908

@ASoldo
Copy link
Author

ASoldo commented Jul 4, 2024

Since update 2.0.26 everything seems to be in order for Nuxt/Vue projects and Js/Ts projects. I have successfully updated lsp with Mason. I'm really glad it's fixed now!

@ASoldo ASoldo closed this as completed Jul 4, 2024
folke pushed a commit to LazyVim/LazyVim that referenced this issue Jul 5, 2024
…ame time (#3908)

## What is this PR for?

At the moment, the config for vue set hybrid mode to `false` which volar
will run a typescript server under the hook. ( hybrid mode false is the
takeover mode in v1, was introduced in `2.0.7` see more information
here: vuejs/language-tools#4119 ).

However, another vtsls with vue language plugin also attached to vue
files, this will cause two typescript server running at the same time.
It can be very easily observed with tools like `htop` volar and vtsls
will have similar memory usage which is abnormal because volar should be
very light by itself. This will introduce issues like duplicate
diagnostics, see
vuejs/language-tools#4159 (comment)

In this pull request, I set the hybrid mode to true as default because
the hybrid mode is the "correct" way moving forward, thus it would be
more stable. Let me know if you feel it should stay as `false` to be
default.

## Does this PR fix an existing issue?

No existing issue.

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants