aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/config/compe.lua38
-rw-r--r--lua/config/lsp.lua6
-rw-r--r--lua/config/nvim-cmp.lua41
-rw-r--r--lua/plugins.lua14
4 files changed, 56 insertions, 43 deletions
diff --git a/lua/config/compe.lua b/lua/config/compe.lua
deleted file mode 100644
index 5286a9d..0000000
--- a/lua/config/compe.lua
+++ /dev/null
@@ -1,38 +0,0 @@
--- nvim-compe settings
-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 = {
- omni = { filetypes = { "tex" } },
- path = true,
- buffer = false,
- spell = { filetypes = { "markdown", "tex" } },
- emoji = true,
- nvim_lsp = true,
- nvim_lua = true,
- ultisnips = true,
- calc = false,
- vsnip = false,
- },
-})
-
-vim.o.completeopt = "menuone,noselect"
-
--- nvim-compe mappings
-local compe_map_opts = { expr = true, noremap = true, silent = true }
-vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", compe_map_opts)
-vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", compe_map_opts)
-vim.api.nvim_set_keymap("i", "<ESC>", "compe#close('<ESC>')", compe_map_opts)
-vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({'delta': +4})", compe_map_opts)
-vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({'delta': -4})", compe_map_opts)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index f362e54..f65eb9e 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -66,7 +66,7 @@ local custom_attach = function(client, bufnr)
-- vim.notify(msg, 'info', {title = 'Nvim-config', timeout = 2500})
end
-local capabilities = vim.lsp.protocol.make_client_capabilities()
+capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
capabilities.textDocument.completion.completionItem.snippetSupport = true
local lspconfig = require("lspconfig")
@@ -88,10 +88,12 @@ lspconfig.pylsp.setup({
flags = {
debounce_text_changes = 200,
},
+ capabilities = capabilities,
})
-- lspconfig.pyright.setup{
-- on_attach = custom_attach,
+-- capabilities = capabilities
-- }
lspconfig.clangd.setup({
@@ -109,6 +111,7 @@ lspconfig.vimls.setup({
flags = {
debounce_text_changes = 500,
},
+ capabilities = capabilities,
})
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
@@ -144,6 +147,7 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
},
},
},
+ capabilities = capabilities,
})
end
diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua
new file mode 100644
index 0000000..97350b2
--- /dev/null
+++ b/lua/config/nvim-cmp.lua
@@ -0,0 +1,41 @@
+-- Setup nvim-cmp.
+local cmp = require'cmp'
+
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ -- For `ultisnips` user.
+ vim.fn["UltiSnips#Anon"](args.body)
+ end,
+ },
+ mapping = {
+ ['<Tab>'] = function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ else
+ fallback()
+ end
+ end,
+ ['<S-Tab>'] = function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ else
+ fallback()
+ end
+ end,
+ ['<Esc>'] = cmp.mapping.close(),
+ },
+ sources = {
+ { name = 'nvim_lsp' }, -- For nvim-lsp
+ { name = 'ultisnips' }, -- For ultisnips user.
+ { name = 'path' }, -- for path completion
+ { name = 'emoji', insert = true, } -- emoji completion
+ },
+ completion = {
+ keyword_length = 1,
+ completeopt = "menu,menuone,noinsert"
+ },
+ experimental = {
+ ghost_text = false
+ }
+})
diff --git a/lua/plugins.lua b/lua/plugins.lua
index e761d41..4d20175 100644
--- a/lua/plugins.lua
+++ b/lua/plugins.lua
@@ -27,10 +27,16 @@ require("packer").startup({
use({"wbthomason/packer.nvim", opt = true})
-- nvim-lsp configuration
- use({ "neovim/nvim-lspconfig", event = 'VimEnter', config = [[require('config.lsp')]] })
+ use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] })
-- auto-completion engine
- use({ "hrsh7th/nvim-compe", event = "InsertEnter *", config = [[require('config.compe')]] })
+ use {"hrsh7th/nvim-cmp", event = "InsertEnter", config = [[require('config.nvim-cmp')]]}
+
+ -- nvim-cmp completion sources
+ use {"hrsh7th/cmp-nvim-lsp", event = "VimEnter"}
+ use {"hrsh7th/cmp-path", after = "nvim-cmp"}
+ use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}}
+ use {"hrsh7th/cmp-emoji", after = 'nvim-cmp'}
if vim.g.is_mac then
use({ "nvim-treesitter/nvim-treesitter", event = 'BufEnter', run = ":TSUpdate", config = [[require('config.treesitter')]] })
@@ -57,7 +63,7 @@ require("packer").startup({
-- Super fast movement with vim-sneak
use({"justinmk/vim-sneak", event = "VimEnter"})
- use { 'phaazon/hop.nvim', as = 'hop', config = [[require('hop').setup()]] }
+ use { 'phaazon/hop.nvim', event = "VimEnter", config = [[require('hop').setup()]] }
-- Clear highlight search automatically for you
use({"romainl/vim-cool", event = "VimEnter"})
@@ -306,7 +312,7 @@ require("packer").startup({
use("gelguy/wilder.nvim")
-- showing keybindings
- use {"folke/which-key.nvim", config = [[require('config.which-key')]]}
+ use {"folke/which-key.nvim", event = "VimEnter", config = [[require('config.which-key')]]}
end,
config = {
max_jobs = 16,