diff options
| author | Mike Hartington <mhartington@users.noreply.github.com> | 2019-11-19 21:47:03 -0500 |
|---|---|---|
| committer | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-19 18:47:03 -0800 |
| commit | 5e61024180c99047a4b5bb638bb7a5d7a7085182 (patch) | |
| tree | 4b89b3318bab5bc9a4c00e8b3e831b952b3313e3 /lua/nvim_lsp/cssls.lua | |
| parent | Add package_json for pyls and update docgen (#32) (diff) | |
| download | nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.tar nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.tar.gz nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.tar.bz2 nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.tar.lz nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.tar.xz nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.tar.zst nvim-lspconfig-5e61024180c99047a4b5bb638bb7a5d7a7085182.zip | |
Add css lsp (#36)
Diffstat (limited to 'lua/nvim_lsp/cssls.lua')
| -rw-r--r-- | lua/nvim_lsp/cssls.lua | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lua/nvim_lsp/cssls.lua b/lua/nvim_lsp/cssls.lua new file mode 100644 index 00000000..c39f81fd --- /dev/null +++ b/lua/nvim_lsp/cssls.lua @@ -0,0 +1,60 @@ +local skeleton = require 'nvim_lsp/skeleton' +local util = require 'nvim_lsp/util' +local lsp = vim.lsp + +local server_name = "cssls" +local bin_name = "css-languageserver" + +local installer = util.npm_installer { + server_name = server_name; + packages = { "vscode-css-languageserver-bin" }; + binaries = {bin_name}; +} + +local root_pattern = util.root_pattern("package.json") + +skeleton[server_name] = { + default_config = util.utf8_config { + cmd = {bin_name, "--stdio"}; + filetypes = {"css", "scss", "less"}; + root_dir = function(fname) + return root_pattern(fname) or vim.loop.os_homedir() + end; + log_level = lsp.protocol.MessageType.Warning; + settings = { + css = { validate = true }, + scss = { validate = true }, + less = { validate = true } + }; + }; + on_new_config = function(new_config) + local install_info = installer.info() + if install_info.is_installed then + if type(new_config.cmd) == 'table' then + -- Try to preserve any additional args from upstream changes. + new_config.cmd[1] = install_info.binaries[bin_name] + else + new_config.cmd = {install_info.binaries[bin_name]} + end + end + end; + docs = { + description = [[ +https://github.com/vscode-langservers/vscode-css-languageserver-bin + +`css-languageserver` can be installed via `:LspInstall cssls` or by yourself with `npm`: +```sh +npm install -g vscode-css-languageserver-bin +``` +]]; + default_config = { + root_dir = [[root_pattern("package.json")]]; + on_init = [[function to handle changing offsetEncoding]]; + capabilities = [[default capabilities, with offsetEncoding utf-8]]; + }; + }; +} + +skeleton[server_name].install = installer.install +skeleton[server_name].install_info = installer.info +-- vim:et ts=2 sw=2 |
