GithubHelp home page GithubHelp logo

Comments (13)

tomtomjhj avatar tomtomjhj commented on July 24, 2024 1

Here's the scenario that I guess you were running into.

  1. In insert mode, do some edits that update the syntax tree.
  2. Leave insert mode with ctrl-c.
  3. Make edits in normal mode that update the syntax tree. This happens to be the change made by code_action.
  4. Enter insert mode, and leave insert mode with ESC, without making changes.
  5. nil error

I have fixed this and explained why this happens in neovim/neovim#29581

from lazyvim.

s1n7ax avatar s1n7ax commented on July 24, 2024 1

@tomtomjhj of course dafuq was I thinking XD

from lazyvim.

folke avatar folke commented on July 24, 2024

Looks like a Neovim bug

from lazyvim.

tomtomjhj avatar tomtomjhj commented on July 24, 2024

the error message says that the error happened when processing bufwritepre, which means that nvim was saving the file and trigger auto formating (which isnt included in your repro steps). were you actually saving the file when this happened? can you reproduce this by doing some edits in insert mode and concurrently trigger auto formatting without leaving insert mode?

also, do you use ctrl-c to exit insert mode?

from lazyvim.

kapral18 avatar kapral18 commented on July 24, 2024

@tomtomjhj

yes I do use mostly ctrl-c instead of esc as much as possible. Do you think it can affect this?

This happens randomly. For example this happens when I try to exit fzf-lua window when I am checking for lsp references and kill it with ctrl-c. But I noticed it mostly happens with list of new references that I haven't visited yet.

Or this happens when I try to complete the auto imports from normal mode with tsserver or typescript-tools add imports functionality with lsp code actions. And again happens with new imports mostly.

@tomtomjhj can you tell me how to trigger autoformatting without leaving insert mode?

from lazyvim.

tomtomjhj avatar tomtomjhj commented on July 24, 2024

yes I do use mostly ctrl-c instead of esc as much as possible. Do you think it can affect this?

yes this seems to be the root cause. leaving insert mode eith ctrl-c doesn't trigger insertleave autocmd, and this confuses treesitter fold stuff. i missed this point when i made changes to it.

the fix is simple: just add a nil check. i was initially hesitant to do this because it didnt seem necessary, but it turns out it's indeed necessary. i'll make pr soon.

from lazyvim.

s1n7ax avatar s1n7ax commented on July 24, 2024

Can confirm this is happening in 0.11 as well. This occurs in Typescript, Lua, Java files.

Almost 70% time this occurs when I organize imports in Typescript files or use vim.lsp.buf.code_action() to import something. And then sometimes when I use Telescope.

from lazyvim.

tomtomjhj avatar tomtomjhj commented on July 24, 2024

@s1n7ax do you use ctrl-c to exit insert mode?

from lazyvim.

kapral18 avatar kapral18 commented on July 24, 2024

this was definitely a ctrl-c issue in my case

from lazyvim.

s1n7ax avatar s1n7ax commented on July 24, 2024

@tomtomjhj Yes but how is that related to error occurring when vim.lsp.buf.code_action() is used? Anyway, just added a remap for <c-c> to <esc>

from lazyvim.

s1n7ax avatar s1n7ax commented on July 24, 2024

@tomtomjhj Ah. Cool. So far no errors with nmap <c-c> <esc>.

from lazyvim.

s1n7ax avatar s1n7ax commented on July 24, 2024

nmap <c-c> <esc> don't fix the issue. Hopefully PR will be merged soon

screenshot 24-07-07 11:13:51

from lazyvim.

tomtomjhj avatar tomtomjhj commented on July 24, 2024

inoremap <c-c> <esc>

from lazyvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.