-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ALERename (tsserver & LSP), ALEOrganizeImports (tsserver) and auto import support (tsserver) #2709
Add ALERename (tsserver & LSP), ALEOrganizeImports (tsserver) and auto import support (tsserver) #2709
Conversation
Add protocol support for the LSP and tsserver Still need to implement the actual renaming in vim
Also replace \n in replacement with <CR>
Nice work! 👍 I've got a long list of emails to get through, and I'll take a look when I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! This kind of thing is difficult to manage. See my suggestions here. I have some of my own code for this kind of stuff already which you can use, plus some stuff to come later, when I finally have the time.
\} | ||
|
||
if has_key(l:suggestion, 'codeActions') | ||
let l:result.user_data = json_encode({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try removing json_encode
here and json_decode
below. I think you can store Dictionary
values too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so too, but I get E731: using Dictionary as a String
when I remove the json_encode
/json_decode
functions :(
autoload/ale/rename.vim
Outdated
|
||
if !empty(l:lsp_linters) | ||
let l:prompt = 'new name: ' | ||
let l:new_name = a:0 ? join(a:000) : input(l:prompt, expand('<cWORD>')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of supporting an optional argument for a new name in the command, always require the new name to be input with input()
and the current name. Then you always know exactly what name ALE is going to try and rename, and it's easy to adjust the current name to something slightly different. See here: ca2026b#diff-c8e42b11378165eaf5fb1be0e53860e6R90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented this change but since feedkeys()
doesn't work for input prompt, I added a new util method ale#util#Input(message, value)
and mocked that method in the test. Let me know if this works!
This is because there could be two symbols with the same name from different modules.
ca7fc6d
to
499b0be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for working on this, and sorry for the delay. This is great work. When I finally get the time, I'll build on this later by finishing my work on showing code actions in menus, including the popup menu.
Let's get people to try this out for a while, and we can fix any bugs people find later. Cheers! 🍻 |
Thanks for your guidance and thank you for merging! 🍺 |
Nice work! But I found autoimport doesn't work when I use deoplete. Is it possible to support that? |
Hi @cirias, I do not use ale/autoload/ale/completion.vim Line 721 in 61cfb3f
it should look like: if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual' && l:source isnot# 'deoplete' Let me know if this works! |
I tried. But it still doesn't work. Also I found the problem is, when |
Perhaps we should move this conversation to a new issue. I just installed and configured deoplete to use ale and I believe I was able to reproduce the issue. Can you confirm that the same happens to you: a) deoplete is configured to use ale edit I believe the reason I'm experiencing this is because Deoplete caches completion results, and ale reduces the number of completion results to I was able to resolve this by setting From deoplete docs:
On a side note, I noticed that the |
Importing external symbols isn't currently designed to work with Deoplete. That will require some additional work. Open an issue for that. |
Excited that this feature could replace our usage of I have noticed that the autoimport feature does not work when autocomplete is manually executed via |
@thisjeremiah What configuration are you using to trigger completion via This is my configuration for imap <C-Space> <Plug>(ale_complete) |
I've actually just been using completion via I set up your mapping and it worked, probably because it is calling In general, I'm trying to reduce the steps needed to autoimport an already written term. The |
Glad that ale is on the road to support One thing (though not bug) I found inconvenient is that, You don't know which file the symbol you are importing from. e.g. When I want to import |
If anyone knows enough about Deoplete to make it work, please create a pull request. I plan on adding code action support with Vim menus later, when I finally have the time. I have some experimental code for that in a branch. I did notice one error with renaming in other files I saw once, but I haven't been able to repeat it since. |
…o import support (tsserver) (dense-analysis#2709) This commit adds support for renaming symbols in tsserver and with LSP tools, and for organising imports with tsserver. Completion results for symbols that can be imported are now suggested if enabled for tsserver completion done via ALE.
Related to #1519
ALERename [new_name]
Tested for
tsserver
, and should work for any LSP that hasrename
capability, but I currently do not have a LSP project to test it on. Currently only supports renaming of symbols (no file rename).ALEOrganizeImports
Works with
tsserver
and will organize all import statements when called.Auto Imports
Currently works with
tsserver
. Thets@completions
message now includes the parameter:includeExternalModuleExports
. If an external completion is returned, the necessary code actions will be stored in theuser_data
variable of the completion item.To support both
ale-manual
andale-automatic
completion triggers, a newaugroup ALECompletionActions
has been added.This functionality can be disabled by setting
g:ale_completion_tsserver_autoimport
to0
.A new function was added for handling code actions:
ale#code_action#HandleCodeAction
. I've tested this extensively on a TypeScript project. I would appreciate feedback, especially on the implementation of this function. There might be a better way to edit the buffer without resorting to visual mode.