if has('vim_starting')
set encoding=utf-8
endif
scriptencoding utf-8
if &compatible
set nocompatible
endif
let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end
execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit
" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-n>'] = function()
local cmp = require('cmp')
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
else
cmp.complete()
end
end,
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<CR>'] = cmp.mapping.confirm({ select = false }),
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
}),
}
local capabilities = require('cmp_nvim_lsp').default_capabilities()
require'lspconfig'.cssls.setup {
capabilities = capabilities,
}
-- the custom vim.ui.input
vim.fn.sign_define("UIInputPromptPrefix", { text = "I", texthl = "Type" })
vim.ui.input = function()
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
-- normal windows
--vim.cmd.vsplit()
--local win = vim.api.nvim_win_get_number(0)
--vim.cmd.buffer(buf)
-- floating windows
local win = vim.api.nvim_open_win(buf, true, {
relative = "cursor", row = -3, col = 0, width = 32,
height = 1, zindex = 1, border = "rounded", title = "Input", noautocmd = true,
})
vim.fn.sign_place(0, "UIInput", "UIInputPromptPrefix", buf, { lnum = 1 })
end
EOF
Description
So, I came across this bug while using my own vim.ui.input handler. As evident in this asciicast, selecting with <C-n> or <C-p> and confirming with <CR> causes the sign placed with vim.fn.sign_place to disappear. This happens in both floating and normal windows.
Curiously, if I :set signcolumn=yes after opening the window but before confirming the selection, the sign persists. But setting it afterwards is no good.
Steps to reproduce
Run the config with nvim -u
:lua vim.ui.input()
Enter random text into the floating buffer for cmp to pick up. Select one of the options and hit <CR>.
Expected behavior
The sign in signcolumn should persist.
Actual behavior
The sign in signcolumn disappears.
Additional context
I feel that I'm doing something wrong considering signs by gitsigns.nvim don't disappear, but I don't know what...
FAQ
Announcement
Minimal reproducible full config
Description
So, I came across this bug while using my own
vim.ui.input
handler. As evident in this asciicast, selecting with<C-n>
or<C-p>
and confirming with<CR>
causes the sign placed withvim.fn.sign_place
to disappear. This happens in both floating and normal windows.Curiously, if I
:set signcolumn=yes
after opening the window but before confirming the selection, the sign persists. But setting it afterwards is no good.Steps to reproduce
nvim -u
:lua vim.ui.input()
<CR>
.Expected behavior
The sign in signcolumn should persist.
Actual behavior
The sign in signcolumn disappears.
Additional context
I feel that I'm doing something wrong considering signs by gitsigns.nvim don't disappear, but I don't know what...