diff options
author | maxime50 <[email protected]> | 2021-05-30 01:06:45 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-30 01:06:45 -0400 |
commit | 04c21be64bbdb52192ce209233505eb3990f7e3a (patch) | |
tree | 2b1011484d988e2693920165f5caa9f8c19673fa | |
parent | 66501fefe7ad7742a36cae147b7efa72a36e289b (diff) |
tailwindcss LSP fix (#442)
-rw-r--r-- | lua/lsp/tailwindcss-ls.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lua/lsp/tailwindcss-ls.lua b/lua/lsp/tailwindcss-ls.lua index 0bc5d80a..d85030ca 100644 --- a/lua/lsp/tailwindcss-ls.lua +++ b/lua/lsp/tailwindcss-ls.lua @@ -1,21 +1,26 @@ local lspconfig = require 'lspconfig' local configs = require 'lspconfig/configs' +local util = require"lspconfig".util -- 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", + "node", DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.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 + init_options = { + userLanguages = { -- I don't know why but the LSP won't autocomplete the tailwind classes without this + } }, + root_dir = function(fname) + return util.root_pattern('tailwind.config.js', 'tailwind.config.ts')(fname) or + util.root_pattern('postcss.config.js', 'postcss.config.ts')(fname) or + util.find_package_json_ancestor(fname) or + util.find_node_modules_ancestor(fname) or + util.find_git_ancestor(fname) + end, on_attach = require'lsp'.common_on_attach } |