orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

Cannot abort capture with `win_split_mode = float`

Open jgollenz opened this issue 2 years ago • 0 comments

Describe the bug

Without win_split_mode = float, one has to write to the capture buffer in order to actually persist the capture content to the file. Closing it with q! will prompt users for input whether they want to close the buffer:

image

This does not happen when the capture window is a float. Closing it will result in a write to the file, no matter what.

Steps to reproduce

  1. nvim -u scripts/minimal_init.lua foo.org (with the minimal_init.lua below)
  2. <leader>oc
  3. select a template
  4. close the template with :q

Expected behavior

  • It shouldn't be able to just close with :q. If you want to abort the capture, you should have to explicitly :q!
  • If the capture is aborted, it shouldn't be written to file

Emacs functionality

n.a.

Minimal init.lua

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])

local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'

local function load_plugins()
  require('packer').startup({
    {
      'wbthomason/packer.nvim',
      { 'nvim-treesitter/nvim-treesitter' },
      { 'kristijanhusak/orgmode.nvim', branch = 'master' },
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
    },
  })
end

_G.load_config = function()
  require('orgmode').setup_ts_grammar()
  require('nvim-treesitter.configs').setup({
    highlight = {
      enable = true,
      additional_vim_regex_highlighting = { 'org' },
    },
  })

  vim.cmd([[packadd nvim-treesitter]])
  vim.cmd([[runtime plugin/nvim-treesitter.lua]])
  vim.cmd([[TSUpdateSync org]])

  -- Close packer after install
  if vim.bo.filetype == 'packer' then
    vim.api.nvim_win_close(0, true)
  end

  require('orgmode').setup({
    org_default_notes_file = '~/org/deleteme.org',
    win_split_mode = 'float',
  })

  -- Reload current file if it's org file to reload tree-sitter
  if vim.bo.filetype == 'org' then
    vim.cmd([[edit!]])
  end
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path })
  load_plugins()
  require('packer').sync()
  vim.cmd([[autocmd User PackerCompileDone ++once lua load_config()]])
else
  load_plugins()
  load_config()
end

Screenshots and recordings

No response

OS / Distro

Ubuntu 20.04

Neovim version/commit

0.9.0-dev-793+g7126d9b8c 0.8.3

Additional context

No response

jgollenz avatar Feb 25 '23 12:02 jgollenz