improve notes workflow and macOS shell setup

This commit is contained in:
Rasyidan Akbar F. 2026-09-03 15:38:56 +07:00
commit 55390ebcde
5 changed files with 83 additions and 21 deletions

View file

@ -52,16 +52,27 @@
XDG_CACHE_HOME = "$HOME/.cache";
};
users.users.${user} = {
home = lib.mkDefault "/Users/${user}";
# Use the macOS system Zsh as the login shell. Nushell remains available as `nu`.
shell = "/bin/zsh";
};
users.users.${user}.home = lib.mkDefault "/Users/${user}";
system = {
primaryUser = user;
stateVersion = 6;
# nix-darwin does not manage an existing primary user unless the user is in
# users.knownUsers. Manage only the login shell to avoid owning the account.
activationScripts.postActivation.text = lib.mkAfter ''
current_shell=$(
/usr/bin/dscl . -read ${lib.escapeShellArg "/Users/${user}"} UserShell 2>/dev/null \
| /usr/bin/awk '{ print $2 }' \
|| true
)
if [ "$current_shell" != "/bin/zsh" ]; then
echo "setting ${user}'s login shell to /bin/zsh..." >&2
/usr/bin/dscl . -create ${lib.escapeShellArg "/Users/${user}"} UserShell /bin/zsh
fi
'';
defaults = {
NSGlobalDomain = {
ApplePressAndHoldEnabled = false;

View file

@ -22,6 +22,7 @@
pyright
nodePackages.typescript-language-server
mdx-language-server
harper # Grammar checking for Markdown and text
rust-analyzer
gopls
clang-tools # provides clangd

View file

@ -13,6 +13,31 @@ local function last_line(value)
return output:match("([^\r\n]+)$")
end
local function first_matching_line(value, pattern)
for line in (value or ""):gmatch("[^\r\n]+") do
local candidate = vim.trim(line)
if candidate:match(pattern) then
return candidate
end
end
end
local function first_actionable_line(value)
for line in (value or ""):gmatch("[^\r\n]+") do
local candidate = vim.trim(line)
if candidate ~= "" and not candidate:match("^%$ ") and not candidate:match('^error: script ".-" exited') then
return candidate
end
end
end
local function command_error(result)
return first_matching_line(result.stdout, "^ERROR%s")
or first_actionable_line(result.stderr)
or first_actionable_line(result.stdout)
or "Notes command failed."
end
local function run(arguments, options)
options = options or {}
@ -39,8 +64,7 @@ local function run(arguments, options)
},
vim.schedule_wrap(function(result)
if result.code ~= 0 then
local message = last_line(result.stderr) or last_line(result.stdout) or "Notes command failed."
notify(message, vim.log.levels.ERROR)
notify(command_error(result), vim.log.levels.ERROR)
return
end

View file

@ -106,6 +106,31 @@ return {
lspconfig.mdx_analyzer.setup({
capabilities = capabilities,
})
-- Harper grammar checking for prose. Keep the profile quiet so it does
-- not enforce capitalization, spelling, sentence length, or house style.
lspconfig.harper_ls.setup({
capabilities = capabilities,
filetypes = { "markdown", "text" },
settings = {
["harper-ls"] = {
diagnosticSeverity = "hint",
linters = {
AvoidContractions = false,
AvoidCurses = false,
Cant = false,
CapitalizePersonalPronouns = false,
GoogleNames = false,
LongSentences = false,
OrthographicConsistency = false,
OxfordComma = false,
SentenceCapitalization = false,
SpellCheck = false,
UseTitleCase = false,
},
},
},
})
end,
},
}