-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom elements language server support (#2570)
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
lua/lspconfig/server_configurations/custom_elements_ls.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
local util = require 'lspconfig.util' | ||
|
||
local bin_name = 'custom-elements-languageserver' | ||
local cmd = { bin_name, '--stdio' } | ||
|
||
if vim.fn.has 'win32' == 1 then | ||
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' } | ||
end | ||
|
||
return { | ||
default_config = { | ||
init_options = { hostInfo = 'neovim' }, | ||
cmd = cmd, | ||
filetypes = { | ||
'javascript', | ||
'javascriptreact', | ||
'javascript.jsx', | ||
'typescript', | ||
'typescriptreact', | ||
'typescript.tsx', | ||
'html', | ||
}, | ||
root_dir = function(fname) | ||
return util.root_pattern 'tsconfig.json'(fname) | ||
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname) | ||
end, | ||
}, | ||
docs = { | ||
description = [[ | ||
https://github.com/Matsuuu/custom-elements-language-server | ||
`custom-elements-languageserver` depends on `typescript`. Both packages can be installed via `npm`: | ||
```sh | ||
npm install -g typescript custom-elements-languageserver | ||
``` | ||
To configure typescript language server, add a | ||
[`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or | ||
[`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your | ||
project. | ||
Here's an example that disables type checking in JavaScript files. | ||
```json | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"checkJs": false | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} | ||
The best way to utilize the Custom Elements Language Server is to enable the [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest)(CEM) in your project by installing | ||
a CEM generator like one provided by [The Open WC Team](https://github.com/open-wc/custom-elements-manifest/tree/master/packages/analyzer). | ||
Generating a CEM in watch mode will provide you with the best user experience. If your dependencies ship with a Custom Elements Manifest, those will be utilized also. | ||
``` | ||
]], | ||
default_config = { | ||
root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]], | ||
}, | ||
}, | ||
} |