Replace luasnips with native snippets

This commit is contained in:
Jan Eitzinger 2024-09-16 06:01:11 +02:00
parent 57e62a827d
commit 040866b9f5
5 changed files with 55 additions and 37 deletions

View File

@ -0,0 +1 @@
/home/jan/.local/share/broot/launcher/bash/1

View File

@ -0,0 +1,4 @@
This file tells broot the installation of the br function was done.
If there's a problem and you want to install it again run
broot -- install

View File

@ -0,0 +1,19 @@
# This script was automatically generated by the broot program
# More information can be found in https://github.com/Canop/broot
# This function starts broot and executes the command
# it produces, if any.
# It's needed because some shell commands, like `cd`,
# have no useful effect if executed in a subshell.
function br --wraps=broot
set -l cmd_file (mktemp)
if broot --outcmd $cmd_file $argv
read --local --null cmd < $cmd_file
rm -f $cmd_file
eval $cmd
else
set -l code $status
rm -f $cmd_file
return $code
end
end

View File

@ -161,7 +161,7 @@ o.wildignore =
'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc' 'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc'
vim.cmd([[ vim.cmd([[
au BufRead,BufNewFile *.md set tw=80 syntax=markdown au BufRead,BufNewFile *.md set spell tw=80 syntax=markdown
]]) ]])
vim.g.markdown_recommended_style = 0 vim.g.markdown_recommended_style = 0

View File

@ -1,36 +1,5 @@
return { return {
{{- if eq .chezmoi.os "openbsd" }} {{- if eq .chezmoi.os "openbsd" }}
-- snippets
{
"L3MON4D3/LuaSnip",
build = "gmake install_jsregexp",
dependencies = {
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_snipmate").lazy_load()
end,
},
opts = {
history = true,
delete_check_events = "TextChanged",
},
-- stylua: ignore
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true,
silent = true,
mode = "i",
},
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
},
},
-- auto completion -- auto completion
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
@ -40,7 +9,13 @@ return {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip", {
"garymjr/nvim-snippets",
opts = {
friendly_snippets = true,
},
dependencies = { "rafamadriz/friendly-snippets" },
},
}, },
opts = function() opts = function()
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
@ -72,7 +47,6 @@ return {
TypeParameter = "󰅲", TypeParameter = "󰅲",
} }
local luasnip = require('luasnip')
local cmp = require("cmp") local cmp = require("cmp")
local defaults = require("cmp.config.default")() local defaults = require("cmp.config.default")()
return { return {
@ -81,7 +55,7 @@ return {
}, },
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) vim.snippet.expand(args.body)
end, end,
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
@ -103,7 +77,7 @@ return {
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp", keyword_length = 1 }, { name = "nvim_lsp", keyword_length = 1 },
{ name = "luasnip", keyword_length = 2 }, { name = "snippets" },
{ name = "path" }, { name = "path" },
}, { }, {
{ name = "buffer", keyword_length = 3 }, { name = "buffer", keyword_length = 3 },
@ -116,7 +90,7 @@ return {
vim_item.menu = ({ vim_item.menu = ({
buffer = "[Buffer]", buffer = "[Buffer]",
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]", snippets = "[Snippets]",
nvim_lua = "[Lua]", nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]", latex_symbols = "[LaTeX]",
})[entry.source.name] })[entry.source.name]
@ -131,6 +105,26 @@ return {
sorting = defaults.sorting, sorting = defaults.sorting,
} }
end, end,
keys = {
{
"<Tab>",
function()
return vim.snippet.active({ direction = 1 }) and "<cmd>lua vim.snippet.jump(1)<cr>" or "<Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
{
"<S-Tab>",
function()
return vim.snippet.active({ direction = -1 }) and "<cmd>lua vim.snippet.jump(-1)<cr>" or "<S-Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
},
config = function(_, opts) config = function(_, opts)
for _, source in ipairs(opts.sources) do for _, source in ipairs(opts.sources) do
source.group_index = source.group_index or 1 source.group_index = source.group_index or 1