preservim / vim-pencil

Rethinking Vim as a tool for writing
Other
1.57k stars 38 forks source link

Disable <cr> mapping #105

Open mangkoran opened 1 year ago

mangkoran commented 1 year ago

First of all, thank you for keeping this plugin maintained. I started to write in Latex and this plugin helped me so much.

I have an issue with the plugin's <cr> mapping. Currently it is in conflict with my nvim-cmp. Every time I want to insert the completion's suggestion, vim-pencil will also trigger the undo feature (I'm not pretty sure).

How can I disable vim-pencil built-in <cr> mapping?

Related #43

https://github.com/preservim/vim-pencil/assets/57625126/deb83a81-12f3-43c1-888b-dec98d7de04c

mangkoran commented 1 year ago

Just some suggestions, how if we make the mapping (and "enhanced" undo feature which do the key remapping) optional? Users would have the choice to whether to enable the "enhanced" undo or not.

reedes commented 1 year ago

This cr conflicting mapping issue came up several years ago. (Should be somewhere in issue history.)

The solution then was to only remap cr if the key was not yet mapped.

Does the remap of cr still occur if pencil is initialized AFTER your plugin is loaded?

Edit: removed brackets from cr

mangkoran commented 1 year ago

Thank you for your reply.

This cr conflicting mapping issue came up several years ago. (Should be somewhere in issue history.)

I suppose it's #43. I linked it in my first post above :)

Does the remap of cr still occur if pencil is initialized AFTER your plugin is loaded?

I will try to check for this but just FYI I lazy-load nvim-cmp on InsertEnter event as I'm using LazyVim, which has this config. So vim-pencil will always loaded before nvim-cmp unfortunately 😔

Friendly cc @folke if loading vim-pencil on ft latex and after nvim-cmp is loaded is possible. My current config for this plugin is below.

{
  "preservim/vim-pencil",
  dependencies = { -- not really sure if this is correct
    "hrsh7th/nvim-cmp",
  },
  config = function()
    vim.g["pencil#autoformat"] = 1
    vim.g["pencil#textwidth"] = 100
    vim.g["pencil#wrapModeDefault"] = "hard"
    vim.fn["pencil#init"]({ wrap = "hard" })
  end,
  ft = {
    "mkd",
    "markdown",
    "tex",
    "latex",
  },
},