summaryrefslogtreecommitdiff
path: root/lua/config/plugins/extra.lua
blob: 1241f6c745a48de7c4e7a8ad7f2fd68b63417f4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
return {
	{
		"multicursor-nvim",
		event = "DeferredUIEnter",
		after = function(_)
			local mc = require("multicursor-nvim")
			mc.setup({
				signs = false,
			})

			-- Keybindings would be a lot better as <localleader>
			local map = vim.keymap.set

			-- NOTE: this required for "repeatable" commands
			-- I'd like to use `2<localleader>cn` for example (and that doesn't work out of box)
			local map_rep = function(modes, bind, action)
				map(modes, bind, function()
					for _ = 1, vim.v.count1, 1 do
						action()
					end
				end)
			end

      -- stylua: ignore start
      map({ "n", "x" }, "<localleader><localleader>", function() mc.clearCursors() end)
      map({ "n", "x" }, "<localleader>R", function() mc.restoreCursors() end)

      map_rep({ "n", "x" }, "<localleader>j", function() mc.lineAddCursor(1) end)
      map_rep({ "n", "x" }, "<localleader>k", function() mc.lineAddCursor(-1) end)
      map_rep({ "n", "x" }, "<localleader>J", function() mc.lineSkipCursor(1) end)
      map_rep({ "n", "x" }, "<localleader>K", function() mc.lineSkipCursor(-1) end)

			map_rep({ "n", "x" }, "<localleader>cn", function() mc.matchAddCursor(1) end)
			map_rep({ "n", "x" }, "<localleader>cN", function() mc.matchAddCursor(-1) end)
			map_rep({ "n", "x" }, "<localleader>cs", function() mc.matchSkipCursor(1) end)
			map_rep({ "n", "x" }, "<localleader>cS", function() mc.matchSkipCursor(-1) end)
      map({ "n", "x" }, "<localleader>cM", mc.matchAllAddCursors)
      map("x", "<localleader>m", mc.matchCursors)
      map("x", "<localleader>s", mc.splitCursors)

      -- map("n", "<localleader>g", mc.addCursorOperator)
      map({ "n", "x" }, "<localleader>g", mc.operator)
			-- stylua: ignore end

			-- Customize how cursors look.
			local hl = vim.api.nvim_set_hl
			hl(0, "MultiCursorCursor", { reverse = true })
			hl(0, "MultiCursorVisual", { link = "Visual" })
			hl(0, "MultiCursorSign", { link = "SignColumn" })
			hl(0, "MultiCursorMatchPreview", { link = "Search" })
			hl(0, "MultiCursorDisabledCursor", { reverse = true })
			hl(0, "MultiCursorDisabledVisual", { link = "Visual" })
			hl(0, "MultiCursorDisabledSign", { link = "SignColumn" })
		end,
	},
	{
		"yanky.nvim",
		event = "DeferredUIEnter",
		after = function(_)
			require("yanky").setup({
				highlight = { timer = 150 },
				system_clipboard = {
					sync_with_ring = true,
				},
			})
		end,
		keys = {
			{ "y", "<Plug>(YankyYank)", mode = { "n", "x" }, desc = "Yank Text" },
			{ "p", "<Plug>(YankyPutAfter)", mode = { "n", "x" }, desc = "Put Text After Cursor" },
			{ "P", "<Plug>(YankyPutBefore)", mode = { "n", "x" }, desc = "Put Text Before Cursor" },
			{ "gp", "<Plug>(YankyGPutAfter)", mode = { "n", "x" }, desc = "Put Text After Selection" },
			{ "gP", "<Plug>(YankyGPutBefore)", mode = { "n", "x" }, desc = "Put Text Before Selection" },
			{ "[y", "<Plug>(YankyCycleForward)", desc = "Cycle Forward Through Yank History" },
			{ "]y", "<Plug>(YankyCycleBackward)", desc = "Cycle Backward Through Yank History" },
			{ "]p", "<Plug>(YankyPutIndentAfterLinewise)", desc = "Put Indented After Cursor (Linewise)" },
			{ "[p", "<Plug>(YankyPutIndentBeforeLinewise)", desc = "Put Indented Before Cursor (Linewise)" },
			{ "]P", "<Plug>(YankyPutIndentAfterLinewise)", desc = "Put Indented After Cursor (Linewise)" },
			{ "[P", "<Plug>(YankyPutIndentBeforeLinewise)", desc = "Put Indented Before Cursor (Linewise)" },
			{ ">p", "<Plug>(YankyPutIndentAfterShiftRight)", desc = "Put and Indent Right" },
			{ "<p", "<Plug>(YankyPutIndentAfterShiftLeft)", desc = "Put and Indent Left" },
			{ ">P", "<Plug>(YankyPutIndentBeforeShiftRight)", desc = "Put Before and Indent Right" },
			{ "<P", "<Plug>(YankyPutIndentBeforeShiftLeft)", desc = "Put Before and Indent Left" },
			{ "=p", "<Plug>(YankyPutAfterFilter)", desc = "Put After Applying a Filter" },
			{ "=P", "<Plug>(YankyPutBeforeFilter)", desc = "Put Before Applying a Filter" },
		},
	},
	{
		"which-key.nvim",
		event = "DeferredUIEnter",
		after = function(_)
			require("which-key").setup()

			require("which-key").add({
				{
					"<leader>w",
					group = "windows",
					proxy = "<C-w>",
					expand = function()
						return require("which-key.extras").expand.win()
					end,
				},

				{ "<leader>s", group = "search" },

				{
					mode = { "n", "v" },
					{ "<leader>g", group = "git" },
					{ "<leader>gh", group = "hunk" },
					{ "<leader>S", group = "surround" },
				},

				{ "<leader>x", group = "extra" },
				{ "<leader>xS", group = "supercollider" },
			})
		end,
	},
	{
		"oil.nvim",
		-- NOTE: lazy loading is not recommended
		event = "DeferredUIEnter",
		after = function(_)
			require("oil").setup()
		end,
		keys = {
			{ "-", "<CMD>Oil<CR>", { desc = "Open parent directory" } },
		},
	},
	{
		"scnvim",
		-- NOTE: this plugin is broken when try to lazyload
		lazy = false,
		after = function(_)
			local scnvim = require("scnvim")
			local map = scnvim.map
			local map_expr = scnvim.map_expr

			scnvim.setup({
				keymaps = {
					["<M-CR>"] = {
						map("editor.send_block", { "i", "n" }),
						map("editor.send_selection", "x"),
					},
					["<C-CR>"] = map("editor.send_line", { "i", "n" }),
					["<C-k>"] = map("signature.show", { "i", "n" }),

					["<F12>"] = map("sclang.hard_stop", { "i", "n", "x" }),
				},
			})

			vim.api.nvim_create_augroup("my.scnvim", { clear = true })
			vim.api.nvim_create_autocmd("InsertEnter", {
				pattern = "*.scd",
				group = "my.scnvim",
				once = true,
				callback = function()
					-- Loading snippets to LuaSnip
					require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets())
				end,
			})
		end,
		keys = {
			{ "<leader>xSs", "<CMD>SCNvimStart<CR>", desc = "Start SuperCollider" },
			{ "<leader>xSS", "<CMD>SCNvimStop<CR>", desc = "Stop SuperCollider" },
			{ "<leader>xSr", "<CMD>SCNvimRecompile<CR>", desc = "Recompile SuperCollider sclang" },
		},
	},
}