nvim/lsp/wc_language_server.lua
Simon Lasbrugnas a2e5555c64
fix(lsp)!: actually use the root lsp/ folder and remove
lua/custom/lsp/** configs

This commit removes the need for nvim-lspconfig which is replaced by the
vim.lsp API.

The lsp/ folder is a copy of nvim-lspconfig's lsp/ folder as it makes it
easy to modify LSP configurations on the fly.

Conform: biome has been replaced with oxfmt
2026-02-02 16:16:06 +01:00

85 lines
2.5 KiB
Lua

---@brief
---
--- https://github.com/wc-toolkit/wc-language-server
---
--- Web Components Language Server provides intelligent editor support for Web Components and custom elements.
--- It offers advanced HTML diagnostics, completion, and validation for custom elements, including support for
--- attribute types, deprecation, and duplicate attribute detection.
---
--- The language server uses the [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest)
--- to generate component integration and validation information
---
--- `wc-language-server` can be installed by following the instructions at the [GitHub repository](https://github.com/wc-toolkit/wc-language-server/blob/main/packages/neovim/README.md).
---
--- The default `cmd` assumes that the `wc-language-server` binary can be found in `$PATH`.
---
--- Alternatively, you can install it via [mason.nvim](https://github.com/williamboman/mason.nvim):
--- ```vim
--- :MasonInstall wc-language-server
--- ```
---
--- ## Configuration
---
--- The language server reads settings from `wc.config.js` (or `.ts/.mjs/.cjs`) at the project root.
--- Use it to customize manifest sources, file scoping, and diagnostic behavior.
---
--- Example `wc.config.js`:
--- ```js
--- export default {
--- // Fetch manifest from a custom path or URL
--- manifestSrc: './dist/custom-elements.json',
---
--- // Narrow which files opt into the language server
--- include: ['src/**/*.ts', 'src/**/*.html'],
---
--- // Skip specific globs
--- exclude: ['**/*.stories.ts'],
---
--- // Per-library overrides
--- libraries: {
--- '@your/pkg': {
--- manifestSrc: 'https://cdn.example.com/custom-elements.json',
--- tagFormatter: (tag) => tag.replace(/^x-/, 'my-'),
--- },
--- },
---
--- // Customize diagnostic severity levels
--- diagnosticSeverity: {
--- duplicateAttribute: 'warning',
--- unknownElement: 'info',
--- },
--- };
--- ```
---
--- See the [configuration documentation](https://github.com/wc-toolkit/wc-language-server#configuration) for more details.
---
---@type vim.lsp.Config
return {
init_options = { hostInfo = 'neovim' },
cmd = { 'wc-language-server', '--stdio' },
filetypes = {
'html',
'javascriptreact',
'typescriptreact',
'astro',
'svelte',
'vue',
'markdown',
'mdx',
'javascript',
'typescript',
'css',
'scss',
'less',
},
root_markers = {
'wc.config.js',
'wc.config.ts',
'wc.config.mjs',
'wc.config.cjs',
'custom-elements.json',
'package.json',
'.git',
},
}