nvim updates

This commit is contained in:
2023-09-25 16:32:30 -04:00
parent 275baa228c
commit 966c050875
5 changed files with 94 additions and 60 deletions

View File

@@ -30,3 +30,33 @@ keymap("x", "J", ":move '>+1<CR>gv-gv", default_options)
-- Toggle nvim-tree open or closed
keymap("n", "<c-n>", "<CMD>:Neotree toggle<CR>", default_options)
-- LuaSnip Keymaps
local ls = require('luasnip')
-- <c-k> to expand snippets.
-- This will expand the snippet or jump to the next item within the snippet.
vim.keymap.set({ "i", "s" }, "<c-k>", function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end, { silent = true })
-- <c-j>
-- This will jump backwards in the snippet.
vim.keymap.set({ "i", "s" }, "<c-j>", function()
if ls.jumpable(-1) then
ls.jump(-1)
end
end, { silent = true })
-- <c-l>
-- This is for selecting withing a list of options.
vim.keymap.set("i", "<c-l>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end, { silent = true })
-- Reload the snippets.
vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/m-housh/lua/snippets/init.lua<cr>")

View File

@@ -6,7 +6,8 @@ return {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-vsnip",
--"hrsh7th/cmp-vsnip",
"saadparwaiz1/cmp_luasnip",
"f3fora/cmp-spell",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-emoji"
@@ -16,6 +17,7 @@ return {
local cmp = require "cmp"
local lspkind = require("lspkind")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local luasnip = require('luasnip')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
@@ -36,9 +38,10 @@ return {
lspkind.init({
symbol_map = {
Text = "",
Method = "",
Function = "",
Text = "",
Method = "󰡱",
Function = "󰡱",
Constructor = "",
Field = "",
Variable = "",
@@ -82,9 +85,9 @@ return {
},
experimental = {native_menu = false, ghost_text = false},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end
expand = function(args)
require('luasnip').lsp_expand(args.body)
end
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
@@ -98,15 +101,17 @@ return {
select = false
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, {"i", "s"}),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
@@ -117,9 +122,13 @@ return {
end, {"i", "s"})
},
sources = {
{name = "nvim_lsp"}, {name = "buffer", keyword_length = 5},
{name = "vsnip"}, {name = "calc"}, {name = "emoji"}, {name = "spell"},
{name = "path"}
{name = "nvim_lsp"},
{name = "buffer", keyword_length = 5},
{name = 'luasnip', option = { show_autosnippets = true } },
{name = "calc"},
{name = "emoji"},
{name = "spell"},
{name = "path"}
}
})

View File

@@ -1,12 +1,33 @@
-- This file contains plugin's that don't require much configuration.
return {
{
"hrsh7th/vim-vsnip",
config = function()
vim.g.vsnip_snippet_dir = os.getenv('HOME') .. '/.config/nvim/snippets/'
end
},
-- {
-- "hrsh7th/vim-vsnip",
-- config = function()
-- vim.g.vsnip_snippet_dir = os.getenv('HOME') .. '/.config/m-housh/snippets/'
-- end
-- },
-- {
-- dir = "~/LocalProjects/plugins/m-housh/swift.nvim"
-- }
{
"L3MON4D3/LuaSnip",
version = "2.*",
build = "make install_jsregexp",
config = function()
local luasnip = require('luasnip')
local types = require('luasnip.util.types')
luasnip.config.set_config {
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true,
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = { { "<-", "Error" } },
},
},
},
}
end
}
}

View File

@@ -0,0 +1,9 @@
local ls = require('luasnip')
local s = ls.snippet
local sn = ls.snippet_node
local ms = ls.multi_snippet
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local t = ls.text_node