bring back nix-darwin hosts compatability

This commit is contained in:
Yan Lin 2025-11-13 10:40:27 +01:00
parent 1b6a0430d2
commit 0bf4fb87c6
13 changed files with 579 additions and 31 deletions

View file

@ -262,12 +262,21 @@ in
action = ":lua open_file_with_system_app()<CR>";
options = { desc = "Open file with system default app"; };
}
] ++ (if pkgs.stdenv.isDarwin then [
{
mode = "n";
key = "<leader>f";
action = ":lua show_file_in_file_manager()<CR>";
options = { desc = "Show current file in Finder"; };
}
] else [
{
mode = "n";
key = "<leader>f";
action = ":!thunar %:h &<CR><CR>";
options = { desc = "Open current file directory in file manager"; };
}
]) ++ [
# Markdown rendering
{
@ -307,11 +316,20 @@ in
})
-- Dictionary completion setup
require("cmp_dictionary").setup({
paths = { "${pkgs.scowl}/share/dict/wamerican.txt" }, -- Nix-provided dictionary
exact_length = 2, -- Minimum length before completion
first_case_insensitive = true, -- Case insensitive matching
})
${lib.optionalString pkgs.stdenv.isDarwin ''
require("cmp_dictionary").setup({
paths = { "/usr/share/dict/words" }, -- Standard dictionary path on macOS
exact_length = 2, -- Minimum length before completion
first_case_insensitive = true, -- Case insensitive matching
})
''}
${lib.optionalString (!pkgs.stdenv.isDarwin) ''
require("cmp_dictionary").setup({
paths = { "${pkgs.scowl}/share/dict/wamerican.txt" }, -- Nix-provided dictionary on NixOS
exact_length = 2, -- Minimum length before completion
first_case_insensitive = true, -- Case insensitive matching
})
''}
-- Jupytext setup for Jupyter notebook viewing
require("jupytext").setup({
@ -352,18 +370,21 @@ in
}
-- OSC-52 clipboard integration (matches tmux setup, works with Ghostty)
-- This enables clipboard functionality across SSH and tmux
vim.g.clipboard = {
name = 'OSC 52',
copy = {
['+'] = require('vim.ui.clipboard.osc52').copy('+'),
['*'] = require('vim.ui.clipboard.osc52').copy('*'),
},
paste = {
['+'] = require('vim.ui.clipboard.osc52').paste('+'),
['*'] = require('vim.ui.clipboard.osc52').paste('*'),
},
}
-- This enables clipboard functionality across SSH, tmux, and multi-platform
-- Only enabled on Linux; macOS uses native clipboard with "unnamedplus"
${lib.optionalString (!pkgs.stdenv.isDarwin) ''
vim.g.clipboard = {
name = 'OSC 52',
copy = {
['+'] = require('vim.ui.clipboard.osc52').copy('+'),
['*'] = require('vim.ui.clipboard.osc52').copy('*'),
},
paste = {
['+'] = require('vim.ui.clipboard.osc52').paste('+'),
['*'] = require('vim.ui.clipboard.osc52').paste('*'),
},
}
''}
-- Close all buffers except current (preserving NvimTree and other special buffers)
function close_other_buffers()
@ -388,13 +409,28 @@ in
function open_file_with_system_app()
local filepath = vim.fn.expand('%:p')
if filepath ~= "" then
-- Use jobstart for async execution (detach = true prevents blocking)
vim.fn.jobstart({'xdg-open', filepath}, {detach = true})
local escaped_path = vim.fn.shellescape(filepath)
${if pkgs.stdenv.isDarwin then
"vim.fn.system('open ' .. escaped_path)"
else
"vim.fn.system('xdg-open ' .. escaped_path)"}
else
print("No file to open")
end
end
${lib.optionalString pkgs.stdenv.isDarwin ''
function show_file_in_file_manager()
local filepath = vim.fn.expand('%:p')
if filepath ~= "" then
local escaped_path = vim.fn.shellescape(filepath)
vim.fn.system('open -R ' .. escaped_path)
else
print("No file to show")
end
end
''}
-- Render-markdown setup (off by default, toggle with <space>+m)
require("render-markdown").setup({
enabled = false, -- Off by default, use <space>+m to toggle