diff options
| author | Nawfal bin Mohmad Rouyan <[email protected]> | 2021-04-01 15:29:52 +0800 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-01 03:29:52 -0400 | 
| commit | c2a937b622e61309f7b40361d6b85494c578a452 (patch) | |
| tree | 2f844a6c28b18889ed07696dd8c54ca7fdf8f1bc | |
| parent | 225266e1b3da7c888287ad0da05cf28782a17833 (diff) | |
Add tailwindcss lsp support (#205)
| -rw-r--r-- | init.lua | 1 | ||||
| -rw-r--r-- | lua/lsp/tailwindcss-ls.lua | 21 | ||||
| -rw-r--r-- | lua/nv-globals.lua | 3 | 
3 files changed, 25 insertions, 0 deletions
| @@ -66,6 +66,7 @@ require('lsp.efm-general-ls')  require('lsp.virtual_text')  require('lsp.latex-ls')  require('lsp.svelte-ls') +require('lsp.tailwindcss-ls')  -- vim.lsp.callbacks["textDocument/publishDiagnostics"] = function() end  -- vim.lsp.handlers["textDocument/publishDiagnostics"] = nil diff --git a/lua/lsp/tailwindcss-ls.lua b/lua/lsp/tailwindcss-ls.lua new file mode 100644 index 00000000..0bc5d80a --- /dev/null +++ b/lua/lsp/tailwindcss-ls.lua @@ -0,0 +1,21 @@ +local lspconfig = require 'lspconfig' +local configs = require 'lspconfig/configs' + +-- Check if tailwindls server already defined. +if not lspconfig.tailwindls then configs['tailwindls'] = {default_config = {}} end + +lspconfig.tailwindls.setup { +    cmd = { +        "node", DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/index.js", +        "--stdio" +    }, +    filetypes = O.tailwindls.filetypes, +    root_dir = require('lspconfig/util').root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"), +    handlers = { +        ["tailwindcss/getConfiguration"] = function(_, _, params, _, bufnr, _) +            -- tailwindcss lang server waits for this repsonse before providing hover +            vim.lsp.buf_notify(bufnr, "tailwindcss/getConfigurationResponse", {_id = params._id}) +        end +    }, +    on_attach = require'lsp'.common_on_attach +} diff --git a/lua/nv-globals.lua b/lua/nv-globals.lua index 4c18a6e1..36c92c23 100644 --- a/lua/nv-globals.lua +++ b/lua/nv-globals.lua @@ -46,6 +46,9 @@ O = {          formatter = '',          autoformat = false,          diagnostics = {virtual_text = true, signs = true, underline = true} +    }, +    tailwindls = { +        filetypes = {'html', 'css', 'scss', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact'}      }      -- css = {formatter = '', autoformat = false, virtual_text = true},      -- json = {formatter = '', autoformat = false, virtual_text = true} | 
