zbirenbaum / copilot-cmp

Lua plugin to turn github copilot into a cmp source
MIT License
1.08k stars 39 forks source link

Indentation wrong on first line of mutli-line and all single line completions #23

Closed cwebster2 closed 1 year ago

cwebster2 commented 1 year ago

I'm not sure if this is something with my cmp config, but i'm only seeing it with this source.

I'm being offered a multi-line copilot completion image

and once selected image

everything shows up properly except the first line which becomes un-indented. I see this on all my copilot completions and single line completions are always un-indented.

my cmp setup is here: https://github.com/cwebster2/vim/blob/nvim-lua/lua/cwebster/completion/cmp.lua my copilot-cmp setup is here: https://github.com/cwebster2/vim/blob/05a6fac5fe6a433c19fbb488f4dcb12972521bbf/lua/cwebster/copilot.lua#L12

zbirenbaum commented 1 year ago

This should never occur. I do some advanced indentation logic to try and fix some of copilot's issues, which includes removing the first/last line indentation set by copilot and offsetting it by current cursor location. There are a ton of indentation issues being brought up, so I'll add this to the list of things to check for, but I'm not sure how to reproduce it.

Could you provide your indentation related neovim options?

cwebster2 commented 1 year ago

I've tried vim.opt.autoindent in both true and false. My formatoptions has -t and +n. smartindent is true (false diesnt change the behavior).

I have tressiter indent enabled as well, but didnt see a difference with it disabled.

I dont think I have any other indentation settings, but I could be missing something. If you have an ideas on things to check or that have caused issues for others, i'm happy to experiment.

cwebster2 commented 1 year ago

I should also point out I'm on neovim nightly.

zbirenbaum commented 1 year ago

I just pushed a large update which dramatically improved the formatting functions and allows micromanagement of formatting via overrides. If your issue is not solved by the changes to the defaults, you can write your own formatting function to fix it for your particular setup. Unfortunately my attempts to create catch all solutions for everyone's setup have not been very successful, so I decided I would no longer try to. There are too many edge cases to consider and variables at play :(

cwebster2 commented 1 year ago

Your latest commit seems to have fixed my indentation issues. Thanks for your work on this plugin!