浏览代码

Check if emmet is active. Enable emmet completion if emmet language server is active (#1335)

* Check if emmet is active.  Enable emmet completion if it is active

* move emmet check after the check for a space character

* Check if emmet is active for the current buffer only
rebuilt 3 年之前
父节点
当前提交
8becb83eeb
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      lua/core/compe.lua

+ 13 - 1
lua/core/compe.lua

@@ -77,6 +77,17 @@ M.setup = function()
     end
   end
 
+  local is_emmet_active = function()
+    local clients = vim.lsp.buf_get_clients()
+
+    for _, client in pairs(clients) do
+      if client.name == "emmet_ls" then
+        return true
+      end
+    end
+    return false
+  end
+
   -- Use (s-)tab to:
   --- move to prev/next item in completion menuone
   --- jump to prev/next snippet's placeholder
@@ -87,8 +98,9 @@ M.setup = function()
       return t "<Plug>(vsnip-jump-next)"
     elseif check_back_space() then
       return t "<Tab>"
+    elseif is_emmet_active() then
+      return vim.fn["compe#complete"]()
     else
-      -- return vim.fn["compe#complete"]() -- < use this if you want <tab> to always offer completion
       return t "<Tab>"
     end
   end