diff --git a/nvim/.config/nvim/after/plugin/compe.vim b/nvim/.config/nvim/after/plugin/compe.vim new file mode 100644 index 0000000..e876373 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/compe.vim @@ -0,0 +1,12 @@ +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' +endfunction + +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ compe#complete() + +inoremap compe#confirm('') +inoremap compe#close('') diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index c4cd936..481ea61 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -32,7 +32,7 @@ vim.o.inccommand = 'split' vim.o.switchbuf = 'useopen' vim.o.encoding = 'utf-8' vim.o.mouse = '' -vim.o.completeopt = 'menuone,noinsert,noselect' +vim.o.completeopt = 'menu,menuone,noselect' vim.o.backspace = 'indent,eol,start' vim.o.wildmenu = true vim.o.wildmode = 'longest:full,full' diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index 5bbf1db..fb5c841 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -1,5 +1,4 @@ local nvim_lsp = require('lspconfig') -local completion = require('completion') local lsp_status = require('lsp-status') local lsp_fuzzy = require('lspfuzzy') local protocol = require('vim.lsp.protocol') @@ -48,7 +47,6 @@ end local on_attach = function(client, bufnr) vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - completion.on_attach(client, bufnr) lsp_status.on_attach(client, bufnr) if client.config.flags then diff --git a/nvim/.config/nvim/lua/modules/completion.lua b/nvim/.config/nvim/lua/modules/completion.lua index e8ae918..4c10849 100644 --- a/nvim/.config/nvim/lua/modules/completion.lua +++ b/nvim/.config/nvim/lua/modules/completion.lua @@ -1,43 +1,23 @@ -local remap = vim.api.nvim_set_keymap +require'compe'.setup { + enabled = true; + autocomplete = true; + debug = false; + min_length = 3; + preselect = 'enable'; + throttle_time = 80; + source_timeout = 200; + incomplete_delay = 400; + allow_prefix_unmatch = false; -vim.g.completion_enable_auto_popup = 0 -vim.g.completion_auto_change_source = 1 -vim.g.completion_trigger_on_delete = 1 -vim.g.completion_matching_ignore_case = 0 -vim.g.completion_matching_strategy_list = { 'exact', 'substring' } - -vim.g.completion_chain_complete_list = { - c = { - { complete_items = { 'buffers', 'tmux' } }, - { mode = { 'tags' } }, - { mode = { 'keyn' } }, - { mode = { '' } }, - { mode = { '' } } - }, - haskell = { - { complete_items = { 'buffers', 'lsp', 'tmux' } }, - { mode = { 'keyn' } }, - { mode = { '' } }, - { mode = { '' } } - }, - rust = { - { complete_items = { 'buffers', 'lsp', 'tmux' } }, - { mode = { 'keyn' } }, - { mode = { '' } }, - { mode = { '' } } - }, - default = { - { complete_items = { 'buffers', 'tmux' } }, - { mode = { 'keyn' } }, - { mode = { '' } }, - { mode = { '' } } - }, + source = { + path = true; + buffer = true; + calc = true; + nvim_lsp = true; + nvim_lua = true; + spell = true; + tags = true; + snippets_nvim = false; + vsnip = false; + }; } - -remap('i', '', 'pumvisible() ? "" : ""', { noremap = true, expr = true }) -remap('i', '', 'pumvisible() ? "" : ""', { noremap = true, expr = true }) -remap('i', '', '(completion_smart_tab)', { noremap = false }) -remap('i', '', '(completion_next_source)', { noremap = false }) -remap('i', '', '(completion_prev_source)', { noremap = false }) - -vim.api.nvim_command('autocmd BufEnter * lua require\'completion\'.on_attach()') diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index e4bb781..e5eaf0b 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -33,11 +33,9 @@ local init = function () } -- For autocompletion use { - 'nvim-lua/completion-nvim', + 'hrsh7th/nvim-compe', config = "require('modules.completion')" } - use 'steelsojka/completion-buffers' - use 'albertoCaroM/completion-tmux' -- For tmux use 'tmux-plugins/vim-tmux-focus-events' -- Git support