Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ranged tag block-pasting #1427

Open
2 tasks done
nuhakala opened this issue May 17, 2024 · 0 comments
Open
2 tasks done

Ranged tag block-pasting #1427

nuhakala opened this issue May 17, 2024 · 0 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@nuhakala
Copy link
Contributor

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

0.9.5

Neorg setup

require("neorg").setup({
	load = {
		["core.concealer"] = {
			config = {
				icons = {
					code_block = {
						conceal = true,
					},
				},
			},
		},
		["core.integrations.telescope"] = {},
		["core.export"] = {},
		["core.defaults"] = {
			config = {
				disable = {
					"core.journal",
				},
			},
		},

		["core.esupports.metagen"] = {
			config = {
				author = "Jäbä",
				undojoin_updates = true,
			},
		},

		["core.dirman"] = {
			config = {
				workspaces = {
					notes = "~/muistiinpanot/",
				},
			},
		},
		["core.completion"] = {
			config = {
				engine = "nvim-cmp",
			},
		},
		["core.keybinds"] = {
			config = {
				default_keybinds = true,
				hook = function(keybinds)
					keybinds.remap_key("norg", "i", "<M-CR>", "<S-CR>")
					keybinds.remap_key("norg", "n", "<M-CR>", "<S-CR>")
					keybinds.map("norg", "n", keybinds.leader .. "mi", "<CMD>Neorg index<CR>")
					keybinds.map(
						"norg",
						"n",
						keybinds.leader .. "g",
						"<CMD>Neorg generate-workspace-summary<CR>",
						{ desc = "Generate summary" }
					)
					keybinds.map(
						"norg",
						"n",
						keybinds.leader .. "c",
						"<CMD>Neorg toc<CR>",
						{ desc = "Table of contents" }
					)

					keybinds.remap_event(
						"norg",
						"n",
						keybinds.leader .. "fl",
						"core.integrations.telescope.find_linkable",
						{ desc = "Neorg find linkable" }
					)
					keybinds.remap_event(
						"norg",
						"n",
						keybinds.leader .. "ff",
						"core.integrations.telescope.find_norg_files",
						{ desc = "Neorg find file" }
					)
					keybinds.remap_event(
						"norg",
						"n",
						keybinds.leader .. "il",
						"core.integrations.telescope.insert_link",
						{ desc = "Neorg insert link" }
					)
					keybinds.remap_event(
						"norg",
						"n",
						keybinds.leader .. "if",
						"core.integrations.telescope.insert_file_link",
						{ desc = "Neorg insert link" }
					)
					keybinds.remap_event(
						"norg",
						"i",
						"<C-,>",
						"core.integrations.telescope.insert_link",
						{ desc = "Neorg insert link" }
					)
					keybinds.remap_event(
						"norg",
						"i",
						"<C-f>",
						"core.integrations.telescope.insert_file_link",
						{ desc = "Neorg insert link" }
					)

					keybinds.unmap("norg", "n", keybinds.leader .. "nn")
					vim.keymap.set("n", "<localleader>nn", function()
						local dirman = require("neorg").modules.get_module("core.dirman")

						vim.ui.input({ prompt = "Enter note name: " }, function(user_input)
							if not user_input or user_input == "" then
								return
							end

							local file_name = user_input:gsub(" ", "_")
							local date = os.date("%Y-%m-%d--")
							local ws = dirman.get_current_workspace()[1]

							dirman.create_file(date .. file_name, ws, {
								no_open = false,
								force = false,
								metadata = {
									title = require("neorg.core").lib.title(user_input),
								},
							})

							vim.api.nvim_buf_set_lines(
								0,
								10,
								14,
								false,
								{ "*Lähteet*:", "- %|TODO: lähde|%", "", "" }
							)
							vim.api.nvim_win_set_cursor(0, { 14, 0 })
						end)
					end, { desc = "Create New Note" })

					-- Undojoin
					keybinds.map("norg", "n", "u", function()
						require("neorg.modules.core.esupports.metagen.module").public.skip_next_update()
						local k = vim.api.nvim_replace_termcodes("u<c-o>", true, false, true)
						vim.api.nvim_feedkeys(k, "n", false)
					end)
					keybinds.map("norg", "n", "<c-r>", function()
						require("neorg.modules.core.esupports.metagen.module").public.skip_next_update()
						local k = vim.api.nvim_replace_termcodes("<c-r><c-o>", true, false, true)
						vim.api.nvim_feedkeys(k, "n", false)
					end)
				end,
			},
		},
		["core.summary"] = {},
	},
})

Actual behavior

core.clipboard.code-blocks does not work as described in wiki. It says that it removes the whitespace only in code-blocks, but it also removes it from table-block. It effectively prevents copy-pasting blocks in place.

I wanted to copy one column in my table and paste in to another column, but due to that module it pasted the column into new lines instead of in-place.

Example:

@table
| aoeu | aoeu | aoeu |
| copy |      | aoeu |
| this |      | aoeu |
| col  |      | aoeu |
| to   |      | aoeu |
| next |      | aoeu |
| col  |      | aoeu |
@end

Outcome was this:

@table
| aoeu | aoeu | aoeu |
| copy |      | aoeu |
copy
this
col 
to  
next
col 
| this |      | aoeu |
| col  |      | aoeu |
| to   |      | aoeu |
| next |      | aoeu |
| col  |      | aoeu |
@end

Expected behavior

When copying blocks in table-section, I want to be able to paste the block in place, like copy-pasting parts of a column. Using the above example, I want the outcome to be like this:

@table
| aoeu | aoeu | aoeu |
| copy | copy | aoeu |
| this | this | aoeu |
| col  | col  | aoeu |
| to   | to   | aoeu |
| next | next | aoeu |
| col  | col  | aoeu |
@end

Steps to reproduce

Try to copy a column in-place in a table-block.

Potentially conflicting plugins

No response

Other information

As noted in discord discussion by vhyrro:

This seems like an issue with the paste functionality, less so with the yanking. Generally you'd want to trim whitespace from all sorts of @ ranged tags but also properly reformat it when pasting.

Help

None

Implementation help

No response

@nuhakala nuhakala added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

1 participant