<CR> not behaving as expected under LazyVim distribution
lyz-code opened this issue · comments
Describe the bug
With a clean install of LazyVim distribution when pressing <CR>
from a heading it creates a new heading instead of moving the cursor to the body of the heading:
* Test <-- press enter in insert mode
The result is:
* Test
* <-- cursor here
Steps to reproduce
mkdir ~/.config/newstarter && cd ~/.config/newstarter
git clone https://github.com/LazyVim/starter .
rm -rf .git*
NVIM_APPNAME=newstarter nvim # and wait for installation of plugins to finish
# Quit Neovim and start again with
NVIM_APPNAME=newstarter nvim lua/plugins/orgmode.lua
Paste the next config in the open buffer (lua/plugins/orgmode.lua
).
return {
{
"nvim-orgmode/orgmode",
branch = "nightly",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", lazy = true },
},
event = "VeryLazy",
config = function()
-- Load treesitter grammar for org
require("orgmode").setup_ts_grammar()
-- Setup treesitter
require("nvim-treesitter.configs").setup({
highlight = {
enable = true,
additional_vim_regex_highlighting = { "org" },
},
ensure_installed = { "org" },
})
-- Setup orgmode
require("orgmode").setup({
org_agenda_files = "~/orgfiles/**/*",
org_default_notes_file = "~/orgfiles/refile.org",
})
end,
},
}
Quit and restart Neovim again opening the desired file
NVIM_APPNAME=newstarter nvim test.org
In insert mode enter * Test<CR>
Expected behavior
* Test <-- press enter in insert mode
The result is:
* Test
<-- cursor here
Emacs functionality
No response
Minimal init.lua
Doesn't apply
Screenshots and recordings
No response
OS / Distro
Debian
Neovim version/commit
v0.9.5
Additional context
I didn't know where to open the issue either here or at LazyVim. As I'm more used to write you I started here.
I'll be grateful if you could at least guide me on how to debug the issue
This is not a bug in Orgmode. List items are added by some other plugin from LazyVim, and I'm not sure which one.
It adds it even if you do not install orgmode plugin at all.
mkdir ~/.config/newstarter && cd ~/.config/newstarter
git clone https://github.com/LazyVim/starter .
rm -rf .git*
NVIM_APPNAME=newstarter nvim # and wait for installation of plugins to finish
NVIM_APPNAME=newstarter nvim test.org
Try adding new line after headline
I guessed so as I could not reproduce with the minimal config. I'll open the issue there.
Sorry for the noise
It's because of the formatoptions
. If you do :set fo-=r
, you will observe the difference.
The r
option automatically inserts the current comment leader after pressing <Enter>
in Insert mode.
To make the change permanent, you should enforce it with an auto-command. I really have no idea what makes Neovim think that the character *
is a comment leader in .org
files.
vim.api.nvim_create_autocmd("FileType", {
pattern = "org",
group = vim.api.nvim_create_augroup("orgmode", { clear = true }),
callback = function()
vim.opt.formatoptions:remove({ "r" })
end,
})
Default formatoptions in Neovim does not have r
(https://neovim.io/doc/user/options.html#formatoptions), so it's probably added by LazyVim.