neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

`coc_current_function` for arrow functions #344

Closed ellioseven closed 2 years ago

ellioseven commented 2 years ago

I'm trying to get the current function to show on lightline, which seems to work for normal functions, but not arrow functions:

// coc_current_function: ""
const foo = () => {
  return "foo"
}

// coc_current_function: "bar"
function bar () {
  return "bar"
}

Is there some kind of configuration I'm missing?

Here is my function:

function! CocCurrentFunction()
  return get(b:, 'coc_current_function', '')
endfunction
chemzqm commented 2 years ago

It's expect since we only know foo is const

Result: {
    "text": "<global>",
    "kind": "script",
    "kindModifiers": "",
    "spans": [
        {
            "start": {
                "line": 1,
                "offset": 1
            },
            "end": {
                "line": 9,
                "offset": 3
            }
        }
    ],
    "childItems": [
        {
            "text": "bar",
            "kind": "function",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 7,
                        "offset": 1
                    },
                    "end": {
                        "line": 9,
                        "offset": 2
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 7,
                    "offset": 10
                },
                "end": {
                    "line": 7,
                    "offset": 13
                }
            }
        },
        {
            "text": "foo",
            "kind": "const",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 2,
                        "offset": 7
                    },
                    "end": {
                        "line": 4,
                        "offset": 2
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 2,
                    "offset": 7
                },
                "end": {
                    "line": 2,
                    "offset": 10
                }
            }
        }
    ]
}
ellioseven commented 2 years ago

So this seems to be a response from ts-server that isn't providing the correct kind. This is an upstream issue then?

chemzqm commented 2 years ago

It's expected, IMO.