aboutsummaryrefslogtreecommitdiffstats
path: root/lsp
diff options
context:
space:
mode:
authorBurton Smith <31320098+break-stuff@users.noreply.github.com>2025-12-07 14:20:48 -0500
committerGitHub <noreply@github.com>2025-12-07 14:20:48 -0500
commit51cbef51f64d7fe003e7445ef34df9aa6527111c (patch)
tree36b1a77e0a8fb4c51ad09fd473c252641d1e3deb /lsp
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.tar
nvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.tar.gz
nvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.tar.bz2
nvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.tar.lz
nvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.tar.xz
nvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.tar.zst
nvim-lspconfig-51cbef51f64d7fe003e7445ef34df9aa6527111c.zip
feat(wc_language_server): web components language server #4228
Diffstat (limited to 'lsp')
-rw-r--r--lsp/wc_language_server.lua85
1 files changed, 85 insertions, 0 deletions
diff --git a/lsp/wc_language_server.lua b/lsp/wc_language_server.lua
new file mode 100644
index 00000000..9005400b
--- /dev/null
+++ b/lsp/wc_language_server.lua
@@ -0,0 +1,85 @@
+---@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',
+ },
+}