summaryrefslogtreecommitdiff
path: root/lua/core/compe.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/core/compe.lua')
-rw-r--r--lua/core/compe.lua33
1 files changed, 24 insertions, 9 deletions
diff --git a/lua/core/compe.lua b/lua/core/compe.lua
index c8152ad1..801e2dd8 100644
--- a/lua/core/compe.lua
+++ b/lua/core/compe.lua
@@ -1,6 +1,6 @@
local M = {}
M.config = function()
- O.completion = {
+ lvim.builtin.compe = {
enabled = true,
autocomplete = true,
debug = false,
@@ -30,18 +30,20 @@ M.config = function()
emoji = { kind = " ﲃ (Emoji)", filetypes = { "markdown", "text" } },
-- for emoji press : (idk if that in compe tho)
},
+ -- FileTypes in this list won't trigger auto-complete when TAB is pressed. Hitting TAB will insert a tab character
+ exclude_filetypes = { "md", "markdown", "mdown", "mkd", "mkdn", "mdwn", "text", "txt" },
}
end
M.setup = function()
- vim.g.vsnip_snippet_dir = O.vsnip_dir
+ vim.g.vsnip_snippet_dir = lvim.vsnip_dir
local status_ok, compe = pcall(require, "compe")
if not status_ok then
return
end
- compe.setup(O.completion)
+ compe.setup(lvim.builtin.compe)
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
@@ -81,16 +83,29 @@ M.setup = function()
end
end
- vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true })
- 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 })
-
vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true })
- vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true })
+ -- vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true })
vim.api.nvim_set_keymap("i", "<C-e>", "compe#close('<C-e>')", { noremap = true, silent = true, expr = true })
vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({ 'delta': +4 })", { noremap = true, silent = true, expr = true })
vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({ 'delta': -4 })", { noremap = true, silent = true, expr = true })
end
+local is_excluded = function(file_type)
+ for _, type in ipairs(lvim.builtin.compe.exclude_filetypes) do
+ if type == file_type then
+ return true
+ end
+ end
+ return false
+end
+
+M.set_tab_keybindings = function()
+ local file_type = vim.fn.expand "%:e"
+ if is_excluded(file_type) == false then
+ vim.api.nvim_buf_set_keymap(0, "i", "<Tab>", "v:lua.tab_complete()", { expr = true })
+ vim.api.nvim_buf_set_keymap(0, "s", "<Tab>", "v:lua.tab_complete()", { expr = true })
+ vim.api.nvim_buf_set_keymap(0, "i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
+ vim.api.nvim_buf_set_keymap(0, "s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
+ end
+end
return M