move to compe
This commit is contained in:
parent
4649db7adc
commit
f5f0e597c4
1 changed files with 69 additions and 16 deletions
85
.vimrc
85
.vimrc
|
|
@ -46,11 +46,8 @@ set ruler
|
||||||
|
|
||||||
" I hate split above, so make it split below. Likewise, to the right.
|
" I hate split above, so make it split below. Likewise, to the right.
|
||||||
set splitbelow
|
set splitbelow
|
||||||
" For autocomplete, show a menu, show it when there's only one option,
|
" For autocomplete, follow requirements for nvim-compe
|
||||||
" and only complete the longest common bit instead of the whole thing (like
|
set completeopt=menuone,noselect
|
||||||
" bash).
|
|
||||||
"set completeopt=menu,menuone,longest
|
|
||||||
set completeopt=noinsert,menuone,noselect,longest
|
|
||||||
set signcolumn=yes
|
set signcolumn=yes
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
|
|
||||||
|
|
@ -149,7 +146,7 @@ Plug 'tpope/vim-abolish'
|
||||||
Plug 'sheerun/vim-polyglot'
|
Plug 'sheerun/vim-polyglot'
|
||||||
Plug 'Shougo/denite.nvim'
|
Plug 'Shougo/denite.nvim'
|
||||||
Plug 'plytophogy/vim-virtualenv'
|
Plug 'plytophogy/vim-virtualenv'
|
||||||
Plug 'ervandew/supertab'
|
"Plug 'ervandew/supertab'
|
||||||
"Plug 'ncm2/ncm2'
|
"Plug 'ncm2/ncm2'
|
||||||
"Plug 'roxma/nvim-yarp'
|
"Plug 'roxma/nvim-yarp'
|
||||||
|
|
||||||
|
|
@ -200,7 +197,8 @@ Plug 'zchee/vim-goasm'
|
||||||
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'nvim-lua/lsp_extensions.nvim'
|
Plug 'nvim-lua/lsp_extensions.nvim'
|
||||||
Plug 'nvim-lua/completion-nvim'
|
Plug 'hrsh7th/nvim-compe'
|
||||||
|
"Plug 'nvim-lua/completion-nvim'
|
||||||
Plug 'onsails/lspkind-nvim'
|
Plug 'onsails/lspkind-nvim'
|
||||||
|
|
||||||
" Plugins that do specific things
|
" Plugins that do specific things
|
||||||
|
|
@ -273,7 +271,6 @@ local nvim_lsp = require'lspconfig'
|
||||||
|
|
||||||
-- function to attach completion when setting up lsp
|
-- function to attach completion when setting up lsp
|
||||||
local on_attach = function(client)
|
local on_attach = function(client)
|
||||||
require'completion'.on_attach(client)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable rust_analyzer
|
-- Enable rust_analyzer
|
||||||
|
|
@ -289,6 +286,65 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- Compe setup
|
||||||
|
require'compe'.setup {
|
||||||
|
enabled = true;
|
||||||
|
autocomplete = true;
|
||||||
|
debug = false;
|
||||||
|
min_length = 1;
|
||||||
|
preselect = 'enable';
|
||||||
|
throttle_time = 80;
|
||||||
|
source_timeout = 200;
|
||||||
|
incomplete_delay = 400;
|
||||||
|
max_abbr_width = 100;
|
||||||
|
max_kind_width = 100;
|
||||||
|
max_menu_width = 100;
|
||||||
|
documentation = true;
|
||||||
|
|
||||||
|
source = {
|
||||||
|
path = true;
|
||||||
|
nvim_lsp = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
local t = function(str)
|
||||||
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local check_back_space = function()
|
||||||
|
local col = vim.fn.col('.') - 1
|
||||||
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use (s-)tab to:
|
||||||
|
--- move to prev/next item in completion menuone
|
||||||
|
--- jump to prev/next snippet's placeholder
|
||||||
|
_G.tab_complete = function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return t "<C-n>"
|
||||||
|
elseif check_back_space() then
|
||||||
|
return t "<Tab>"
|
||||||
|
else
|
||||||
|
return vim.fn['compe#complete']()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_G.s_tab_complete = function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return t "<C-p>"
|
||||||
|
else
|
||||||
|
return t "<S-Tab>"
|
||||||
|
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})
|
||||||
|
|
||||||
require('lspkind').init({
|
require('lspkind').init({
|
||||||
-- disables text annotations
|
-- disables text annotations
|
||||||
with_text = false,
|
with_text = false,
|
||||||
|
|
@ -322,16 +378,8 @@ require('lspkind').init({
|
||||||
Struct = 'struct',
|
Struct = 'struct',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
" Use <Tab> and <S-Tab> to navigate through popup menu
|
|
||||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
||||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
||||||
|
|
||||||
" use <Tab> as trigger keys
|
|
||||||
imap <Tab> <Plug>(completion_smart_tab)
|
|
||||||
imap <S-Tab> <Plug>(completion_smart_s_tab)
|
|
||||||
|
|
||||||
" Code navigation shortcuts
|
" Code navigation shortcuts
|
||||||
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
||||||
|
|
@ -360,6 +408,11 @@ let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
||||||
let g:completion_matching_smart_case = 1
|
let g:completion_matching_smart_case = 1
|
||||||
let g:completion_sorting = 'length'
|
let g:completion_sorting = 'length'
|
||||||
|
|
||||||
|
inoremap <silent><expr> <CR> compe#confirm('<CR>')
|
||||||
|
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
||||||
|
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
||||||
|
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
||||||
|
|
||||||
|
|
||||||
" **** End LSP
|
" **** End LSP
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue