252 lines
8.1 KiB
Lua
252 lines
8.1 KiB
Lua
require("lz.n").load({
|
|
{
|
|
"typst-preview.nvim",
|
|
ft = "typst",
|
|
after = function()
|
|
-- Setup typst-preview
|
|
require("typst-preview").setup({
|
|
-- Optionally configure things here
|
|
dependencies_bin = require("nix-info").settings.typstPreviewDependencies,
|
|
})
|
|
|
|
vim.keymap.set("n", "<leader>tp", "<cmd>TypstPreviewToggle<cr>", { desc = "[T]ypst [P]review Toggle" })
|
|
end,
|
|
},
|
|
{
|
|
"lazydev.nvim",
|
|
cmd = "LazyDev",
|
|
ft = "lua",
|
|
after = function()
|
|
require("lazydev").setup({
|
|
library = {
|
|
{ words = { "nix%-info", "settings" }, path = "nix-info" },
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
{
|
|
"nvim-lspconfig",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
before = function()
|
|
require("lz.n").trigger_load("lazydev.nvim")
|
|
end,
|
|
after = function()
|
|
local telescope_plugins = {
|
|
"project.nvim",
|
|
"telescope.nvim",
|
|
"telescope-fzf-native.nvim",
|
|
"telescope-ui-select.nvim",
|
|
}
|
|
|
|
local telescope_picker = function(picker)
|
|
return function()
|
|
require("lz.n").trigger_load(telescope_plugins)
|
|
require("telescope.builtin")[picker]()
|
|
end
|
|
end
|
|
|
|
local lsp_float = { border = "single" }
|
|
|
|
local navic_excluded_filetypes = {
|
|
[""] = true,
|
|
help = true,
|
|
minifiles = true,
|
|
TelescopePrompt = true,
|
|
Trouble = true,
|
|
}
|
|
|
|
local function navic_enabled(bufnr)
|
|
return vim.bo[bufnr].buftype == "" and not navic_excluded_filetypes[vim.bo[bufnr].filetype]
|
|
end
|
|
|
|
_G.lux_navic_location = function()
|
|
local ok, navic = pcall(require, "nvim-navic")
|
|
if not ok or not navic.is_available() then
|
|
return ""
|
|
end
|
|
|
|
return navic.get_location()
|
|
end
|
|
|
|
local function update_winbar(winid, bufnr)
|
|
if not vim.api.nvim_win_is_valid(winid) then
|
|
return
|
|
end
|
|
|
|
local is_float = vim.api.nvim_win_get_config(winid).relative ~= ""
|
|
local winbar = ""
|
|
if not is_float and vim.b[bufnr].lux_navic_attached and navic_enabled(bufnr) then
|
|
winbar = "%{%v:lua.lux_navic_location()%}"
|
|
end
|
|
|
|
vim.api.nvim_set_option_value("winbar", winbar, { win = winid })
|
|
end
|
|
|
|
local function update_winbars_for_buffer(bufnr)
|
|
for _, winid in ipairs(vim.fn.win_findbuf(bufnr)) do
|
|
update_winbar(winid, bufnr)
|
|
end
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "WinEnter" }, {
|
|
group = vim.api.nvim_create_augroup("lux-navic-winbar", { clear = true }),
|
|
callback = function(args)
|
|
update_winbar(vim.api.nvim_get_current_win(), args.buf)
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("lux-lsp-attach", { clear = true }),
|
|
callback = function(args)
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
local bufnr = args.buf
|
|
|
|
local map = function(keys, func, desc, mode)
|
|
mode = mode or "n"
|
|
vim.keymap.set(mode, keys, func, { buffer = bufnr, desc = "LSP: " .. desc })
|
|
end
|
|
|
|
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
|
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
|
|
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
|
map("K", function()
|
|
vim.lsp.buf.hover(lsp_float)
|
|
end, "Hover Documentation")
|
|
map("<C-s>", function()
|
|
vim.lsp.buf.signature_help(lsp_float)
|
|
end, "Signature Help", { "i", "s" })
|
|
|
|
map("gd", telescope_picker("lsp_definitions"), "[G]oto [D]efinition")
|
|
map("gr", telescope_picker("lsp_references"), "[G]oto [R]eferences")
|
|
map("gI", telescope_picker("lsp_implementations"), "[G]oto [I]mplementation")
|
|
map("<leader>D", telescope_picker("lsp_type_definitions"), "Type [D]efinition")
|
|
map("<leader>ds", telescope_picker("lsp_document_symbols"), "[D]ocument [S]ymbols")
|
|
map("<leader>ws", telescope_picker("lsp_dynamic_workspace_symbols"), "[W]orkspace [S]ymbols")
|
|
|
|
if client and client:supports_method("textDocument/documentSymbol", bufnr) and navic_enabled(bufnr) then
|
|
require("lz.n").trigger_load("nvim-navic")
|
|
local ok, navic = pcall(require, "nvim-navic")
|
|
if ok then
|
|
navic.attach(client, bufnr)
|
|
vim.b[bufnr].lux_navic_attached = true
|
|
update_winbars_for_buffer(bufnr)
|
|
end
|
|
end
|
|
|
|
if client and client:supports_method("textDocument/documentHighlight", bufnr) then
|
|
local highlight_augroup = vim.api.nvim_create_augroup("lux-lsp-highlight", { clear = false })
|
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
buffer = bufnr,
|
|
group = highlight_augroup,
|
|
callback = vim.lsp.buf.document_highlight,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
|
buffer = bufnr,
|
|
group = highlight_augroup,
|
|
callback = vim.lsp.buf.clear_references,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspDetach", {
|
|
group = vim.api.nvim_create_augroup("lux-lsp-detach", { clear = true }),
|
|
callback = function(event)
|
|
vim.lsp.buf.clear_references()
|
|
vim.api.nvim_clear_autocmds({ group = "lux-lsp-highlight", buffer = event.buf })
|
|
end,
|
|
})
|
|
end
|
|
|
|
if client and client:supports_method("textDocument/inlayHint", bufnr) then
|
|
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
|
map("<leader>th", function()
|
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }))
|
|
end, "[T]oggle Inlay [H]ints")
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.diagnostic.config({
|
|
severity_sort = true,
|
|
underline = true,
|
|
signs = {
|
|
text = {
|
|
[vim.diagnostic.severity.ERROR] = " ",
|
|
[vim.diagnostic.severity.WARN] = " ",
|
|
[vim.diagnostic.severity.INFO] = " ",
|
|
[vim.diagnostic.severity.HINT] = " ",
|
|
},
|
|
},
|
|
virtual_text = false,
|
|
virtual_lines = {
|
|
current_line = true,
|
|
},
|
|
float = {
|
|
border = "single",
|
|
source = "if_many",
|
|
},
|
|
})
|
|
|
|
vim.lsp.config("lua_ls", {
|
|
settings = {
|
|
Lua = {
|
|
runtime = { version = "LuaJIT" },
|
|
signatureHelp = { enabled = true },
|
|
diagnostics = { globals = { "vim" } },
|
|
telemetry = { enabled = false },
|
|
completion = { callSnippet = "Replace" },
|
|
},
|
|
},
|
|
})
|
|
vim.lsp.enable("lua_ls")
|
|
|
|
local settings = require("nix-info").settings
|
|
|
|
vim.lsp.config("nixd", {
|
|
settings = {
|
|
nixd = {
|
|
nixpkgs = { expr = settings.nixdExtras.nixpkgs },
|
|
options = {
|
|
nixos = { expr = settings.nixdExtras.nixos_options },
|
|
["home-manager"] = { expr = settings.nixdExtras.home_manager_options },
|
|
},
|
|
formatting = { command = { "nixfmt" } },
|
|
},
|
|
},
|
|
})
|
|
vim.lsp.enable("nixd")
|
|
|
|
vim.lsp.enable("dafny")
|
|
vim.lsp.enable("ts_ls")
|
|
vim.lsp.enable("rust_analyzer")
|
|
vim.lsp.enable("ty")
|
|
vim.lsp.enable("ruff")
|
|
vim.lsp.enable("astro")
|
|
|
|
vim.lsp.config("tinymist", {
|
|
settings = {
|
|
tinymist = {
|
|
formatterMode = "typstyle",
|
|
},
|
|
},
|
|
})
|
|
vim.lsp.enable("tinymist")
|
|
end,
|
|
},
|
|
{
|
|
"trouble.nvim",
|
|
cmd = "Trouble",
|
|
keys = {
|
|
{ "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)" },
|
|
{ "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)" },
|
|
},
|
|
after = function()
|
|
require("trouble").setup({
|
|
focus = true,
|
|
preview = {
|
|
border = "single",
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
})
|