summaryrefslogtreecommitdiffstats
path: root/.config/nvim/after/plugin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.config/nvim/after/plugin/lsp.lua57
1 files changed, 53 insertions, 4 deletions
diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua
index 227e2eb..1056274 100644
--- a/.config/nvim/after/plugin/lsp.lua
+++ b/.config/nvim/after/plugin/lsp.lua
@@ -40,11 +40,60 @@ require('mason-lspconfig').setup({
local cmp = require('cmp')
local cmp_select = { behavior = cmp.SelectBehavior.Select }
+cmp.setup({
+ window = {
+ -- completion = cmp.config.window.bordered(),
+ -- documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-i>'] = cmp.mapping.select_next_item(cmp_select),
+ ['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
+ ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'vsnip' }, -- For vsnip users.
+ -- { name = 'luasnip' }, -- For luasnip users.
+ -- { name = 'ultisnips' }, -- For ultisnips users.
+ -- { name = 'snippy' }, -- For snippy users.
+ }, {
+ { name = 'buffer' },
+ })
+})
+
+ -- Set configuration for specific filetype.
+ cmp.setup.filetype('gitcommit', {
+ sources = cmp.config.sources({
+ { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
+ }, {
+ { name = 'buffer' },
+ })
+ })
+
+ -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
+ cmp.setup.cmdline({ '/', '?' }, {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = {
+ { name = 'buffer' }
+ }
+ })
+
+ -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
+ cmp.setup.cmdline(':', {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = cmp.config.sources({
+ { name = 'path' }
+ }, {
+ { name = 'cmdline' }
+ })
+ })
+
local cmp_mappings = lsp.defaults.cmp_mappings({
- ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
- ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
- ['<C-n>'] = cmp.mapping.confirm({ select = true }),
- ['<C-Space>'] = cmp.mapping.complete(),
})