vim-easymotion icon indicating copy to clipboard operation
vim-easymotion copied to clipboard

Linters get confused

Open adelin-b opened this issue 4 years ago • 20 comments

Here is a small issue I have : When easymotion is used the linter get mad. Any tips on where to hook to know if linter should lint or if someone implemented that ?

adelin-b avatar Jul 29 '19 14:07 adelin-b

I think this is an issue with how the motion targets get shown. It seems like it changes the actual text of the buffer, and many linters with live linting will try to send the contents of the buffer for linting. (I ran into this on https://github.com/neoclide/coc-tsserver and it seems to be a problem for Language Server Protocol plugins in general).

Seems like neovim is considering some things that may help:

https://github.com/neovim/neovim/issues/8068 https://github.com/neovim/neovim/issues/1767

dlants avatar Aug 21 '19 22:08 dlants

I got just the same problem using (https://github.com/neoclide/coc-tsserver) did you guys get a way around this issue?

rocinante42 avatar Feb 27 '20 18:02 rocinante42

same issue here.. wondering if there is a workaround to linter triggering

dseeni avatar Mar 27 '20 16:03 dseeni

Same issue as well.

vieko avatar May 11 '20 07:05 vieko

I would like to use easymotion-bd-w but coc got mad, so for now gonna only use easymotion-overwin-f2

zer09 avatar May 14 '20 12:05 zer09

I resolved to using vim-sneak for now, hoping one day this is addressed.

vieko avatar May 20 '20 17:05 vieko

@vieko does label-mode in vim-sneak not have this issue? I tried looking through that repo and it seems that they use highlighting somehow to display labels though I'm not familiar enough with vim-script to tell how they actually do it...

dlants avatar May 20 '20 18:05 dlants

label-mode works just fine for vim-sneak, good call! There's bound to be a hint / trail to follow here.

vieko avatar May 20 '20 18:05 vieko

Hey, same problem here with coc-rust-analyzer. So I cross-post the issues for reference.

I thought easymotion hints were displayed using virtual text, and not actual changes to the buffer. Can virtual text be used to display easymotion hints? Or can it only be used where there is no actual text? I suspect no linter would be confused if hints were displayed using virtual text instead, but then maybe there would be conflicts to solve between the actual linter messages and easymotion hints?

iago-lito avatar Jun 01 '20 08:06 iago-lito

There's an issue and workaround here, I'm trying it out now

https://github.com/neoclide/coc.nvim/issues/110

kswope avatar Jul 09 '20 20:07 kswope

I love easymotion and coc both. And this is the only issue that is making me stick to vscode. Hope easymotion provides a workaround to fix this issue

numToStr avatar Jul 15 '20 15:07 numToStr

Im facing the same issue.

kujbika avatar Jul 20 '20 10:07 kujbika

I use this work around, posted here maybe someone else need it.

in ~/.config/nvim/init.vim

function! DoingEasyMotion()
    let g:is_doing_easymotion = 1
    let cancelled = EasyMotion#WB(0,2)
    let g:is_doing_easymotion = 0
endfunction
nmap f :call DoingEasyMotion()<CR>

the idea is setting a flag before easymotion function. then at somewhere else, use the flag to determine linter behavior. I use nvim-lua/diagnostic-nvim to do the linter thing (lsp diagnostic), so

lua << EOF
  local nvim_lsp = require'nvim_lsp'
  local completion = require'completion'
  local diagnostic = require'diagnostic'

  local orig = diagnostic.publish_diagnostics
  diagnostic.publish_diagnostics = function(bufnr, diagnostics)
    local status, result = pcall(vim.api.nvim_get_var, "is_doing_easymotion")
    if status == true or result == 1 then
      return
    end
    orig(bufnr, diagnostics)
  end

  local on_attach = function(_, bufnr)
    completion.on_attach()
    diagnostic.on_attach()
  end

  nvim_lsp.rust_analyzer.setup({on_attach=on_attach})
  nvim_lsp.gopls.setup({on_attach=on_attach})
EOF

sekirocc avatar Jul 25 '20 18:07 sekirocc

Adding an User autocmd should make this a lot easier. Please take a look at my PR.

n-p-e avatar Oct 13 '20 06:10 n-p-e

Any insight on this?

ecesar88 avatar Jan 09 '21 21:01 ecesar88

I saw something here

https://github.com/easymotion/vim-easymotion/pull/440#issuecomment-727844125

kswope avatar Jan 09 '21 23:01 kswope

The autocmd change mentioned in #440 is an okay temporary fix with one major issue. When you listen to that event it triggers all folds to close making easymotion unusable on any buffer with folds unless you have a very high foldlevel.

ivanterrible avatar Apr 19 '21 18:04 ivanterrible

It seems that all of you meant coc and not other linters. I'm marking this issue to be solved on my PR.

timsu92 avatar Aug 29 '22 08:08 timsu92

Switch to hop as shown here you can also integrate it in vscode without any extra configuration: https://github.com/phaazon/hop.nvim/issues/349

Since this etension doesn't write to the buffer it also works native in vscode

quantumfate avatar Jan 12 '23 12:01 quantumfate

There seems to be repetitive EasyMotionPromptBegin EasyMotionPromptEnd user events if motion requires more than 1 keypress to move cursor. Because of this autocmd doesn't work correctly with native nvim lsp.

I have this below workaround

vim.api.nvim_create_autocmd("User", {pattern = {"EasyMotionPromptBegin"}, callback = function() vim.diagnostic.disable() end})
function check_easymotion()
  local timer = vim.loop.new_timer()
  timer:start(500, 0, vim.schedule_wrap(function()
    -- vim.notify("check_easymotion")
    if vim.fn["EasyMotion#is_active"]() == 0 then
      vim.diagnostic.enable()
      vim.g.waiting_for_easy_motion = false
    else
      check_easymotion()
    end
  end))
end
vim.api.nvim_create_autocmd("User", {
  pattern = "EasyMotionPromptEnd",
  callback = function()
    if vim.g.waiting_for_easy_motion then return end
    vim.g.waiting_for_easy_motion = true
    check_easymotion()
  end
})

but it required cursor to move at least once after EasyMotion to enable the diagnostics.

I'll see if I can create PR to fix this behaviour

yogeshlonkar avatar Nov 13 '23 17:11 yogeshlonkar