ported the lua, port is complete, I think.

This commit is contained in:
Gabe Venberg 2026-03-13 15:47:42 +01:00
parent 7c9d33f7bb
commit 24a7f2cda3
26 changed files with 810 additions and 868 deletions

7
lua/lsp/C.lua Normal file
View file

@ -0,0 +1,7 @@
return {
{
"clangd",
for_cat = "C",
lsp = {},
},
}

7
lua/lsp/bash.lua Normal file
View file

@ -0,0 +1,7 @@
return {
{
"bashls",
for_cat = "bash",
lsp = {},
},
}

92
lua/lsp/init.lua Normal file
View file

@ -0,0 +1,92 @@
local lspEnabled = nixInfo("settings", "cat", "lsp")
if lspEnabled then
local Snacks = require("snacks")
vim.keymap.set("n", "<leader>lI", Snacks.picker.lsp_implementations, { desc = "Goto [I]mplementation" })
vim.keymap.set("n", "<leader>lR", Snacks.picker.lsp_references, { desc = "Goto [R]eferences" })
vim.keymap.set("n", "<leader>li", Snacks.picker.diagnostics, { desc = "D[i]agnostics" })
vim.keymap.set("n", "<leader>ls", Snacks.picker.lsp_symbols, { desc = "Document [S]ymbols" })
vim.keymap.set("n", "<leader>lws", Snacks.picker.lsp_workspace_symbols, { desc = "[W]orkspace [S]ymbols" })
vim.keymap.set("n", "<leader>lD", vim.lsp.buf.declaration, { desc = "Goto [D]eclaration" })
vim.keymap.set("n", "<leader>lt", vim.lsp.buf.type_definition, { desc = "Type [D]efinition" })
vim.keymap.set({ "n", "v", }, "<leader>la", vim.lsp.buf.code_action, { desc = "[C]ode Action" })
vim.keymap.set("n", "<leader>ld", vim.lsp.buf.definition, { desc = "Goto [D]efinition" })
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "Format buffer" })
vim.keymap.set("n", "<leader>lh", vim.lsp.buf.hover, { desc = "Hover Documentation" })
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { desc = "[R]ename" })
vim.keymap.set("n", "<leader>ls", vim.lsp.buf.signature_help, { desc = "Signature Documentation" })
vim.keymap.set("n", "<leader>lwa", vim.lsp.buf.add_workspace_folder, { desc = "[W]orkspace [A]dd Folder" })
vim.keymap.set("n", "<leader>lwl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end,
{ desc = "[W]orkspace [L]ist Folders" })
vim.keymap.set("n", "<leader>lwr", vim.lsp.buf.remove_workspace_folder, { desc = "[W]orkspace [R]emove Folder" })
-- setup lsp progress notifications
local progress = vim.defaulttable()
vim.api.nvim_create_autocmd("LspProgress", {
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
local value = ev.data.params
.value --[[@as {percentage?: number, title?: string, message?: string, kind: "begin" | "report" | "end"}]]
if not client or type(value) ~= "table" then
return
end
local p = progress[client.id]
for i = 1, #p + 1 do
if i == #p + 1 or p[i].token == ev.data.params.token then
p[i] = {
token = ev.data.params.token,
msg = ("[%3d%%] %s%s"):format(
value.kind == "end" and 100 or value.percentage or 100,
value.title or "",
value.message and (" **%s**"):format(value.message) or ""
),
done = value.kind == "end",
}
break
end
end
local msg = {} ---@type string[]
progress[client.id] = vim.tbl_filter(function(v)
return table.insert(msg, v.msg) or not v.done
end, p)
local spinner = { "", "", "", "", "", "", "", "", "", "" }
vim.notify(table.concat(msg, "\n"), "info", {
id = "lsp_progress",
title = client.name,
opts = function(notif)
notif.icon = #progress[client.id] == 0 and ""
or spinner[math.floor(vim.uv.hrtime() / (1e6 * 80)) % #spinner + 1]
end,
})
end,
})
end
require('lze').load {
{
"nvim-lspconfig",
for_cat = "lsp",
on_require = { "lspconfig" },
-- rustaceanvim and zk-nvim dont require("lspconfig")
ft = { "markdown", "rust" },
-- NOTE: define a function for lsp,
-- and it will run for all specs with type(plugin.lsp) == table
-- when their filetype trigger loads them
lsp = function(plugin)
vim.lsp.config(plugin.name, plugin.lsp or {})
vim.lsp.enable(plugin.name)
end,
},
{ import = "lsp.lua" },
{ import = "lsp.python" },
{ import = "lsp.C" },
{ import = "lsp.nix" },
{ import = "lsp.typst" },
{ import = "lsp.bash" },
{ import = "lsp.zk" },
{ import = "lsp.rust" },
}

45
lua/lsp/lua.lua Normal file
View file

@ -0,0 +1,45 @@
return {
{
-- lazydev makes your lsp way better in your config without needing extra lsp configuration.
"lazydev.nvim",
for_cat = "lua",
auto_enable = true,
cmd = { "LazyDev" },
ft = "lua",
after = function(_)
require('lazydev').setup({
library = {
{ words = { "nixInfo%.lze" }, path = nixInfo("lze", "plugins", "start", "lze") .. '/lua', },
{ words = { "nixInfo%.lze" }, path = nixInfo("lzextras", "plugins", "start", "lzextras") .. '/lua' },
},
})
end,
},
{
-- name of the lsp
"lua_ls",
for_cat = "lua",
-- provide a table containing filetypes,
-- and then whatever your functions defined in the function type specs expect.
-- in our case, it just expects the normal lspconfig setup options,
-- but with a default on_attach and capabilities
lsp = {
-- if you provide the filetypes it doesn't ask lspconfig for the filetypes
filetypes = { 'lua' },
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
formatters = {
ignoreComments = true,
},
signatureHelp = { enabled = true },
diagnostics = {
globals = { "nixInfo", "vim", },
disable = { 'missing-fields' },
},
telemetry = { enabled = false },
},
},
},
},
}

27
lua/lsp/nix.lua Normal file
View file

@ -0,0 +1,27 @@
return {
{
"nixd",
enabled = nixInfo.isNix, -- mason doesn't have nixd
for_cat = "nix",
lsp = {
filetypes = { "nix" },
settings = {
nixd = {
nixpkgs = {
expr = [[import <nixpkgs> {}]],
},
options = {
},
formatting = {
command = { "nixfmt" }
},
diagnostic = {
suppress = {
"sema-escaping-with"
}
}
}
},
},
},
}

12
lua/lsp/python.lua Normal file
View file

@ -0,0 +1,12 @@
return {
{
"ty",
for_cat = "python",
lsp = {},
},
{
"ruff",
for_cat = "python",
lsp = {},
},
}

6
lua/lsp/rust.lua Normal file
View file

@ -0,0 +1,6 @@
return {
{
"rustaceanvim",
for_cat = "rust",
},
}

13
lua/lsp/typst.lua Normal file
View file

@ -0,0 +1,13 @@
return {
{
"tinymist",
for_cat = "typst",
lsp = {
filetypes = { "typst" },
settings = {
formatterMode = "typstyle",
},
},
},
}

23
lua/lsp/zk.lua Normal file
View file

@ -0,0 +1,23 @@
return {
{
"zk-nvim",
for_cat = "zk",
ft = "markdown",
after = function()
require("zk").setup({ picker = "snacks_picker" })
vim.api.nvim_set_keymap("n", "<leader>zb", "<Cmd>ZkBackLinks<CR>", { desc = "Show [B]acklinkgs" })
vim.api.nvim_set_keymap("n", "<leader>zl", "<Cmd>ZkLinks<CR>", { desc = "Show [L]inks" })
vim.api.nvim_set_keymap("n", "<leader>zi", ":'<,'>ZkInsertLink<CR>", { desc = "[I]nsert link" })
vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>",
{ desc = "[N]ew note" })
vim.api.nvim_set_keymap("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", { desc = "[O]pen notes" })
vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", { desc = "Search [T]ags" })
vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", { desc = "[F]ind note from selection" })
vim.api.nvim_set_keymap("v", "<leader>zn", ":'<,'>ZkNewFromTitleSelection<CR>", {
desc =
"[N]ew note from selection"
})
end
},
}