Open defpis opened 1 year ago
Hey @defpis! I can't quite reproduce this:
What exact keys are you pressing for the examples?
Could you create a minimal reproducible config using the minimal config? https://github.com/JoosepAlviste/nvim-ts-context-commentstring/blob/9bff161dfece6ecf3459e6e46ca42e49f9ed939f/utils/minimal_init.lua
Thanks for taking the time to check out the problem, any help would be appreciated. There is minimal config:
local options = { -- :help options
backup = false, -- Don't create a backup file
clipboard = 'unnamedplus', -- Allow NeoVim to access system clipboard
conceallevel = 0, -- Make `` visible in Markdown files
fileencoding = 'utf-8', -- Use `utf-8` as encoding
hlsearch = true, -- Highlight all matches on previous search pattern
ignorecase = true, -- Ignore case in search patterns
mouse = 'a', -- Allow the mouse to be used in NeoVim
showmode = false, -- Hide NeoVim modes in the status bar
showtabline = 2, -- Always show tabs
smartcase = true, -- Ignore `ignorecase` if search pattern contains upper case characters
smartindent = true, -- Make indenting smarter on newline
splitbelow = true, -- Force all horizontal splits to go below current window
splitright = true, -- Force all vertical splits to go to the right of current window
swapfile = false, -- Don't create a swapfile
termguicolors = true, -- Set term gui colors
timeoutlen = 1000, -- Time to wait for a mapped sequence to complete (in milliseconds)
updatetime = 300, -- Faster completion (4000ms default)
writebackup = false, -- If a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
expandtab = true, -- Convert tabs to spaces
shiftwidth = 2, -- The number of spaces inserted for each indentation
tabstop = 2, -- Insert 2 spaces for a tab
cursorline = true, -- Highlight the current line
cursorlineopt = 'number', -- Hightlight the current line number
number = true, -- Set numbered lines
relativenumber = true, -- Set relative numbered lines
signcolumn = 'yes', -- Always show the sign column, otherwise it would shift the text each time
wrap = false, -- Display long lines as one
scrolloff = 8, -- Minimal number of screen lines to keep above and below the cursor
sidescrolloff = 8, -- Minimal number of screen columns to keep left and right the cursor
cmdheight = 1, -- More space in the neovim command line for displaying messages
pumheight = 10, -- Make popup menu smaller
background = 'dark', -- Tell NeoVim what the background color is
laststatus = 3, -- Use global statusline
}
for key, value in pairs(options) do
vim.opt[key] = value
end
local lazy_path = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazy_path) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable',
lazy_path,
})
end
vim.opt.rtp:prepend(lazy_path)
require('lazy').setup({
{
'gbprod/yanky.nvim',
config = function()
require('yanky').setup({
preserve_cursor_position = { enabled = true },
highlight = { on_put = false, on_yank = false },
})
end,
},
{
'phaazon/hop.nvim',
branch = 'v2',
config = function()
require('hop').setup({ keys = 'etovxqpdygfblzhckisuran' })
end,
},
-- {
-- 'numToStr/Comment.nvim',
-- config = function()
-- require('Comment').setup()
-- -- local ft = require('Comment.ft')
-- -- ft.set('json', { '// %s', '/* %s */' })
-- end,
-- },
{
'kylechui/nvim-surround',
config = function()
require('nvim-surround').setup()
end,
},
{ 'nvim-treesitter/nvim-treesitter-textobjects', dependencies = { 'nvim-treesitter' } },
{
'nvim-treesitter/nvim-treesitter',
dependencies = { 'JoosepAlviste/nvim-ts-context-commentstring' }, -- FIXME: May cause j/k position incorrect
config = function()
require('nvim-treesitter.configs').setup({
ensure_installed = {
'lua',
'typescript',
'tsx',
'javascript',
'html',
'css',
'scss',
'json',
'jsonc',
'yaml',
'markdown',
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<Leader><CR>',
node_incremental = '<CR>',
node_decremental = '<BS>',
scope_incremental = '<Leader><CR>',
},
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
['af'] = '@function.outer',
['if'] = '@function.inner',
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
},
},
},
context_commentstring = { enable = true },
})
end,
},
})
both terminal and vscode cursor can't move correct position.
Thanks for the minimal config!
I tried it out, but still can't reproduce the issue:
To be honest, I don't have any ideas as to what might be going wrong 😕 Maybe we could get someone else to try to reproduce it?
I don't think that this plugin should affect j
/k
in any way as it just sets up an autocommand on CursorHold
and that's it. Maybe there's something outside of Vim that's affecting it somehow?
Thank you. There may be a problem with my computer environment. I try to find the reason by myself, I close this issue.
Can we reopen this please?
This is sensitive to updatetime
. I can reproduce this with updatetime=100
and holding on an intermediate line for more than 100ms.
FWIW, disabling the CursorHold
autocmd fixes it, but this is obviously undesireable (autocmd! context_commentstring_ft CursorHold
)
I was able to reproduce this now, when using the CursorHold
autocommand. It looks like setting an option inside CursorHold
is causing the issue, e.g., here:
I did a quick search, but couldn't find any other issues or questions about this behaviour, so I unfortunately don't have a good solution for this yet.
I can recommend using a commenting plugin integration, though, and disabling the autocommand like described in the integrations wiki page: https://github.com/JoosepAlviste/nvim-ts-context-commentstring/wiki/Integrations
Current behavior:
Desired behavior: