summaryrefslogtreecommitdiff
path: root/lua/core/compe.lua
diff options
context:
space:
mode:
authorchristianchiarulli <[email protected]>2021-08-29 14:17:32 -0400
committerchristianchiarulli <[email protected]>2021-08-29 14:17:32 -0400
commited5559d259e38a78796a7d81421f02ba6dafac4b (patch)
treeafa9c00c017382bac547265a8a1e16b9770a07eb /lua/core/compe.lua
parente7b6d3b6f5982ea1042ffd499a7b85c18f0b782e (diff)
parentc7a5122fe2c14dba0f28f1c077f838f957884afc (diff)
Merge branch 'rolling' of github.com:ChristianChiarulli/LunarVim
Diffstat (limited to 'lua/core/compe.lua')
-rw-r--r--lua/core/compe.lua29
1 files changed, 21 insertions, 8 deletions
diff --git a/lua/core/compe.lua b/lua/core/compe.lua
index c2f97e27..9eb3dcfa 100644
--- a/lua/core/compe.lua
+++ b/lua/core/compe.lua
@@ -1,8 +1,9 @@
local M = {}
-local Log = require "core.log"
+
M.config = function()
lvim.builtin.compe = {
- enabled = true,
+ active = true,
+ on_config_done = nil,
autocomplete = true,
debug = false,
min_length = 1,
@@ -61,11 +62,7 @@ end
M.setup = function()
vim.g.vsnip_snippet_dir = lvim.vsnip_dir
- local status_ok, compe = pcall(require, "compe")
- if not status_ok then
- Log:get_default().error "Failed to load compe"
- return
- end
+ local compe = require "compe"
compe.setup(lvim.builtin.compe)
@@ -82,6 +79,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
@@ -92,8 +100,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
@@ -115,6 +124,10 @@ M.setup = function()
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true })
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
+
+ if lvim.builtin.compe.on_config_done then
+ lvim.builtin.compe.on_config_done(compe)
+ end
end
return M