coq_nvim icon indicating copy to clipboard operation
coq_nvim copied to clipboard

Cursor jumps few lines down after LSP import

Open radmen opened this issue 2 years ago • 4 comments

Hey,

First of all, I love this plugin. I think it was enough to motivate me to switch my config to Lua. I installed COQ + LSP (w/ intelephense for PHP).

When typing a function outside of the namespace, LSP provides suggestions for the function and on <CR> it inserts the required use function statement with the function name.

However, this moves the cursor few lines down, away from the completed keyword.

https://user-images.githubusercontent.com/1190255/130318441-d4b74b46-2b39-4ca6-a5e8-221e5cb30be5.mp4

This is something that happens to me also when using coc.nvim, so maybe it's not an issue with the package, but rather the LSP implementation?

radmen avatar Aug 21 '21 10:08 radmen

humm, on a different LSP it looks ok, im gonna install intelephense later and try it out and figure out whats wrong.

possibly LSP server side issue, but then really, even if its a server side issue, sometimes the client can do workarounds, but then it depends on if the workaround will break other LSPs or not.

https://user-images.githubusercontent.com/50598611/130556476-1a68d40e-38e8-4e32-baee-cc2e9ac96ae3.mov

ms-jpq avatar Aug 24 '21 04:08 ms-jpq

Hmm, as you said, this might be the problem with Intelephense as I'm having similar issues on coc.nvim. Feel free to close this issue if you don't want to work on any workarounds. Frankly, I don't think you should make them.

Thank you!

radmen avatar Aug 24 '21 07:08 radmen

:: replied to wrong thread

ms-jpq avatar Aug 24 '21 10:08 ms-jpq

:: replied to wrong thread

I have some problem.

test

my config:

local nvim_lsp = require('lspconfig')
local coq = require "coq"

local on_attach = function(client, bufnr)
    local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
    local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

    -- Enable completion triggered by <c-x><c-o>
    buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

    -- Mappings.
    local opts = { noremap=true, silent=true } 

    buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
    buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
    buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
end

nvim_lsp.intelephense.setup(coq.lsp_ensure_capabilities({
    on_attach = on_attach,
    flags = {
        debounce_text_changes = 150,
    }
}))

how to repeat bug:

  1. mkdir test
  2. cd test
  3. git init
  4. mkdir A
  5. cd A
  6. nvim A.php
  7. paste:
<?php

namespace A;

final class A
{
    public static function aaa()
    {
    }
}
  1. :wq
  2. cd ..
  3. nvim B.php
  4. paste:
<?php

final class B
{
    public function test(): void
    {
        A::aaa();
    }

    public function test2(): void
    {
    }
}
  1. :w
  2. :7^a<C-space><Tab><CR>

ta-tikoma avatar Feb 11 '22 15:02 ta-tikoma