nvim: Switch to nvim-compe
This commit is contained in:
parent
6ef47458e2
commit
9918959aa2
5 changed files with 35 additions and 47 deletions
12
nvim/.config/nvim/after/plugin/compe.vim
Normal file
12
nvim/.config/nvim/after/plugin/compe.vim
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
function! s:check_back_space() abort
|
||||||
|
let col = col('.') - 1
|
||||||
|
return !col || getline('.')[col - 1] =~ '\s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
inoremap <silent><expr> <TAB>
|
||||||
|
\ pumvisible() ? "\<C-n>" :
|
||||||
|
\ <SID>check_back_space() ? "\<TAB>" :
|
||||||
|
\ compe#complete()
|
||||||
|
|
||||||
|
inoremap <silent><expr> <CR> compe#confirm('<CR>')
|
||||||
|
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
|
@ -32,7 +32,7 @@ vim.o.inccommand = 'split'
|
||||||
vim.o.switchbuf = 'useopen'
|
vim.o.switchbuf = 'useopen'
|
||||||
vim.o.encoding = 'utf-8'
|
vim.o.encoding = 'utf-8'
|
||||||
vim.o.mouse = ''
|
vim.o.mouse = ''
|
||||||
vim.o.completeopt = 'menuone,noinsert,noselect'
|
vim.o.completeopt = 'menu,menuone,noselect'
|
||||||
vim.o.backspace = 'indent,eol,start'
|
vim.o.backspace = 'indent,eol,start'
|
||||||
vim.o.wildmenu = true
|
vim.o.wildmenu = true
|
||||||
vim.o.wildmode = 'longest:full,full'
|
vim.o.wildmode = 'longest:full,full'
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local nvim_lsp = require('lspconfig')
|
local nvim_lsp = require('lspconfig')
|
||||||
local completion = require('completion')
|
|
||||||
local lsp_status = require('lsp-status')
|
local lsp_status = require('lsp-status')
|
||||||
local lsp_fuzzy = require('lspfuzzy')
|
local lsp_fuzzy = require('lspfuzzy')
|
||||||
local protocol = require('vim.lsp.protocol')
|
local protocol = require('vim.lsp.protocol')
|
||||||
|
@ -48,7 +47,6 @@ end
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
completion.on_attach(client, bufnr)
|
|
||||||
lsp_status.on_attach(client, bufnr)
|
lsp_status.on_attach(client, bufnr)
|
||||||
|
|
||||||
if client.config.flags then
|
if client.config.flags then
|
||||||
|
|
|
@ -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
|
source = {
|
||||||
vim.g.completion_auto_change_source = 1
|
path = true;
|
||||||
vim.g.completion_trigger_on_delete = 1
|
buffer = true;
|
||||||
vim.g.completion_matching_ignore_case = 0
|
calc = true;
|
||||||
vim.g.completion_matching_strategy_list = { 'exact', 'substring' }
|
nvim_lsp = true;
|
||||||
|
nvim_lua = true;
|
||||||
vim.g.completion_chain_complete_list = {
|
spell = true;
|
||||||
c = {
|
tags = true;
|
||||||
{ complete_items = { 'buffers', 'tmux' } },
|
snippets_nvim = false;
|
||||||
{ mode = { 'tags' } },
|
vsnip = false;
|
||||||
{ mode = { 'keyn' } },
|
};
|
||||||
{ mode = { '<c-p>' } },
|
|
||||||
{ mode = { '<c-n>' } }
|
|
||||||
},
|
|
||||||
haskell = {
|
|
||||||
{ complete_items = { 'buffers', 'lsp', 'tmux' } },
|
|
||||||
{ mode = { 'keyn' } },
|
|
||||||
{ mode = { '<c-p>' } },
|
|
||||||
{ mode = { '<c-n>' } }
|
|
||||||
},
|
|
||||||
rust = {
|
|
||||||
{ complete_items = { 'buffers', 'lsp', 'tmux' } },
|
|
||||||
{ mode = { 'keyn' } },
|
|
||||||
{ mode = { '<c-p>' } },
|
|
||||||
{ mode = { '<c-n>' } }
|
|
||||||
},
|
|
||||||
default = {
|
|
||||||
{ complete_items = { 'buffers', 'tmux' } },
|
|
||||||
{ mode = { 'keyn' } },
|
|
||||||
{ mode = { '<c-p>' } },
|
|
||||||
{ mode = { '<c-n>' } }
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remap('i', '<Tab>', 'pumvisible() ? "<C-n>" : "<Tab>"', { noremap = true, expr = true })
|
|
||||||
remap('i', '<S-Tab>', 'pumvisible() ? "<C-p>" : "<S-Tab>"', { noremap = true, expr = true })
|
|
||||||
remap('i', '<Tab>', '<Plug>(completion_smart_tab)', { noremap = false })
|
|
||||||
remap('i', '<C-j>', '<Plug>(completion_next_source)', { noremap = false })
|
|
||||||
remap('i', '<C-k>', '<Plug>(completion_prev_source)', { noremap = false })
|
|
||||||
|
|
||||||
vim.api.nvim_command('autocmd BufEnter * lua require\'completion\'.on_attach()')
|
|
||||||
|
|
|
@ -33,11 +33,9 @@ local init = function ()
|
||||||
}
|
}
|
||||||
-- For autocompletion
|
-- For autocompletion
|
||||||
use {
|
use {
|
||||||
'nvim-lua/completion-nvim',
|
'hrsh7th/nvim-compe',
|
||||||
config = "require('modules.completion')"
|
config = "require('modules.completion')"
|
||||||
}
|
}
|
||||||
use 'steelsojka/completion-buffers'
|
|
||||||
use 'albertoCaroM/completion-tmux'
|
|
||||||
-- For tmux
|
-- For tmux
|
||||||
use 'tmux-plugins/vim-tmux-focus-events'
|
use 'tmux-plugins/vim-tmux-focus-events'
|
||||||
-- Git support
|
-- Git support
|
||||||
|
|
Loading…
Reference in a new issue