From 393cdae531a3c5067bd32643b71ebd9b9969e476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofus=20Albert=20H=C3=B8gsbro=20Rose?= Date: Sun, 2 Mar 2025 18:35:02 +0100 Subject: [PATCH] feat: added typst LSP and support Now requires use of a firefox profile, the skeleton of which is included in the repo. --- README.md | 26 +++++---- firefox-profiles/.gitignore | 3 + .../typst-preview/chrome/userChrome.css | 4 ++ firefox-profiles/typst-preview/user.js | 49 ++++++++++++++++ lazy-lock.json | 5 +- lsp/tinymist.lua | 9 +++ lua/lsp.lua | 1 + lua/plugins.lua | 1 + lua/plugins/langs/typst/typst-preview.lua | 57 +++++++++++++++++++ nvim.version | 2 +- 10 files changed, 144 insertions(+), 13 deletions(-) create mode 100644 firefox-profiles/.gitignore create mode 100644 firefox-profiles/typst-preview/chrome/userChrome.css create mode 100644 firefox-profiles/typst-preview/user.js create mode 100644 lsp/tinymist.lua create mode 100644 lua/plugins/langs/typst/typst-preview.lua diff --git a/README.md b/README.md index 0cb1f8b..40b180d 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,19 @@ sudo apt install xclip # OR wl-clipboard ## - FIRST, install rustup ## - https://www.rust-lang.org/ rustup component add rust-analyzer -cargo install --force bob-nvim -cargo install --force rscls -cargo install --force ripgrep -cargo install --force rust-script -cargo install --force tree-sitter-cli -cargo install --force fd-find -cargo install --force bat -cargo install --force git-delta -cargo install --force skim -cargo install --force stylua +cargo install --force --locked bob-nvim +cargo install --force --locked rscls +cargo install --force --locked ripgrep +cargo install --force --locked rust-script +cargo install --force --locked tree-sitter-cli +cargo install --force --locked fd-find +cargo install --force --locked bat +cargo install --force --locked git-delta +cargo install --force --locked skim +cargo install --force --locked stylua +cargo install --force --locked tinymist +cargo install --force --locked typstyle +cargo install --force --locked --features=ssl websocat # Python ## - FIRST, install uv @@ -52,6 +55,9 @@ cd $HOME/comps/neovim uv init --no-readme --python 3.12 remote-python cd remote-python uv add pynvim jupyter_client requests websocket-client plotly kaleido==0.2.1 + +# Firefox +## Create a profile typst-preview w/ user.js? ``` diff --git a/firefox-profiles/.gitignore b/firefox-profiles/.gitignore new file mode 100644 index 0000000..a26a335 --- /dev/null +++ b/firefox-profiles/.gitignore @@ -0,0 +1,3 @@ +typst-preview/* +!typst-preview/user.js +!typst-preview/chrome diff --git a/firefox-profiles/typst-preview/chrome/userChrome.css b/firefox-profiles/typst-preview/chrome/userChrome.css new file mode 100644 index 0000000..4763d3d --- /dev/null +++ b/firefox-profiles/typst-preview/chrome/userChrome.css @@ -0,0 +1,4 @@ +#tabbrowser-tabs { visibility: collapse !important; } +#TabsToolbar-customization-target { visibility: collapse !important; } +#navigator-toolbox {visibility: collapse !important;} +browser {margin-right: -14px; margin-bottom: -14px;} diff --git a/firefox-profiles/typst-preview/user.js b/firefox-profiles/typst-preview/user.js new file mode 100644 index 0000000..d38b355 --- /dev/null +++ b/firefox-profiles/typst-preview/user.js @@ -0,0 +1,49 @@ +user_pref("browser.shell.checkDefaultBrowser", false); +user_pref("browser.startup.page", 0); +user_pref("browser.startup.homepage", "about:blank"); +user_pref("browser.tabs.tabmanager.enabled", false); + +user_pref("geo.provider.ms-windows-location", false); // [WINDOWS] +user_pref("geo.provider.use_corelocation", false); // [MAC] +user_pref("geo.provider.use_gpsd", false); // [LINUX] +user_pref("geo.provider.use_geoclue", false); // [FF102+] [LINUX] + +user_pref("browser.newtabpage.enabled", false); +user_pref("extensions.enabledAddons", ""); +user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); + +user_pref("identity.fxaccounts.enabled", true); // Firefox Accounts & Sync [FF60+] [RESTART] +user_pref("extensions.pocket.enabled", false); // Pocket Account [FF46+] +user_pref("extensions.pocket.onSaveRecs", false); +user_pref("extensions.screenshots.disabled", true); // [FF55+] +user_pref("reader.parse-on-load.enabled", false); // Reader View +user_pref("browser.tabs.firefox-view", true); +user_pref("services.sync.prefs.sync.browser.firefox-view.feature-tour", false); + + +// Smooth Scrolling +user_pref("extensions.formautofill.addresses.enabled", false); +user_pref("extensions.formautofill.creditCards.enabled", false); +user_pref("extensions.formautofill.heuristics.enabled", false); + +user_pref("general.smoothScroll.msdPhysics.enabled", true); +user_pref("general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS", 250); +user_pref("general.smoothScroll.msdPhysics.motionBeginSpringConstant", 450); +user_pref("general.smoothScroll.msdPhysics.regularSpringConstant", 450); +user_pref("general.smoothScroll.msdPhysics.slowdownMinDeltaMS", 50); +user_pref("general.smoothScroll.msdPhysics.slowdownMinDeltaRatio;0", 4); +user_pref("general.smoothScroll.msdPhysics.slowdownSpringConstant", 5000); +user_pref("mousewheel.min_line_scroll_amount", 30); +user_pref("toolkit.scrollbox.horizontalScrollDistance", 4); +user_pref("toolkit.scrollbox.verticalScrollDistance", 5); +user_pref("general.smoothScroll.mouseWheel.durationMinMS", 250); +user_pref("apz.frame_delay.enabled", false); + +user_pref("browser.sessionstore.warnOnQuit", false); +user_pref("browser.warnOnQuit", false); + +user_pref("privacy.trackingprotection.enabled", true); +user_pref("layout.frame_rate.precise", true); +user_pref("webgl.force-enabled", true); +user_pref("layers.acceleration.force-enabled", true); +user_pref("layers.offmainthreadcomposition.enabled", true); diff --git a/lazy-lock.json b/lazy-lock.json index e9ad172..6cec650 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -7,7 +7,7 @@ "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "gitsigns.nvim": { "branch": "main", "commit": "9b36d497495436c135659902054ee637e0ba6021" }, "img-clip.nvim": { "branch": "main", "commit": "5ded6f468d633ccfb315905fe8901d6c95ae8f29" }, - "lazy.nvim": { "branch": "main", "commit": "f15a93907ddad3d9139aea465ae18336d87f5ce6" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lsp_lines.nvim": { "branch": "main", "commit": "a92c755f182b89ea91bd8a6a2227208026f27b4d" }, "mdmath.nvim": { "branch": "main", "commit": "699acb27fd34bfdf92a43ce0abdd17f0c7a948fe" }, "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, @@ -23,7 +23,8 @@ "projections.nvim": { "branch": "main", "commit": "889914169fa1f5c00fb8659653b5a8330fb223e6" }, "render-markdown.nvim": { "branch": "main", "commit": "17a77463f945c4b9e4f371c752efd90e3e1bf604" }, "snacks.nvim": { "branch": "main", "commit": "b773368f8aa6e84a68e979f0e335d23de71f405a" }, - "tiny-code-action.nvim": { "branch": "main", "commit": "34d8a0053a833dbc51b2eecc1170bd35aa18baa4" }, + "tiny-code-action.nvim": { "branch": "main", "commit": "cc2f6045e67e01355c49fea10568baba856e844a" }, + "typst-preview.nvim": { "branch": "master", "commit": "8c5dbd5175e39444185f48d16819d18a549c10b2" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "which-key.nvim": { "branch": "main", "commit": "0e76a87ac51772569aec678dc74baa8e2a86100c" } } diff --git a/lsp/tinymist.lua b/lsp/tinymist.lua new file mode 100644 index 0000000..8ff6c9b --- /dev/null +++ b/lsp/tinymist.lua @@ -0,0 +1,9 @@ +return { + cmd = { 'tinymist' }, + filetypes = { 'typst' }, + settings = { + formatterMode = 'typstyle', + exportPdf = 'onType', + semanticTokens = 'disable', + }, +} diff --git a/lua/lsp.lua b/lua/lsp.lua index ec89cd9..e073e1c 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -3,4 +3,5 @@ vim.lsp.enable({ 'basedpyright', 'rust_analyzer', 'lua-language-server', + 'tinymist', }) diff --git a/lua/plugins.lua b/lua/plugins.lua index b3e3684..8a9268c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -95,6 +95,7 @@ require('lazy').setup({ --require('plugins/langs/md_quarto/mkdnflow') --require('plugins/langs/md_quarto/easytables'), require('plugins/langs/md_quarto/render-markdown-nvim'), + require('plugins/langs/typst/typst-preview'), -- Lang: Python --require('plugins/langs/python/f-string-toggle'), diff --git a/lua/plugins/langs/typst/typst-preview.lua b/lua/plugins/langs/typst/typst-preview.lua new file mode 100644 index 0000000..1f9a261 --- /dev/null +++ b/lua/plugins/langs/typst/typst-preview.lua @@ -0,0 +1,57 @@ +return { + -- Fix tinymist Check + 'Parsifa1/typst-preview.nvim', + commit = '8c5dbd5175e39444185f48d16819d18a549c10b2', + --'chomosuke/typst-preview.nvim', + --commit = 'df393b47c5bc35abe4d60bb479afd0c15802fda8', + lazy = true, + + cmd = { + 'TypstPreviewUpdate', + 'TypstPreview', + 'TypstPreviewStop', + 'TypstPreviewToggle', + 'TypstPreviewFollowCursor', + 'TypstPreviewNoFollowCursor', + 'TypstPreviewFollowCursorToggle', + 'TypstPreviewSyncCursor', + }, + + keys = { + { + 'fp', + function() + vim.cmd('TypstPreview') + end, + desc = '[F]ile(typst) [P]review On', + ft = 'typst', + }, + { + 'fP', + function() + vim.cmd('TypstPreviewStop') + end, + desc = '[F]ile(typst) [P]review Off', + ft = 'typst', + }, + { + 'fs', + function() + vim.cmd('TypstPreviewSyncCursor') + end, + desc = '[F]ile(typst) [S]ync Cursor', + ft = 'typst', + }, + }, + + opts = { + debug = false, + open_cmd = 'firefox %s --no-remote --profile '.. vim.fn.stdpath('config') .. '/firefox-profiles/typst-preview --class typst-preview', + --open_cmd = 'chromium --temp-profile --disable-plugins --app=%s', + follow_cursor = true, + dependencies_bin = { + ['tinymist'] = vim.env.HOME .. '/.cargo/bin/tinymist', + ['websocat'] = vim.env.HOME .. '/.cargo/bin/websocat', + }, + }, +} diff --git a/nvim.version b/nvim.version index 4419732..492876a 100644 --- a/nvim.version +++ b/nvim.version @@ -1 +1 @@ -e4a58a7ca03457668492f8f41189ea2f23700172 \ No newline at end of file +85caaa70d44b7b18c633aa0b140de5f3f6d3eee7 \ No newline at end of file