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

How to rename symbol #376

Closed fcojavierdomenech closed 2 years ago

fcojavierdomenech commented 2 years ago

Using neovim with coc and tsserver.

Whenever I hit CocActions on a var a pop up appears with some options, but I can't find the rename one there.

How can I rename some symbol and its references?

el-og commented 2 years ago

I haven't tried this myself, but there is a NOTE in README.md about that.

Note: for rename import on file rename, you have to install watchman in your $PATH.

chemzqm commented 2 years ago

It's not a code action, :h CocAction('rename')

fcojavierdomenech commented 2 years ago

I haven't tried this myself, but there is a NOTE in README.md about that.

Note: for rename import on file rename, you have to install watchman in your $PATH.

yeah, that works great with watchman, but it's mainly for moving/renaming files (not symbols).

fcojavierdomenech commented 2 years ago

It's not a code action, :h CocAction('rename')

you mean <Leader>rn right? It does not work in most cases: Invalid position for rename

chemzqm commented 2 years ago

It's expected, your cursor should under a variable.

fcojavierdomenech commented 2 years ago

Captura de Pantalla 2022-05-20 a las 13 23 50

I guessed that too but It doesn't work

fcojavierdomenech commented 2 years ago

Captura de Pantalla 2022-05-20 a las 13 31 11

chemzqm commented 2 years ago

Need verbose output, I can't reproduce https://github.com/neoclide/coc-tsserver#troubleshooting

fcojavierdomenech commented 2 years ago

openTsServerLog:

{"seq":12,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/domain/model/productId.ts","line":7,"offset":1,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/domain/model/productId.ts"]}}
Perf 404  [15:01:06.769] 12::documentHighlights: elapsed time (in milliseconds) 1.0711
Info 405  [15:01:06.769] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":12,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/domain/model/productId.ts","highlightSpans":[{"start":{"line":1,"offset":1},"end":{"line":1,"offset":7},"kind":"none"},{"start":{"line":2,"offset":1},"end":{"line":2,"offset":7},"kind":"none"},{"start":{"line":3,"offset":1},"end":{"line":3,"offset":7},"kind":"none"},{"start":{"line":5,"offset":1},"end":{"line":5,"offset":7},"kind":"none"},{"start":{"line":7,"offset":1},"end":{"line":7,"offset":7},"kind":"none"},{"start":{"line":9,"offset":1},"end":{"line":9,"offset":7},"kind":"none"},{"start":{"line":11,"offset":1},"end":{"line":11,"offset":7},"kind":"none"},{"start":{"line":13,"offset":1},"end":{"line":13,"offset":7},"kind":"none"}]}]}
Info 406  [15:01:14.305] request:
    {"seq":13,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","line":17,"offset":3,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"]}}
Perf 407  [15:01:14.306] 13::documentHighlights: elapsed time (in milliseconds) 1.7383
Info 408  [15:01:14.306] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":13,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","highlightSpans":[{"start":{"line":17,"offset":3},"end":{"line":17,"offset":21},"contextStart":{"line":17,"offset":3},"contextEnd":{"line":17,"offset":48},"kind":"reference"},{"start":{"line":36,"offset":10},"end":{"line":36,"offset":28},"kind":"writtenReference"},{"start":{"line":54,"offset":14},"end":{"line":54,"offset":32},"kind":"reference"},{"start":{"line":58,"offset":59},"end":{"line":58,"offset":77},"kind":"reference"}]}]}
Info 409  [15:01:18.759] request:
    {"seq":14,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","line":17,"offset":3,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"]}}
Perf 410  [15:01:18.760] 14::documentHighlights: elapsed time (in milliseconds) 1.1051
Info 411  [15:01:18.760] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":14,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","highlightSpans":[{"start":{"line":17,"offset":3},"end":{"line":17,"offset":21},"contextStart":{"line":17,"offset":3},"contextEnd":{"line":17,"offset":48},"kind":"reference"},{"start":{"line":36,"offset":10},"end":{"line":36,"offset":28},"kind":"writtenReference"},{"start":{"line":54,"offset":14},"end":{"line":54,"offset":32},"kind":"reference"},{"start":{"line":58,"offset":59},"end":{"line":58,"offset":77},"kind":"reference"}]}]}
Info 412  [15:01:22.735] request:
    {"seq":15,"type":"request","command":"documentHighlights","arguments":{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","line":17,"offset":3,"filesToSearch":["/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"]}}
Perf 413  [15:01:22.737] 15::documentHighlights: elapsed time (in milliseconds) 1.1419
Info 414  [15:01:22.737] response:
    {"seq":0,"type":"response","command":"documentHighlights","request_seq":15,"success":true,"body":[{"file":"/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts","highlightSpans":[{"start":{"line":17,"offset":3},"end":{"line":17,"offset":21},"contextStart":{"line":17,"offset":3},"contextEnd":{"line":17,"offset":48},"kind":"reference"},{"start":{"line":36,"offset":10},"end":{"line":36,"offset":28},"kind":"writtenReference"},{"start":{"line":54,"offset":14},"end":{"line":54,"offset":32},"kind":"reference"},{"start":{"line":58,"offset":59},"end":{"line":58,"offset":77},"kind":"reference"}]}]}
Info 415  [15:01:33.227] DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory
Info 416  [15:01:33.227] Project: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json Detected ignored path: /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290
Info 417  [15:01:33.227] Elapsed:: 0.09258100017905235ms DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory
Info 418  [15:01:33.277] DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory
Info 419  [15:01:33.277] Project: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json Detected ignored path: /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290
Info 420  [15:01:33.277] Elapsed:: 0.08864900097250938ms DirectoryWatcher:: Triggered with /users/franciscojavierdomenech/workspace/my-project/new-webapp/.git/.watchman-cookie-MacBook-Pro-de-Francisco.local-927-290 :: WatchInfo: /users/franciscojavierdomenech/workspace/my-project/new-webapp 1 undefined Config: /Users/franciscojavierdomenech/workspace/my-project/new-webapp/tsconfig.json WatchType: Wild card directory

showOutput:


[Trace - 13:01:18.759] Sending request: documentHighlights (14). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "line": 17,
        "offset": 3,
        "filesToSearch": [
            "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"
        ]
}
[Trace - 13:01:18.761] Response received: documentHighlights (14). Request took 2 ms. Success: true 
Result: [
{
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "highlightSpans": [
        {
            "start": {
                "line": 17,
                "offset": 3
            },
            "end": {
                "line": 17,
                "offset": 21
            },
            "contextStart": {
                "line": 17,
                "offset": 3
            },
            "contextEnd": {
                "line": 17,
                "offset": 48
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 36,
                "offset": 10
            },
            "end": {
                "line": 36,
                "offset": 28
            },
            "kind": "writtenReference"
        },
        {
            "start": {
                "line": 54,
                "offset": 14
            },
            "end": {
                "line": 54,
                "offset": 32
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 58,
                "offset": 59
            },
            "end": {
                "line": 58,
                "offset": 77
            },
            "kind": "reference"
        }
    ]
}
]
[Trace - 13:01:22.733] TypeScript Server: trying to cancel ongoing request with sequence number 14
[Trace - 13:01:22.735] Sending request: documentHighlights (15). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "line": 17,
        "offset": 3,
        "filesToSearch": [
            "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"
        ]
}
[Trace - 13:01:22.737] Response received: documentHighlights (15). Request took 2 ms. Success: true 
Result: [
{
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "highlightSpans": [
        {
            "start": {
                "line": 17,
                "offset": 3
            },
            "end": {
                "line": 17,
                "offset": 21
            },
            "contextStart": {
                "line": 17,
                "offset": 3
            },
            "contextEnd": {
                "line": 17,
                "offset": 48
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 36,
                "offset": 10
            },
            "end": {
                "line": 36,
                "offset": 28
            },
            "kind": "writtenReference"
        },
        {
            "start": {
                "line": 54,
                "offset": 14
            },
            "end": {
                "line": 54,
                "offset": 32
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 58,
                "offset": 59
            },
            "end": {
                "line": 58,
                "offset": 77
            },
            "kind": "reference"
        }
    ]
}
]
[Trace - 13:01:24.424] TypeScript Server: trying to cancel ongoing request with sequence number 15
[Trace - 13:02:11.592] Sending request: documentHighlights (16). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "line": 17,
        "offset": 3,
        "filesToSearch": [
            "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts"
        ]
}
[Trace - 13:02:11.593] Response received: documentHighlights (16). Request took 1 ms. Success: true 
Result: [
{
    "file": "/Users/franciscojavierdomenech/workspace/my-project/new-webapp/src/app/ui/webapp/page/onboarding/product-advisor/product-advisor.ts",
        "highlightSpans": [
        {
            "start": {
                "line": 17,
                "offset": 3
            },
            "end": {
                "line": 17,
                "offset": 21
            },
            "contextStart": {
                "line": 17,
                "offset": 3
            },
            "contextEnd": {
                "line": 17,
                "offset": 48
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 36,
                "offset": 10
            },
            "end": {
                "line": 36,
                "offset": 28
            },
            "kind": "writtenReference"
        },
        {
            "start": {
                "line": 54,
                "offset": 14
            },
            "end": {
                "line": 54,
                "offset": 32
            },
            "kind": "reference"
        },
        {
            "start": {
                "line": 58,
                "offset": 59
            },
            "end": {
                "line": 58,
                "offset": 77
            },
            "kind": "reference"
        }
    ]
}
]
[Trace - 13:02:12.308] TypeScript Server: trying to cancel ongoing request with sequence number 16

Thanks for the follow-up

chemzqm commented 2 years ago

Rename request not exists.

fcojavierdomenech commented 2 years ago

I didn't see it either, but that's all the logs after doing the rename thing (same as the picture I sent you).

Maybe coc raises the error position not found even before comunicating with tsserver, which means it must be a prob related to coc instead of tsserver, who knows.

fcojavierdomenech commented 2 years ago

man, I was about to call it a day and close everything. Then I realized I had a nvim session opened in background (I tend to do Ctrl-z for returning back to the terminal from nvim). Closed everything, tried again, just in case... and the rename action works PERFECTLY.

So, in order to reproduce the error (well, not really an error):

More than happy now knowing what was causing the issue. Thanks for the support.

fcojavierdomenech commented 2 years ago

In case anyone ends here looking for help: https://github.com/iamcco/coc-angular/issues/58