Skip to content

Commit 1a93f03

Browse files
committed
yayayayayayayyayayayayayaya i love theprimeagen yayayayayayaya
1 parent 1cbcb01 commit 1a93f03

8 files changed

Lines changed: 140 additions & 147 deletions

File tree

xdg_config/nvim/.gdb_history

Whitespace-only changes.

xdg_config/nvim/after/ftplugin/typescript.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ augroup MyTypescriptCommands
44
" autocmd BufWritePost <buffer> :silent! !prettier --write %
55
augroup END
66

7-
setlocal shiftwidth=2
7+
setlocal shiftwidth=4
8+
setlocal formatoptions-=o

xdg_config/nvim/after/plugin/completion.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ local cmp = require "cmp"
3131

3232
cmp.setup {
3333
mapping = {
34+
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
35+
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
3436
["<C-d>"] = cmp.mapping.scroll_docs(-4),
3537
["<C-f>"] = cmp.mapping.scroll_docs(4),
36-
["<C-e>"] = cmp.mapping.close(),
38+
["<C-e>"] = cmp.mapping.abort(),
3739
["<c-y>"] = cmp.mapping(
3840
cmp.mapping.confirm {
3941
behavior = cmp.ConfirmBehavior.Insert,

xdg_config/nvim/after/plugin/luasnip.lua

Lines changed: 44 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ if vim.g.snippets ~= "luasnip" or not pcall(require, "luasnip") then
22
return
33
end
44

5+
local make = R("tj.snips").make
6+
57
local ls = require "luasnip"
68
local types = require "luasnip.util.types"
79

@@ -77,44 +79,18 @@ local events = require "luasnip.util.events"
7779
-- return ls.parser.parse_snippet({ trig = trig }, expanded)
7880
-- end
7981

80-
local shortcut = function(val)
81-
if type(val) == "string" then
82-
return { t { val }, i(0) }
83-
end
84-
85-
if type(val) == "table" then
86-
for k, v in ipairs(val) do
87-
if type(v) == "string" then
88-
val[k] = t { v }
89-
end
90-
end
91-
end
92-
93-
return val
94-
end
95-
96-
local make = function(tbl)
97-
local result = {}
98-
for k, v in pairs(tbl) do
99-
table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v))))
100-
end
101-
102-
return result
103-
end
104-
10582
local same = function(index)
10683
return f(function(args)
10784
return args[1]
10885
end, { index })
10986
end
11087

111-
local snippets = {}
112-
11388
local toexpand_count = 0
11489

11590
-- `all` key means for all filetypes.
11691
-- Shared between all filetypes. Has lower priority than a particular ft tho
117-
snippets.all = {
92+
-- snippets.all = {
93+
ls.add_snippets(nil, {
11894
-- basic, don't need to know anything else
11995
-- arg 1: string
12096
-- arg 2: a node
@@ -202,31 +178,25 @@ snippets.all = {
202178

203179
--
204180
-- ls.parser.parse_snippet({trig = "lsp"}, "$1 is ${2|hard,easy,challenging|}")
205-
}
206-
207-
table.insert(snippets.all, ls.parser.parse_snippet("example", "-- $TM_FILENAME\nfunc $1($2) $3 {\n\t$0\n}"))
208-
209-
-- luasnip.lua
210-
-- func() {}
211-
212-
table.insert(
213-
snippets.all,
214-
snippet("cond", {
215-
t "will only expand in c-style comments",
216-
}, {
217-
condition = function(
218-
line_to_cursor --[[ , matched_trigger, captures ]]
219-
)
220-
local commentstring = "%s*" .. vim.bo.commentstring:gsub("%%s", "")
221-
-- optional whitespace followed by //
222-
return line_to_cursor:match(commentstring)
223-
end,
224-
})
225-
)
181+
})
182+
183+
-- table.insert(
184+
-- snippets.all,
185+
-- snippet("cond", {
186+
-- t "will only expand in c-style comments",
187+
-- }, {
188+
-- condition = function(
189+
-- line_to_cursor --[[ , matched_trigger, captures ]]
190+
-- )
191+
-- local commentstring = "%s*" .. vim.bo.commentstring:gsub("%%s", "")
192+
-- -- optional whitespace followed by //
193+
-- return line_to_cursor:match(commentstring)
194+
-- end,
195+
-- })
196+
-- )
226197

227198
-- Make sure to not pass an invalid command, as io.popen() may write over nvim-text.
228-
table.insert(
229-
snippets.all,
199+
ls.add_snippets(nil, {
230200
snippet(
231201
{ trig = "$$ (.*)", regTrig = true },
232202
f(function(_, snip, command)
@@ -247,30 +217,8 @@ table.insert(
247217
return false
248218
end,
249219
}
250-
)
251-
)
252-
253-
-- Lambda example
254-
table.insert(
255-
snippets.all,
256-
snippet("transform2", {
257-
i(1, "initial text here"),
258-
t " :: ",
259-
i(2, "replacement for text"),
260-
t " :: ",
261-
-- t { "", "" },
262-
-- Lambdas can also apply transforms USING the text of other nodes:
263-
l(l._1:gsub("text", l._2), { 1, 2 }),
264-
})
265-
)
266-
267-
-- initial text :: this is going to be replaced :: initial tthis is going to be replacedxt
268-
-- this is where we have text :: TEXT :: this is where we have TEXT
269-
270-
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/tj/snips/ft/*.lua", true)) do
271-
local ft = vim.fn.fnamemodify(ft_path, ":t:r")
272-
snippets[ft] = make(loadfile(ft_path)())
273-
end
220+
),
221+
})
274222

275223
local js_attr_split = function(args)
276224
local val = args[1][1]
@@ -294,32 +242,31 @@ local fill_line = function(char)
294242
end
295243
end
296244

297-
snippets.rst = make {
298-
jsa = {
299-
":js:attr:`",
300-
d(2, js_attr_split, { 1 }),
301-
" <",
302-
i(1),
303-
">",
304-
"`",
305-
},
306-
307-
link = { ".. _", i(1), ":" },
245+
ls.add_snippets(
246+
"rst",
247+
make {
248+
jsa = {
249+
":js:attr:`",
250+
d(2, js_attr_split, { 1 }),
251+
" <",
252+
i(1),
253+
">",
254+
"`",
255+
},
308256

309-
head = f(fill_line "=", {}),
310-
sub = f(fill_line "-", {}),
311-
subsub = f(fill_line "^", {}),
257+
link = { ".. _", i(1), ":" },
312258

313-
ref = { ":ref:`", same(1), " <", i(1), ">`" },
314-
}
259+
head = f(fill_line "=", {}),
260+
sub = f(fill_line "-", {}),
261+
subsub = f(fill_line "^", {}),
315262

316-
ls.snippets = snippets
263+
ref = { ":ref:`", same(1), " <", i(1), ">`" },
264+
}
265+
)
317266

318-
ls.autosnippets = {
319-
all = {
320-
ls.parser.parse_snippet("$file$", "$TM_FILENAME"),
321-
},
322-
}
267+
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/tj/snips/ft/*.lua", true)) do
268+
loadfile(ft_path)()
269+
end
323270

324271
-- <c-k> is my expansion key
325272
-- this will expand the current item or jump to the next item within the snippet.

xdg_config/nvim/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,7 @@ require "tj.lsp"
8484
-- Telescope BTW
8585
require "tj.telescope.setup"
8686
require "tj.telescope.mappings"
87+
88+
vim.keymap.set("n", "<space>hello", function()
89+
print "live demos!!"
90+
end)

xdg_config/nvim/lua/tj/lsp/init.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ local custom_attach = function(client)
8686
buf_inoremap { "<c-s>", vim.lsp.buf.signature_help }
8787

8888
buf_nnoremap { "<space>cr", vim.lsp.buf.rename }
89-
telescope_mapper("<space>ca", "lsp_code_actions", nil, true)
89+
buf_nnoremap { "<space>ca", vim.lsp.buf.code_action }
9090

9191
buf_nnoremap { "gd", vim.lsp.buf.definition }
9292
buf_nnoremap { "gD", vim.lsp.buf.declaration }
@@ -119,13 +119,15 @@ local custom_attach = function(client)
119119
end
120120

121121
if client.resolved_capabilities.code_lens then
122-
vim.cmd [[
123-
augroup lsp_document_codelens
124-
au! * <buffer>
125-
autocmd BufEnter ++once <buffer> lua require"vim.lsp.codelens".refresh()
126-
autocmd BufWritePost,CursorHold <buffer> lua require"vim.lsp.codelens".refresh()
127-
augroup END
128-
]]
122+
if filetype ~= "elm" then
123+
vim.cmd [[
124+
augroup lsp_document_codelens
125+
au! * <buffer>
126+
autocmd BufEnter ++once <buffer> lua require"vim.lsp.codelens".refresh()
127+
autocmd BufWritePost,CursorHold <buffer> lua require"vim.lsp.codelens".refresh()
128+
augroup END
129+
]]
130+
end
129131
end
130132

131133
-- Attach any filetype specific options to the client
@@ -206,6 +208,8 @@ local servers = {
206208
-- },
207209
-- },
208210

211+
elmls = true,
212+
209213
tsserver = {
210214
init_options = ts_util.init_options,
211215
cmd = { "typescript-language-server", "--stdio" },

xdg_config/nvim/lua/tj/snips/ft/go.lua

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
local ls = require "luasnip"
22

3+
require("luasnip.session.snippet_collection").clear_snippets "go"
4+
35
-- local snippet = ls.s
46
local snippet_from_nodes = ls.sn
57

8+
local s = ls.s
69
local i = ls.insert_node
710
local t = ls.text_node
811
local d = ls.dynamic_node
@@ -11,6 +14,7 @@ local fmt = require("luasnip.extras.fmt").fmt
1114

1215
local shared = R "tj.snips"
1316
local same = shared.same
17+
local make = shared.make
1418

1519
local ts_locals = require "nvim-treesitter.locals"
1620
local ts_utils = require "nvim-treesitter.ts_utils"
@@ -104,44 +108,47 @@ local go_ret_vals = function(args)
104108
)
105109
end
106110

107-
local M = {
108-
main = {
109-
t { "func main() {", "\t" },
110-
i(0),
111-
t { "", "}" },
112-
},
113-
114-
ef = {
115-
i(1, { "val" }),
116-
t ", err := ",
117-
i(2, { "f" }),
118-
t "(",
119-
i(3),
120-
t ")",
121-
i(0),
122-
},
123-
124-
efi = {
125-
i(1, { "val" }),
126-
", ",
127-
i(2, { "err" }),
128-
" := ",
129-
i(3, { "f" }),
130-
"(",
131-
i(4),
132-
")",
133-
t { "", "if " },
134-
same(2),
135-
t { " != nil {", "\treturn " },
136-
d(5, go_ret_vals, { 2, 3 }),
137-
t { "", "}" },
138-
i(0),
139-
},
140-
141-
-- TODO: Fix this up so that it actually uses the tree sitter thing
142-
ie = { "if err != nil {", "\treturn err", i(0), "}" },
143-
}
144-
145-
M.f = fmt("func {}({}) {} {{\n\t{}\n}}", { i(1, "name"), i(2), i(3), i(0) })
111+
ls.add_snippets(
112+
"go",
113+
make {
114+
main = {
115+
t { "func main() {", "\t" },
116+
i(0),
117+
t { "", "}" },
118+
},
119+
120+
ef = {
121+
i(1, { "val" }),
122+
t ", err := ",
123+
i(2, { "f" }),
124+
t "(",
125+
i(3),
126+
t ")",
127+
i(0),
128+
},
129+
130+
efi = {
131+
i(1, { "val" }),
132+
", ",
133+
i(2, { "err" }),
134+
" := ",
135+
i(3, { "f" }),
136+
"(",
137+
i(4),
138+
")",
139+
t { "", "if " },
140+
same(2),
141+
t { " != nil {", "\treturn " },
142+
d(5, go_ret_vals, { 2, 3 }),
143+
t { "", "}" },
144+
i(0),
145+
},
146+
147+
-- TODO: Fix this up so that it actually uses the tree sitter thing
148+
ie = { "if err != nil {", "\treturn err", i(0), "}" },
149+
}
150+
)
146151

147-
return M
152+
ls.add_snippets("go", {
153+
s("f", fmt("func {}({}) {} {{\n\t{}\n}}", { i(1, "name"), i(2), i(3), i(0) })),
154+
})

0 commit comments

Comments
 (0)