ray-x / lsp_signature.nvim

LSP signature hint as you type
Apache License 2.0
2.07k stars 57 forks source link

incorrect active signature #240

Open kulakilam opened 1 year ago

kulakilam commented 1 year ago

the number i typed in is a floating type, I think the active signature should be the third one. actually whatever i typed in, the active signature is always the first one. image image

vim version: neovim 0.8.1 my minimal init.vim:

set expandtab
set shiftwidth=4
set tabstop=4

call plug#begin()
Plug 'neovim/nvim-lspconfig'

Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'

Plug 'ray-x/lsp_signature.nvim'
call plug#end()

lua << EOF

require('lsp_signature').setup()
require('lspconfig').ccls.setup{}
require('cmp').setup{}

EOF

the cpp sample code:

#include <iostream>
using namespace std;

class printData
{
    public:
        void print(double  f) {
            cout << "float: " << f << endl;
        }

        void print(int i) {
            cout << "integer: " << i << endl;
        }

        void print(int i, int j) {
            cout << "integer: " << i << j << endl;
        }

        void print(double i, int j) {
            cout << "integer: " << i << j << endl;
        }

        void print(char c[]) {
            cout << "string: " << c << endl;
        }
};

int main(void)
{
    printData pd;

    pd.print(5);

    pd.print(500.263);

    char c[] = "Hello C++";
    pd.print(c);

    return 0;
}
ray-x commented 1 year ago

Did some debug for cpp. Look to me a incorrect LSP response was sent from ccls/clangd

שׁ ...packer/opt/lsp_signature.nvim/lua/lsp_signature/init.lua:577 |1: delta |2:   pd.print(" |3:   pd.print(" |4:   pd.print(" |5: {
  trigger = "CursorHold"
}

שׁ ...cker/opt/lsp_signature.nvim/lua/lsp_signature/helper.lua:597 |1: {
  triggerCharacters = { "(", ")", "{", "}", "<", ">", "," }
}
 |2:   pd.print("
שׁ ...cker/opt/lsp_signature.nvim/lua/lsp_signature/helper.lua:235 |1: ( |2: true
שׁ ...packer/opt/lsp_signature.nvim/lua/lsp_signature/init.lua:803 |1: Insert leave cleanup |2: i
שׁ ...packer/opt/lsp_signature.nvim/lua/lsp_signature/init.lua:900 |1: sig cleanup |2: {
  activeParameter = 0,
  activeSignature = 0,
  signatures = { {
      label = "print(int i) -> void",
      parameters = { {
          label = { 6, 11 }
        } }
    }, {
      label = "print(char *c) -> void",
      parameters = { {
          label = { 6, 13 }
        } }
    }, {
      label = "print(double f) -> void",
      parameters = { {
          label = { 6, 14 }
        } }
    }, {
      label = "print(int i, int j) -> void",
      parameters = { {
          label = { 6, 11 }
        }, {
          label = { 13, 18 }
        } }
    }, {
      label = "print(double i, int j) -> void",
      parameters = { {
          label = { 6, 14 }
        }, {
          label = { 16, 21 }
        } }
    } }
}
 |3: {
  bufnr = 1,
  client_id = 3,
  method = "textDocument/signatureHelp",
  params = {
    position = {
      character = 12,
      line = 22
    },
    textDocument = {
      uri = "file:///home/ray/lsp_test/cpp/funcoverride.cpp"
    }
  }
}

The issue is that:

  activeParameter = 0,
  activeSignature = 0,

If I enter pd.print(" it suppose to send

  activeParameter = 1,
  activeSignature = 1,