Thomas 1 年之前
父节点
当前提交
56e6563f98
共有 5 个文件被更改,包括 72 次插入16 次删除
  1. 6 5
      init.lua
  2. 1 0
      lazy-lock.json
  3. 4 0
      lua/config/mappings.lua
  4. 13 8
      lua/plugins/mason.lua
  5. 48 3
      lua/plugins/typst.lua

+ 6 - 5
init.lua

@@ -12,13 +12,14 @@ local opt = vim.opt
 
 opt.relativenumber = true
 
-opt.undodir = os.getenv "HOME" .. "/.vim/undodir"
+opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
 
 -- Languages
-opt.spelllang = 'en_us,fr'
+opt.spelllang = "en_us,fr"
 opt.spell = true
 
 vim.cmd("autocmd BufRead,BufNewFile *.typ set filetype=typst")
+vim.cmd("xnoremap p pgvy")
 
 local symbols = { Error = "󰅙", Info = "󰋼", Hint = "󰌵", Warn = "" }
 
@@ -28,9 +29,9 @@ for name, icon in pairs(symbols) do
 end
 
 vim.diagnostic.config({
-  virtual_text = {
-    prefix = "●",
-  },
+	virtual_text = {
+		prefix = "●",
+	},
 })
 
 require("config.lazy")

+ 1 - 0
lazy-lock.json

@@ -43,6 +43,7 @@
   "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
   "transparent.nvim": { "branch": "main", "commit": "fd35a46f4b7c1b244249266bdcb2da3814f01724" },
   "trouble.nvim": { "branch": "main", "commit": "03c1fbf518bef683422a3be9643c3da190903488" },
+  "typst-preview.nvim": { "branch": "master", "commit": "15eaaffc0a2d8cd871f485f399d1d67ed3322a0b" },
   "typst.vim": { "branch": "main", "commit": "4d18ced62599ffe5b3c0e5e49566d5456121bc02" },
   "vim-lastplace": { "branch": "master", "commit": "e58cb0df716d3c88605ae49db5c4741db8b48aa9" },
   "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" },

+ 4 - 0
lua/config/mappings.lua

@@ -165,6 +165,7 @@ wk.add({
 		{ "<leader>tn", "<cmd>tabn<CR>", desc = "Go to next tab" }, --  go to next tab
 		{ "<leader>tp", "<cmd>tabp<CR>", desc = "Go to previous tab" }, --  go to previous tab
 		{ "<leader>tf", "<cmd>tabnew %<CR>", desc = "Open current buffer in new tab" }, --  move current buffer to new tab
+    { "<Esc>", "<cmd>noh<CR>", desc = "clears search highlights", noremap = true, silent = true },
 	},
 	{
 		mode = "v",
@@ -173,5 +174,8 @@ wk.add({
 
 		-- Comment
 		{ "<leader>/", "gc", desc = "comment toggle", remap = true },
+
+
+    { "<Esc>", "<cmd>noh<CR>", desc = "clears search highlights", noremap = true, silent = true },
 	},
 })

+ 13 - 8
lua/plugins/mason.lua

@@ -14,7 +14,7 @@ return {
 					"rust_analyzer",
 					"tsserver",
 					"typst_lsp",
-          "html",
+					"html",
 					"r_language_server", --[[ "vscode-html-language-server" ]]
 				},
 			})
@@ -23,17 +23,22 @@ return {
 	{
 		"neovim/nvim-lspconfig",
 		config = function()
-      local capabilities = require('cmp_nvim_lsp').default_capabilities()
-
+			local capabilities = require("cmp_nvim_lsp").default_capabilities()
 
 			-- After setting up mason-lspconfig you may set up servers via lspconfig
-			require("lspconfig").lua_ls.setup({capabilities = capabilities})
+			require("lspconfig").lua_ls.setup({ capabilities = capabilities })
 			-- require("lspconfig").rust_analyzer.setup({capabilities = capabilities})
-			require("lspconfig").r_language_server.setup({capabilities = capabilities})
-			require("lspconfig").html.setup({capabilities = capabilities})
-			require("lspconfig").typst_lsp.setup({capabilities = capabilities})
+			require("lspconfig").r_language_server.setup({ capabilities = capabilities })
+			require("lspconfig").html.setup({ capabilities = capabilities })
+			require("lspconfig").typst_lsp.setup({
+				capabilities = capabilities,
+				settings = {
+					exportPdf = "onType", -- Choose onType, onSave or never.
+					-- serverPath = "" -- Normally, there is no need to uncomment it.
+				},
+			})
 			require("lspconfig").tsserver.setup({
-        capabilities = capabilities,
+				capabilities = capabilities,
 				init_options = {
 					plugins = {},
 				},

+ 48 - 3
lua/plugins/typst.lua

@@ -1,5 +1,50 @@
 return {
-  'kaarmu/typst.vim',
-  ft = 'typst',
-  lazy=false,
+	{ "kaarmu/typst.vim", ft = "typst", lazy = false },
+	{
+		"chomosuke/typst-preview.nvim",
+		lazy = false, -- or ft = 'typst'
+		version = "0.3.*",
+		config = function()
+			require("typst-preview").setup({
+				-- Setting this true will enable printing debug information with print()
+				debug = false,
+
+				-- Custom format string to open the output link provided with %s
+				-- Example: open_cmd = 'firefox %s -P typst-preview --class typst-preview'
+				open_cmd = nil,
+
+				-- Setting this to 'always' will invert black and white in the preview
+				-- Setting this to 'auto' will invert depending if the browser has enable
+				-- dark mode
+				invert_colors = "never",
+
+				-- Whether the preview will follow the cursor in the source file
+				follow_cursor = true,
+
+				-- Provide the path to binaries for dependencies.
+				-- Setting this will skip the download of the binary by the plugin.
+				-- Warning: Be aware that your version might be older than the one
+				-- required.
+				dependencies_bin = {
+					-- if you are using tinymist, just set ['typst-preview'] = "tinymist".
+					["typst-preview"] = nil,
+					["websocat"] = nil,
+				},
+
+				-- This function will be called to determine the root of the typst project
+				get_root = function(path_of_main_file)
+					return vim.fn.fnamemodify(path_of_main_file, ":p:h")
+				end,
+
+				-- This function will be called to determine the main file of the typst
+				-- project.
+				get_main_file = function(path_of_buffer)
+					return path_of_buffer
+				end,
+			})
+		end,
+		build = function()
+			require("typst-preview").update()
+		end,
+	},
 }