diff options
| author | Matsu <huhta.matias@gmail.com> | 2023-04-24 09:41:31 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-24 14:41:31 +0800 |
| commit | 659dd79a8e395597a85448b43836a4d228370148 (patch) | |
| tree | a9ed66c838d92b67303987304036125eb9f72dd5 /lua | |
| parent | fix(lspinfo): sub fname to check root (#2573) (diff) | |
| download | nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.tar nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.tar.gz nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.tar.bz2 nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.tar.lz nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.tar.xz nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.tar.zst nvim-lspconfig-659dd79a8e395597a85448b43836a4d228370148.zip | |
feat: add custom elements language server support (#2570)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/custom_elements_ls.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/custom_elements_ls.lua b/lua/lspconfig/server_configurations/custom_elements_ls.lua new file mode 100644 index 00000000..31b9ae82 --- /dev/null +++ b/lua/lspconfig/server_configurations/custom_elements_ls.lua @@ -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")]], + }, + }, +} |
