aboutsummaryrefslogtreecommitdiffstats
path: root/after/plugin
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-04-11 08:41:09 +0200
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-04-11 08:41:09 +0200
commit5f6142f224ac128d62c4cb5c7d4acf45db19e5c2 (patch)
tree3630b6d24bac761c3e0c2381112fb4ec63d83f2e /after/plugin
parent76c51d6b471250550afd0461b4ea4316a5b4f506 (diff)
downloadnvim-conf-5f6142f224ac128d62c4cb5c7d4acf45db19e5c2.tar.gz
nvim-conf-5f6142f224ac128d62c4cb5c7d4acf45db19e5c2.zip
Apply stylelua and clean
Diffstat (limited to 'after/plugin')
-rw-r--r--after/plugin/luasnip.lua109
-rw-r--r--after/plugin/treesitter.lua2
2 files changed, 55 insertions, 56 deletions
diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua
index 65d3dcb..9891eb3 100644
--- a/after/plugin/luasnip.lua
+++ b/after/plugin/luasnip.lua
@@ -1,29 +1,29 @@
if vim.g.snippets ~= "luasnip" then
- return
+ return
end
-local ls = require "luasnip"
-local types = require "luasnip.util.types"
+local ls = require("luasnip")
+local types = require("luasnip.util.types")
-ls.config.set_config {
- -- This tells LuaSnip to remember to keep around the last snippet.
- -- You can jump back into even if you move outside of the selection
- history = true,
+ls.config.set_config({
+ -- This tells LuaSnip to remember to keep around the last snippet.
+ -- You can jump back into even if you move outside of the selection
+ history = true,
- -- This one is cool cause if you have dynamic snippets, it updatesas you type!
- updateevents = "TextChanged,TextChangedI",
+ -- This one is cool cause if you have dynamic snippets, it updatesas you type!
+ updateevents = "TextChanged,TextChangedI",
- -- Autosnippets:
- enable_autosnippets = true,
+ -- Autosnippets:
+ enable_autosnippets = true,
- ext_opts = {
- [types.choiceNode] = {
- active = {
- virt_text = { { "<- Choice", "Error" } },
- },
- },
- },
-}
+ ext_opts = {
+ [types.choiceNode] = {
+ active = {
+ virt_text = { { "<- Choice", "Error" } },
+ },
+ },
+ },
+})
-- create snippet
-- s(context, nodes, condition, ...)
@@ -31,7 +31,7 @@ local snippet = ls.s
-- TODO: Write about this.
-- Useful for dynamic nodes and choice nodes
-local snippet_from_nodes = ls.sn
+-- local snippet_from_nodes = ls.sn
-- This is the simplest node.
-- Creates a new text node. Places cursor after node by default.
@@ -52,7 +52,7 @@ local i = ls.insert_node
-- Function Node
-- Takes a function that returns text
-local f = ls.function_node
+-- local f = ls.function_node
-- This a choice snippet. You can move through with <c-l> (in my config)
-- c(1, { t {"hello"}, t {"world"}, }),
@@ -61,68 +61,67 @@ local f = ls.function_node
-- The second argument is a table of possible nodes.
-- Note, one thing that's nice is you don't have to include
-- the jump position for nodes that normally require one (can be nil)
-local c = ls.choice_node
+-- local c = ls.choice_node
-local d = ls.dynamic_node
+-- local d = ls.dynamic_node
-- TODO: Document what I've learned about lambda
-local l = require("luasnip.extras").lambda
+-- local l = require("luasnip.extras").lambda
-local events = require "luasnip.util.events"
+-- local events = require("luasnip.util.events")
local shortcut = function(val)
- if type(val) == "string" then
- return { t { val }, i(0) }
- end
-
- if type(val) == "table" then
- for k, v in ipairs(val) do
- if type(v) == "string" then
- val[k] = t { v }
- end
- end
- end
-
- return val
+ if type(val) == "string" then
+ return { t({ val }), i(0) }
+ end
+
+ if type(val) == "table" then
+ for k, v in ipairs(val) do
+ if type(v) == "string" then
+ val[k] = t({ v })
+ end
+ end
+ end
+
+ return val
end
local make = function(tbl)
- local result = {}
- for k, v in pairs(tbl) do
- table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v))))
- end
+ local result = {}
+ for k, v in pairs(tbl) do
+ table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v))))
+ end
- return result
+ return result
end
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/alpha/snips/ft/*.lua", true)) do
- local ft = vim.fn.fnamemodify(ft_path, ":t:r")
- ls.add_snippets(ft, make(loadfile(ft_path)()))
+ local ft = vim.fn.fnamemodify(ft_path, ":t:r")
+ ls.add_snippets(ft, make(loadfile(ft_path)()))
end
-
-- <c-k> is my expansion key
-- this will expand the current item 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
+ if ls.expand_or_jumpable() then
+ ls.expand_or_jump()
+ end
end, { silent = true })
-- <c-j> is my jump backwards key.
-- this always moves to the previous item within the snippet
vim.keymap.set({ "i", "s" }, "<c-j>", function()
- if ls.jumpable(-1) then
- ls.jump(-1)
- end
+ if ls.jumpable(-1) then
+ ls.jump(-1)
+ end
end, { silent = true })
-- <c-l> is selecting within a list of options.
-- This is useful for choice nodes (introduced in the forthcoming episode 2)
vim.keymap.set("i", "<c-l>", function()
- if ls.choice_active() then
- ls.change_choice(1)
- end
+ if ls.choice_active() then
+ ls.change_choice(1)
+ end
end)
-- shorcut to source my luasnips file again, which will reload my snippets
diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua
index 876a3d9..69791bd 100644
--- a/after/plugin/treesitter.lua
+++ b/after/plugin/treesitter.lua
@@ -12,7 +12,7 @@ require "nvim-treesitter.configs".setup {
enable = true,
},
incremental_selection = {
- enable = false,
+ enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",