feat: add elixir stuff
This commit is contained in:
parent
9f931b563f
commit
667b7a9db3
4 changed files with 189 additions and 0 deletions
|
@ -2,6 +2,7 @@ local conform = require("conform")
|
|||
|
||||
local formatters_by_ft = {
|
||||
["*"] = { "codespell", "trim_whitespace" },
|
||||
elixir = { "mix" },
|
||||
gleam = { "gleam" },
|
||||
go = { "gofmt" },
|
||||
json = { "jq" },
|
||||
|
|
|
@ -133,6 +133,10 @@ for _, lsp in ipairs(servers) do
|
|||
lspconfig_setup(lsp, {})
|
||||
end
|
||||
|
||||
lspconfig_setup("elixirls", {
|
||||
cmd = { "elixir-ls" },
|
||||
})
|
||||
|
||||
lspconfig_setup("nixd", {
|
||||
settings = {
|
||||
nixd = {
|
||||
|
|
46
modules/programs/nvim/plugins/snippets/elixir.lua
Normal file
46
modules/programs/nvim/plugins/snippets/elixir.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
local k = require("luasnip.nodes.key_indexer").new_key
|
||||
|
||||
local def_template = [[
|
||||
def {fname}({args}) do
|
||||
{final}
|
||||
end
|
||||
]]
|
||||
|
||||
local def = s(
|
||||
"def",
|
||||
fmt(def_template, {
|
||||
fname = i(1, "fname"),
|
||||
args = i(2),
|
||||
final = i(3),
|
||||
}, { priority = 1001 })
|
||||
)
|
||||
|
||||
return {
|
||||
def,
|
||||
}
|
138
modules/programs/nvim/plugins/snippets/heex.lua
Normal file
138
modules/programs/nvim/plugins/snippets/heex.lua
Normal file
|
@ -0,0 +1,138 @@
|
|||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
local k = require("luasnip.nodes.key_indexer").new_key
|
||||
|
||||
local pe = s(
|
||||
"pe",
|
||||
fmt("<%= {final} %>", {
|
||||
final = i(1),
|
||||
}, { priority = 1001 })
|
||||
)
|
||||
|
||||
local ln = s(
|
||||
"ln",
|
||||
fmt(
|
||||
[[
|
||||
<.link navigate={{~p"{path}"}}">{final}</.link>
|
||||
]],
|
||||
{ path = i(1, "/"), final = i(2) },
|
||||
{ priority = 1001 }
|
||||
)
|
||||
)
|
||||
|
||||
local lp = s(
|
||||
"lp",
|
||||
fmt(
|
||||
[[
|
||||
<.link patch={{~p"{path}"}}">{final}</.link>
|
||||
]],
|
||||
{ path = i(1, "/"), final = i(2) },
|
||||
{ priority = 1001 }
|
||||
)
|
||||
)
|
||||
|
||||
local if_ = s(
|
||||
"if",
|
||||
fmt("<%= if {condition} do %>{final}<% end %>", { condition = i(1, "condition"), final = i(2) }, { priority = 1001 })
|
||||
)
|
||||
|
||||
local ife = s(
|
||||
"ife",
|
||||
fmt(
|
||||
[[
|
||||
<%= if {condition} do %>
|
||||
{when}
|
||||
<% else %>
|
||||
{final}
|
||||
<% end %>"
|
||||
]],
|
||||
{ condition = i(1, "condition"), when = i(2), final = i(3) },
|
||||
{ priority = 1001 }
|
||||
)
|
||||
)
|
||||
|
||||
local for_ = s(
|
||||
"for",
|
||||
fmt(
|
||||
[[
|
||||
<%= for {item} <- {list} do %>
|
||||
{final}
|
||||
<% end %>
|
||||
]],
|
||||
{ item = i(1, "item"), list = i(2, "items"), final = i(3) },
|
||||
{ priority = 1001 }
|
||||
)
|
||||
)
|
||||
|
||||
local lc =
|
||||
s("lc", fmt("<.live_component module={{{module}}} id={{{id}}} />", { module = i(1), id = i(2) }, { priority = 1001 }))
|
||||
|
||||
local slot = s(
|
||||
"slot",
|
||||
fmt("<:slot>{final}</:slot>", {
|
||||
final = i(1),
|
||||
}, { priority = 1001 })
|
||||
)
|
||||
|
||||
local socketp = s(
|
||||
"socketp",
|
||||
fmt(
|
||||
[[
|
||||
socket =
|
||||
socket
|
||||
|> {final}
|
||||
]],
|
||||
{ final = i(1) },
|
||||
{ priority = 1001 }
|
||||
)
|
||||
)
|
||||
|
||||
local fl = s(
|
||||
"fl",
|
||||
fmt(
|
||||
[[
|
||||
<{elem} :for={{{item} <- {list}}} class="{class}">
|
||||
{final}
|
||||
</{elem}>
|
||||
]],
|
||||
{ elem = i(1, "div"), item = i(2, "item"), list = i(3, "items"), class = i(4), final = i(5) },
|
||||
{ priority = 1001, repeat_duplicates = true }
|
||||
)
|
||||
)
|
||||
|
||||
return {
|
||||
pe,
|
||||
ln,
|
||||
lp,
|
||||
if_,
|
||||
ife,
|
||||
for_,
|
||||
lc,
|
||||
slot,
|
||||
socketp,
|
||||
fl,
|
||||
}
|
Loading…
Reference in a new issue