-
-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
I have this in configuration for writing typographic quotes:
------------------------------------------------------------
-- require("nvim-autopairs").setup({
-- map_cr = true, -- map <CR> on insert mode
-- disable_filetype = { "TelescopePrompt", "markdown", "rst", "tex" },
-- })
------------------------------------------------------------
-- Simple Lua function to get typographic quotes based on spelllang
local function get_smart_quotes()
local double_low_high = { de = true, cs = true, pl = true }
local lang = vim.bo.spelllang or ""
local active_langs = vim.split(lang, ",")
for _, l in ipairs(active_langs) do
local base = l:sub(1, 2):lower() -- Get "de" from "de_de"
if double_low_high[base] then
-- German/Czech „ “
return vim.fn.nr2char(0x201E), vim.fn.nr2char(0x201C)
elseif base == "fr" then
-- French « » (with a   inside)
return vim.fn.nr2char(0x00ab) .. vim.fn.nr2char(0x2009),
vim.fn.nr2char(0x2009) .. vim.fn.nr2char(0x00bb)
end
end
-- Default fallback (English) “ ”
return vim.fn.nr2char(0x201C), vim.fn.nr2char(0x201D)
end
-- Map " to insert the correct smart quote in Insert mode
vim.api.nvim_create_autocmd({ "FileType", "BufEnter" },
{
pattern = "*",
callback = function()
if vim.tbl_contains({ "markdown", "rst", "tex", "plaintex" }, vim.bo.filetype) then
vim.keymap.set('i', '"', function()
local open, close = get_smart_quotes()
local line = vim.api.nvim_get_current_line()
local col = vim.api.nvim_win_get_cursor(0)[2]
local quote
-- for Unicode checking (not required here, because we
-- check for space only)
-- local prev_char = vim.fn.strcharpart(line, vim.fn.strchars(line, 0, col - 1), 1)
local prev_char = col > 0 and line:sub(col + 1, col + 1) or ""
if col == 0 or prev_char:match("%s") then
quote = open
else
quote = close
end
vim.api.nvim_put({ quote }, "c", true, true)
return "" -- Return empty string to prevent default quote insertion
end, { buffer = true })
end
end
})Unfortunately, when I uncomment setup of nvim-autopairs the typographic quotes think stops working (even with disable_filetype configuration). Any idea why? Is there some way how to make the plugin not to break my mapping?
Mapping bug
- provide result of command
:verbose imap <cr>.
no mapping (in Czech)
Steps to reproduce
see above
Minimal config
see aboveReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working