mirror of
https://github.com/WarrenHood/dotfiles.git
synced 2025-06-15 19:14:58 +01:00
Add luasnip
This commit is contained in:
parent
799708b9f9
commit
ed32743a88
7
neovim/.config/nvim/LuaSnip/all.lua
Normal file
7
neovim/.config/nvim/LuaSnip/all.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
|
||||
return {
|
||||
ls.parser.parse_snippet("test", "fn $1($2) {\n$0}"),
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ cmp.setup({
|
|||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
vim.lsp.buf.format,
|
||||
},
|
||||
|
@ -26,7 +26,7 @@ cmp.setup({
|
|||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "vsnip" }, -- For vsnip users.
|
||||
{ name = "luasnip" },
|
||||
{ name = "treesitter" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
|
|
|
@ -29,7 +29,7 @@ map('n', '<C-B>', ':NvimTreeToggle<CR>')
|
|||
map('n', '<S-t>', ':ToggleTerm<CR>')
|
||||
map('t', '<S-t>', '<C-\\><C-n>:ToggleTerm<CR>')
|
||||
|
||||
-- Pane navigation
|
||||
--[[ -- Pane navigation
|
||||
map('n', '<C-h>', ':wincmd h<CR>')
|
||||
map('n', '<C-j>', ':wincmd j<CR>')
|
||||
map('n', '<C-k>', ':wincmd k<CR>')
|
||||
|
@ -38,8 +38,20 @@ map('n', '<C-l>', ':wincmd l<CR>')
|
|||
map('t', '<C-h>', '<C-\\><C-n>:wincmd h<CR>')
|
||||
map('t', '<C-j>', '<C-\\><C-n>:wincmd j<CR>')
|
||||
map('t', '<C-k>', '<C-\\><C-n>:wincmd k<CR>')
|
||||
map('t', '<C-l>', '<C-\\><C-n>:wincmd l<CR>')
|
||||
map('t', '<C-l>', '<C-\\><C-n>:wincmd l<CR>') ]]
|
||||
|
||||
-- Pane management
|
||||
map('n', '<leader>sv', ':vsplit<CR>', { desc = 'Split Vertical' })
|
||||
map('n', '<leader>sh', ':split<CR>', { desc = 'Split Horizontal' })
|
||||
|
||||
|
||||
-- luasnip
|
||||
vim.cmd[[
|
||||
" Use Tab to expand and jump through snippets
|
||||
imap <silent><expr> <C-k> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
|
||||
smap <silent><expr> <C-k> luasnip#jumpable(1) ? '<Plug>luasnip-jump-next' : '<Tab>'
|
||||
|
||||
" Use Shift-Tab to jump backwards through snippets
|
||||
imap <silent><expr> <C-j> luasnip#jumpable(-1) ? '<Plug>luasnip-jump-prev' : '<S-Tab>'
|
||||
smap <silent><expr> <C-j> luasnip#jumpable(-1) ? '<Plug>luasnip-jump-prev' : '<S-Tab>'
|
||||
]]
|
||||
|
|
|
@ -24,4 +24,14 @@ require'nvim-treesitter.configs'.setup {
|
|||
}
|
||||
|
||||
|
||||
-- luasnip config
|
||||
require("luasnip").config.set_config({ -- Setting LuaSnip config
|
||||
|
||||
-- Enable autotriggered snippets
|
||||
enable_autosnippets = true,
|
||||
|
||||
-- Use Tab (or some other key if you prefer) to trigger visual selection
|
||||
store_selection_keys = "<Tab>",
|
||||
})
|
||||
|
||||
require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/LuaSnip/"})
|
||||
|
|
|
@ -36,8 +36,8 @@ require("packer").startup(function()
|
|||
use("hrsh7th/cmp-path")
|
||||
use("hrsh7th/cmp-cmdline")
|
||||
use("hrsh7th/nvim-cmp")
|
||||
use("hrsh7th/cmp-vsnip")
|
||||
use("hrsh7th/vim-vsnip")
|
||||
use("saadparwaiz1/cmp_luasnip")
|
||||
use("L3MON4D3/LuaSnip")
|
||||
|
||||
-- Treesitter
|
||||
use("nvim-treesitter/nvim-treesitter")
|
||||
|
|
Loading…
Reference in a new issue