diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2021-10-24 22:47:51 +0200 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2021-10-24 22:47:51 +0200 |
| commit | b51479362becb5e0341b9c3fb0a71f4d07d87866 (patch) | |
| tree | 06514da373f3586feccfba677d832b844d16d49b | |
| parent | baa775734722374cbe8f633423c85e86fc3b2c2d (diff) | |
| download | nvim-conf-b51479362becb5e0341b9c3fb0a71f4d07d87866.tar.gz nvim-conf-b51479362becb5e0341b9c3fb0a71f4d07d87866.zip | |
Update to use nvim-cmp instead of compe
| -rw-r--r-- | init.vim | 2 | ||||
| -rw-r--r-- | lua/alpha/completition.lua | 58 | ||||
| -rw-r--r-- | lua/alpha/init.lua | 1 | ||||
| -rw-r--r-- | lua/plugins.lua | 39 | ||||
| -rw-r--r-- | plugin/lsp.vim | 56 |
5 files changed, 98 insertions, 58 deletions
@@ -25,7 +25,7 @@ autocmd BufWritePre * %s/\s\+$//e augroup fmtphp autocmd! - autocmd BufWritePre *.php undojoin | lua vim.lsp.buf.formatting() + autocmd BufWritePre filetype php undojoin | lua vim.lsp.buf.formatting() augroup END filetype plugin indent on diff --git a/lua/alpha/completition.lua b/lua/alpha/completition.lua new file mode 100644 index 0000000..1fff833 --- /dev/null +++ b/lua/alpha/completition.lua @@ -0,0 +1,58 @@ +local lspkind = require "lspkind" +lspkind.init() + +local cmp = require "cmp" + +cmp.setup { + mapping = { + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-e>"] = cmp.mapping.close(), + ["<C-y>"] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + ["<c-space>"] = cmp.mapping.complete(), + }, + sources = { + { name = "nvim_lua" }, + + { name = "nvim_lsp" }, + { name = "path" }, + { name = "luasnip" }, + { name = "buffer", keyword_length = 5 }, + }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = { + format = lspkind.cmp_format { + with_text = true, + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + } + }, + + experimental = { + native_menu = false, + + ghost_text = true, + } +} + +-- local Group = require("colorbuddy.group").Group +-- local g = require("colorbuddy.group").groups +-- local s = require("colorbuddy.style").styles + +-- Group.new("CmpItemAbbr", g.Comment) +-- Group.new("CmpItemAbbrDeprecated", g.Error) +-- Group.new("CmpItemAbbrMatchFuzzy", g.CmpItemAbbr.fg:dark(), nil, s.italic) +-- Group.new("CmpItemKind", g.Special) +-- Group.new("CmpItemMenu", g.NonText) diff --git a/lua/alpha/init.lua b/lua/alpha/init.lua index bc869ec..2ab9a0f 100644 --- a/lua/alpha/init.lua +++ b/lua/alpha/init.lua @@ -3,3 +3,4 @@ require("alpha.refactoring") require("alpha.snippets") require("alpha.harpoon") require("alpha.refactor") +require("alpha.completition") diff --git a/lua/plugins.lua b/lua/plugins.lua index c8013f4..6ae52a1 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -52,38 +52,19 @@ return require('packer').startup(function(use) use { 'tpope/vim-dispatch', opt = true, cmd = {'Dispatch', 'Make', 'Focus', 'Start'}} + use "hrsh7th/nvim-cmp" + use "hrsh7th/cmp-buffer" + use "hrsh7th/cmp-path" + use "hrsh7th/cmp-nvim-lua" + use "hrsh7th/cmp-nvim-lsp" + use "saadparwaiz1/cmp_luasnip" + use "onsails/lspkind-nvim" + + use "tjdevries/colorbuddy.nvim" + use { 'neovim/nvim-lspconfig', requires = { - { - 'hrsh7th/nvim-compe', - config = function() - require'compe'.setup { - enable = true; - autocomplete = true; - debug = false; - min_lenght = 1; - preselect = 'enable'; - throttle_time = 80; - source_timeout = 200; - resolve_timeout = 800; - incomplete_delay = 400; - max_abbr_width = 100; - max_kind_width = 100; - - source = { - path = true; - buffer = true; - calc = true; - nvim_lsp = true; - nvim_lua = true; - vsnip = false; - ultisnips = false; - luasnip = true; - }; - } - end - }, { 'kabouzeid/nvim-lspinstall' } } } diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 850a63b..7905181 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -1,31 +1,31 @@ -let g:compe = {} -let g:compe.enabled = v:true -let g:compe.autocomplete = v:true -let g:compe.debug = v:false -let g:compe.min_length = 1 -let g:compe.preselect = 'enable' -let g:compe.throttle_time = 80 -let g:compe.source_timeout = 200 -let g:compe.incomplete_delay = 400 -let g:compe.max_abbr_width = 100 -let g:compe.max_kind_width = 100 -let g:compe.max_menu_width = 100 -let g:compe.documentation = v:true - -let g:compe.source = {} -let g:compe.source.path = v:true -let g:compe.source.buffer = v:true -let g:compe.source.calc = v:true -let g:compe.source.nvim_lsp = v:true -let g:compe.source.nvim_lua = v:true -let g:compe.source.vsnip = v:false -let g:compe.source.luasnip = v:true - -inoremap <silent><expr> <C-Space> compe#complete() -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 }) +" let g:compe = {} +" let g:compe.enabled = v:true +" let g:compe.autocomplete = v:true +" let g:compe.debug = v:false +" let g:compe.min_length = 1 +" let g:compe.preselect = 'enable' +" let g:compe.throttle_time = 80 +" let g:compe.source_timeout = 200 +" let g:compe.incomplete_delay = 400 +" let g:compe.max_abbr_width = 100 +" let g:compe.max_kind_width = 100 +" let g:compe.max_menu_width = 100 +" let g:compe.documentation = v:true + +" let g:compe.source = {} +" let g:compe.source.path = v:true +" let g:compe.source.buffer = v:true +" let g:compe.source.calc = v:true +" let g:compe.source.nvim_lsp = v:true +" let g:compe.source.nvim_lua = v:true +" let g:compe.source.vsnip = v:false +" let g:compe.source.luasnip = v:true + +" inoremap <silent><expr> <C-Space> compe#complete() +" 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 }) fun! LspLocationList() lua vim.lsp.diagnostic.set_loclist({open_loclist = false}) |