2024-11-22 02:48:41 -05:00
|
|
|
self: {
|
2024-05-07 22:49:00 -04:00
|
|
|
config,
|
|
|
|
lib,
|
2024-12-16 23:44:33 -05:00
|
|
|
osConfig,
|
2024-08-05 16:40:32 -04:00
|
|
|
pkgs,
|
|
|
|
self,
|
2024-05-07 22:49:00 -04:00
|
|
|
...
|
|
|
|
}: let
|
2024-11-22 02:48:41 -05:00
|
|
|
inherit (self.inputs) vimplugin-easytables-src;
|
|
|
|
inherit (self.lib.${pkgs.system}) buildPlugin;
|
|
|
|
|
2024-12-22 00:04:13 -05:00
|
|
|
inherit (lib) concatStringsSep mkIf;
|
2024-05-07 22:49:00 -04:00
|
|
|
|
2024-11-22 02:48:41 -05:00
|
|
|
cfg = config.programs.neovim;
|
2024-12-22 03:12:45 -05:00
|
|
|
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
2024-12-16 23:44:33 -05:00
|
|
|
isServer = osConfig.roles.server.sshd.enable or false;
|
|
|
|
|
|
|
|
githubCSS = pkgs.fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/OzakIOne/markdown-github-dark/5bd0bcf3ad20cf9f58591f97a597fd68fc699f8e/style.css";
|
|
|
|
hash = "sha256-deQvQOOyK6iP7kjVrgEdFTyOP80RWXMrETs6gi7DTmo=";
|
|
|
|
};
|
2024-11-22 02:48:41 -05:00
|
|
|
in {
|
2024-12-21 23:34:10 -05:00
|
|
|
config = mkIf cfg.enable {
|
2024-05-07 22:49:00 -04:00
|
|
|
programs = {
|
|
|
|
neovim = {
|
2024-06-01 17:41:48 -04:00
|
|
|
extraLuaConfig =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-06-01 17:41:48 -04:00
|
|
|
''
|
2024-12-22 03:12:45 -05:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
|
|
pattern = { 'markdown', 'tex' },
|
|
|
|
|
|
|
|
callback = function()
|
|
|
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
|
|
|
|
|
|
|
if (devShells['markdown'] == nil) then
|
|
|
|
devShells['markdown'] = 1;
|
|
|
|
|
2024-12-22 12:53:27 -05:00
|
|
|
require('nix-develop').nix_develop({'${flakeEnv}#markdown'}, function()
|
2024-12-22 12:42:29 -05:00
|
|
|
vim.cmd[[LspStart]];
|
2024-12-22 12:53:27 -05:00
|
|
|
end);
|
2024-12-22 03:12:45 -05:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
});
|
|
|
|
|
2024-06-01 17:41:48 -04:00
|
|
|
local lsp = require('lspconfig');
|
2024-05-11 20:10:45 -04:00
|
|
|
|
2024-07-28 02:54:34 -04:00
|
|
|
lsp.texlab.setup({
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
2024-12-22 03:12:45 -05:00
|
|
|
autostart = false,
|
2024-07-28 02:54:34 -04:00
|
|
|
|
2024-06-02 00:04:59 -04:00
|
|
|
settings = {
|
|
|
|
texlab = {
|
|
|
|
formatterLineLength = 100,
|
|
|
|
latexFormatter = 'latexindent',
|
|
|
|
latexindent = {
|
|
|
|
modifyLineBreaks = false,
|
|
|
|
["local"] = '.indentconfig.yaml';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-07-28 02:54:34 -04:00
|
|
|
});
|
2024-06-01 17:41:48 -04:00
|
|
|
'';
|
|
|
|
|
|
|
|
plugins = [
|
2024-05-07 22:49:00 -04:00
|
|
|
{
|
|
|
|
plugin = buildPlugin "easytables-nvim" vimplugin-easytables-src;
|
|
|
|
type = "lua";
|
|
|
|
config =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-05-07 22:49:00 -04:00
|
|
|
''
|
|
|
|
require('easytables').setup();
|
|
|
|
'';
|
|
|
|
}
|
2024-06-01 17:41:48 -04:00
|
|
|
|
|
|
|
{
|
2024-08-31 19:16:06 -04:00
|
|
|
plugin = pkgs.vimPlugins.knap;
|
2024-06-01 17:41:48 -04:00
|
|
|
type = "lua";
|
2024-12-16 23:44:33 -05:00
|
|
|
config = let
|
|
|
|
mdToPDF = "pandoc --css ${githubCSS} %docroot% -o /tmp/%outputfile%";
|
|
|
|
mdToPDFViewer = "sioyek /tmp/%outputfile%";
|
|
|
|
|
|
|
|
mdToHTML = "pandoc --standalone --embed-resource --highlight-style=breezedark --css ${githubCSS} %docroot% -o /tmp/%outputfile%";
|
|
|
|
mdToHTMLViewer =
|
|
|
|
if isServer
|
|
|
|
then
|
|
|
|
concatStringsSep " " [
|
|
|
|
"${pkgs.nodePackages.live-server}/bin/live-server"
|
|
|
|
"--host=0.0.0.0"
|
|
|
|
"--port=6565"
|
|
|
|
"--quiet"
|
|
|
|
"--no-browser"
|
|
|
|
"--watch=%outputfile%"
|
|
|
|
"--entry-file=%outputfile%"
|
|
|
|
"--wait=800"
|
|
|
|
"/tmp"
|
|
|
|
]
|
|
|
|
else "firefox -new-window /tmp/%outputfile%";
|
|
|
|
in
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-06-01 17:41:48 -04:00
|
|
|
''
|
2024-06-08 21:30:44 -04:00
|
|
|
vim.g.knap_settings = {
|
2024-06-01 17:41:48 -04:00
|
|
|
-- HTML
|
2024-06-08 21:30:44 -04:00
|
|
|
htmloutputext = 'html',
|
|
|
|
htmltohtml = 'none',
|
2024-06-01 17:41:48 -04:00
|
|
|
htmltohtmlviewerlaunch = "",
|
2024-06-08 21:30:44 -04:00
|
|
|
htmltohtmlviewerrefresh = 'none',
|
2024-06-01 17:41:48 -04:00
|
|
|
|
|
|
|
-- Markdown
|
2024-06-08 21:30:44 -04:00
|
|
|
mdoutputext = 'html',
|
|
|
|
markdownoutputext = 'html',
|
|
|
|
|
|
|
|
-- Markdown to PDF
|
2024-12-16 23:44:33 -05:00
|
|
|
mdtopdf = '${mdToPDF}',
|
|
|
|
markdowntopdf = '${mdToPDF}',
|
|
|
|
mdtopdfviewerlaunch = '${mdToPDFViewer}',
|
|
|
|
markdowntopdfviewerlaunch = '${mdToPDFViewer}',
|
2024-06-01 17:41:48 -04:00
|
|
|
mdtopdfviewerrefresh = 'none',
|
2024-12-16 23:44:33 -05:00
|
|
|
markdowntopdfviewerrefresh = 'none',
|
2024-06-08 21:30:44 -04:00
|
|
|
|
|
|
|
-- Markdown to HTML
|
2024-12-16 23:44:33 -05:00
|
|
|
mdtohtml = '${mdToHTML}',
|
|
|
|
markdowntohtml = '${mdToHTML}',
|
|
|
|
mdtohtmlviewerlaunch = '${mdToHTMLViewer}',
|
|
|
|
markdowntohtmlviewerlaunch = '${mdToHTMLViewer}',
|
2024-06-01 17:41:48 -04:00
|
|
|
mdtohtmlviewerrefresh = 'none',
|
|
|
|
markdowntohtmlviewerrefresh = 'none',
|
|
|
|
|
|
|
|
-- LaTeX
|
|
|
|
-- TODO: stop from polluting workspace
|
|
|
|
};
|
|
|
|
|
2024-12-16 23:44:33 -05:00
|
|
|
vim.api.nvim_create_autocmd('BufUnload', {
|
|
|
|
pattern = '*',
|
|
|
|
callback = function()
|
2024-12-17 18:15:10 -05:00
|
|
|
os.execute("killall -qr live-server");
|
2024-12-16 23:44:33 -05:00
|
|
|
end,
|
|
|
|
});
|
|
|
|
|
2024-06-01 17:41:48 -04:00
|
|
|
-- F4 processes the document once, and refreshes the view
|
2024-06-08 21:30:44 -04:00
|
|
|
vim.keymap.set({ 'n', 'v', 'i' }, '<F4>', function()
|
2024-06-01 17:41:48 -04:00
|
|
|
require('knap').process_once();
|
|
|
|
end);
|
|
|
|
|
|
|
|
-- F5 closes the viewer application, and
|
|
|
|
-- allows settings to be reset
|
2024-06-08 21:30:44 -04:00
|
|
|
vim.keymap.set({ 'n', 'v', 'i' }, '<F5>', function()
|
2024-06-01 17:41:48 -04:00
|
|
|
require('knap').close_viewer();
|
|
|
|
end);
|
|
|
|
|
|
|
|
-- F6 toggles the auto-processing on and off
|
2024-06-08 21:30:44 -04:00
|
|
|
vim.keymap.set({ 'n', 'v', 'i' }, '<F6>', function()
|
2024-06-01 17:41:48 -04:00
|
|
|
require('knap').toggle_autopreviewing();
|
|
|
|
end);
|
|
|
|
|
|
|
|
-- F7 invokes a SyncTeX forward search, or similar,
|
|
|
|
-- where appropriate
|
2024-06-08 21:30:44 -04:00
|
|
|
vim.keymap.set({ 'n', 'v', 'i' }, '<F7>', function()
|
2024-06-01 17:41:48 -04:00
|
|
|
require('knap').forward_jump();
|
|
|
|
end);
|
|
|
|
'';
|
|
|
|
}
|
2024-05-07 22:49:00 -04:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-11-22 02:48:41 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
# For accurate stack trace
|
2024-12-21 23:34:10 -05:00
|
|
|
_file = ./default.nix;
|
2024-11-22 02:48:41 -05:00
|
|
|
}
|