summaryrefslogtreecommitdiff
path: root/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/lua/cmp_config.lua20
-rw-r--r--nvim/.config/nvim/lua/plugins.lua26
-rw-r--r--nvim/.config/nvim/lua/vsnip_config.lua27
3 files changed, 59 insertions, 14 deletions
diff --git a/nvim/.config/nvim/lua/cmp_config.lua b/nvim/.config/nvim/lua/cmp_config.lua
index fa1610f..fcad211 100644
--- a/nvim/.config/nvim/lua/cmp_config.lua
+++ b/nvim/.config/nvim/lua/cmp_config.lua
@@ -15,20 +15,28 @@ cmp.setup({
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
- ['<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.
+ ['<c-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<c-f>'] = cmp.mapping.scroll_docs(4),
+ ['<c-space>'] = cmp.mapping.complete(),
+ ['<esc>'] = cmp.mapping.abort(),
+ ['<cr>'] = cmp.mapping.confirm({
+ behavior = cmp.ConfirmBehavior.Insert,
+ select = true,
+ }),
}),
sources = cmp.config.sources({
+ { name = 'nvim_lua' },
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
{ name = 'path' },
- })
+ }),
+
+ experimental = {
+ ghost_text = true,
+ },
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua
index c578dbc..6fa67f0 100644
--- a/nvim/.config/nvim/lua/plugins.lua
+++ b/nvim/.config/nvim/lua/plugins.lua
@@ -34,16 +34,14 @@ return require('packer').startup(function()
config = function() require('neogit_config') end
}
+ -- Snippets
use {
- 'neovim/nvim-lspconfig',
- requires = {
- "jose-elias-alvarez/null-ls.nvim",
- "jose-elias-alvarez/nvim-lsp-ts-utils",
- "hrsh7th/cmp-nvim-lsp'",
- },
- config = function() require('lsp_config') end
+ 'hrsh7th/vim-vsnip',
+ config = function() require('vsnip_config') end,
}
+ use 'hrsh7th/vim-vsnip-integ'
+ -- Completion
use {
'hrsh7th/nvim-cmp',
requires = {
@@ -51,9 +49,21 @@ return require('packer').startup(function()
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
+ 'hrsh7th/cmp-nvim-lua',
'hrsh7th/vim-vsnip',
},
- config = function() require('cmp_config') end
+ config = function() require('cmp_config') end,
+ }
+
+ -- Language server support
+ use {
+ 'neovim/nvim-lspconfig',
+ requires = {
+ 'jose-elias-alvarez/null-ls.nvim',
+ 'jose-elias-alvarez/nvim-lsp-ts-utils',
+ 'hrsh7th/cmp-nvim-lsp',
+ },
+ config = function() require('lsp_config') end,
}
use {
diff --git a/nvim/.config/nvim/lua/vsnip_config.lua b/nvim/.config/nvim/lua/vsnip_config.lua
new file mode 100644
index 0000000..f7c2836
--- /dev/null
+++ b/nvim/.config/nvim/lua/vsnip_config.lua
@@ -0,0 +1,27 @@
+-- NOTE: You can use other key to expand snippet.
+
+-- Expand
+vim.cmd("imap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'")
+vim.cmd("smap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'")
+
+-- Expand or jump
+vim.cmd("imap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'")
+vim.cmd("smap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'")
+
+-- Jump forward or backward
+vim.cmd("imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'")
+vim.cmd("smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'")
+vim.cmd("imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'")
+vim.cmd("smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'")
+
+-- Select or cut text to use as $TM_SELECTED_TEXT in the next snippet.
+-- See https://github.com/hrsh7th/vim-vsnip/pull/50
+vim.cmd("nmap s <Plug>(vsnip-select-text)")
+vim.cmd("xmap s <Plug>(vsnip-select-text)")
+vim.cmd("nmap S <Plug>(vsnip-cut-text)")
+vim.cmd("xmap S <Plug>(vsnip-cut-text)")
+
+-- If you want to use snippet for multiple filetypes, you can `g:vsnip_filetypes` for it.
+vim.cmd("let g:vsnip_filetypes = {}")
+vim.cmd("let g:vsnip_filetypes.javascriptreact = ['javascript']")
+vim.cmd("let g:vsnip_filetypes.typescriptreact = ['typescript']")