zbirenbaum / copilot-cmp

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

Add tab indent detection #94

Closed zbirenbaum closed 10 months ago

zbirenbaum commented 10 months ago

The improved indentation validation introduced in #92 unfortunately broke tab completion, this will autodetect which to use by doing the following

  1. if there is whitespace at the start of the line before the cursor already, use tabs when that whitespace has a tab char, or vim.o.shiftwidth space chars per indent when that whitespace contains spaces.
  2. If there is no whitespace at the start of the cursor line, use tabs when vim.bo.expandtab is set to false, and the same number of spaces per indent as above when it is set to true

Overall this should be an improvement over prior releases for tabs since it won't rely on copilot correctly detecting and using the right indent char, and will instead force compliance with whichever indentation method your editor is set up to use

dinhtungdu commented 10 months ago

I can confirm this PR fix the indentation issue. Both space and tab indentation work as expected.