mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
nvim updates
This commit is contained in:
@@ -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>")
|
||||
|
||||
@@ -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"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
9
nvim/m-housh/lua/snippets/init.lua
Normal file
9
nvim/m-housh/lua/snippets/init.lua
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user