feat: improve typst support

This commit is contained in:
Youwen Wu 2024-10-08 00:06:40 -07:00
parent ad551a46f8
commit 6cdb83a772
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
3 changed files with 52 additions and 3 deletions

View file

@ -13,7 +13,7 @@
nushell.enable = true;
svelte.enable = true;
tailwindcss.enable = true;
typst-lsp.enable = true;
tinymist.enable = true;
marksman.enable = true;
};
};

View file

@ -18,7 +18,57 @@
enable = true;
settings.delay = 1000;
};
nvim-autopairs.enable = true;
nvim-autopairs = {
enable = true;
luaConfig.post = ''
local npairs = require('nvim-autopairs')
local Rule = require('nvim-autopairs.rule')
local cond = require('nvim-autopairs.conds')
npairs.add_rules({
Rule("$", "$",{"tex", "latex", "typst"})
-- don't add a pair if the next character is %
:with_pair(cond.not_after_regex("%%"))
-- don't add a pair if the previous character is xxx
:with_pair(cond.not_before_regex("xxx", 3))
-- don't move right when repeat character
:with_move(cond.none())
-- don't delete if the next character is xx
:with_del(cond.not_after_regex("xx"))
-- disable adding a newline when you press <cr>
:with_cr(cond.none())
},
{
Rule("_", "_","typst")
-- don't add a pair if the previous character is xxx
:with_pair(cond.not_before_regex("[%w%.]", 3))
-- don't move right when repeat character
:with_move(cond.none())
-- don't delete if the next character is xx
:with_del(cond.not_after_regex("[%w%.]"))
},
{
Rule("*", "*","typst")
-- don't add a pair if the previous character is xxx
:with_pair(cond.not_before_regex("[%w%.]", 3))
-- don't move right when repeat character
:with_move(cond.none())
-- don't delete if the next character is xx
:with_del(cond.not_after_regex("[%w%.]"))
},
{
Rule("$$","$$","tex")
:with_pair(function(opts)
print(vim.inspect(opts))
if opts.line=="aa $$" then
-- don't add pair on that line
return false
end
end)
}
)
'';
};
yanky = {
enable = true;
enableTelescope = true;

View file

@ -1,6 +1,5 @@
{ inputs, pkgs, ... }:
{
plugins.typst-vim.enable = true;
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
name = "typst-preview.nvim";