Files
dev/configs/nixos/modules/shell/nvim/config.lua

62 lines
1.8 KiB
Lua

-- Imperative configuration that has no typed nixvim option: the colorscheme call and autocmds.
-- gbprod/nord.nvim.
require("nord").setup({
transparent = true,
})
vim.cmd.colorscheme("nord")
-- Keep floating windows distinct from the current line highlight.
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#2e3440" })
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "#88c0d0", bg = "#2e3440" })
local open_floating_preview = vim.lsp.util.open_floating_preview
vim.lsp.util.open_floating_preview = function(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or "rounded"
return open_floating_preview(contents, syntax, opts, ...)
end
-- Format Rust buffers before writing them.
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.rs",
callback = function(args)
vim.lsp.buf.format({
bufnr = args.buf,
timeout_ms = 2000,
filter = function(client)
return client.name == "rust_analyzer"
end,
})
end,
})
-- Conceal markdown syntax in markdown buffers.
-- conceallevel is window-local, so it is set with opt_local when the filetype
-- is applied to the buffer's window.
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.opt_local.conceallevel = 2
end,
})
-- Soft-wrap prose buffers without inserting line breaks.
vim.api.nvim_create_autocmd("FileType", {
pattern = { "gitcommit", "markdown", "text" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.linebreak = true
vim.opt_local.breakindent = true
end,
})
-- Turn line blame off again once the Neogit status buffer is closed.
vim.api.nvim_create_autocmd("BufUnload", {
callback = function(args)
if vim.bo[args.buf].filetype == "NeogitStatus" then
require("gitsigns").toggle_current_line_blame(false)
end
end,
})